function validateSweeps() {
	$("div").remove(".errorform");
	$("div").remove(".errorform2");
	
	var msgString = "";
	if( !isOneLetter(trim(document.sweepsForm.firstname.value))) { 
		msgString = "Please enter your first name."; 
		$("#errors").append("<div class='errorform2' id='error1'><div class='right2'></div><div class='mid' style='width: 143px;'><div class='errormessage'>" + msgString + "</div></div><div class='left2'></div></div>");
		$("#error1").css("top",$('#firstnameId').offset().top - 3);
		$("#error1").css("left",$('#firstnameId').offset().left - 253);
	} 
	if( !isOneLetter(trim(document.sweepsForm.lastname.value))) { 
		msgString = "Please enter your last name."; 
		$("#errors").append("<div class='errorform' id='error2'><div class='left'></div><div class='mid'><div class='errormessage'>" + msgString + "</div></div><div class='right'></div></div>");
		$("#error2").css("top",$('#lastnameId').offset().top - 3);
		$("#error2").css("left",$('#lastnameId').offset().left + 105);
	}
	if( !isOneLetter(trim(document.sweepsForm.street1.value))) { 
		msgString = "Please enter your address."; 
		$("#errors").append("<div class='errorform2' id='error3'><div class='right2'></div><div class='mid' style='width: 128px;'><div class='errormessage'>" + msgString + "</div></div><div class='left2'></div></div>");
		$("#error3").css("top",$('#street1Id').offset().top - 3);
		$("#error3").css("left",$('#street1Id').offset().left - 253);
	} 
	if( !isOneLetter(trim(document.sweepsForm.city.value))) { 
		msgString = "Please enter your city."; 
		$("#errors").append("<div class='errorform2' id='error4'><div class='right2'></div><div class='mid' style='width: 110px;'><div class='errormessage'>" + msgString + "</div></div><div class='left2'></div></div>");
		$("#error4").css("top",$('#cityId').offset().top - 3);
		$("#error4").css("left",$('#cityId').offset().left - 253);
	} 
	if(document.sweepsForm.state[document.sweepsForm.state.selectedIndex].value=="") {
		msgString = "Please select your state."; 
		$("#errors").append("<div class='errorform' id='error5'><div class='left'></div><div class='mid'><div class='errormessage'>" + msgString + "</div></div><div class='right'></div></div>");
		$("#error5").css("top",$('#stateId').offset().top - 3);
		$("#error5").css("left",$('#stateId').offset().left + 105);
	}
		if(!isPostalCode( document.sweepsForm.zip.value ) && !isZip( document.sweepsForm.zip.value ) ) {
		msgString = "Please enter a valid zip or postal code.";
		$("#errors").append("<div class='errorform2' id='error6'><div class='right2'></div><div class='mid' style='width: 193px;'><div class='errormessage'>" + msgString + "</div></div><div class='left2'></div></div>");
		$("#error6").css("top",$('#zipId').offset().top - 3);
		$("#error6").css("left",$('#zipId').offset().left - 253);
	}	
	if(document.sweepsForm.country[document.sweepsForm.country.selectedIndex].value=="") {
		msgString = "Please select your country."; 
		$("#errors").append("<div class='errorform' id='error15'><div class='left'></div><div class='mid'><div class='errormessage'>" + msgString + "</div></div><div class='right'></div></div>");
		$("#error15").css("top",$('#countryId').offset().top - 3);
		$("#error15").css("left",$('#countryId').offset().left + 105);
	}
	if( !isEmail(trim(document.sweepsForm.email.value))) { 
		msgString = "Please enter a valid email address."; 
		$("#errors").append("<div class='errorform2' id='error7'><div class='right2'></div><div class='mid' style='width: 167px;'><div class='errormessage'>" + msgString + "</div></div><div class='left2'></div></div>");
		$("#error7").css("top",$('#emailId').offset().top - 3);
		$("#error7").css("left",$('#emailId').offset().left - 253);
	}
	if( !isOneLetter(trim(document.sweepsForm.confirmEmail.value))) { 
		msgString = "Please enter a valid email address."; 
		$("#errors").append("<div class='errorform' id='error8'><div class='left'></div><div class='mid'><div class='errormessage'>" + msgString + "</div></div><div class='right'></div></div>");
		$("#error8").css("top",$('#confirmEmailId').offset().top - 3);
		$("#error8").css("left",$('#confirmEmailId').offset().left + 105);
	}
	if(( isOneLetter(trim(document.sweepsForm.confirmEmail.value)) && isOneLetter(trim(document.sweepsForm.confirmEmail.value))) && (trim(document.sweepsForm.email.value) !=  trim(document.sweepsForm.confirmEmail.value))) { 
		msgString = "Please confirm your email address."; 
		$("#errors").append("<div class='errorform' id='error7'><div class='left'></div><div class='mid'><div class='errormessage'>" + msgString + "</div></div><div class='right'></div></div>");
		$("#error7").css("top",$('#confirmEmailId').offset().top - 3);
		$("#error7").css("left",$('#confirmEmailId').offset().left + 105);
	}
	
	if(document.sweepsForm.BirthMonth[document.sweepsForm.BirthMonth.selectedIndex].value=="" || document.sweepsForm.BirthYear[document.sweepsForm.BirthYear.selectedIndex].value=="") {
		msgString = "Please enter your birthday."; 
		$("#errors").append("<div class='errorform2' id='error9'><div class='right2'></div><div class='mid' style='width: 132px;'><div class='errormessage'>" + msgString + "</div></div><div class='left2'></div></div>");
		$("#error9").css("top",$('#BirthYear').offset().top - 3);
		$("#error9").css("left",$('#BirthMonth').offset().left - 253);
	} else if (document.sweepsForm.BirthYear[document.sweepsForm.BirthYear.selectedIndex].value>="1996") {
		msgString = "You must be 13 years old.";
		$("#errors").append("<div class='errorform2' id='error9'><div class='right2'></div><div class='mid' style='width: 132px;'><div class='errormessage'>" + msgString + "</div></div><div class='left2'></div></div>");
		$("#error9").css("top",$('#BirthYear').offset().top - 3);
		$("#error9").css("left",$('#BirthMonth').offset().left - 253);
	} else if (document.sweepsForm.BirthYear[document.sweepsForm.BirthYear.selectedIndex].value=="1995" &&  document.sweepsForm.BirthMonth[document.sweepsForm.BirthMonth.selectedIndex].value >= "09"  ) {
		msgString = "You must be 13 years old."; 
		$("#errors").append("<div class='errorform2' id='error9'><div class='right2'></div><div class='mid' style='width: 132px;'><div class='errormessage'>" + msgString + "</div></div><div class='left2'></div></div>");
		$("#error9").css("top",$('#BirthYear').offset().top - 3);
		$("#error9").css("left",$('#BirthMonth').offset().left - 253);
	}
	if( !isPhoneNumber(trim(document.sweepsForm.phoneNumber.value))) { 
		msgString = "Please enter a valid phone number."; 
		$("#errors").append("<div class='errorform' id='error10'><div class='left'></div><div class='mid'><div class='errormessage'>" + msgString + "</div></div><div class='right'></div></div>");
		$("#error10").css("top",$('#phoneNumberId').offset().top - 3);
		$("#error10").css("left",$('#phoneNumberId').offset().left + 105);
	}
	if( !document.sweepsForm.agree.checked) {  
		msgString = "Please agree to the terms and conditions."; 
		$("#errors").append("<div class='errorform2' id='error12'><div class='right2'></div><div class='mid' style='width: 196px;'><div class='errormessage'>" + msgString + "</div></div><div class='left2'></div></div>");
		$("#error12").css("top",$('#agreeId').offset().top - 4);
		$("#error12").css("left",$('#agreeId').offset().left - 253);
	}
	if( msgString.length > 0 ) {  
		return false;
	} else {
		if (trim(document.sweepsForm.phoneNumber.value) > 0) {
			document.sweepsForm.phoneNumber.value = correctPhoneNumber(document.sweepsForm.phoneNumber.value);
		}
	}
	return true;
}

