var ageLimit = 18;

function userServerAge()
{
      if((age==0)||(age > ageLimit - 1))
      {
            return true;
      }
      else
      {
            return false;
      }
}


function doCheck(){

	//form validation
	if (document.getElementById("bmonth").value < 1){
		alert("Please select your birth Month");
		document.ageCheck.bmonth.focus();
		return false;
		}
	if (document.getElementById("bday").value < 1){
		alert("Please select your birth Day");
		document.ageCheck.bday.focus();
		return false;
		}
	if (document.getElementById("byear").value < 1){
		alert("Please select your birth Year");
		document.ageCheck.byear.focus();
		return false;
	}
			
	// age calculations		
	var birthDate=new Date(document.getElementById("byear").value, document.getElementById("bmonth").value-1, document.getElementById("bday").value);
	var curDate=new Date();
	var userClientAge=curDate.getFullYear()-birthDate.getFullYear();
	
	if(curDate.getMonth() < birthDate.getMonth()) {
		  userClientAge--;    
	}
	else if((curDate.getMonth() == birthDate.getMonth()) && (curDate.getDate() < birthDate.getDate())) {
		  userClientAge--;    
	}
	
	// check age against age limit
	if(userClientAge>= ageLimit) {
	   if(userServerAge()) {
				if (confirm("Thanks. Your birthday is "+(birthDate.getMonth()+1)+"/"+birthDate.getDate()+"/"+birthDate.getFullYear()+", correct?")) {
					document.cookie= 'rossiok=1;expires="Fri, 20 Jun 2009 12:00:01 UTC";';
					showRedband();
				} else {
				return false;
			 }
	   } else {
		   alert("You must be " + ageLimit + " to view the red band material. In the meantime, enjoy the green band content.");
		   showGreenband();  
	   }
	} else {
		alert("You must be " + ageLimit + " to view the red band material. In the meantime, enjoy the green band content.");
		showGreenband();  
	}

} // doCheck


function preCheck(){
	var f_cookie= document.cookie;
	// alert(f_cookie)
	if (f_cookie.search(/rossibad/)>=0){
		window.location = "http://www.myspace.com/";
	} else if (f_cookie.search(/rossiok/)>=0){
		showRossi();
		var h_form=document.getElementById("age_check");
		h_form.innerHTML="";
	} else {
		document.ageCheck.bday.focus();
	}
}//preCheck
      


