//在Firefox中实现层浮动效果的代码
function floatFirefoxDiv(divName)
{
	if (document.layers){
		document.layers[''+divName+''].position = 'fixed';
	}
	else if (document.all){
		document.all[''+divName+''].style.position='fixed';
	}
	else if (document.getElementById){
		document.getElementById(''+divName+'').style.position='fixed';
	}
}


//判断浏览器的类型，是IE，还是Firefox。如果不是两种浏览器中的任何一种，则返回为“IE”
function checkNavigatorType()
{
	if (window.navigator.userAgent.indexOf("MSIE")>=1)
	{
	//如果浏览器为IE
		return "IE";
	}
	else
	{
		if (window.navigator.userAgent.indexOf("Firefox")>=1)
		{
	//如果浏览器为Firefox
			return "FF";
		}
		else
		{
			return "IE";
		}
	}
}

function showFloatButton(serverAddress,assistantNameString,preString,surString,statusPicAddress,buttonWidth,buttonHeight,buttonLeft,buttonTop,buttonType,frameName)
{
//	var serverAddress="userbutton.php"
//	"userbutton.php?assistantName=xp&preString=&surString="
	var sourceURL=location.href
	var buttonUrl=serverAddress+"userbutton.php"+"?assistantName="+assistantNameString+"&preString="+preString+"&surString="+surString+"&statusPicAddress="+statusPicAddress+"&serverAddress="+serverAddress+"&buttonType="+buttonType+"&frameName="+frameName+"&sourceURL="+sourceURL;

//	alert(buttonUrl);

	if(checkNavigatorType()=="IE")
	{
		document.write("<style type=\"text/css\">");
	
		document.write("#"+frameName+"{");
		document.write("position:absolute;");
		document.write("left: expression(eval(document.body.scrollLeft)+"+buttonLeft+");");
		document.write("top: expression(eval(document.body.scrollTop)+"+buttonTop+");");
		document.write("width: "+buttonWidth+"px;");
		document.write("height: "+buttonHeight+"px;");
	
		document.write("</style>");

		document.write("<DIV id=\""+frameName+"\"><iframe marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" scrolling=\"no\"  height=\""+buttonHeight+"\" width=\""+buttonWidth+"\" name=\""+frameName+assistantNameString+"\" src=\""+buttonUrl+"\"></iframe></DIV>");
		
	}
	else
	{
		document.write("<style type=\"text/css\">");
	
		document.write("#ffFloat{");
		document.write("position:absolute;");
		document.write("left: "+buttonLeft+"px;");
		document.write("top: "+buttonTop+"px;");
		document.write("width: "+buttonWidth+"px;");
		document.write("height: "+buttonHeight+"px;");
	
		document.write("</style>");
	
		document.write("<DIV id=\"ffFloat\"><iframe marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" scrolling=\"no\"  height=\""+buttonHeight+"\" width=\""+buttonWidth+"\" name=\"clientFrame\" src=\""+buttonUrl+"\"></iframe></DIV>");

		floatFirefoxDiv('ffFloat');
	}

}


function showButton(serverAddress,assistantNameString,preString,surString,statusPicAddress,buttonWidth,buttonHeight,buttonType,frameName)
{
	var sourceURL=location.href

	var buttonUrl=serverAddress+"userbutton.php"+"?assistantName="+assistantNameString+"&preString="+preString+"&surString="+surString+"&statusPicAddress="+statusPicAddress+"&serverAddress="+serverAddress+"&buttonType="+buttonType+"&frameName="+frameName+"&sourceURL="+sourceURL;
//	alert(buttonUrl);
	document.write("<iframe marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" scrolling=\"no\"  height=\""+buttonHeight+"\" width=\""+buttonWidth+"\" name=\""+frameName+"\" src=\""+buttonUrl+"\"></iframe>");
}



//布尔型变量，用于说明当前对话窗口是否可见
var isChatVisible =0;

function tableTdTransformtoRight(assistantName)
{
	var leftCell1 = document.getElementById("leftSide1");
	var leftCell2 = document.getElementById("leftSide2");
	var rightCell = document.getElementById("rightSide");
	leftCell1.style.width = "15px";
	leftCell2.style.width = "240px";
	rightCell.style.width = "15px";
	leftCell2.innerHTML = assistantName+"真的乐意为您效劳！";
	
	
}

function tableTdTransformtoLeft()
{
	var leftCell1 = document.getElementById("leftSide1");
	var leftCell2 = document.getElementById("leftSide2");
	var rightCell = document.getElementById("rightSide");
	leftCell1.style.width = "0px";
	leftCell2.style.width = "0px";
	rightCell.style.width = "270px";
	leftCell2.innerHTML = "";
	
}


//会话窗口的显示与隐藏
function toggleChat(assistantName)
{
	var layer = document.getElementById("floatChat");
	if ( 0 == isChatVisible )
	{
		layer.style.overflow = "visible";
		isChatVisible = 1;
		tableTdTransformtoRight(assistantName);
	}
	else if (1 == isChatVisible)
	{
		layer.style.overflow = "hidden";
		isChatVisible = 0;
		tableTdTransformtoLeft();
	}
}

//延时一段时间后弹出对话框询问用户是否愿意与客服交谈，用户选择“是”，则弹出与客服的会话窗口
function confirmChatWin()
{
	if(confirm(notificationinDialog))
	{
		var popupWind=window.open(urlinDialog,"","width=500, height=400, toolbar=no, location=no, directories=no, status=no, menubar=no" );
	}
}

var urlinDialog="";
var notificationinDialog="";

function setUrlinDialogAndNotification(serverAddress, notificationString, assistantNameString, sourceUrlString)
{
	urlinDialog=serverAddress+"im/customerim.php?destUserName="+assistantNameString+"&sourceUrl="+sourceUrlString;
//	alert(urlinDialog);
	notificationinDialog = notificationString;
}

function timerWin(timeLength)
{
	setTimeout("confirmChatWin();",timeLength);
}


/*

显示用户状态，点击弹出会话窗口的iframe代码如下：
	var buttonUrl=serverAddress+"userbutton.php"+"?assistantName="+assistantNameString+"&preString="+preString+"&surString="+surString+"&statusPicAddress="+statusPicAddress+"&serverAddress="+serverAddress;
<iframe marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"  height="19" width="78" name="clientStatus" src="http://59.64.179.29/im/userbutton.php?assistantName=xp&preString=&surString=&statusPicAddress=image\status0\&serverAddress=59.64.179.29/im"></iframe>

<iframe frameborder="0" scrolling="no"  height="19" width="78" name="clientStatus" src="http://59.64.179.29/im/userstatus.php?assistantName=xp&preString=&surString=&statusPicAddress=image\status0\&serverAddress=59.64.179.29/im"></iframe>




*/

function showFloatPic(showString, showStringSize, showStringColor, picAddress,buttonWidth,buttonHeight,buttonLeft,buttonTop,frameName)
{
	document.write("<style type=\"text/css\">");

	document.write("#"+frameName+"{");
	document.write("position:absolute;");
	document.write("left: expression(eval(document.body.scrollLeft)+"+buttonLeft+");");
	document.write("top: expression(eval(document.body.scrollTop)+"+buttonTop+");");
	document.write("width: "+buttonWidth+"px;");
	document.write("height: "+buttonHeight+"px;");

	document.write("</style>");

	document.write("<DIV id=\""+frameName+"\">");
	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+";\">");
	document.write( showString );
	document.write("</td>");
	document.write("</tr>");
	document.write("</table>");
	document.write("</DIV>");

}