function SubmitFormMail(nextStep,type) {
	var tError;
	if (type=='Mail') { tError=CheckInputMail(); }
	if (type=='Phone') { tError=CheckInputPhone(); }
	if (type=='Friend') { tError=CheckInputFriend(); }
	if (tError.length> 0) {
		alert ("Merci de remplir les champs ci-dessous:\n\n"+tError);
	}else{
		getContent(nextStep,'dinamic_survey','ajax');
	}
}

function CheckInputPhone() {
	var Error=''
	if (document.forms['contactform'].country.value.length < 2)
		Error=Error+"* Pays\n";
	if (document.forms['contactform'].location.value.length < 2)
		Error=Error+"* Location\n";
	return Error;
}
						
function CheckInputMail() {
	var Error=''
	if (document.forms['contactform'].name.value.length < 2)
		Error=Error+"* Nom\n";
	if (!CheckEmailForm (document.forms['contactform'].email.value))
		Error=Error+"* Courriel\n";
	return Error;
}

function CheckInputFriend() {
	var Error=''
	if (document.forms['contactform'].name.value.length < 2)
		Error=Error+"* Nom\n";
	if (!CheckEmailForm (document.forms['contactform'].email.value))
		Error=Error+"* Courriel\n";
	if (document.forms['contactform'].friendname.value.length < 2)
		Error=Error+"* Friend Name\n";
	if (!CheckEmailForm (document.forms['contactform'].friendemail.value))
		Error=Error+"* Friend Courriel\n";
	if (document.forms['contactform'].subject.value.length < 2)
		Error=Error+"* Subject\n";
	return Error;
}
								
function CheckEmailForm (What) {
	What=""+What;
	Ret = true;
	if (What.length < 3) {
		Ret=false;
	}
	if (What.indexOf("@") < 0) {
		Ret=false;
	}
	if (What.indexOf(".") < 0) {
		Ret=false;
	}
	return Ret;
}

function ReplaceNewLines (myinput) {
	var savelastbreak=0;
	var output="";
	for (var i=0; i<myinput.length; i++) {
		if ((myinput.charCodeAt(i)==13) || (myinput.charCodeAt(i)==10)) {
			if (myinput.charCodeAt(i)==10)
				output=output+"<br>";
		}else{
			output=output+myinput.substr(i,1);
		}
	}
	return output;
}
