/*This js file is added for ENH_14,EPLTM-7113 by rajesh masna*/
/*This js file is modified by Murthy on 4th Feb, 2009 to address Jira ID : EPLTFM-8125 
* handleOnClose method has been updated by cookieValue >=0
*/
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0)
    break;
  }
  return null;
}

function setCookie (name, value) {
  var argv = setCookie.arguments;
  var argc = setCookie.arguments.length;
  var expires = (2 < argc) ? argv[2] : null;
  var path = (3 < argc) ? argv[3] : null;
  var domain = (4 < argc) ? argv[4] : null;
  var secure = (5 < argc) ? argv[5] : false;
  
  document.cookie = name + "=" + escape (value) +
   ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
   ((path == null) ? "" : ("; path=" + path)) +
   ((domain == null) ? "" : ("; domain=" + domain)) +
   ((secure == true) ? "; secure" : "");
}
var agentId;

var finalVisitValue;
var cookieValue = 0;
function DisplayInfo(csrAgentId) {
  agentId =  csrAgentId;
	  if(getCookie("DNBiPageVisitCounterCookie")!=null && getCookie("DNBiPageVisitCounterCookie")!="") {
		 cookieValue = getCookie("DNBiPageVisitCounterCookie");
		 cookieValue++;
	  }
	  
	  setCookie("DNBiPageVisitCounterCookie", cookieValue, null, "/", null, false);
  
  // this method is commented
 //setVFocus();
}

function setVFocus()
{
	if(document.Register!=null&&document.Register!=""){
  		document.Register.logonId.focus();
  	}
}


function handleOnClose(configuredPopupValue,searchValue,configuredCookieValue) {

	
	if (event.clientX < 0 ||event.clientY < 0) {
		var showPopUp;
		if(configuredPopupValue=="Y"){
		  	if(getCookie("DNBiPageVisitCookie")!=null||agentId!= ""){
			 	showPopUp = false;
			 }
			else if ((getCookie("DNBiPageVisitCookie")==null && cookieValue >= configuredCookieValue  && (agentId==null || agentId==""))||(getCookie("DNBiPageVisitCookie")==null && searchValue == "true" && (agentId==null || agentId==""))){
			 	showPopUp = true;
			 }
			if(showPopUp){
	   			var expdate = new Date();
	  			var DNBiVisitedPagesCookieValue;
	  			expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 30));
	  			setCookie("DNBiPageVisitCookie", "popupshowed", expdate, "/", null, false);
			    window.open("SiteAbandonPopUp?storeId=10001","sitepopup");
			}
		}
	}
}

/* 
 * EPLTFM-10648 - Function to surpress the java script error while navigating through menu links. The links are driven from the JSP 
 * CachedMdsbMenuInclude.jsp and the function occurences in the files CachedMdsbHeaderDisplay.jsp, CachedMdsbMenuInclude.jsp
 */
function ab_click(x,y)
{}

