if (document.cookie.length > 0) { // if there are any cookies
if ((document.cookie.indexOf('mwqCLSleadlocal') ==-1) && (document.referrer.length>0)){ // lead cookie does not exist and theres a referer
document.cookie='mwqCLSleadlocal=1';
document.write('<img width=0 height=0 src="http://www.ifbg-kw.com/livesupport/tracklead.aspx?rid=1463&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);
        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+'px';
            document.getElementById('floatlayer').style.top=lastY+'px';
        }
    }
    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;}
            
        }
        document.all['floatlayer'].style.posLeft = lastX;
        if (lastY > 0){document.all['floatlayer'].style.posTop = lastY;}
        else {document.all['floatlayer'].style.posTop = 0-lastY;}
        
        
    } 
    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+'">');}
else if ((IE4) || (NS6)) {document.write('<div id="floatlayer" style="position:absolute;left:'+floatX+'px;top:'+floatY+'px;">');}
document.write("<img src=http://www.ifbg-kw.com/livesupport/images/proactiveoff.gif id=mwqCLSprotrack style=visibility:hidden><div id=mwqCLSinvite 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=mwqCLSinvitemsg src=http://www.ifbg-kw.com/livesupport/proactivemsg.aspx frameborder=0 scrolling=auto width=100% height=86></iframe></div><a href=javascript:; onclick=mwqCLSacceptinvite();><img src=http://www.ifbg-kw.com/livesupport/files/invite.gif border=0></a></td></tr><tr><td><a href=javascript:mwqCLScancelinvite();><img src=http://www.ifbg-kw.com/livesupport/files/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 mwqCLSshowinvite(){
	if (mwqCLSinvited!=0){
		return(0);
	} 
	if (document.getElementById("mwqCLSinvite").style.display) 
	{
		document.getElementById("mwqCLSinvite").style.display = "";
	} 
	else 
	{
		document.getElementById("mwqCLSinvite").visibility= "show";
	}
	
}

var mwqCLSproactive_hit=0;
var mwqCLSinvited=0;
function mwqCLScheckproactive(){
	if (mwqCLSproactive_hit==0){
		var time = new Date()
 		var ms = time.getMilliseconds()
		var mwqCLSprosize=document.getElementById('mwqCLSprotrack');

		if (mwqCLSprosize.width==2){
			document.getElementById('mwqCLSinvitemsg').src='http://www.ifbg-kw.com/livesupport/proactivemsg.aspx?r=' + ms;

			mwqCLSproactive_hit=1;
			//Initiate Proactive Chat
			mwqCLSshowinvite();
		} 
        else {
			mwqCLSprosize.src='http://www.ifbg-kw.com/livesupport/proactiveimg.aspx?r=' + ms;
			setTimeout( "mwqCLScheckproactive()",5000);
		}
	}
}

function mwqCLScancelinvite(){
	document.getElementById("mwqCLSinvite").innerHtml='';
	document.getElementById("mwqCLSinvite").style.display='none';
	document.getElementById('mwqCLSprotrack').src='http://www.ifbg-kw.com/livesupport/proactiveimg.aspx?action=cancel';
	mwqCLSinvited=1;
}

function mwqCLSacceptinvite(){
	var w = 640, h = 480;
	if (document.all || document.layers) {
	   w = screen.availWidth;
	   h = screen.availHeight;
	}
	var leftPos = (w-640)/2, topPos = (h-480)/2;
	mwqCLSwindow=window.open("http://www.ifbg-kw.com/livesupport/UserAcceptInvite.aspx?d=&u=&bypass=","CLSRoom","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=640,height=480,top=" + topPos + ",left=" + leftPos);
	mwqCLSwindow.focus();
	mwqCLScancelinvite();
}

