if (document.cookie.length > 0) { // if there are any cookies
if ((document.cookie.indexOf('xlaALSleadlocal') ==-1) && (document.referrer.length>0)){ // lead cookie does not exist and theres a referer
document.cookie='xlaALSleadlocal=1';
document.write('<img width=0 height=0 src="http://toyotalivehelp.livelead.ca/LiveHelpFR/tracklead.aspx?rid=928&lead=' + escape(document.referrer) + '">');}}

floatX=10;
floatY=10;
layerwidth=700;
layerheight=450;
halign="center";
valign="top";
delayspeed=0;

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;
            document.getElementById('floatlayer').style.top=lastY;
            document.getElementById('floatlayer').style.zIndex=50;
        }
    }
    else if (IE4)
    {
        if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
        {
            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;}
            }
        } 
        else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
        {
            if (lastX==-1 || delayspeed==0)
            {
                lastX=document.documentElement.scrollLeft + floatX;
                lastY=document.documentElement.scrollTop + floatY;
            }
            else
            {
                var dx=Math.abs(document.documentElement.scrollLeft+floatX-lastX);
                var dy=Math.abs(document.documentElement.scrollTop+floatY-lastY);
                var d=Math.sqrt(dx*dx+dy*dy);
                var c=Math.round(d/10);
                
                if (document.documentElement.scrollLeft+floatX>lastX) {lastX=lastX+delayspeed+c;}
                if (document.documentElement.scrollLeft+floatX<lastX) {lastX=lastX-delayspeed-c;}
                if (document.documentElement.scrollTop+floatY>lastY) {lastY=lastY+delayspeed+c;}
                if (document.documentElement.scrollTop+floatY<lastY) {lastY=lastY-delayspeed-c;}
            }
        }
           
        document.all['floatlayer'].style.posLeft = lastX;
        document.all['floatlayer'].style.posTop = lastY;
        document.all['floatlayer'].style.zIndex = 50;
    } 
    
    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=http://toyotalivehelp.livelead.ca/LiveHelpFR/images/proactiveoff.gif id=xlaALSprotrack style=visibility:hidden><div id=xlaALSinvite STYLE='visibility:hide;display:none;'><table border=0 cellspacing=0 cellpadding=0 style='border: solid 1px #000000;'><tr><td style='background: #D31517; padding: 8px; border-bottom: solid 1px #000000;' align='right'><a href='javascript:xlaALScancelinvite();' style='#color: #FFFFFF; font-weight: bold; text-decoration: underline;'>Fermer - Cliquer ici</a></td></tr><tr><td style='background: #FFFFFF;' align='center'><iframe id=xlaALSinvitemsg src=http://toyotalivehelp.livelead.ca/LiveHelpFR/proactivemsg.aspx frameborder=0 scrolling=auto width=650 height=20></iframe></td></tr><tr><td style='border-top: solid 1px #000000;'><a href=javascript:; onclick=xlaALSacceptinvite();><img src=http://toyotalivehelp.livelead.ca/LiveHelpFR/files/invite.jpg 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;

var rnd = 0;
var xlaALSproactive_hit=0;
var xlaALSinvited=0;

function xlaALSshowinvite()
{
	if (xlaALSinvited!=0)
	{
		return(0);
	} 
	if (xlaALSinvite.style.display) 
	{
		xlaALSinvite.style.display = "";
		xShowHideSelects('hidden');
		adjust();
	} 
	else 
	{
		xlaALSinvite.visibility = "show";
		xShowHideSelects('hidden');
		adjust();
	}
}

function xlaALScheckproactive()
{
	if (xlaALSproactive_hit==0)
	{
		var time = new Date()
 		var ms = time.getMilliseconds()
		var xlaALSprosize=document.getElementById('xlaALSprotrack');

		if (xlaALSprosize.width==2)
		{
			document.getElementById('xlaALSinvitemsg').src='http://toyotalivehelp.livelead.ca/LiveHelpFR/proactivemsg.aspx?r=' + ms;

			xlaALSproactive_hit=1;
			xlaALSshowinvite();
		} 
		else 
		{
			xlaALSprosize.src='http://toyotalivehelp.livelead.ca/LiveHelpFR/proactiveimg.aspx?r=' + ms;
			setTimeout( "xlaALScheckproactive()",3000);
		}
	}
}

function xShowHideSelects(eStatus)
{
	var xSelects = document.getElementsByTagName('select');
	
	for( var i = 0; i < xSelects.length; i++)
	{
		xSelects[i].style.visibility = eStatus;
	}
}

function xlaALScancelinvite()
{
	document.getElementById("xlaALSinvite").innerHtml='';
	document.getElementById("xlaALSinvite").style.display='none';
	document.getElementById('xlaALSprotrack').src='http://toyotalivehelp.livelead.ca/LiveHelpFR/proactiveimg.aspx?action=cancel';
	xlaALSinvited=1;
	xShowHideSelects('visible');
}

function xlaALSacceptinvite()
{
	var w = 640, h = 480;
	if (document.all || document.layers) 
	{
	   w = screen.availWidth;
	   h = screen.availHeight;
	}
	var leftPos = (w-760)/2, topPos = (h-600)/2;
	xlaALSwindow=window.open("http://toyotalivehelp.livelead.ca/LiveHelpFR/UserAcceptInvite.aspx?d=&u=&bypass=","ALSRoom","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=760,height=600,top=" + topPos + ",left=" + leftPos);
	xlaALSwindow.focus();
	xlaALScancelinvite();
	xShowHideSelects('visible');
}

