<!--

var LocationSearchHashtable;

function LoadLocationSearchHashtable()
{
	if (location.search.length >= 1)
	{
		var locationSearchArray = unescape(location.search.substring(1, location.search.length)).split('&');
		var locIndex = 0;
		var locationSearchKeyValue;
		
		if (locationSearchArray.length > 0)
		{
			LocationSearchHashtable = new Array();
			
			for (locIndex = 0; locIndex < locationSearchArray.length; locIndex++)
			{
				locationSearchKeyValue = locationSearchArray[locIndex].split('=');
				
				if (locationSearchKeyValue.length == 2)
				{
					LocationSearchHashtable[locationSearchKeyValue[0]] = locationSearchKeyValue[1];
				}					
			}
		}
	}
}

function CheckLocationSearchValue(searchKey)
{
	if (!LocationSearchHashtable)
	{
		LoadLocationSearchHashtable();
		
		if (LocationSearchHashtable)
			return CheckLocationSearchValue(searchKey);
			
		return null;
	}
	else
	{
		return LocationSearchHashtable[searchKey];
	}
}

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 == "" || ReturnValue == "no") 
  {	
	if (!CheckLocationSearchValue('daccess') || CheckLocationSearchValue('daccess') != 'true')
	{
		window.location.replace('default.html' + location.search);
	}
  }
}

function WriteCookie(CookieName,CookieValue)
{
	var cookieExpireDate = new Date();
	cookieExpireDate.setTime(cookieExpireDate.getTime()+(0*24*60*60*1000));
	var expireCookieString = "; expires=" + cookieExpireDate.toGMTString();
    document.cookie = CookieName + "=" + escape(CookieValue); + expireCookieString;
	return CookieValue;
}

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0) { date.setTime(date.getTime() - skew); }
}

// determine age
function howOld(day,month,year) {
    var c = new Date(); // a new instance
    fixDate(c);

    var thisDay = c.getDate();
    var thisMonth = c.getMonth() + 1;
    var thisYear = c.getFullYear();

    var yearsold = thisYear - year; 
    var monthsold = 0;
    var daysold = 0;
    var age = '';

    if (thisMonth >= month) {
      monthsold = thisMonth - month;
    }
    else {
      yearsold--;
      monthsold = thisMonth + 12 - month;
    }

    if (thisDay >= day) {
     daysold = thisDay - day;
    }
    else {
        if (monthsold > 0) {
          monthsold--;
        }
        else {
          yearsold--;
          monthsold += 11;
        }
        daysold = thisDay + 31 - day;
    }

    if (yearsold < 0) return '';

    if ((yearsold == 0) && (monthsold == 0) && (daysold == 0)) return '';

    if (yearsold > 0) {
        age = yearsold;
        if (yearsold > 1) age;
        age += ' ';
    }

    return age;
}




function doSubmit() {
 var f = document.forms[0];
 var dob,theMonth,theDay;


 /* Validate month: check for digits, then check:  1 <= month <= 12 */
 if(f.ctl00_ContentPlaceHolder1_DOB_MM.value.match(/\d{1,2}/)) {

   theMonth = eval(f.ctl00_ContentPlaceHolder1_DOB_MM.value);		
   if(!(theMonth <= 12 && theMonth >= 1)){
     alert('Please enter a valid month of birth.');
     f.ctl00_ContentPlaceHolder1_DOB_MM.focus();
     f.ctl00_ContentPlaceHolder1_DOB_MM.select(); 
     return(false); 
  }
 } 
 else {
  alert('Please enter a valid month of birth.');
  f.ctl00_ContentPlaceHolder1_DOB_MM.focus();
  f.ctl00_ContentPlaceHolder1_DOB_MM.select(); 
  return(false); 
 }
  
 /* Validate day: check for digits, then check:  1 <= day <= 31 */
 if(f.ctl00_ContentPlaceHolder1_DOB_DD.value.match(/\d{1,2}/)) {
   theDay = eval(f.ctl00_ContentPlaceHolder1_DOB_DD.value);
   if(!(theDay >= 1 && theDay <= 31)) {
      alert('Please enter a valid day of birth.'); 
      f.ctl00_ContentPlaceHolder1_DOB_DD.focus(); 
      f.ctl00_ContentPlaceHolder1_DOB_DD.select(); 
      return(false); 
   }
 }
 else {
   alert('Please enter a valid day of birth.'); 
   f.ctl00_ContentPlaceHolder1_DOB_DD.focus(); 
   f.ctl00_ContentPlaceHolder1_DOB_DD.select(); 
   return(false); 
 }

 if(!f.ctl00_ContentPlaceHolder1_DOB_YY.value.match(/\d{4}/) || f.ctl00_ContentPlaceHolder1_DOB_YY.value=="00") { 
    alert('Please enter a valid year of birth (xxxx).'); 
    f.ctl00_ContentPlaceHolder1_DOB_YY.focus(); 
    f.ctl00_ContentPlaceHolder1_DOB_YY.select(); 
    return(false); 
 }
 
 var age = howOld(f.ctl00_ContentPlaceHolder1_DOB_DD.value, f.ctl00_ContentPlaceHolder1_DOB_MM.value, f.ctl00_ContentPlaceHolder1_DOB_YY.value);
 
 if((age >= 21) && (age <= 150)) {
    dob = f.ctl00_ContentPlaceHolder1_DOB_YY.value + "-" + f.ctl00_ContentPlaceHolder1_DOB_MM.value + "-" + f.ctl00_ContentPlaceHolder1_DOB_DD.value;
    WriteCookie('admit','yes');
    
    //alert('cookie wrote yes');
    
    return(true)
 }
 else {
   alert('Sorry, you must be 21 years of age to enter this site.'); 
   WriteCookie('admit','no');
   //alert('cookie wrote no');
    return(false); 
    
   }

//passed validation
return(true);
}
function goHigh() {
  goPage('true');
}
function goLow() {
  goPage('false');
}
function goPage(speed) {
  if(doSubmit()) {
      var query = window.location.search.substring(1);
      var pairs = query.split("&");
      var referUrl;
      
      for (var i=0;i<pairs.length;i++)
	   {
         var temp = pairs[i];
         var arr1 = temp.split("=");
         if (arr1[0] == "referUrl") {
             referUrl = arr1[1];
         }		   
	   }

      if (referUrl) {
         document.location.href= unescape(referUrl);
      } else {
         document.location.href='budweiser.asp?host=' + speed + "&" + query;
      }
      
  }
}
// -->