//=============borrowed from warsteiner-usa and edited============
function checkForCR( mon, day, yr, thisyr) {


    if(IE) {
        if (this.event.keyCode == 13) {

           //oldEnuf( mon, day, yr, thisyr);

           document.forms[0].bdate.focus();

        }
 
    }

}


function oldEnuf() 
{
        var d = new Date();
        bMon = 99;

        bDay = 99;

        bYr = 9999;
        
        var thisyr = d.getFullYear() - 2000;
        var mon = d.getMonth();
        var day = d.getDay();
        var yr = d.getFullYear() - parseInt(document.getElementById("selectRegion").options[document.getElementById("selectRegion").selectedIndex].value);
        // only needed if they used a two digit year


        if (yr > 1999)  {

            yrShort = yr - 2000;

        } 
	else if (yr > 99) {

            yrShort = yr - 1900;

        }

              
 
       isDateFormat = false;
      
 
       birthdate = document.forms[0].bdate.value.split("/");
 
        
        if ( birthdate != null  && birthdate.length == 3) {
                 	// m,d,y

                 	isDateFormat = true;

        	}
		else {

	            birthdate = ageCheckForm.bdate.value.split("-");
		    // second chance
	
            if ( birthdate != null && birthdate.length == 3) {
  
                  	isDateFormat = true;

            		}
     
        }
    
        if (isDateFormat &&  birthdate != null) { 

            bMon = parseInt( birthdate[0]);

            if (birthdate[1] != null)  {
 
                bDay = parseInt( birthdate[1]);
 
            } else {
 
                isDateFormat = false;
 
            }
            if (birthdate[2] != null)  {
 
                bYr = parseInt( birthdate[2]);

                yrLen = birthdate[2].length;

            } else {
 
                isDateFormat = false;
 
            }

        }
    
            
        isOldEnuf = false;

        if (isDateFormat) { 
 
               
            
		if (isNaN(bYr) || isNaN(bYr) || isNaN(bYr)) {

                	isDateFormat = false;

            	} 
		else {
 
        	       if (yrLen == 4 && bYr < yr) {

                	    isOldEnuf = true;

                	} 
			else if (yrLen <= 2 && bYr > thisyr && bYr < yrShort) {
    
                  	  isOldEnuf = true;

                	} 
			else if (bYr == yr || bYr == yrShort) {

                    		if (bMon < mon) {

                        		isOldEnuf = true;

                    		} 
				else if (bMon == mon && bDay <= day) {

                        		isOldEnuf = true;

                    		}

               		 }		

            	}

        }
               
        if (!isDateFormat) {
  
            alert( "Please enter birthdate in this format: m/d/yy i.e. 1/2/34");

            ageCheckForm.bdate.value = "";

        } else if (!isOldEnuf) {
      
            if(navigator.appName == "Microsoft Internet Explorer")
                {
                document.write("<meta http-equiv='REFRESH' content='0;url=http://www.google.ca/'>");//type in the full url            
                window.location.reload(true);//force refresh for IE, a newly written tag won't make this happen
                }
            else{
                window.location.replace( "http://www.google.ca/");//should point to underage page
                }

        } else {
            setCookie("warsteinerforlife", "Pass");
            if(getCookie("warsteinerforlife")==null)//check if cookies are enabled
            {
                alert("You need cookies enabled to enter this website");
            }
            else{
                //alert(getCookie("warsteinerforlife"));
                if(navigator.appName == "Microsoft Internet Explorer"){
                    document.write("<meta http-equiv='REFRESH' content='0;url=home.html'>");//type in the full url
                    window.location.reload(true);//force refresh for IE, a newly written tag won't make this happen
                    }
                else{
                    window.location.href = "home.html";//point to main page
                    }
            }
   
        }

    }
    //=====end borrowing from warsteiner-usa

function setCookie ( name, value)
{
    var cCookie = name + "=" + escape ( value );
    document.cookie = cCookie;
}

function getCookie ( name )
{
    var results = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
    if (results)
        return (unescape(results[2]));
    else
        return null;
}

function checkCookie( name )
{   if(getCookie(name)==null)
        if(navigator.appName == "Microsoft Internet Explorer"){
            document.write("<meta http-equiv='REFRESH' content='0;url=age.html'>");//type in the full url
            window.location.reload(true);//force refresh for IE, a newly written tag won't make this happen
            }
        else{
            window.location = "age.html";//point to first page
            }        
    else
        return;
}
/* use in each page other than age.html to redirected to age.html
<noscript>
<!--point to the first page-->
<meta http-equiv='REFRESH' content='0;url=age.html'> 
</noscript>
*/

function checkEnter(e){ 
    //Used for IE and Netscape, since IE is finiky about Enters
    if(e && e.which){ //Netscape
        e = e;
        characterCode = e.which;
    }
    else{
        e = event;
        characterCode = e.keyCode; 
    }

    if(characterCode == 13){ 
        document.forms[0].submit();
        oldEnuf();
    }
    else{
        return;
    }

}