// JavaScript Document
function validate(form){
	if (form == 'portal'){
	if (!document.portal.AgeCheck.checked){
		alert ('You MUST be at least 13 years of age in order to enter this online Sweepstakes.\n\n If you are at least 13 years old, please check the appropriate box on the page.\n\n If you are 12 or younger, please exit the Sweepstakes page and ask your parent(s) to enter instead.\n\n Thank you.');
		return false;
	} else if(!document.portal.terms.checked){
		alert ('You MUST accept the terms and rules in order to enter this online Sweepstakes.\n\n Please check the appropriate box on the page to continue.');
		return false;}}
		else if (form == 'entry'){
			if (!document.entry.employment.checked){
				alert ('If you or your immediate family are employess of Harmatz Entertainment or Vista Entertainment Center, you are not eligible to participate in this online Sweepstakes.\n\n If you or your immediate family are not employees of these companies, please check the appropriate box to continue');
				return false;
			}
			else if ((document.entry.FirstName.value).replace(/^\s*|\s*$/g,'')==''||(document.entry.LastName.value).replace(/^\s*|\s*$/g,'')==''||(document.entry.Email.value).replace(/^\s*|\s*$/g,'')==''||(document.entry.Birthday.value).replace(/^\s*|\s*$/g,'')==''){
				alert ('Please fill in all text fields on the page in order to enter online Sweepstakes');
				return false;
			}
			else {
				var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
				var address = document.entry.Email.value;
				if(reg.test(address) == false){
					alert('Invalid Email Address');
					return false;
				}
				else if(document.entry.FirstName.value.length < 2 || document.entry.LastName.value.length < 3){
					alert ('Please provide your full First and Last name to be eligble.');
					return false;
				}
				else {
					var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
					var strValue = document.entry.Birthday.value;
 
  //check to see if in correct format
  if(!objRegExp.test(strValue))
    return false; //doesn't match pattern, bad date
  else{
    var strSeparator = strValue.substring(2,3) 
    var arrayDate = strValue.split(strSeparator); 
    //create a lookup for months not equal to Feb.
    var arrayLookup = { '01' : 31,'03' : 31, 
                        '04' : 30,'05' : 31,
                        '06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,
                        '10' : 31,'11' : 30,'12' : 31}
    var intDay = parseInt(arrayDate[1],10); 

    //check if month value and day value agree
    if(arrayLookup[arrayDate[0]] != null) {
      if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
        return true; //found in lookup table, good date
    }
    
    //check for February (bugfix 20050322)
    //bugfix  for parseInt kevin
    //bugfix  biss year  O.Jp Voutat
    var intMonth = parseInt(arrayDate[0],10);
    if (intMonth == 2) { 
       var intYear = parseInt(arrayDate[2]);
       if (intDay > 0 && intDay < 29) {
           return true;
       }
       else if (intDay == 29) {
         if ((intYear % 4 == 0) && (intYear % 100 != 0) || 
             (intYear % 400 == 0)) {
              // year div by 4 and ((not div by 100) or div by 400) ->ok
             return true;
         }   
       }
    }
  }  
  alert ('Birthday is not a valid date');
  return false; //any other values, bad date

					}
				}
			}
		}




function whereto(ident){
	document.entry.action = ident;
}

function reset_form() {
if (confirm("Are you sure you want to clear form?")) {
document.entry.FirstName.value = '';
document.entry.LastName.value = '';
document.entry.Email.value = '';
document.entry.Birthday.value = '';
}
}

function year_calc(){
}
