function validate_form (obj_form) {
	obj_form.first_name.value = trim ( obj_form.first_name.value );
	obj_form.last_name.value = trim ( obj_form.last_name.value );
	obj_form.address1.value = trim ( obj_form.address1.value );
	obj_form.address2.value = trim ( obj_form.address2.value );
	obj_form.city.value = trim ( obj_form.city.value );
	obj_form.zip.value = trim ( obj_form.zip.value );
	obj_form.email.value = trim ( obj_form.email.value );
	obj_form.phone.value = trim ( obj_form.phone.value );
	obj_form.password.value = trim ( obj_form.password.value );
	obj_form.password2.value = trim ( obj_form.password2.value );

	if ( obj_form.name_title.selectedIndex==0 ) {
		obj_form.name_title.focus ();
		alert ( "Le titre est un champ obligatoire." );
		return false;
	}
	if ( obj_form.first_name.value == "" ) {	
		obj_form.first_name.focus ();
		alert ( "Le prénom est un champ obligatoire." );
		return false;
	}
	if ( obj_form.last_name.value == "" ) {	
		obj_form.last_name.focus ();
		alert ( "Le nom est un champ obligatoire." );
		return false;
	}
	if ( obj_form.address1.value == "" ) {	
		obj_form.address1.focus ();
		alert ( "L’adresse de rue est un champ obligatoire." );
		return false;
	}
	if ( obj_form.city.value == "" ) {	
		obj_form.city.focus ();
		alert ( "La ville est un champ obligatoire." );
		return false;
	}
	if ( obj_form.zip.value == "" ) {	
		obj_form.zip.focus ();
		alert ( "Le code postal est un champ obligatoire." );
		return false;
	}
/*
	if ( obj_form.country [ 0 ].selected ) {
		obj_form.country.focus ();
		alert ( "Country is a required field." );
		return false;
	}
*/
	if ( obj_form.state [ 0 ].selected ) {	
		obj_form.state.focus ();
		alert ( "La province est un champ obligatoire." );
		return false;
	}
	if ( obj_form.gender[ 0 ].selected ) {
		obj_form.gender.focus ();
		alert ( "Sexe est un champ obligatoire." );
		return false;
	}
	if ( obj_form.email.value == "" ) {	
		obj_form.email.focus ();
		alert ( "L’adresse électronique est un champ obligatoire." );
		return false;
	}
	if ( !isEmail(obj_form.email.value)) {	
		obj_form.email.focus ();
		alert ( "Vous devez entrer une adresse électronique valide." );
		return false;
	}
	if ( obj_form.phone.value == '' ) {
		obj_form.phone.focus ();
		alert ( "Le numéro de téléphone est un champ obligatoire." );
		return false;
	}
	if(obj_form.mode.value == "add") {
		if ( obj_form.password.value == "" ) {	
			obj_form.password.focus ();
			alert ( "Le mot de passe est un champ obligatoire." );
			return false;
		}
	}
	if(obj_form.password.value.length>0) {
		if(obj_form.password.value.length<4) {
			obj_form.password.focus ();
			alert ( "Votre mot de passe doit comporter au moins 4 caractères." );
			return false;
		} else if ( obj_form.password2.value == "" ) {	
			obj_form.password2.focus ();
			alert ( "Veuillez confirmer votre mot de passe." );
			return false;
		}
	}
	if ( obj_form.password.value != obj_form.password2.value ) {	
		obj_form.password.value = "";
		obj_form.password2.value = "";
		obj_form.password.focus ();
		alert ( "La confirmation de votre mot de passe ne correspond pas à votre mot de passe. Veuillez réinscrire votre mot de passe et la confirmation de votre mot de passe." );
		return false;
	}
	return true;
}

function checkCountry(obj) {
	var state_name = document.getElementById('state_name');
	var state_options = document.getElementById('state_options');
	var prov_name = document.getElementById('prov_name');
	var prov_options = document.getElementById('prov_options');
	
	
	var state_star = document.getElementById('state_star');
	//prov_options.style.visibility = 'visible';
	if ( obj.options[obj.selectedIndex].value == "USA" ) {	
		//alert('in1');
		prov_options.style.visibility = "hidden";
		prov_name.style.visibility = "hidden";
		prov_options.style.position = "absolute";
		prov_name.style.position = "absolute";
		
		state_star.style.visibility = "visible";
		
		state_name.style.visibility = "visible";
		state_name.style.position = "static";
		state_options.style.visibility = "visible";
		state_options.style.position = "static";
	} else { 
		if ( obj.options[obj.selectedIndex].value == "CAN" ) {	
			
			state_name.style.visibility = "hidden";
			state_options.style.visibility = "hidden";
			state_name.style.position = "absolute";
			state_options.style.position = "absolute";
			
			prov_name.style.visibility = "visible";
			prov_options.style.visibility = "visible";
			prov_name.style.position = "static";
			prov_options.style.position = "static";
			state_star.style.visibility = "visible";
		} else { 
			//alert('in3');
			prov_name.style.visibility = "hidden";
			prov_options.style.visibility = "hidden";
			prov_options.style.position = "absolute";
			prov_name.style.position = "absolute";
			
			state_name.style.visibility = "hidden";
			state_options.style.visibility = "hidden";
			state_options.style.position = "absolute";
			state_name.style.position = "absolute";
			state_star.style.visibility = "hidden";
		}
	}
}

function init() {
	checkCountry(document.consumer.country);
}
