var popWinKeyBenefits = null;
var popWinAppBenefits = null;
var popWinEmpBenefits = null;
var popWinOnYourSite = null;

function getCookie(name){
  var cname = name + "=";               
  var dc = document.cookie;  
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) + 
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

function delCookie (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function openPopWinKeyBenefits(popWinKeyBenefitsUrl,onTop) {
  popWinKeyBenefits = window.open(popWinKeyBenefitsUrl,'popWinKeyBenefits','dependent,width=360, height=360,left=20,top=20,scrollbars,resizable');
  if (popWinKeyBenefits.blur && onTop==1)
      popWinKeyBenefits.focus();
}

function openPopWinAppBenefits(popWinAppUrl,onTop) {
  popWinAppBenefits = window.open(popWinAppUrl,'popWinAppBenefits','dependent,width=360, height=360,left=20,top=20,scrollbars,resizable');
  if (popWinAppBenefits.blur && onTop==1)
    popWinAppBenefits.focus();
}

function openPopWinEmpBenefits(popWinEmpUrl, onTop) {
  popWinEmpBenefits = window.open(popWinEmpUrl,'popWinEmpBenefits','dependent,width=360, height=360,left=20,top=20,scrollbars,resizable');
  if (popWinEmpBenefits.blur && onTop==1)
    popWinEmpBenefits.focus();
}

function openPopWinOnYourSite(popWinSiteUrl, onTop) {
  popWinOnYourSite = window.open(popWinSiteUrl,'popWinOnYourSite','dependent,width=360, height=360,left=20,top=20,scrollbars,resizable');
  if (popWinOnYourSite.blur && onTop==1)
    popWinOnYourSite.focus();
}

function popWinNow(popWinNowUrl) {
  var loggedIn = "0";
  loggedIn = getCookie('LOGGEDIN');
  if (loggedIn == "0")
    openPopWinKeyBenefits(popWinNowUrl,0);
}

function popWinAppNow(popWinAppNowUrl) {
  var loggedIn = "0";
  loggedIn = getCookie('LOGGEDIN');
  if (loggedIn == "0")
    openPopWinAppBenefits(popWinAppNowUrl,0);
}

function popWinEmpNow(popWinEmpNowUrl) {
  var loggedIn = "0";
  loggedIn = getCookie('LOGGEDIN');
  if (loggedIn == "0")
    openPopWinEmpBenefits(popWinEmpNowUrl,0);
}

function resizePopWin(popWidth,popHeight) {
    window.resizeTo(popWidth,popHeight);
} 

function closePopWins() {
	if (popWinKeyBenefits && popWinKeyBenefits != null) popWinKeyBenefits.close();
	if (popWinAppBenefits && popWinAppBenefits != null) popWinAppBenefits.close();
    if (popWinEmpBenefits && popWinEmpBenefits != null) popWinEmpBenefits.close();
    if (popWinOnYourSite && popWinOnYourSite != null) popWinOnYourSite.close();
}
