<!--
months= new Array(12);
months[0]="January";
months[1]="February";
months[2]="March";
months[3]="April";
months[4]="May";
months[5]="June";
months[6]="July";
months[7]="August";
months[8]="September";
months[9]="October";
months[10]="November";
months[11]="December";

// calculate required birth date
compareDate = useTimeOfEntry==true ? compareDate = new Date() : compareDate = eventStartDate;
bornBeforeDateString = months[compareDate.getMonth()] + " " + compareDate.getDate() + " " + (compareDate.getFullYear() - requiredAgeInYears);
bornBeforeDate = new Date(bornBeforeDateString);
// alert("must be born before or on " + bornBeforeDate.toString());

// convert the birthdate to milliseconds for an exact comparison
bornBefore = bornBeforeDate.getTime();

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) {
    var c = new Date(2003, 3, 10); // a new instance
	//new Date(99, 12, 31)
//    fixDate(c);
    
    /*
    var thisDay = 6;
    var thisMonth = 1;
    var thisYear = 2003;
    */ 
    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 += ' ';
    }

	alert(age);
    return age;
}


function doSubmit() {
 var f = document.full_registration;
 var dob,theMonth,theDay;
 var regDashes = /-/;
 var regNum = /\D/;
 var regZipCode = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
 
 if (f.first.value == "") { 
 	alert('Please enter your first name.'); 
 	f.first.focus(); 
 	return; 
 }
 
 if (f.last.value == "") { 
 	alert('Please enter your last name.'); 
 	f.last.focus(); 
 	return; 
 }

 if (!f.email.value.match(/^\S+@\S+\.\S+$/)) {
   alert('Please enter a valid e-mail address.');
   f.email.select();
   f.email.focus();
   return;
   }

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

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

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

 if (!f.zip.value.match(regZipCode)) { 
 	alert('Please enter a valid US zip code.'); 
 	f.zip.select(); 
 	f.zip.focus(); 
 	return; 
 }

 if (f.phone.value == "") { alert('Please enter your phone number.'); f.phone.focus(); return; }

 if (f.phone.value.match(regDashes)) {
	 alert('Please enter your area code and phone number without dashes.');
	 f.phone.focus();
	 return;
 }

if (f.phone.value.match(regNum)) {
	alert('Please enter only numbers for your phone');
	f.phone.focus();
	return;
}
 
 if (f.phone.value.length < 10) {
	 alert('Please be sure you enter both your area code and phone number.');
	 f.phone.focus();
	 return;
 }
 
 if (f.phone.value.length > 10) {
	 alert('Please enter only 10 digits for your area code and phone number.');
	 f.phone.focus();
	 return;
 }
 
dobString = months[f.dob_month.value-1] + " " + f.dob_day.value + " " + f.dob_year.value;
dobDate = new Date(dobString);
dobSeconds = dobDate.getTime();
//alert ("born_before is " + born_before + " and dob_seconds is " + dob_seconds);

if (dobSeconds <= bornBefore && ReadCookie("register") != "no")
{
   //alert("age = " + age + " and cookie = " + ReadCookie("register"));
    var dob_full = f.dob_year.value + "-" + f.dob_month.value + "-" + f.dob_day.value;
    f.dob_full.value = dob_full;
} else {
 	WriteCookie('register','no',86400000);
	if (document.location.href.indexOf('ff1sweeps')!=-1) 
	{
		alert('We’re sorry, but you are not eligible to enter the Fond Farewell Sweepstakes.  Please feel free to play our Three-Way Conversation Game though and try and guess what’s going to happen next on Dawson’s Creek!');
	}
	if (document.location.href.indexOf('ff2sweeps')!=-1) 
	{
		alert('We’re sorry, but you are not eligible to enter the Fond Farewell Sweepstakes.  Please feel free to play our Three-Way Conversation Game though and try and guess what’s going to happen next on Dawson’s Creek!');
	}
	if (document.location.href.indexOf('tpsweeps')!=-1) 
	{
		alert('We’re sorry, but you are not eligible to enter the Triple Pack Sweepstakes. Please feel free to play our Three-Way Conversation Game though and try and guess what’s going to happen next on Dawson’s Creek!');
	}
	window.location = "http://www.dawsonscreek.com/verizon/main.html";
	return false;
 }

/*
 var age = howOld(f.dob_day.value, f.dob_month.value, f.dob_year.value);
 
 if(age >= 13 && ReadCookie("register") != "no") {
    //alert("age = " + age + " and cookie = " + ReadCookie("register"));
    var dob_full = f.dob_year.value + "-" + f.dob_month.value + "-" + f.dob_day.value;
    f.dob_full.value = dob_full;
 } else {
 	WriteCookie('register','no',86400000);
	alert('Sorry we cannot offer this promotion to you at this time.');
	window.location = "http://www.sonypictures.com";
	return;
 }
*/
f.submit();
}

function checkDOB(aForm) 
{
	f = aForm;
 /* 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();
     f.dob_month.select(); 
     return false; 
  }
 } 
 else {
  alert('Please enter a valid month of birth.');
  f.dob_month.focus();
  f.dob_month.select(); 
  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(); 
      f.dob_day.select(); 
      return false; 
   }
 }
 else {
   alert('Please enter a valid day of birth.'); 
   f.dob_day.focus(); 
   f.dob_day.select(); 
   return false; 
 }

 if(!f.dob_year.value.match(/\d{4}/) || f.dob_year.value=="0000") { 
    alert('Please enter a valid year of birth (xxxx).'); 
    f.dob_year.focus(); 
    f.dob_year.select(); 
    return false; 
 }
 return true;
 }
// -->
