function goToLang(langlang)
{
document.location.href="?new_lang="+langlang;;
}

function Form_Validator_aff(partnerform)
{	

var emailaff = document.getElementById('emailaff');
var password = document.getElementById('password');
	if (password.value == "" && emailaff.value == "")
	{
		alert("Please enter your email address and password.");
		return false;	
	}	
	if (password.value == "")
	{
		alert("Please enter your password.");
		return false;	
	}
	if(emailValidator(emailaff, "Please enter a valid email address"))
	{
		document.partnerform.submit();
		
	}		
	return false;
}





function Form_Validator_mer(merchantform)
{	

	var emailmer = document.getElementById('emailmer');
	var password2 = document.getElementById('password2');
	if (password2.value == "" && emailmer.value == "")
	{
		alert("Please enter your email address and password.");
		return false;	
	}	
	if (password2.value == "")
	{
		alert("Please enter your password.");
		return false;	
	}
	if(emailValidator(emailmer, "Please enter a valid email address"))
	{
		document.merchantform.submit();
		
	}		
	return false;
}


function emailValidator(elem, helperMsg){
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(elem.value))
{
	return true;
} else if (!elem.value)
	{
  	alert("Please enter your email address");
  	elem.focus();
  	return false;
	}else{

		alert(helperMsg);
		elem.focus();
		return false;
		}
}



function sendpass()
	{
	var emailaff = document.getElementById('emailaff');
	
			
			
		
	if (partnerform.userID.value == "")
		alert("Enter your Email to receive password.");
	else
		{
		if(emailValidator(emailaff, "Please enter a valid email address"))
			{
				
			document.location = "http://my.lidango.com/afflogin.php?sendpass=1&userID="+partnerform.userID.value;
			}
		
		}
	}



function sendmerpass()
{
var emailmer = document.getElementById('emailmer');	

if (merchantform.userID.value == "")
	alert("Enter your Email to receive password.");
else
	{
	if(emailValidator(emailmer, "Please enter a valid email address"))
		{
		
		document.location = "merlogin.php?sendpass=1&userID="+merchantform.userID.value;
		}	
		
	
	}
}



////////// MERCHANT //////////////////////

function Form_Validator_m(theForm)
{
var ss = document.theForm.URL.value.substr(0,7);

if (ss == "http://" || ss == "HTTP://" || ss == "Http://" || ss == "Https:/" || ss == "https:/" || ss == "HTTPS:/")
	{
		
	}
	 else
	{
	alert("Website URL must begin with http:// or https:// .");
  		document.theForm.URL.focus();
  		return (false);
	}	
if (document.theForm.URL.value == "http://")
	{
	alert("Please enter website URL.");
  		document.theForm.URL.focus();
  		return (false);
	}
if (document.theForm.URL.value == "")
	{
	alert("Please enter website URL.");
  		document.theForm.URL.focus();
  		return (false);
	}
if (document.theForm.categoryID.value == "0")
	{
	alert("Please enter website category.");
  		document.theForm.categoryID.focus();
  		return (false);
	}
if (document.theForm.fname.value == "")
	{
	alert("Please enter your name.");
  		document.theForm.fname.focus();
  		return (false);
	}
if (document.theForm.lname.value == "")
	{
	alert("Please enter your last name.");
  		document.theForm.lname.focus();
  		return (false);
	}
if (document.theForm.company.value == "")
	{
	alert("Please enter your company.");
  		document.theForm.company.focus();
  		return (false);
	}
if (document.theForm.address.value == "")
	{
	alert("Please enter your address.");
  		document.theForm.address.focus();
  		return (false);
	}
if (document.theForm.city.value == "")
	{
	alert("Please enter your city.");
  		document.theForm.city.focus();
  		return (false);
	}
if (document.theForm.country.value == "0")
	{
	alert("Please select your Country");
  		document.theForm.country.focus();
  		return (false);
}

if (document.theForm.phone.value == "")
	{
	alert("Please enter your phone.");
  		document.theForm.phone.focus();
  		return (false);
}

var email = document.getElementById('email');
if(emailValidator_m(email, "Please enter a valid email address")){
			document.theForm.submit();
	}
	return false;
}





