function validateEditProfile(){
	
	var root = document.register;
	
	var firstName = root.first_name.value;
	var lastName = root.last_name.value;
	var nationality = root.nationality.value;
	var gender = root.gender.value;
	var address = root.address.value;
	var city = root.city.value;
	var country = root.country.value;
	var phone = root.phone.value;
	var email = root.email.value;

	if (firstName == ''){
		alert('Please specify your first name');
		root.first_name.focus();
		return false;
	}
	
	if (lastName == ''){
		alert('Please specify your last name');
		root.last_name.focus();
		return false;
	}
	
	if (nationality == ''){
		alert('Please select your nationality');
		root.nationality.focus();
		return false;
	}
	
	if (gender == ''){
		alert('Please select your gender');
		root.gender.focus();
		return false;
	}
	
	if (address == ''){
		alert('Please provide your address');
		root.address.focus();
		return false;
	}
	
	if (city == ''){
		alert('Please provide your city');
		root.city.focus();
		return false;
	}
	
	if (country == ''){
		alert('Please select your country');
		root.country.focus();
		return false;
	}
	
	if (phone == ''){
		alert('Please give your phone');
		root.phone.focus();
		return false;
	}
	
	if (email == ''){
		alert('Please give your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	flag=email.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.focus();
		return false;
	}
	
	return true;
}

function passValidation(){
	var root = document.change_password;
	var oldp = root.old.value;
	var newp = root.newp.value;
	var confnew = root.confnew.value;
	
	if (oldp == '' || newp == '' || confnew == ''){
		alert('Please fill up all the fields');
		root.old.focus();
		return false;
	}
	if (!isNaN(newp)){
		alert('Please insert a password that contains characters.');
		root.newp.focus();
		return false;
	}
	
	if (newp != confnew){
		alert('The password and it\'s confirmation do not match');
		root.confnew.focus();
		return false;
	}
	
	oldp = hex_md5(oldp);
	newp = hex_md5(newp);
	confnew = hex_md5(confnew);
	
	root.old.value = oldp;
	root.newp.value = newp;
	root.confnew.value = confnew;
	root.enc.value = '1';
	
	return true;
}

function validateRegistration(){
	
	var root = document.register;
	
	var firstName = root.first_name.value;
	var lastName = root.last_name.value;
	var nationality = root.nationality.value;
	var gender = root.gender.value;
	var country = root.countries.value;
	var address = root.address.value;
	var city = root.city.value;
	var phone = root.phone.value;
	var email = root.email.value;
	var secret_question = root.secret_question.value;
	var secret_answer = root.secret_answer.value;
	
	if (firstName == ''){
		alert('Please specify your first name');
		root.first_name.focus();
		return false;
	}
	
	if (lastName == ''){
		alert('Please specify your last name');
		root.last_name.focus();
		return false;
	}
	
	if (nationality == ''){
		alert('Please select your nationality');
		root.nationality.focus();
		return false;
	}
	
	if (gender == ''){
		alert('Please select your gender');
		root.gender.focus();
		return false;
	}
	
	if (address == ''){
		alert('Please specify your address');
		root.address.focus();
		return false;
	}
	
	if (city == ''){
		alert('Please specify your city');
		root.city.focus();
		return false;
	}
	
	if (country == ''){
		alert('Please select your country');
		root.countries.focus();
		return false;
	}
	
	if (phone == ''){
		alert('Please give your phone number');
		root.phone.focus();
		return false;
	}
	if (email == ''){
		alert('Please give your personal email');
		root.email.focus();
		return false;
	}
	
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	flag=email.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.focus();
		return false;
	}
	
	if (secret_question == ''){
		alert('Please give your secret question');
		root.secret_question.focus();
		return false;
	}
	
	if (secret_answer == ''){
		alert('Please give your secret answer');
		root.secret_answer.focus();
		return false;
	}
	return true;
}

function clearRegisterForm(){
	
	var root = document.register;
	
	if (confirm('Are you sure you want to clear the form?')){
		
		root.first_name.value = '';
		root.last_name.value = '';
		root.nationality.value = '';
		root.gender.value = '';
		root.countries.value = '';
		root.phone.value = '';
		root.email.value = '';
		root.password.value = '';
		root.confirm_password.value = '';
		root.secret_question.value = '';
		root.secret_answer.value = '';
		root.address.value = '';
		root.city.value = '';
		root.state_region.value = '';
		root.postal_code.value = '';
	}
	return false;
}

function openGoodies() {
	window.open("/premium/seg/sms/goodies.php", "goodies", "top=10,left=650,width=350,height=550,location=0,status=1,history=0,resizable=1,scrollbars=1");
	return false;
}