//判断浏览器
var userAgent=navigator.userAgent,isIE=false;
if (userAgent.indexOf('MSIE') != -1)
{
	isIE=true;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

//获取X坐标
function GetFixPosX(strWidth)
{
	var result;
	if(isIE)
	{
		//result=(parseInt(screen.width)-parseInt(strWidth))/2-window.screenLeft;
		if(document.documentElement.scrollHeight>document.body.scrollHeight)
		    result=(parseInt(document.documentElement.scrollWidth)-parseInt(strWidth))/2-document.documentElement.scrollLeft;
		else
			result=(parseInt(document.body.scrollWidth)-parseInt(strWidth))/2-document.body.scrollLeft;
	}
	else
	{
		result=(parseInt(self.innerWidth)-parseInt(strWidth))/2;
	}
	
	return result;
}

//获取Y坐标
function GetFixPosY(strHeight)
{
	var result;
	if(isIE)
	{
		if(document.documentElement.scrollHeight>document.body.scrollHeight)
		{
			result=(parseInt(document.documentElement.clientHeight)-parseInt(strHeight))/2;
			result=result+parseInt(document.documentElement.scrollTop);
		}
		else
		{
			result=(parseInt(document.body.clientHeight)-parseInt(strHeight))/2;
			result=result+parseInt(document.body.scrollTop);
		}
	}
	else
	{
		if(document.documentElement.scrollHeight>document.body.scrollHeight)
		{
			result=(parseInt(document.documentElement.clientHeight)-parseInt(strHeight))/2;
			result=result+parseInt(document.documentElement.scrollTop);
		}
		else
		{
			result=(parseInt(self.innerHeight)-parseInt(strHeight))/2;
			result=result+parseInt(document.body.scrollTop);
		}
	}
	
	return result;
}

//定位层
function SetDivPos(layerName)
{
	var layerObj=document.getElementById(layerName);
	var strWidth=(""+layerObj.style.width).replace(/px/g,"");
	var strHeight=(""+layerObj.style.height).replace(/px/g,"");
	var x,y;

	//x=GetFixPosX(strWidth);
	x="908";
	y=GetFixPosY(parseInt(strHeight)+200);
	
	MM_findObj(layerName).style.left=x+'px';
	MM_findObj(layerName).style.top=y+'px';
	
	setTimeout("SetDivPos(\""+ layerName +"\")",20);//设置20毫秒后再调用函数MoveLayer()
}

//自动调整高度
function SetHeight()
{
	var leftHeight=MM_findObj('lyMainLeft').offsetHeight;
	var rightHeight=MM_findObj('lyMainRight').offsetHeight;
	var leftLayer=MM_findObj('lyMainLeft');
	
	if(leftHeight<rightHeight)
		leftLayer.style.height=rightHeight+'px';
}