function sendpass_m()
{
var emailmer = document.getElementById('ID');	

if (merchantform.userID.value == "")
	alert("Enter your Email to receive password.");
else
	{
	if(emailValidator_m(emailmer, "Please enter a valid email address"))
		{
		
		document.location = "merlogin.php?sendpass=1&userID="+merchantform.userID.value;
		}	
		

	}
}




function submitmer_m()
{
if (merchantform.userID.value == "")
	alert("Please enter your email address and password");
else if (merchantform.password.value == "")
	alert("Please enter your password");
else
	merchantform.submit();

}

function emailValidator_m(elem, helperMsg)
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(elem.value)){
	return true;
} else if (!elem.value){
  alert("Please enter your email address");
 
  elem.focus();
  return false;
}else{
	var mail=false;
	alert(helperMsg);
	elem.focus();
	return false;
}
}


////////////////////// AFFILIATE //////////////////////////////////////////////


function Form_Validator_a(theForm)
	{
	    var ss = document.theForm.URL.value.substr(0,7);

	if (ss == "http://" || ss == "HTTP://" || ss == "Http://" || ss == "Https:/" || ss == "https:/" || ss == "HTTPS:/")
		{
			
		}
	else
		{
		alert("Website URL must begin with http:// or https:// .");
    		document.theForm.URL.focus();
    		return (false);
		}	
	if (document.theForm.URL.value == "http://")
		{
		alert("Please enter website URL.");
    		document.theForm.URL.focus();
    		return (false);
		}
	if (document.theForm.URL.value == "")
		{
		alert("Please enter website URL.");
    		document.theForm.URL.focus();
    		return (false);
		}
	if (document.theForm.siteName.value == "")
		{
		alert("Please enter website name.");
    		document.theForm.siteName.focus();
    		return (false);
		}
	if (document.theForm.IMP.value == 0)
		{
		alert("Please select website visits.");
    		document.theForm.IMP.focus();
    		return (false);
		}
	if (document.theForm.fname.value == "")
		{
		alert("Please enter your name.");
    		document.theForm.fname.focus();
    		return (false);
		}
	if (document.theForm.lname.value == "")
		{
		alert("Please enter your last name.");
    		document.theForm.lname.focus();
    		return (false);
		}
	if (document.theForm.address.value == "")
		{
		alert("Please enter your address.");
    		document.theForm.address.focus();
    		return (false);
		}
	if (document.theForm.city.value == "")
		{
		alert("Please enter your city.");
    		document.theForm.city.focus();
    		return (false);
		}
	if (document.theForm.state.value == "0")
		{
		alert("Please select your State");
    		document.theForm.state.focus();
    		return (false);
	}
	if (document.theForm.zip.value == "")
		{
		alert("Please enter your Zip/Postcode.");
    		document.theForm.zip.focus();
    		return (false);
		}
	if (document.theForm.country.value == "0")
		{
		alert("Please select your Country");
    		document.theForm.country.focus();
    		return (false);
	}
	if (document.theForm.phone.value == "")
		{
		alert("Please enter your phone.");
    		document.theForm.phone.focus();
    		return (false);
		}
	if (document.theForm.checkname.value == "")
		{
		alert("Please enter the money recipient.");
    		document.theForm.checkname.focus();
    		return (false);
		}
	if (document.theForm.howfoundus.value == "")
		{
		alert("Please type how did you hear about us.");
    		document.theForm.howfoundus.focus();
    		return (false);
		}
	if (document.theForm.terms.checked == false)
		{
		alert("You have to accept the Terms & Conditions of Lidango.");
    		document.theForm.terms.focus();
    		return (false);
		}
	
	var email = document.getElementById('email');
	
	if(emailValidator_a(email, "Please enter a valid email address")){
			var startsn= document.getElementById('start_sign');
					startsn.submit()
		}
		return false;
	}




