document.write('<img width=0 height=0 border=0 src="../sswchat/tracklead.aspx?rid=7767&lead=' + escape(document.referrer) + '">');

floatX=10;
floatY=10;
layerwidth=325;
layerheight=280;
halign="center";
valign="center";
delayspeed=2;

NS6=false;
IE4=(document.all);
if (!IE4) {NS6=(document.getElementById);}
NS4=(document.layers);

function adjust()
{
    if ((NS4) || (NS6)) 
    {
            if (lastX==-1 || delayspeed==0)
            {
                lastX=window.pageXOffset + floatX;
                lastY=window.pageYOffset + floatY;
            }
            else
            {
                var dx=Math.abs(window.pageXOffset+floatX-lastX);
                var dy=Math.abs(window.pageYOffset+floatY-lastY);
                var d=Math.sqrt(dx*dx+dy*dy);
                var c=Math.round(d/10);
                
//                alert(c);
//                alert(lastX);
//                alert(delayspeed);
//                
                if (window.pageXOffset+floatX>lastX) {lastX=lastX+delayspeed+c;}
                if (window.pageXOffset+floatX<lastX) {lastX=lastX-delayspeed-c;}
                if (window.pageYOffset+floatY>lastY) {lastY=lastY+delayspeed+c;}
                if (window.pageYOffset+floatY<lastY) {lastY=lastY-delayspeed-c;}
            }
            if (NS4)
            {
                document.layers['floatlayer'].pageX = lastX;
                document.layers['floatlayer'].pageY = lastY;
            }
            if (NS6)
            {
                document.getElementById('floatlayer').style.left=lastX;
                document.getElementById('floatlayer').style.top=lastY;
            }
        }
        else if (IE4)
        {
            if (lastX==-1 || delayspeed==0)
            {
                lastX=document.body.scrollLeft + floatX;
                lastY=document.body.scrollTop + floatY;
            }
            else
            {
                var dx=Math.abs(document.body.scrollLeft+floatX-lastX);
                var dy=Math.abs(document.body.scrollTop+floatY-lastY);
                var d=Math.sqrt(dx*dx+dy*dy);
                var c=Math.round(d/10);
                if (document.body.scrollLeft+floatX>lastX) {lastX=lastX+delayspeed+c;}
                if (document.body.scrollLeft+floatX<lastX) {lastX=lastX-delayspeed-c;}
                if (document.body.scrollTop+floatY>lastY) {lastY=lastY+delayspeed+c;}
                if (document.body.scrollTop+floatY<lastY) {lastY=lastY-delayspeed-c;}
            }
            try
            {
                document.all['floatlayer'].style.posLeft = lastX;
                document.all['floatlayer'].style.posTop = lastY;
            }
            catch(err)
            {
            }
    } 
    setTimeout('adjust()',50);
}

function define()
{
    if ((NS4) || (NS6)) 
    { 
        if (halign=="left") {floatX=ifloatX};
        if (halign=="right") {floatX=window.innerWidth-ifloatX-layerwidth-20};
        if (halign=="center") {floatX=Math.round((window.innerWidth-20)/2)-Math.round(layerwidth/2)};
        if (valign=="top") {floatY=ifloatY};
        if (valign=="bottom") {floatY=window.innerHeight-ifloatY-layerheight};
        if (valign=="center") {floatY=Math.round((window.innerHeight-20)/2)-Math.round(layerheight/2)};
    }
    if (IE4) 
    {
        if (halign=="left") {floatX=ifloatX};
        if (halign=="right") {floatX=document.body.offsetWidth-ifloatX-layerwidth-20}
        if (halign=="center") {floatX=Math.round((document.body.offsetWidth-20)/2)-Math.round(layerwidth/2)}
        if (valign=="top") {floatY=ifloatY};
        if (valign=="bottom") {floatY=document.body.offsetHeight-ifloatY-layerheight}
        if (valign=="center") {floatY=Math.round((document.body.offsetHeight-20)/2)-Math.round(layerheight/2)}
    }
}





if (NS4) {document.write('LAYER NAME="floatlayer" LEFT="'+floatX+'" TOP="'+floatY+'">');}
if ((IE4) || (NS6)) {document.write('<div id="floatlayer" style="position:absolute; left:'+floatX+'; top:'+floatY+';">');}

document.write("<img src=../Sharedimages/Spacer.gif id=Chatprotrack style=visibility:hidden;><div id=Chatinvite STYLE='visibility:hide;display:none;'><table border=0 cellspacing=0 cellpadding=0><tr><td><div style='position:relative;left:140px;top:128px;width:158px;height:86px;z-index:1;'><iframe id=Chatinvitemsg src='../sswchat/proactivemsg.aspx' frameborder=0 scrolling=auto width=100% height=86></iframe></div><a href=javascript:; onclick=Chatacceptinvite();><img src=../images/chat/invite.gif border=0></a></td></tr><tr><td><a href=javascript:Chatcancelinvite();><img src=../images/chat/invite-close.gif border=0></a></td></tr></table></div>");



if (NS4) 
{
    document.write('</LAYER>');
}
if ((IE4) || (NS6)) 
{
    document.write('</DIV>');
}
ifloatX=floatX;
ifloatY=floatY;
define();
window.onresize=define;
lastX=-1;
lastY=-1;
adjust();


var rnd = 0;
function Chatshowinvite()
{
	if (Chatinvited!=0)
	{
		return(0);
	} 
	if (Chatinvite.style.display)
	{
		Chatinvite.style.display = "";
	} else {
		Chatinvite.visibility= "show";
	}
}

var Chatproactive_hit=0;
var Chatinvited=0;
function Chatcheckproactive(){
	if (Chatproactive_hit==0){
		var time = new Date()
 		var ms = time.getMilliseconds()
		var Chatprosize=document.getElementById('Chatprotrack');

		if (Chatprosize.width==2){
			document.getElementById('Chatinvitemsg').src='../sswcaht/proactivemsg.aspx?r=' + ms;

			Chatproactive_hit=1;
			//Initiate Proactive Chat
			Chatshowinvite();
		} else {
			Chatprosize.src='../sswchat/proactiveimg.aspx?r=' + ms;
			setTimeout( "Chatcheckproactive()",5000);
		}
	}
}

function Chatcancelinvite(){
	document.getElementById("Chatinvite").innerHtml='';
	document.getElementById("Chatinvite").style.display='none';
	document.getElementById('Chatprotrack').src='../sswchat/proactiveimg.aspx?action=cancel';
	Chatinvited=1;
}

function Chatacceptinvite(){
	var w = 640, h = 480;
	if (document.all || document.layers) {
	   w = screen.availWidth;
	   h = screen.availHeight;
	}
	var leftPos = (w-520)/2, topPos = (h-350)/2;
	Chatwindow=window.open("../sswchat/UserAcceptInvite.aspx?d=&u=&bypass=","SSWRoom","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=520,height=350,top=" + topPos + ",left=" + leftPos);
	Chatwindow.focus();
	Chatcancelinvite();
}

