function makeTextVisible() {
	if (document.applyForm.howDidYouHear.value == 'agent' || document.applyForm.howDidYouHear.value == 'friendfamily' || document.applyForm.howDidYouHear.value == 'studentalumni' || document.applyForm.howDidYouHear.value == 'print' || document.applyForm.howDidYouHear.value == 'otherweb' || document.applyForm.howDidYouHear.value == 'referral') {
document.getElementById('textBoxDiv').style.display = 'block';
    }
	else {
		document.getElementById('textBoxDiv').style.display = 'none';
    }
}



function formCheck(formobj){
var fieldRequired = Array("first_name", "last_name", "email", "email_conf", "home_country", "city_center", "about_us");
var fieldDescription = Array("First Name", "Last Name", "Email", "Confirm Email", "Home Country", "Which city center are you interested in?", "How did you hear about us?");
var alertMsg = "Please complete the following field(s):\n";
var l_Msg = alertMsg.length;
var fieldEmail = document.forms[0];

for (var i = 0; i < fieldRequired.length; i++){
var obj = formobj.elements[fieldRequired[i]];
	if (obj){
		switch(obj.type){
			case "select-one":
			if (obj.selectedIndex < 1 || obj.options[obj.selectedIndex].text == ""){
			alertMsg += " - " + fieldDescription[i] + "\n";
			}
			break;

		case "text":
		case "textarea":
			if (obj.value == "" || obj.value == null){
				alertMsg += " - " + fieldDescription[i] + "\n";
				}
			break;
		default:
			if (obj.value == "" || obj.value == null){
				alertMsg += " - " + fieldDescription[i] + "\n";
			}

						}
			}

											}
if (fieldEmail.email.value.replace(/^\s*|\s*$/g,"") != fieldEmail.email_conf.value.replace(/^\s*|\s*$/g,""))
				{ // email address
					alertMsg += "The email addresses you entered do not match.  Please correct the \"Email\" and \"Confirm Email\" fields.\n";
				}
if (alertMsg.length == l_Msg){
return true;
}else{
alert(alertMsg);
return false;
}
}
function emailvalidate(email) {
	rexp = /(\w+)+(\.)*(\w+)*(\.)*\w*@(\w+\.)+[A-Za-z]+(\.)*[A-Za-z]/;
	result = email.search(rexp);
	//alert(result);
	return result
	}
function formvalidate() { 
		
		
		// validates first name contains chars
		if (document.apply_now.first_name.value == ""){
			alert ("Please enter your First Name");
			return false;
		}
		// validates last name contains chars
		if (document.apply_now.last_name.value == ""){
			alert ("Please enter your Last Name");
			return false;
		}
		// validates email
		if (document.apply_now.email.value == ""){
			alert ("Please enter your Email Address");
			return false;
		}	
		// validate email address is correct
		if (emailvalidate(document.apply_now.email.value) == -1 ) {
		  	alert ("Please Enter a Valid Email Address");
			return false;
		}
		// validates confirmemail field
		if (document.apply_now.email_conf.value == ""){
			alert ("Please Enter a Confirmation Email Address");
			return false;
		}
		// validates promo code length
    	if (document.apply_now.promoCode.length > 6){
        alert("Promo code should be between 4-6 characters");
        return false;
    	}

		// validates that email and confirmemail are identical
		if (document.apply_now.email.value != document.apply_now.email_conf.value){
			alert ("Make sure the Emails you entered are matching");
			return false;
		}
		// Validates Date of Birth
		if (document.apply_now.dobMM.value == "-" || document.apply_now.dobDD.value == "-" || document.apply_now.dobYY.value == "-"){
			alert ("Please enter your Date of Birth");
			return false;
		}
		// Validates Country of Birth
		if (document.apply_now.country_of_birth.value == "-"){
			alert ("Please choose your Country of Birth");
			return false;
		}
		// Validates Country of Citizenship
		if (document.apply_now.country_of_citizenship.value == "-"){
			alert ("Please choose your Country of Citizenship");
			return false;
		}
		// Validates City Center
		if (document.apply_now.city_center.value == "-"){
			alert ("Please choose city center that you are interested in");
			return false;
		}
		// Validates About Us
		if (document.apply_now.about_us.value == "-"){
			alert ("Please select your referral source");
			return false;
		}
		// Validates Visa Type
		if (document.apply_now.visa.value == "-"){
			alert ("Please choose your type of visa");
			return false;
		}
		// Validates Start Date
		if (document.apply_now.startDate_MM.value == "-" || document.apply_now.startDate_DD.value == "-" || document.apply_now.startDate_YY.value == "-"){
			alert ("Please choose start date");
			return false;
		}
		// validates number of weeks
		if (document.apply_now.number_of_weeks.value == ""){
			alert ("Please enter Number of Weeks You Plan to Study");
			return false;
		}
		// validates street info
		if (document.apply_now.street.value == ""){
			alert ("Please enter your Street");
			return false;
		}
		// validates city
		if (document.apply_now.city.value == ""){
			alert ("Please enter your city");
			return false;
		}

		// validates postal code
		if (document.apply_now.ZIP.value == ""){
			alert ("Please enter your ZIP Code");
			return false;
		}
		// validates country
		if (document.apply_now.country.value == "-"){
			alert ("Please select your country of residence");
			return false;
		}
		return true;
				
}	

function formvalidate_tellabout() { 
// validates email1 field
		if (document.tellabout.senders_name.value == ""){
			alert ("Your full name is required");
			return false;
		}
		if (document.tellabout.senders_email.value == ""){
			alert ("Your email address is required");
			return false;
		}
		// validates email1 field
		if (document.tellabout.email1.value == ""){
			alert ("Your colleague's email 1 is required");
			return false;
		}
} 
function formvalidate_requestInfoHP() { 
// validates email1 field
		if (document.requestInfoHP.newsEmail.value == ""){
			alert ("Your email is required");
			return false;
		}
		/*if (document.requestInfoHP.firstName.value == ""){
			alert ("Your first name is required");
			return false;
		}
		// validates email1 field
		if (document.requestInfoHP.lastName.value == ""){
			alert ("Your last name is required");
			return false;
		}
		if (document.requestInfoHP.cityCenter.value == "-"){
			alert ("Please choose a city center you are interested in");
			return false;
		}
		if (document.requestInfoHP.newsCountry.value == "-"){
			alert ("Please choose your country");
			return false;
		}*/
} 
function showHide(obj)
{
var el = document.getElementById(obj);
	if(el.style.display != "block")
	{
	el.style.display = "block";
	}
	else
	{
	el.style.display = "none";
	}
}