<!--

function TestForCookie()
//*	Attempts to write cookie.  If it cannot, a window pops up explaining that  
//*	customers will need cookies enabled to shop this merchant's storefront
{
	var expiryDate, PopUpCounter
	expiryDate = new Date();
	expiryDate.setTime (expiryDate.getTime() + 365*(24 * 60 * 60 * 1000)); // dead in 365 days
	
	if (GetCookie("SessionCookieTest") != "yes"){
		document.cookie="SessionCookieTest=yes";
		if (GetCookie("SessionCookieTest") != "yes"){
			window.open('http://cgi2.safeshopper.com/cookiemessage.htm', 'CkMsg', 'scrollbars=yes,width=450,height=300,resizable');
			SetCookie("SessionCookieTest", "no", expiryDate);
		}
	}
}	

function SurveyPopUp()
//*	Searches the Querystring for an instance of AffiliateID.  If found, this value will be stored in a cookie to be retrieved
//*	at the time of REALTIME Credit Card authorization to be associated with applicable FreeMerchant STOREID
{
	var currentDate, expiryDate, PopUpCounter
	currentDate = new Date ();
	expiryDate = new Date()
	expiryDate.setTime (expiryDate.getTime() + 365*(24 * 60 * 60 * 1000)); // dead in 365 days
	PopUpCounter = 0;
	
	if (GetCookie("FMSurveyPop1") == null){
		SetCookie("FMSurveyPop1", PopUpCounter, expiryDate);
		window.open('http://www.ehost.com/survey/survey_fm.html', 'survey', 'toolbar=yes, directories=no, location=no, status=yes, menubar=no, resizable=yes, scrollbars=yes, width=500, height=400');
	}
	else{
		PopUpCounter = GetCookie("FMSurveyPop1");
		PopUpCounter = parseInt(PopUpCounter) + 1;
		if (PopUpCounter < 4) {
			SetCookie("FMSurveyPop1", PopUpCounter, expiryDate);
			window.open('http://www.ehost.com/survey/survey_fm.html', 'survey', 'toolbar=yes, directories=no, location=no, status=yes, menubar=no, resizable=yes, scrollbars=yes, width=500, height=400');
		}
	}
}	
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, expiry) {
  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) ? expiry : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
// -->