function isPhoneNumber(string) {
	if (string.search(/^(1\s*[-\/\.]?)?(\((\d{3})\)|(\d{3}))\s*[-\/\.]?\s*(\d{3})\s*[-\/\.]?\s*(\d{4})\s*(([xX]|[eE][xX][tT])\.?\s*(\d+))*$/) != -1)
		return true;
	else
		return false;
}
function correctPhoneNumber (string) {
	phoneNumber = string.replace(/ /g,"");
	phoneNumber = phoneNumber.replace(/\(/g,"");
	phoneNumber = phoneNumber.replace(/\)/g,"");
	phoneNumber = phoneNumber.replace(/-/g,"");
	phoneNumber = phoneNumber.replace(/\./g,"");
	return phoneNumber;
}
function isBirthday(string) {
	if (string.search(/^\d{2}\s*[\/\\]\d{4}/) != -1) {
		return true;
	} else {
		return false;
	}
}
window.onresize = resize;
function resize(){
	if ( $(".errorform").length > 0 || $(".errorform2").length > 0 ) {
		validatesweepsFormSweeps();
	}
}

function isPostalCode(string) {
	if (string.search(/^\s*[a-ceghj-npr-tvxy]\d[a-ceghj-npr-tv-z](\s)?\d[a-ceghj-npr-tv-z]\d\s*$/i) != -1) {
		return true;
	} else {
		return false;
	}
}
function isZip(string) {
	if (string.search(/^\d{5}/) != -1)
		return true;
	else
		return false;
}
function isOneLetter(string) {
	if (string.length >= 1)
		return true;
	else
		return false;
}
function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}
function trim(str){
	while(''+str.charAt(0)==' ')
	str=str.substring(1,str.length);
	while(''+str.charAt(str.length-1)==' ')
	str=str.substring(0,str.length-1);
	return str;
}

function popup(url,w,h)
{
	var width = w;
	var height = h;
	var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	var popupURL = url;
	var popup = window.open(popupURL,"aerie",'toolbar=0,top='+TopPosition+',left='+LeftPosition+',width='+width+',height='+height+',location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1');
	popup.location=popupURL;
	popup.opener=self;
	popup.focus();
}