<!--

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
// An adaptation of Dorcht's function for setting a cookie.

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");
}


// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
// Heinle's function for retrieving a cookie.

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;
}


// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds

// An adaptation of Dorcht's function for deleting a cookie.

function deleteCookie (name,path,domain) {

  path = '/';
  //  domain = 'www.bodyrx.com';

  if (getCookie(name)) {
    document.cookie = name + "=" + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + "; expires=Thu, 01-Jan-70 00:00:01 GMT";

  }
}


// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function CheckCookie(myName) {

//set expiration date 1 Hour ahead

var expiration = new Date();
expiration.setTime(expiration.getTime() + 3600000);

var x = 2;

var temp = getCookie(myName);

if (temp != 2) { if (temp == null) {
  temp = 1;
  setCookie(myName, temp, null, '/');

  } else {
  temp++;
  setCookie(myName, temp, null, '/');

  }	} else {

if (temp == 2) {
  temp++;
  setCookie(myName, temp, null, '/');

newWin=window.open("http://www.bodyrx.com/reg_popup.htm","form_window","resizable=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,copyhistory=0,width=400,height=300,top=100,left=100");
  }	}

}

// after loading above code, run it once. (Simulates "onLoad" condition).

CheckCookie('counter');

// -->
