﻿var clientY=0;
/*window.onbeforeunload=function(evt)
{
	if(clientY<30)
	alert(clientY);
}*/
function OpenLiveChatLayer()
{	
	$("divBG1").style.display="";
    $("divLC").style.display="";
}
function CloseLiveChatLayer()
{
	$("divBG1").style.display="none";
	$("divLC").style.display="none";
}
function LayerPosition(divId1,divId2)
{
	var tbMenu=document.getElementById(divId1);
	var tdId=document.getElementById(divId2);
	var MenuStyle =tbMenu.style; 
	var MeTop = tdId.offsetTop;
	var MeLeft = tdId.offsetLeft;
	while (tdId = tdId.offsetParent)
	{
		MeTop+=tdId.offsetTop;
		MeLeft+=tdId.offsetLeft;
	} 
	MenuStyle.top=Number(MeTop+200)+"px";
	MenuStyle.left = Number(MeLeft+270)+"px"; 
}

function InitLiveChatLayer()
{
	LayerPosition("divLC","top");
	$("divBG1").style.width=document.body.scrollWidth+"px";
	$("divBG1").style.height=document.body.scrollHeight+"px";
}
function pageload1()
{
InitLiveChatLayer();
window.onresize = function(){InitLiveChatLayer();}
}
pageload1();
window.document.onmousemove=function(evt)
{
	evt=evt || window.event;
	clientY=evt.clientY;
}

function regularChatDisplay(e) { 
    //window.onbeforeunload = null; 
    if(clientY<30)
    {
		alert("Wait! A live agent would like to talk to you about "+
          "last minute savings. Please hit 'Cancel' on the next"+
          " window to remain on this page..."); 
          OpenLiveChatLayer();
          $("hidVisitPageDetail").value="pop";
          Main("");
		return "\n\nPress 'CANCEL' below to chat...\n\n"; 
    }   
} 
window.onbeforeunload = regularChatDisplay;


