//document.getElementById('cemailcont').value,document.getElementById('cnombrecont').value,document.getElementById('cladacont').value,document.getElementById('ctelcont').value ,document.getElementById('ccomentariocont').value, document.getElementById('asunto').value
function SendMail(c,cm,a)  {
	
	$.post("calls/Sm.php", {c: ""+c+"", cm: ""+cm+"" , a: ""+a+""}, function(data)    {
			switch(data){
				case "1":
					alert("Correo Enviado Satisfactoriamente, proximamente se comunicaran con usted, gracias.");
					
					//document.getElementById('cont').reset();
					Go(10,0);
				break;
				default:
					alert("Problemas al Enviar Correo, Intente de Nuevo");
				break;
			}
		}        
	);
}


function vmail(){
	var m=document.getElementById('cemailcont').value;
	var pos=m.indexOf("@");
	var u=m.substring(0, pos);
	var d=m.substring(pos+1);
	var re=true;
	var pos2=d.indexOf(".");
	var emp=d.substring(0, pos2);
	var tipo=d.substring(pos2+1);
	var hayError = false;
	if (   (m.indexOf("@")==-1) || ((u.length==0) || (u==".")) || ((d.length==0) && (d.indexOf(".")==-1)) || ((emp.length=="") || (tipo.length<2))	){
	  	alert("Debes introducir una dirección de e-mail válida");
	  	document.getElementById('cemailcont').value=" ";
	  	document.getElementById('cemailcont').focus();
	  	return false;
	}
	if ((u.length==0) || (u==".")){
	  	alert("Debes introducir una dirección de e-mail válida");
	  	document.getElementById('cemailcont').value=" ";
	  	document.getElementById('cemailcont').focus();
	  	return false;
	}
	if ((d.length==0) && (d.indexOf(".")==-1)){
	  	alert("Debes introducir una dirección de e-mail válida");
	  	document.getElementById('cemailcont').value=" ";
	  	document.getElementById('cemailcont').focus();
	  	return false;
	}
	if((emp.length=="") || (tipo.length<2)){
		alert("Debes introducir una dirección de e-mail válida");
  	  	document.getElementById('cemailcont').value=" ";
	  	document.getElementById('cemailcont').focus();
	  	return false;
	}
	return re;
}

function vlfrm(){
	var r=vmail();
	if (document.getElementById('asunto').value=='0'){
		alert("Se requiere seleccionar un Asunto");
		document.getElementById('asunto').focus();
	}else{
		if (document.getElementById('cemailcont').value.length==0 || document.getElementById('ccomentariocont').value.length==0){
			alert("Se requieren llenar todos los Campos, por Favor..");
		}else{
			if (r){
				SendMail(document.getElementById('cemailcont').value,document.getElementById('ccomentariocont').value, document.getElementById('asunto').value);
			}
		}
	}
};

function vlfrmFaq(){
	var r=vmail();
	if (document.getElementById('ccomentariocont').value.length==0){
		alert("Se requieren llenar Información sobre su duda, por Favor..");
		document.getElementById('ccomentariocont').focus();
	}else{
		if (r){
			SendMail(document.getElementById('cemailcont').value,'','','',document.getElementById('ccomentariocont').value,7);
		}
	}
};

function SoloLetras(e) { 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; 
	patron =/[A-Za-zñÑ\s]/; 
    te = String.fromCharCode(tecla); 
    return patron.test(te); 
} 

function SoloNumeros(e) { 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; 
	patron =/\d/;; 
    te = String.fromCharCode(tecla); 
    return patron.test(te); 
}
