// Remove the slashes below to turn on FREE Shipping Option. Upload from UECSDB too.
// alert("TODAY'S SPECIAL " + "\nFREE GROUND SHIPPING (till 1pm EST)*" + "\n*some restrictions apply.");

function open_remote()
{
  var count;
  var remote;

  count = getcookie4( "survey_01_counts" );

  if ( count < "1111" )
  {
    count = count + 1;
    setcookie1("survey_01_counts", count);
    remote = window.open("survey.htm?ref=" + document.URL, "_remote_control", "toolbar=no,width=450,height=400,resizable=yes,scrollbars=yes");
  }
  if ( count = "1111" )
  {
  }
  if ( count = "" )
  {
    count = 1;
    setcookie1("survey_01_counts", count);
    remote = window.open("survey.htm?ref=" + document.URL, "_remote_control", "toolbar=no,width=450,height=400,resizable=yes,scrollbars=yes");
  }
  if ( remote != null )
  { 
    if ( remote.opener == null )
    { 
      remote.opener = self;
    } 
  }
} 
  
function getcookie3(name) {
	var cname="~`" + name + "="
	if(document.cookie.length>0) {
		var begin=document.cookie.indexOf(cname);
		if(begin!=-1) {
			begin+=cname.length
			var end=document.cookie.indexOf("%7E%60",begin)
			if(end==-1) end=document.cookie.length
			return unescape(document.cookie.substring(begin,end)) 
		}
	}
	return "" 
}

function getcookie4(name) {
	var cname="~`" + name + "="
	if(document.cookie.length>0) {
		var begin=document.cookie.indexOf(cname);
		if(begin!=-1) {
			begin+=cname.length
			var end=document.cookie.indexOf("~`",begin)
			if(end==-1) end=document.cookie.length
			return unescape(document.cookie.substring(begin,end)) 
		}
	}
	return "" 
}


function setcookie1(name, value, exp) {
	if (exp==null) {var expdate=new Date(); expdate.setTime(expdate.getTime()+(30*24*60*60*1000));} else var expdate=exp;
	document.cookie = "~`" + name + "=" + escape(value) + "~`; path=/; expires=" + expdate.toGMTString();
}


function open_survey ()
{

	if ( document.URL.search(/google/i) == -1 )
	{
	  if ( getcookie3("survey_01") != "done" )
	  {
	    open_remote();
	  }
	}

}

function cookie_set( name, value, exp )
{
}

function cookie_get( name )
{
  var allcookies = document.cookie;
  var pos = allcookies.indexOf( name + "=" );
  if ( pos != -1 )
  {
    var start = pos + name.lenght + 1;
    var end = allcookies.indexOf(";", start)
    if ( end == -1 )
    {
      end = allcookies.lenght;
    }
    var value = allcookies.substring(start, end);
    value = unesacape($value);
    return value;
  }
}

function log()
{
  var client_id = getcookie3("client_id");
  if ( client_id == "" )
  {
    remote = window.open("log.php", "log", "toolbar=no,width=200,height=100,resizable=no,scrollbars=no");
    if ( remote != null )
    { 
      if ( remote.opener == null )
      { 
        remote.opener = self; 
       } 
    } 
  }
}

var referer_history = getcookie4("referer_history")
var new_referer = document.referrer;

if ( new_referer.search(/usereasy.com/i) == -1 && new_referer != "")
{
  referer_history = referer_history + new_referer + "->" + document.URL + "|!|";
  setcookie1("referer_history", referer_history);
}

//document.write ("<br>Post Test<br>");
//document.write ("<br>" + document.URL);
//document.write ("<br>" + new_referer);
//document.write ("<br>New function" + cookie_get("~'referer_history"));
