// Talisma Custom Development
// By: Shawn Hilditch
// Date: Oct 27, 2005
// All changes marked by //TPS

// NetAgent Server data
// *** Modify the following line to include the full URL path to the NetAgent server
var prefix = 'https://liverep.esignal.com/netagent/proactive/';
var load_img = new Image();
var pop_img = new Image();
var now = new Date();
//Change to false if you don't want to see alerts.
var alerts = false;

//TPS - Send Invite record to NetAgent
function recordInvite(){
	load_img.src = prefix+'poppedchat.aspx?rand='+now.getTime();
	if (alerts) alert("Popped");
}

//Popup Session Layer Popup Script -- C.Y. Lee 012605 -> 073005.
function neverCookie() { // This cookie set is for NEVER AGAIN!
cookieName = "LiveRepNever";
	if(document.cookie != document.cookie) 
	{index = document.cookie.indexOf(cookieName);}
	else {index = -1;}
	if (index == -1){
	document.cookie=cookieName+"="+"Never=Yes"+"; expires=Monday, 04-Apr-2035 05:00:00 GMT";
//TPS
	load_img.src = prefix+'blocked.aspx?rand='+now.getTime();
	if (alerts) alert("Blocked");
	}
}
function noNextCookie() { // This cookie set is for NO 2nd invite if triggered the Sales que!
cookieName = "LiveRepNoNext";
	if(document.cookie != document.cookie) 
	{index = document.cookie.indexOf(cookieName);}
	else {index = -1;}
	if (index == -1){
	document.cookie=cookieName+"="+"NoNext=Yes";
//TPS
	if (alerts) alert("Refused");
	load_img.src = prefix+'refused.aspx?rand='+now.getTime();
	}
}
/*function get_cookie1(LiveRepA1) {
  var search = LiveRepA1 + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length // set index of beginning of value
      end = document.cookie.indexOf(";", offset); // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}*/
function hideLayers(id) {
document.getElementById(id).style.visibility="hidden";
}
function showLayer(id) {
document.getElementById(id).style.visibility="visible";
}
function loadInviteQuoTrek(){
	//if (get_cookie1('poppedup1')=='')
	//document.cookie="poppedup1=yes"
	markup =  "<div id='layer1' style='position:absolute; width:200px; height:115px; z-index:1; left:230px; top:230px;\n";
	markup += " visibility: hidden;'>\n"
	markup += "<img id='open_image' src='https://liverep.esignal.com/netagent/nada/request_chat_image.asp?ROUTEIDENT=QuoTrek&\n";
	markup += "OPENIMG=invite1.gif&CLOSEDIMG=clearPixel.gif'\n";
	markup += " width='288' height='192' border='0' usemap='#noThanks'> <map name='noThanks'>\n"; //NOTHANKS WITH CLOSE
	markup += "<area shape='rect' coords='214,171,288,191' href='#' onClick=hideLayers('layer1')>\n";
	markup += "<area shape='rect' coords='98,171,137,191' href='#' onClick=\"neverCookie();hideLayers('layer1')\">\n"; //NEVER COOKIE
	markup += "<area shape='rect' coords='208,108,268,137'\n";
//TPS - Change URL to point to eSginalInite.asp - this will show as an accepted proactive chat	
	markup += "href='https://liverep.esignal.com/netagent/nada/request_chat_link.asp?\n";
	markup += "ROUTEIDENT=QuoTrek&OPENLINK=https://liverep.esignal.com/netagent/proactive/eSignalInvite.aspx?\n";
	markup += "client=HTMLCLIENT%26RouteIdent=QuoTrek%26LoginName=Anonymous%20User&EMAIL=anonymous.user@talisma.com&\n";
	markup += "CLOSEDLINK=https://liverep.esignal.com/closed.asp' target='_blank' onClick=\"noNextCookie();hideLayers('layer1')\">\n";
	document.write(markup);
	setTimeout("showLayer('layer1')", 5000);
//TPS
	// Write entry to DB 
	if (document.title == "")
		load_img.src = prefix+'add.aspx?URL=' + document.location + '&TITLE=' + document.location + '&REFERRER=' + document.referrer;
	else
		load_img.src = prefix+'add.aspx?URL=' + document.location + '&TITLE=' + document.title + '&REFERRER=' + document.referrer;

	if (alerts) alert("Page Added");

	// Check the image in the div section, as the open image doesn't always work.
	if (open_image.width > 10){
		//TPS - Send Invite record to NetAgent only when invite is popped
		setTimeout("recordInvite()", 6000);
	}

}
//loadInvite()
// end of script -- C.Y. Lee 012605 1st development; 05/05/05 2nd development -- Bingo!