<!-- Hide script from old browsers

//functions to do form validation, validates the three different forms on the website

validEmail = false;
function validateEmail(emailAddress){
	domain = emailAddress.slice(emailAddress.lastIndexOf('@')+1);
	address = emailAddress.slice(0, emailAddress.lastIndexOf('@'));
	RE = new RegExp();
	RE = /((([a-z0-9\-]+)\.)+)([a-z]{2,6})$/gi
	if((!(RE.test(domain))&&!(validEmail))||(address=='')){
		alert('Your email address is invalid.\nPlease enter a correct email address.');
		delete domain;
		delete RE;
		return false;
	}
	validEmail = true;
	delete domain;
	delete RE;
	return true;
}

//strips any blank spaces from the start or end of the string and returns the resulting string
function strip(currentString){
	if(currentString.charAt(0)==' '||currentString.charAt(0)=='\n'){
		return strip(currentString.slice(1));
	}
	if(currentString.charAt(currentString.length-1)==' '||currentString.charAt(currentString.length-1)=='\n'){
		return strip(currentString.slice(0,-1));
	}	
	return currentString;
}

function inquiry(currentForm){
	emailAddressValue = strip(currentForm.Email.value);
	commentQuestionValue = strip(currentForm.elements['Comment/Question'].value);
	
	if(emailAddressValue==''){
		alert('You email address is empty.\nPlease enter an email.');
		currentForm.Email.focus();
		currentForm.Email.select();
		return false;
  }  
  
  if( !validateEmail(emailAddressValue) ){
		currentForm.Email.focus();
		currentForm.Email.select();
		return false;
    
//		if(commentQuestionValue!=''){
//			alert('You have submitted a comment/question.\nPlease supply an email so that we can reply.');
//			currentForm.Email.focus();	
//			return false;
//		}
//		if((currentForm.elements['Send_Program_Information'].checked)){
//				alert('You have requested us to send you information.\nPlease supply an email.');
//				currentForm.Email.focus();
//				return false;
//		}
	}
//	if(!(validateEmail(emailAddressValue))){
//		currentForm.Email.focus();
//		currentForm.Email.select();
//		return false;
//	}
	if(commentQuestionValue==''){
//		if(!(currentForm.elements['Send_Program_Information'].checked)){	
			alert('You have not entered a comment/question.\nPlease enter a comment/question.');
			currentForm.elements['Comment/Question'].focus();
			return false;
//		}
	}
	return true;
}

function teachkoreanz(currentForm){
	if(strip(currentForm.Name.value)==''){
		alert('Please enter your name so that we know who is applying.');
		currentForm.Name.focus();
		currentForm.Name.select();
		return false;
	}
	if(currentForm.Age.value=='Age not selected'){
		alert('Please select your age.');		
		currentForm.Age.focus();
		return false;
	}
	if(currentForm.Gender.value=='Gender not selected'){
		alert('Please select your gender.');		
		currentForm.Gender.focus();
		return false;
	}
	if(strip(currentForm.Street.value)==''){
		alert('Please enter your street.');		
		currentForm.Street.focus();
		currentForm.Street.select();
		return false;
	}
	if(strip(currentForm.Suburb.value)==''){
		alert('Please enter your suburb.');		
		currentForm.Suburb.focus();
		currentForm.Suburb.select();
		return false;
	}
	if(strip(currentForm.City.value)==''){
		alert('Please enter your city.');		
		currentForm.City.focus();
		currentForm.City.select();
		return false;
	}
	if(strip(currentForm.Country.value)==''){
		alert('Please enter your country.');		
		currentForm.Country.focus();
		currentForm.Country.select();
		return false;
	}
	if(strip(currentForm.elements['Phone_(home)'].value)==''){
		alert('Please enter your home phone number.');
		currentForm.elements['Phone_(home)'].focus();
		currentForm.elements['Phone_(home)'].select();
		return false;
	}
	if(!validateEmail(strip(currentForm.Email.value))){
		currentForm.Email.focus();
		currentForm.Email.select();
		return false;
	}
	if(strip(currentForm.elements['Country_of_Birth'].value)==''){
		alert('Please enter the country where you were born.');
		currentForm.elements['Country_of_Birth'].focus();
		currentForm.elements['Country_of_Birth'].select();
		return false;
	}
	if(!(currentForm.elements['Australian_Passport'].checked || currentForm.elements['Canadian_Passport'].checked || currentForm.elements['Irish_Passport'].checked || currentForm.elements['New_Zealand_Passport'].checked || currentForm.elements['South_African_Passport'].checked || currentForm.elements['UK_Passport'].checked || currentForm.elements['USA_Passport'].checked)){
		alert('Please select a country for the nationality of your passport.\nWithout a passport from one of the listed countries you will not be eligible for a Korean work visa.');
		currentForm.elements['Australian_Passport'].focus();
		return false;
	}	
	if(strip(currentForm.elements['University_Degree(s)'].value)==''){
		alert('Please enter the type of Bachelor degree you have.\nWithout a Bachelor degree you will not be eligible for a Korean work visa.');
		currentForm.elements['University_Degree(s)'].focus();
		currentForm.elements['University_Degree(s)'].select();
		return false;
	}
	if(strip(currentForm.elements['Major_Field_of_Study'].value)==''){
		alert('Please enter enter your major field of study while at University.');
		currentForm.elements['Major_Field_of_Study'].focus();
		currentForm.elements['Major_Field_of_Study'].select();
		return false;
	}
	if(strip(currentForm.elements['Graduating_University'].value)==''){
		alert('Please enter the university you graduated from.\nPlease also include the state/province.');
		currentForm.elements['Graduating_University'].focus();
		currentForm.elements['Graduating_University'].select();
		return false;
	}
	//if((strip(currentForm.photo.value)=='')&&(strip(currentForm.elements['Physical Description'].value)=='')){
	//	alert('Please either submit a photo of yourself or enter a brief physical description.');
	//	currentForm.photo.focus();
	//	currentForm.photo.select();
	//	return false;
	//}
	if(currentForm.elements['Earliest_Start_Month'].value=='Month not selected'){
		alert('Please select an earliest start month.');		
		currentForm.elements['Earliest_Start_Month'].focus();
		return false;
	} 
	if(currentForm.elements['Latest_Start_Month'].value=='Month not selected'){
		alert('Please select a latest start month.');		
		currentForm.elements['Latest_Start_Month'].focus();
		return false;
	} 
	
	return true;
}


