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 ("Please fill the following fields in correctly:\n\n"+tError);
	}else{

		getContent(nextStep,'dinamic_survey','ajax');
	}
}

function CheckInputPhone() {
	var Error=''
	if (document.forms['contactform'].country.value.length < 2)
		Error=Error+"* Country\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+"* Name\n";
	if (!CheckEmailForm (document.forms['contactform'].email.value))
		Error=Error+"* E-mail\n";

	if(!Checktelephone())	
		Error=Error+"* Telephone should be numeric\n";
		
	if (document.forms['contactform'].customer_country.value.length < 2)
		Error=Error+"* Country of residence\n";
	
	return Error;
}

function CheckInputFriend() {
	var Error=''
	if (document.forms['contactform'].name.value.length < 2)
		Error=Error+"* Name\n";
	if (!CheckEmailForm (document.forms['contactform'].email.value))
		Error=Error+"* E-mail\n";
	if (document.forms['contactform'].friendname.value.length < 2)
		Error=Error+"* Friend Name\n";
	if (!CheckEmailForm (document.forms['contactform'].friendemail.value))
		Error=Error+"* Friend E-mail\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;
}
			
function Checktelephone()
{
	var ret = true;

	  if(document.forms['contactform'].tel.value!="") 
	 	 if (isNaN(document.forms['contactform'].tel.value))
	   		ret = false;
  
 	return ret;       
}
function fnvalidate(nextStep,type)
{

	var tError="";
	
	var umvalue=document.contactform.um.value;
	var Uhrvalue= document.contactform.Uhr.value;
	var emailvalue=document.contactform.email.value;
	
	/*if(((Uhrvalue != "") || (umvalue != "")) && ((umvalue != "") || (Uhrvalue != "")))
	{
		alert("inside Uhrvalue...."+Uhrvalue);
		alert("inside umvalue...."+umvalue);
		
		if(	(umvalue != "") && (Uhrvalue != "")	)
		{
			alert("in")
		}
		else
		{
			var telvalue=document.contactform.telnum.value;
			if((!telvalue)&&(!emailvalue))
			{
				
				tError=tError + "Bitte f&#252;llen Sie eine der folgenden Felder" + "\n" + "telefonummer" + "\n" + "Email" + "\n";
			}
		}
	}*/
	
	
	
	if((Uhrvalue) && (umvalue))
	{
		
		
		
			var telvalue=document.contactform.telnum.value;
			if((!telvalue)&&(!emailvalue))
			{
				
				tError=tError + "Bitte fullen Sie eine der folgenden Felder" + "\n" + "telefonummer" + "\n" + "Email" + "\n";
			}
		
	}else if(   ((Uhrvalue) && !(umvalue)) ||(  !(Uhrvalue) && (umvalue))    )
	{
	
	 tError=tError + "Bitte "+ x + " Sie sowohl das Datums- als auch das Uhrzeitfeld aus." + "\n";
	
	
	
	}
	
	
	
	
	
	
	
	
	if(emailvalue)
		{
	
			if (!CheckEmailForm (document.forms['contactform'].email.value))
			tError=tError+"\n Bitte fullen Sie das Feld E-Mail korrekt:\n";
	
		}



	
	
	if (tError.length> 0) 
	{
		alert (tError);
	}
	else
	{
		getContent(nextStep,'dinamic_survey','ajax');
		
	}
	
	
	
}


