<!--
function ReadCookie (CookieName)
{
	var CookieString = document.cookie;
	var CookieSet = CookieString.split (';');
	var SetSize = CookieSet.length;
	var CookiePieces
	var ReturnValue = "";
	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, expiry)
{
	var expDate = new Date();

	if(expiry)
	{
		expDate.setTime (expDate.getTime() + expiry);
		document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + expDate.toGMTString();
	}
	else
	{
		document.cookie = cookieName + "=" + escape (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,chkDay,chkMonth,chkYear) {
	var chkDay = (chkDay == null) ? '' : chkDay;
	var chkMonth = (chkMonth == null) ? '' : chkMonth;
	var chkYear = (chkYear == null) ? '' : chkYear;

	var c = new Date(); // a new instance
	fixDate(c);

	if(chkDay != '' && chkMonth != '' && chkYear != ''){
		var thisDay = chkDay - 1;
		var thisMonth = chkMonth;
		var thisYear = chkYear;
	}
	else{
		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(type) {
 var f = document.full_registration;
 var dob,theMonth,theDay;
 var regNum = /\D/;

 var regZipCode = /(^\d{5}$)/;
 
 kidDay = 2;
 kidMonth = 9;
 KidYear = 2006;
 
if(type=="generalTeen" || type=="generalKids"){
 whosName = "parent's";
}else{
 whosName = "your";
}
 
 if (f.first.value == "") { alert('Please enter ' + whosName + ' first name.'); f.first.focus(); return false; }
 if (f.last.value == "") { alert('Please enter ' + whosName + ' last name.'); f.last.focus(); return false; }
 if (!f.email.value.match(/^\S+@\S+\.\S+$/)) {
   alert('Please enter a valid e-mail address.');
   f.email.select();
   f.email.focus();
   return false;
   }
   
if(type=="contactUs"){
	if (f.subject.value == "") { alert('Please select subject'); f.subject.focus(); return false; }
	if (f.message.value == "") { alert('Please enter message'); f.message.focus(); return false; }

}
if(type != "news" && type !="contactUs"){
	if (f.phone.value.match(regNum)) {
           alert('Please enter only numbers for ' + whosName + ' phone.');
           f.phone.focus();
           return false;
   	}  
	if (f.phone.value.length < 10) {
            alert('Please be sure you enter both ' + whosName + ' area code and phone number.');
            f.phone.focus();
            return false;
	}
}
else{
    if(type!="contactUs"){
      if(f.mobileoptin.checked){
        if (f.phone.value.match(regNum)) {
           alert('Please enter only numbers for mobile phone.');
           f.phone.focus();
           return false;
        }
        if (f.phone.value.length < 11) {
            alert('Please be sure you enter 11 digit phone number.');
            f.phone.focus();
            return false;
        }
	}
    }
}


 
if(type=="generalCollege"){
if(f.school_year.value==""){
 	alert('Please select college school year'); f.school_year.focus(); return false;
 }
}

if(type=="generalTeen" || type=="generalKids"){
if(f.school_year.value==""){
 	alert('Please select school year'); f.school_year.focus(); return false;
 }
}

if (f.address1.value == "") { alert('Please enter ' + whosName + ' mailing address.'); f.address1.focus(); return false; }

 if (f.city.value == "") { alert('Please enter ' + whosName + ' city.'); f.city.focus(); return false; }

 if (f.state.value == "") { alert('Please enter ' + whosName + ' state.'); f.state.focus(); return false; }

 if (f.zip.value == "") { alert('Please enter a valid zip code.'); f.zip.focus(); return false; }

 if (f.zip.value.length < 5) {
         alert('Please enter at least 5 digits for ' + whosName + ' zip code.');
         f.zip.focus();
         return false;
 }

if (f.zip.value.match(regNum)) {
        alert('Please enter only numbers for ' + whosName + ' zip code.');
        f.zip.focus();
        return false;
}
 /* Validate month: check for digits, then check:  1 <= month <= 12 */
 if(f.dob_month.value.match(/\d{1,2}/)) {
   theMonth = eval(f.dob_month.value);		
   if(!(theMonth <= 12 && theMonth >= 1)){
     alert('Please enter a valid month of birth.');
     f.dob_month.focus();
     return false; 
  }
 } 
 else {
  alert('Please enter a valid month of birth.');
  f.dob_month.focus();
  return false; 
 }
  
 /* Validate day: check for digits, then check:  1 <= day <= 31 */
 if(f.dob_day.value.match(/\d{1,2}/)) {
   theDay = eval(f.dob_day.value);
   if(!(theDay >= 1 && theDay <= 31)) {
      alert('Please enter a valid day of birth.'); 
      f.dob_day.focus(); 
      return false; 
   }
 }
 else {
   alert('Please enter a valid day of birth.'); 
   f.dob_day.focus(); 
   return false; 
 }

 if(!f.dob_year.value.match(/\d{4}/) || f.dob_year.value=="0000") { 
    alert('Please a valid year of birth (xxxx).'); 
    f.dob_year.focus(); 
    return false; 
 }
 
 if(type=="generalRegional"){
 	if(f.Audition_City.value==""){
 	alert('Please select audition city'); f.Audition_City.focus(); return false;
 	}
 
 	var age = howOld(f.dob_day.value, f.dob_month.value, f.dob_year.value);	
 	if(age >= 18 && ReadCookie("register") != "no") {
	    dob = f.dob_year.value + "-" + f.dob_month.value + "-" + f.dob_day.value;
	    f.dob_full.value = dob;
	} else {
	     WriteCookie('register','no');
	     window.location='noservice.php';
	     return false;
 	}	
 }
  if(type=="generalCollege"){
  	if(f.Audition_City.value==""){
   	alert('Please select audition city'); f.Audition_City.focus(); return false;
 	}
	var age = howOld(f.dob_day.value, f.dob_month.value, f.dob_year.value);
  	if(age >= 13 && ReadCookie("register") != "no") {
 	    dob = f.dob_year.value + "-" + f.dob_month.value + "-" + f.dob_day.value;
 	    f.dob_full.value = dob;
 	} else {
 	     WriteCookie('register','no');
 	     window.location='noservice.php';
 	     return false;
  	}	
 }
   if(type=="generalTeen"){
   	if(f.Audition_City.value==""){
    	alert('Please select audition city'); f.Audition_City.focus(); return false;
  	}
	var age = howOld(f.dob_day.value, f.dob_month.value, f.dob_year.value);
   	if(age >= 13 && age <= 17 && ReadCookie("register") != "no") {
  	    dob = f.dob_year.value + "-" + f.dob_month.value + "-" + f.dob_day.value;
  	    f.dob_full.value = dob;
  	} else {
  	     WriteCookie('register','no');
  	     window.location='noservice.php';
  	     return false;
   	}	
 }
  if(type=="generalKids"){
    	if(f.Audition_City.value==""){
     	alert('Please select audition city'); f.Audition_City.focus(); return false;
   	}
		var age = howOld(f.dob_day.value, f.dob_month.value, f.dob_year.value, 2, 9, 2006);
    	if(age >= 10 && age <= 12 && ReadCookie("register") != "no") {
   	    dob = f.dob_year.value + "-" + f.dob_month.value + "-" + f.dob_day.value;
   	    f.dob_full.value = dob;
   	} else {
   	     WriteCookie('register','no');
   	     window.location='noservice.php';
   	     return false;
    	}	
 }
 
   if(type=="contactUs" || type=="news"){
		var age = howOld(f.dob_day.value, f.dob_month.value, f.dob_year.value);
     	if(age >= 13 && ReadCookie("register") != "no") {
    	    dob = f.dob_year.value + "-" + f.dob_month.value + "-" + f.dob_day.value;
    	    f.dob_full.value = dob;
    	} else {
    	     WriteCookie('register','no');
    	     window.location='noservice.php';
    	     return false;
     	}	
 }

//f.submit();
return true;
}
// -->

