﻿    var antServer = "www.bigantsoft.com" ;
    var antPort = "6660" ;
    var lang = "en" ;
	
	function talk(loginName,userName,dept,jobTitle,phone,mobile,email,pic)
	{

		var livechat_query = "server=" + antServer+ "&port=" + antPort + "&lang=" + lang + "&savehistory=1" ;
		//var url = "/livechatfile/talk.htm?" + livechat_query  ;
		var url = "/include/visiter.html?" + livechat_query  ;
		if (loginName != undefined) {url += "&loginname=" + escape(loginName) ;}
		if (userName != undefined) {url += "&username=" + escape(userName) ;}
		if (dept != undefined) {url += "&dept=" + escape(dept) ;}
		if (jobTitle != undefined) {url += "&jobtitle=" + escape(jobTitle);}
		if (phone != undefined) {url += "&phone=" + escape(phone);}
		if (mobile != undefined) {url += "&mobile=" + escape(mobile);}
		if (email != undefined) {url += "&email=" + escape(email);}
		if (pic != undefined) {url += "&pic=" + escape(pic);}
		var w = 550;
		var h = 435 ;
		var l = (screen.width-w) / 2 ;
		var t = (screen.height-h) / 2 ;
		window.open(url,"livechat","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",scroll=0,resize=auto");
	}
	
 
	function talk2(loginName,userName,dept,jobTitle,phone,mobile,email,pic)
	{
        talk(antServer,antPort,lang,loginName,userName,dept,jobTitle,phone,mobile,email,pic) ;
	}
	
	function getIcon(userIndex)
	{
        if (UserList[userIndex].Online == 0)
            document.write("<img src='http://" + antServer + ":" + antPort + "/livechatfile/images/img_man.gif' align='absmiddle' />");
        else
            document.write("<img src='http://" + antServer + ":" + antPort + "/livechatfile/images/img_ManOnline.gif' align='absmiddle' />");
    }	
	
    function getScrollXY(){
        var x,y;
        if(document.body.scrollTop){
          x=document.body.scrollLeft;
          y=document.body.scrollTop;
        }
        else{
          x=document.documentElement.scrollLeft;
          y=document.documentElement.scrollTop;
        }
        return {x:x,y:y};
    } 

    function getWinWidth()  
    {   
        if (window.innerWidth)//for Firefox   
            return window.innerWidth;    
        else if((document.body) && (document.body.clientWidth))     
            return document.body.clientWidth;   

        if (document.documentElement && document.documentElement.clientWidth)   
            return document.documentElement.clientWidth;   
        return 0;   
    }   
    
    function getAbsWidth_Left(minWidth,liveChatWidth)
    {
        return getAbsWidth(minWidth,liveChatWidth,"Left");
    }
    function getAbsWidth_Right(minWidth,liveChatWidth)
    {
        return getAbsWidth(minWidth,liveChatWidth,"Right");
    }
    function getAbsWidth(minWidth,liveChatWidth,flag)
    {
        if (liveChatWidth == undefined)
            liveChatWidth = 115 ; 
        var winWidth = getWinWidth() ;
        var _width = 0 ;
        if (flag == "Right")
        {
            if ((minWidth + liveChatWidth) > winWidth)
                _width = minWidth - liveChatWidth ;
            else
                _width = minWidth + (winWidth-minWidth)/2 ; 
        }
        if (flag == "Left")
        {
            if ((winWidth-minWidth)/2<liveChatWidth)
                _width = 0 ;
            else
                _width = (winWidth-minWidth)/2-liveChatWidth ; 
        }
        return _width ;
    }
	
	function setFloat(x,y)
	{
		var div = document.getElementById("livechat");
		
		window.onscroll = function () { 
			div.style.top = getScrollXY().y + y; 
		} 
		div.style.top = y ;
		div.style.left = x ;
	}
