//得到滚动后窗口的纵向绝对位置 
function getWinScrollTop() 
{
    var WinScrollTop;
    if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') 
    {
       WinScrollTop = document.documentElement.scrollTop;
    }
    else if (typeof document.body != 'undefined') 
    {
       WinScrollTop = document.body.scrollTop;
    }
    else
    	 WinScrollTop = 0;
    return WinScrollTop;
}


function getWinHeight() 
{
    var WinHeight;
    if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') 
    {
       WinHeight = document.documentElement.clientHeight;
    }
    else if (typeof document.body != 'undefined') 
    {
       WinHeight = document.body.clientHeight;
    }
    else
    	 WinHeight = 0;
    return WinHeight;
}

function getWinScrollLeft() 
{
    var WinScrollLeft;
    if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') 
    {
       WinScrollLeft = document.documentElement.scrollLeft;
    }
    else if (typeof document.body != 'undefined') 
    {
       WinScrollLeft = document.body.scrollLeft;
    }
    else
    	 WinScrollLeft = 0;
    return WinScrollLeft;
}


function getWinWidth() 
{
    var WinWidth;
    if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') 
    {
       WinWidth = document.documentElement.clientWidth;
    }
    else if (typeof document.body != 'undefined') 
    {
       WinWidth = document.body.clientWidth;
    }
    else
    	 WinWidth = 0;
    return WinWidth;
}

function MoveLayer(layerName, DivWidth, DivHeight, posX, posY, alignType ) 
{ 
	var winScrollTop = getWinScrollTop();
	var winHeight = getWinHeight();
	var winScrollLeft = getWinScrollLeft();
	var winWidth = getWinWidth();

	var x = 0;
	var y = 0;
	
	switch( alignType )
	{
		case '-1':
			x = (winScrollLeft - 0)+ (winWidth/2 - 0) - (DivWidth/2 - 0); 
			y = (winScrollTop - 0)+ (winHeight/2 - 0) - (DivHeight/2 - 0); 
			break;

		case '2':
			x = (winScrollLeft - 0)+ (winWidth - 0) -(DivWidth -0 )- (posX - 0); 
			y = (winScrollTop - 0)+ (posY - 0); 
			break;

		case '3':
			x = (winScrollLeft - 0)+ (posX - 0); 
			y = (winScrollTop - 0)+ (winHeight - 0) -(DivHeight -0 )- (posY - 0); 
			break;

		case '4':
			x = (winScrollLeft - 0)+ (winWidth - 0) -(DivWidth -0 )- (posX - 0); 
			y = (winScrollTop - 0)+ (winHeight - 0) -(DivHeight -0 )- (posY - 0); 
			break;
			
		default:
			x = (winScrollLeft - 0)+ (posX - 0); 
			y = (winScrollTop - 0)+ (posY - 0); 
	}
	eval("document.all." + layerName + ".style.left = x"); //垂直移动层 
	eval("document.all." + layerName + ".style.top = y"); //垂直移动层 
} 

function showW3CFloatButton(serverAddress, assistantNameString, preString, surString, statusPicAddress, buttonWidth,buttonHeight,left,top,buttonType,layerName, alignType, menuId)
{
	var sourceURL=location.href;
	
	var enterMenuId = "";
	if( typeof(menuId) != 'undefined' )
		enterMenuId = menuId;
	
	var buttonUrl=serverAddress+"userbutton.php"+"?assistantName="+assistantNameString+"&preString="+preString+"&surString="+surString+"&statusPicAddress="+statusPicAddress+"&serverAddress="+serverAddress+"&buttonType="+buttonType+"&frameName=frame"+layerName+"&menuid="+enterMenuId+"&sourceURL="+sourceURL;

	document.write("<style type=\"text/css\">");
	document.write("#"+layerName+"{");
	document.write("border: thin; ");
	document.write("left: 0px;");
	document.write("top: 0px;");
	document.write("POSITION: absolute; ");
	document.write("width:"+buttonWidth+"px;");
	document.write("height:"+buttonHeight+"px;");
	document.write("z-index:0;");
	document.write("}");
	document.write("</style>");
	
	document.write("<DIV id=\""+layerName+"\"><iframe marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" scrolling=\"no\"  height=\""+buttonHeight+"\" width=\""+buttonWidth+"\" name=\"frame"+layerName+"\" src=\""+buttonUrl+"\"></iframe></DIV>");
	
	var alignPoint = arguments[11]?arguments[11]:1;
	MoveLayer( layerName, buttonWidth, buttonHeight, left, top, alignPoint);
	setInterval("MoveLayer('"+layerName+"','"+buttonWidth+"','"+buttonHeight+"','"+left+"','"+top+"', '"+alignPoint+"' )",100);
}


function showW3CFloatPic(showString, showStringSize, showStringColor, picAddress, buttonWidth,buttonHeight,left,top, layerName, alignType)
{
	document.write("<style type=\"text/css\">");
	document.write("#"+layerName+"{");
	document.write("border: thin; ");
	document.write("left: "+left+"px;");
	document.write("top: "+top+"px;");
	document.write("POSITION: absolute; ");
	document.write("width:"+buttonWidth+"px;");
	document.write("height:"+buttonHeight+"px;");
	document.write("z-index:0;");
	document.write("}");
	document.write("</style>");
	
	document.write("<DIV id=\""+layerName+"\">");
	
	document.write("<table width=\""+buttonWidth+"\" height=\""+buttonHeight+"\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
	document.write("<tr>");
	document.write("<td background=\""+picAddress+"\" style=\"font-size:"+showStringSize+"px; color:#"+showStringColor+"; padding-left:10px;\">");
	document.write( showString );
	document.write("</td>");
	document.write("</tr>");
	document.write("</table>");

	
	document.write("</DIV>");
	
	var alignPoint = arguments[9]?arguments[9]:1;
	MoveLayer( layerName, buttonWidth, buttonHeight, left, top, alignPoint);
	setInterval("MoveLayer('"+layerName+"','"+buttonWidth+"','"+buttonHeight+"','"+left+"','"+top+"', '"+alignPoint+"' )",100);
}

function showButton(serverAddress,assistantNameString,preString,surString,statusPicAddress,buttonWidth,buttonHeight,buttonType,frameName,menuId)
{
	var sourceURL=location.href;
	
	var enterMenuId = "";
	if( typeof(menuId) != 'undefined' )
		enterMenuId = menuId;
	
	var buttonUrl=serverAddress+"userbutton.php"+"?assistantName="+assistantNameString+"&preString="+preString+"&surString="+surString+"&statusPicAddress="+statusPicAddress+"&serverAddress="+serverAddress+"&buttonType="+buttonType+"&frameName="+frameName+"&menuid="+enterMenuId+"&sourceURL="+sourceURL;
	
	document.write("<iframe marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" scrolling=\"no\"  height=\""+buttonHeight+"\" width=\""+buttonWidth+"\" name=\""+frameName+"\" src=\""+buttonUrl+"\"></iframe>");
}
