var expDays = 30; // number of days the cookie should last

var page = "only-popup-once.html";
var windowprops = "width=300,height=200,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes";

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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 = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = GetCookie (name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function amt(){
  var count = GetCookie('snpcount')
  if(count == null) {
    SetCookie('snpcount','1')
    return 1
  } else {
    var newcount = parseInt(count) + 1;
    DeleteCookie('snpcount')
    SetCookie('snpcount',newcount,exp)
    return count
  }
}

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function checkCount(id) {
  var count = GetCookie('snpcount');
  if (count == null) {
    count=1;
    SetCookie('snpcount', count, exp);
	
	// INSERT THE CODE TO MAKE THE DYNAMIC LAYER APPEAR HERE
    
	var width = Math.round( (document.documentElement.clientWidth / 2) );
	
	if (id == 1) {
	
		var newWidth = width - 320;
	
	} else {
		
		var newWidth = width - 180;
		
	}
	
	document.write("<div id ='floater' style='font: Arial, Helvetica, sans-serif;color: #666666; text-decoration: none;position:absolute;left:" + newWidth + "px;top:255px;width:281px;height:auto;z-index:100;background-color: #FFFFFF;border: 1px solid #CC0000;visibility: visible;text-align: center;padding: 22px 22px 18px;'><h2 style='font-size: 105%;line-height: 110%;margin: 0px 0px 4px;padding: 0px;'>IMPORTANT NOTICE!</h2><br />This site is designed for the guidance of insurance professionals only and should not be relied upon by customers. <strong>If you are a customer, <a href='holding_customer.html' style='text-decoration:underline;color: #666666;'>click here</a>.</strong><br /><br /><span class='smallbody'><a href='#' onclick=\"MM_showHideLayers('floater','','hide')\" style='font-size: 90%; color: #666666; text-decoration:underline;'>Close this message</a></span></div>");
	
  } else {
    count++;
    SetCookie('snpcount', count, exp);
  }
}