function sendpass_a()
{

var emailaff = document.getElementById('userID');

		
		
	
if (partnerform.userID.value == "")
	alert("Enter your Email to receive password.");
else
	{
	if(emailValidator_a(emailaff, "Please enter a valid email address"))
		{
	
		document.location = "afflogin.php?sendpass=1&userID="+partnerform.userID.value;
		}
	
	}
}




function submit_a()
{
if (partnerform.userID.value == "")
	alert("Please enter your email address and password");
else if (partnerform.password.value == "")
	alert("Please enter your password");
else
	partnerform.submit();

}



function emailValidator_a(elem, helperMsg){
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(elem.value)){
	return true;
} else if (!elem.value){
  alert("Please enter your email address");
  elem.focus();
  return false;
}else{
	alert(helperMsg);
	elem.focus();
	return false;
}
}

function Form_Validator_c(theForm)
	{
	var ss = document.theForm.companyurl.value.substr(0,7);

	if (document.theForm.fname.value == "")
		{
		alert("Please enter your First Name.");
    		document.theForm.fname.focus();
    		return (false);
		}

	if (document.theForm.lname.value == "")
		{
		alert("Please enter your Last Name.");
    		document.theForm.lname.focus();
    		return (false);
		}

	if (document.theForm.companyname.value == "")
		{
		alert("Please enter your Company Name.");
    		document.theForm.companyname.focus();
    		return (false);
		}

	if (ss == "http://" || ss == "HTTP://" || ss == "Http://" || ss == "Https:/" || ss == "https:/" || ss == "HTTPS:/")
		{
			
		}
	else
		{
		alert("URL must begin with http:// or https:// .");
    		document.theForm.companyurl.focus();
    		return (false);
		}	
	if (document.theForm.companyurl.value == "http://")
		{
		alert("Please enter URL.");
    		document.theForm.companyurl.focus();
    		return (false);
		}
	if (document.theForm.companyurl.value == "")
		{
		alert("Please enter URL.");
    		document.theForm.companyurl.focus();
    		return (false);
		}

	var email = document.getElementById('email');

	if ((email.value == null) || (email.value == "")){
		alert("Please Enter your Email");
		email.focus();
		return (false);
	}
	if (echeck(email.value) == false){
		email.value="";
		email.focus();
		return (false);
	}

	if (document.theForm.phone.value == "")
		{
		alert("Please enter your Phone Number.");
    		document.theForm.phone.focus();
    		return (false);
		}

	if (document.theForm.address.value == "")
		{
		alert("Please enter your Address.");
    		document.theForm.address.focus();
    		return (false);
		}

	if (document.theForm.city.value == "")
		{
		alert("Please enter your City.");
    		document.theForm.city.focus();
    		return (false);
		}

	if (document.theForm.state.value == "0" && document.theForm.state_other.value == "")
		{
		alert("Please select your State or fill out the State Other field if you are outside of the United States.");
    		document.theForm.state_other.focus();
    		return (false);
		}

	if (document.theForm.zip.value == "")
		{
		alert("Please enter your Zip Code.");
    		document.theForm.zip.focus();
    		return (false);
		}

	if (document.theForm.country.value == "0")
		{
		alert("Please select your Country.");
    		document.theForm.country.focus();
    		return (false);
		}
		
	var contact = document.getElementById('contact');
	//contact.action = "http://www.lidango.com/cpm/mersignup.php";
	contact.submit();
	}

function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }

 		 return true;				
	}

function emailantispam(email1, email2, email3, email4){
   emailE = email1 + email2 + '@' + email3 + email4;
   document.write('<a href="mailto:' + emailE + '">' + emailE + '</a>')
}
