<!-- # Version 4.2.0 - 22 July 2003 -->
<!--

// 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) {

//alert(name+' , '+value+' , '+expires);

  document.cookie = name + "=" + escape(value) +
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
 
//alert(getCookie(name));
}


// 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.ASCRacing.com';

  if (getCookie(name)) {//alert('delete '+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);
}


//set expiration date 1 Hour ahead
var expires = new Date();
expires.setTime(expires.getTime() + (60 * 60 * 1000));


function CheckCookie(myName) {

var clicks = '2';

var count = getCookie(myName);
var popped = getCookie('popped');

//alert('Popped value='+popped);
//alert('Count value='+count);

if (popped != null)
	{
	return;
	} else {
	if (count != clicks)
		{
		if (count == null)
			{
			count = 1;
			setCookie(myName, count, expires, '/');
			} else {
			count++;
			setCookie(myName, count, expires, '/');
			}
		} else {
		if (count == clicks)
			{
			count++;
			setCookie(myName, count, expires, '/');
			// Wait 5 seconds for the dust to settle.
			setTimeout('openerup()',5000);
//newWin=window.open("http://www.ASCRacing.com/popup/form.html","form_window","resizable=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,copyhistory=0,width=437,height=592,top=5,left=50");
//newWin.focus();
			}
		}
	}
}

function openerup() {
newWin=window.open("http://www.ASCRacing.com/popup/form.html","form_window","resizable=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,copyhistory=0,width=437,height=392,top=5,left=50");
newWin.focus();
}

// after loading above code, run it once. (Simulates "onLoad" condition).

CheckCookie('counter');

function Subscribe() {
newWin=window.open("http://www.ASCRacing.com/popup/form.html","form_window","resizable=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,copyhistory=0,width=437,height=248,top=5,left=50");
newWin.focus();
}

// -->
