function goto(section, country){

	window.location = "listings.php?section="+section+"&country="+country;
	
}

function changeImage(id, image){
	document.getElementById(id).src=image;
}

function addAddress(){
	
	
}

/************ FORM VALIDATION FUNCTIONS *************/

function validateRegistrationPart1(){
	
	if(!validate())
		return false;
	if(!validateEmailAddress('email_address'))
		return false;
	if(!document.getElementById('terms').checked){
		alert('Please read and agree to our terms and conditions');
		return false;
	}
}

function validateRegistrationPart2(){
	
	if(!validate())
		return false;
	if(!validateEmailAddress('email_address'))
		return false;
	if(!validateSame('password', 'retype_password'))
		return false;
	
}

//check that all fields with classname 'required' are filled in
function validate(){
var elems=document.getElementsByTagName('input'); 
for(var i=0;i<elems.length;i++){
	if((elems[i].className=='required')&&(elems[i].value=="")){
		alert("Please fill in all required fields");
		return false;
	}
}
return true;
}

/*** This validation function checks that an email address contains both '@' and '.' **/
function validateEmailAddress(email_address){
var email = document.getElementById(email_address).value;
	if((email.indexOf('@')==-1)||(email.indexOf('.')==-1)){
		alert("Invalid email address");
		return false;
	}
	else
		return true;
}

//Check that two fields have the same values, useful for password changes etc
function validateSame(type, retype){
if(document.getElementById(type).value == document.getElementById(retype).value)
	return true;
else{
	alert("Passwords do not match.");
	return false;
}
}
