function setCookie (name, value) {
  var argv = setCookie.arguments;
  var argc = setCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var tempcook = name + "=" + escape (value);
  if (expires) {
    tempcook = tempcook + "; expires=" + expires.toGMTString();
    }
  document.cookie = tempcook;
  }

function getCookie(name) {
  var cookie = " " + document.cookie;
  var search = " " + name + "=";
  var setStr = null;
  var offset = 0;
  var end = 0;
  if (cookie.length > 0) {
    offset = cookie.indexOf(search);
    if (offset != -1) {
      offset += search.length;
      end = cookie.indexOf(";", offset)
      if (end == -1) {
        end = cookie.length;
        };
      setStr = unescape(cookie.substring(offset, end));
      };
    };
  return(setStr);
  };

function delCookie (name) {
  document.cookie = name + "=del;expires=Mon, 01-Jan-2000 00:00:00 GMT";
  }; 





if (!document.cookie) { //if no cookie sets one with a count of 1
setCookie("clickcount","1");
} 

else 

{ // if there is a cookie

var loggedin = getCookie("loggedin");
if (loggedin == "yes") { //document.write("logged in. show page as normal."); 
}

if (loggedin != "yes") { //document.write("not logged in. checking how many clicks.");

var currentclick = getCookie("clickcount");
//document.write("there is a cookie. it's " + currentclick + "<br><br>"); 
delCookie("clickcount");
++currentclick;



//This next code is to allow visitors to view certain pages and not get pulled to the signup page, such as information requests or distributor signups.
//If they go to a safe page it simply credits them back that page view.
if(document.location.href == "http://www.econofrost.com/form_information_request.html") { currentclick = currentclick - 1; }
if(document.location.href == "http://www.econofrost.com/form_become_distributor.html") { currentclick = currentclick - 1; }





setCookie("clickcount",currentclick);

if (currentclick < 5) { //if cookie and count is under 10
//document.write("click count is under 10. Page shown as normal."); 
}
else 
{ //if cookie and count is over 10 and not logged in
//document.write("not logged in. taking them to the register/login page."); 
window.location=("http://www.econofrost.com/cookies/login.php);
}


} //end of if cookie and count is over 10

} //end of main if there is a cookie
