//Change when needed	
	var ofAge = "default.asp";
	var tooYoung = "tooyoung.asp";
	var minAge = 13;
	var verifyAge = "ageverification.asp"
	var remembered = "zipcode.asp"



	var agt=navigator.userAgent.toLowerCase();

	function send()
	{document.theform.submit();}

	function cookieChecker()
	{
		ReadCookie("admit");
	}

	function displayYear()
	{
		
		var agt=navigator.userAgent.toLowerCase();
		var age = validAge();
			if((age >= minAge) && (age <= 150)) {
   				if (agt.indexOf("opera") != -1) 
				{
					window.close();
					window.open(ofAge);
				}
				var cookie = WriteCookie('admit','yes');
			 }
 			else {
  				var cookie = WriteCookie('admit','no');
				if (agt.indexOf("opera") != -1) 
				{
					window.close();
					window.open(tooYoung);
				}
				else {
				window.location.replace(tooYoung);
				}
   				return(true);
  			 }
		
		ReadCookie(cookie);	
		return(true);
	}
	function validAge()
	{
		var validYear = parseFloat(myForm.yearField.value);
	  	var month = parseFloat(myForm.month.value);
		var date = parseFloat(myForm.day.value);
            	Today=new Date();
            	var yr = Today.getYear();
           	var mo = Today.getMonth() + 1;
		var dy = Today.getDate();
		
		if (yr < 1900) 
			{yr = yr + 1900;}

	    	    			
		 if((mo == month) && (date <= dy)) 
			  {var yrsOld = yr - validYear;}  
            
		else 
			{var yrsOld = (yr - validYear) - 1;}

		WriteCookie('date',month + '/' + date + '/' + validYear);
		WriteCookie('age',yrsOld);

		 return yrsOld;
	}

function ReadCookie(CookieName)
{
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var ReturnValue = "";
  var CookiePieces;
  var x = 0;
  
  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++)
  {
    CookiePieces = CookieSet[x].split ('=');

    if (CookiePieces[0].substring (0,1) == ' ')
    {
      CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
    }
    
    if (CookiePieces[0] == CookieName)
    {
      ReturnValue = CookiePieces[1];
    }
  }

  if (ReturnValue == 'yes') {
     var query = window.location.search.substring(0);
	if (agt.indexOf("opera") != -1) 
	{
		window.close();
		window.open(ofAge);
	}
     window.location.replace(ofAge);
  }
  else if (ReturnValue == 'no') {
	if (agt.indexOf("opera") != -1) 
	{
		window.close();
		window.open(tooYoung);
	}
	else {
		window.location.replace(tooYoung);
	}
	
  }
}

function CookieReader(CookieName)
{
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var ReturnValue = "";
  var CookiePieces;
  var x = 0;
  
  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++)
  {
    CookiePieces = CookieSet[x].split ('=');

    if (CookiePieces[0].substring (0,1) == ' ')
    {
      CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
    }
    
    if (CookiePieces[0] == CookieName)
    {
      ReturnValue = CookiePieces[1];
    }
  }

	return ReturnValue;
}

function WriteCookie(CookieName,CookieValue)
{
    document.cookie = CookieName + "=" + escape(CookieValue);
	return CookieValue;
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function CheckifYoung()
{
	var CookieName='admit';

	  var CookieString = document.cookie;
	  var CookieSet = CookieString.split (';');
	  var SetSize = CookieSet.length;
	  var ReturnValue = "";
	  var CookiePieces;
	  var x = 0;
	  
	  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++)
	  {
		CookiePieces = CookieSet[x].split ('=');

		if (CookiePieces[0].substring (0,1) == ' ')
		{
		  CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
		}
		
		if (CookiePieces[0] == CookieName)
		{
		  ReturnValue = CookiePieces[1];
		}
	  }

	  if (ReturnValue == 'yes') {
		 var query = window.location.search.substring(0);
		if (agt.indexOf("opera") != -1) 
		{
			window.close();
			window.open(ofAge);
		}
		 window.location.replace(ofAge);
	  }
	  else if (ReturnValue == 'no') {
		//window.location.replace(tooYoung);
	  }else {
		window.location.replace(verifyAge);
	  }
}

function CheckifOld()
{
	/*window.location.href='ageVerification.html';
 */
	var CookieName='admit';
  
  var CookieString = document.cookie;
  var CookieSet = CookieString.split (';');
  var SetSize = CookieSet.length;
  var ReturnValue = "";
  var CookiePieces;
  var x = 0;
  
  for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++)
  {
    CookiePieces = CookieSet[x].split ('=');

    if (CookiePieces[0].substring (0,1) == ' ')
    {
      CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
    }
    
    if (CookiePieces[0] == CookieName)
    {
      ReturnValue = CookiePieces[1];
    }
  }

  if (ReturnValue == 'yes') {
     var query = window.location.search.substring(0);
     //window.location.href=ofAge;
  }
  else if (ReturnValue == 'no') {
		if (agt.indexOf("opera") != -1) 
		{
			window.close();
			window.open(tooYoung);
		}
		else {
			window.location.replace(tooYoung);
		}
		
  }else {
	window.location.replace(verifyAge);
  }
 
}






/***************************************************************************
 ***************************************************************************
 ***************************************************************************/
