// JavaScript Document

function verify() {
var themessage = "Le requieren terminar los campos siguientes: ";
if (document.form.nombre.value=="") {
themessage = themessage + "Nombre + ";
}
if (document.form.email.value=="") {
themessage = themessage + "E-mail";
}
if (document.form.email.value!="") {
	text=document.form.email.value
	
	// Check For Bad Chars
	badchar = " ()<>\/[]{}+-*|;,'"
	for (i=0;i<text.length;i++) {
		for (j=0;j<badchar.length;j++) {
			if (text.charAt(i) == badchar.charAt(j)) {
				alert("Incorpore por favor su E-mail válido")				
//				alert("Your Email Address May Has Some Bad Character or there is some space between letters")
				return false
			}
		}
	}
	// There Should Be a dot (.) Symbol
	if (text.indexOf(".") == -1) {
		alert("Incorpore por favor su E-mail válido")
//		alert("Your Email Address Doesnot have any dot(.) symbol")
		return false
	}
	// There Should Be an @ Symbol
	if (text.indexOf("@") == -1) {
		alert("Incorpore por favor su E-mail válido")
//		alert("Your Email Address Doesnot have any @ symbol")
		return false
	}
	else {
	// Only one @ symbol should be found
		symbolfound = 0
		for (i=0;i<text.length;i++) {
			if (text.charAt(i) == "@") {
				symbolfound++
			}
			else {
				continue
			}
		}
		if (symbolfound != 1) {
			alert("Incorpore por favor su E-mail válido")
//			alert("Ooops  Your Email Address Has More Than One @ Symbol")
			return false
		}
	}
	// Check For Syntax Errors Such as .@  or   @.  or  ..
	if (text.indexOf("@.") != -1 || text.indexOf(".@") != -1 || text.indexOf("..") != -1) {
		alert("Incorpore por favor su E-mail válido")		
//		alert("Sorry Your Email Address has two symbol side by side and it is wrong")
		return false
	}
	// The first character shouldn't be @ or .
	if (text.charAt(0) == "@" || text.charAt(0) == ".") {
		alert("Incorpore por favor su E-mail válido")		
//		alert("E-mail: Your first character seem to be . or @ and it is wrong")
		return false
	}
	// The last character shouldn't be @ or .
	if (text.charAt(text.length-1) == "@" || text.charAt(text.length-1) == ".") {
		alert("Incorpore por favor su E-mail válido")		
//		alert("E-mail: Your last character seem to be . or @ and it is wrong")
		return false
	}
	// The @ Symbol should be found before .
	foundchar1 = text.indexOf("@")
	foundchar2 = text.indexOf(".")
	if (foundchar1 > foundchar2) {
		alert("Incorpore por favor su E-mail válido")		
//		alert("E-mail: Sorry The @ Symbol should be found before dot(.)symbol but it isnt in yours")
		return false
	}
}
//alert if fields are empty and cancel form submit
if (themessage == "Le requieren terminar los campos siguientes: ") 
{
	submit_Alerta();
/////////////////////////////////////////////////////////////////////////////	
		
  	window.open('', 'Card', 'top=100,left=100,height=350,width=500');
	document.form.target="Card"; 
	document.form.action = "sendcard.php"; 
	document.form.submit(); 
	
	document.form.reset();
}
else {
alert(themessage);
return false;
   }
}


function submit_Alerta(){
	
	
	document.getElementById("BillFirstName").value = document.getElementById("nombre").value;
	document.getElementById("BillAddress").value = document.getElementById("direccion").value;
	document.getElementById("BillCity").value = document.getElementById("ciudad").value;
	document.getElementById("BillState").value = document.getElementById("estado2").value;
	document.getElementById("BillZip").value = document.getElementById("zip2").value;
	document.getElementById("BillPhone").value = "(" + document.getElementById("telefonoloc").value + ")" + "-" + document.getElementById("telefononum").value;
	document.getElementById("BillEMail").value = document.getElementById("email").value;
	
	//document.alerta.getElementById("ItemDesc").value = document.alerta.getElementById("email").value
	document.getElementById("ItemCost").value = document.getElementById("cash").value;
	
	window.open('', 'eProcessingNetwork', '');
	document.alerta.target = "eProcessingNetwork"; 
	document.alerta.action = "https://www.eProcessingNetwork.Com/cgi-bin/wo/order.pl";
	
	document.alerta.submit();
		
}