//功能：JS容错代码
function killErrors() {
return true;
}
window.onerror = killErrors;


var speed= 15;//速度  数字越大,速度越慢
var ci = 10;//运动次数   数字越大,速度越慢
var left=0;//方框左位置
var top=0;//方框上位置
var width=0;//方框宽
var height=0;//方框高
var aimleft=0;//目标左位置
var aimtop=0;//目标上位置
var aimwidth=0;//目标宽
var aimheight=0;//目标高
var lb=0;//左步长
var tb=0;//上步长
var wb=0;//宽步长
var hb=0;//高步长
var fk = null;
var aim = null;
var aim1 = null;
var lastObj = null;
function initObj(oid){
	if (!fk){fk = document.getElementById('fk');}
	if (!aim){aim = document.getElementById('aim');}
	if (!aim1)aim1 = document.getElementById('aim1');
	if (oid)
		append(fk,document.getElementById(oid),true);
}
function append(o,oc,cloned){
	while (o.hasChildNodes())o.removeChild(o.firstChild);
	if (cloned)oc = oc.cloneNode(true);
	oc.className = 'show';
	o.appendChild(oc);
}
/*
* 取得对象位置、大小
* 取得目标对象位置、大小
*/
function setSource(obj,oid){
	initObj(oid);
	left      = getOffset(obj).Left;
	top       = getOffset(obj).Top;
	width     = obj.offsetWidth;
	height    = obj.offsetHeight;

	aimleft   = getOffset(aim).Left;
	aimtop    = getOffset(aim).Top;

	aimwidth  = aim.offsetWidth;
	aimheight = aim.offsetHeight;
	if (lastObj)lastObj.className='nom';
	obj.className = 'nom01';
	lastObj = obj;
	fk.style.display='';
	clearInterval(MyMar);	
}

/*
*是否压缩图片
*/
var flag=false;

function DrawImage(obj,imageWidth,imageHeight) {

   var image=new Image();

   image.src=obj.src;

   if(image.width>0 && image.height>0){

    flag=true;

    if(image.width/image.height>= imageWidth/imageHeight){

     if(image.width>imageWidth){

     obj.width=imageWidth;

     obj.height=(image.height*imageWidth)/image.width;

     }else{

     obj.width=image.width;

     obj.height=image.height;

     }

     }

    else{

     if(image.height>imageHeight){

     obj.height=imageHeight;

     obj.width=(image.width*imageHeight)/image.height;

     }else{

     obj.width=image.width;

     obj.height=image.height;

     }

     }

    }
    }

/**
* 设置方向步长、宽高步长
*/
function setStep(){
	lb = (aimleft-left)/ci;
	tb = (aimtop-top)/ci;
	wb = (aimwidth-width)/ci;
	hb = (aimheight-height)/ci;
}

/**
* 移动
*/
function move(){
	setStep();
	left+=lb;
	top+=tb;
	width+=wb;
	height+=hb;
	if(left<aimleft-2 || top<aimtop-2 || width<aimwidth-2 || height<aimheight-2){
		fk.style.left = left+"px";
		fk.style.top = top+"px";
		fk.style.width = width+"px";
		fk.style.height = height+"px";
	}else{
		if (fk)
			while(fk.hasChildNodes()){append(aim1,fk.firstChild);}
		hiddenFK();
		clearInterval(MyMar)
	}
}

function hiddenFK(){
	initObj();
	fk.style.display='none';
}

/**
* 取得某元素在页面中相对页面左上顶点的位置
*/
function getOffset(obj){
	var offsetleft = obj.offsetLeft;
	var offsettop = obj.offsetTop;
	while (obj.offsetParent != document.body)
	{
		obj = obj.offsetParent;
		offsetleft += obj.offsetLeft;
		offsettop += obj.offsetTop;
	}
	return {Left : offsetleft, Top : offsettop};
}
var MyMar=setInterval(move,speed);


function Start(ObjId,method){
var BoxHeight = $G(ObjId).offsetHeight;   			//获取对象高度
var MinHeight = 5;									//定义对象最小高度
var MaxHeight = 155;					 			//定义对象最大高度
var BoxAddMax = 1;									//递增量初始值
var Every_Add = 0.5;								//每次的递(减)增量  [数值越大速度越快]

var Reduce    = (BoxAddMax - Every_Add);
var Add       = (BoxAddMax + Every_Add);

//关闭动作**************************************
if (method == "Close"){
var Alter_Close = function(){						//构建一个虚拟的[递减]循环
	BoxAddMax /= Reduce;
	BoxHeight -= BoxAddMax;
	if (BoxHeight <= MinHeight){
		$G(ObjId).style.display = "none";
		window.clearInterval(BoxAction);
	}
	else $G(ObjId).style.height = BoxHeight;
}
var BoxAction = window.setInterval(Alter_Close,1);
}

}