function employers(currentForm){
	if(strip(currentForm.elements['Directors_Name'].value)==''){
		alert('Please enter your name so that we know who is applying.');
		currentForm.elements['Directors_Name'].focus();
		currentForm.elements['Directors_Name'].select();
		return false;
	}
	if(strip(currentForm.elements['School_Name'].value)==''){
		alert('Please enter the name of the school.');		
		currentForm.elements['School_Name'].focus();
		currentForm.elements['School_Name'].select();
		return false;
	}
	if(strip(currentForm.elements['Postal_Address'].value)==''){
		alert('Please enter the postal address for the school.');		
		currentForm.elements['Postal_Address'].focus();
		currentForm.elements['Postal_Address'].select();
		return false;
	}
	if(strip(currentForm.City.value)==''){
		alert('Please enter the city where your school is.');		
		currentForm.City.focus();
		currentForm.City.select();
		return false;
	}
	if(strip(currentForm.elements['Zip_Code'].value)==''){
		alert('Please enter a Zip Code.');		
		currentForm.elements['Zip_Code'].focus();
		currentForm.elements['Zip_Code'].select();
		return false;
	}
	if(strip(currentForm.Phone.value)==''){
		alert('Please enter a phone number.');
		currentForm.Phone.focus();
		currentForm.Phone.select();
		return false;
	}
	if(strip(currentForm.Fax.value)==''){
		alert('Please enter a fax number.');
		currentForm.Fax.focus();
		currentForm.Fax.select();
		return false;
	}
	if(!validateEmail(strip(currentForm.Email.value))){
		currentForm.Email.focus();
		currentForm.Email.select();
		return false;
	}
	return true;
}

function resubmitApp(currentForm){
	if(!currentForm.elements['Physical Description'])
		return true;
	if((strip(currentForm.photo.value)=='')&&(strip(currentForm.elements['Physical Description'].value)=='')){
		alert('Please either submit a photo of yourself or enter a brief physical description.');
		currentForm.photo.focus();
		currentForm.photo.select();
		return false;
	}	
}

submitted = false;

function validate(currentForm){
	if(submitted){
		alert('Please wait for the form to be processed.\nThis may take a few seconds.\nYou do not need to click the submit button more that once.');
		return false;
	}
	if(currentForm.name=='inquiry'){
		submitted = inquiry(currentForm);
		return submitted;
	}
	else if(currentForm.name=='teachkoreanz'){
		submitted = teachkoreanz(currentForm);
		return submitted;
	}
	else if(currentForm.name=='employers'){
		submitted = employers(currentForm);
		return submitted;
	}
	else if(currentForm.name=='resubmitApp'){
		submitted = resubmitApp(currentForm);
		return submitted;
	}
	
	submitted = true;
	return true;
}

//function to open a popwindow for slideshows
function slideShow(showName){
	address = showName + '.htm';
	window.open(address,'','toolbar=no,menubar=no,status=yes,location=no,scrollbars=no,width=400,height=420');
}

// End hiding script from old browsers -->



