// JavaScript Document
var campoTelDos = "number"
var estado = "ok"
var controlCierre = "";
var controlVentanaDos = "yes"

//function validaNombre (campoNombre,evt) 
//{
//
//		if(window.event) // IE
//		 {
//		  	key = evt.keyCode;
//		 }
//		  else 
//		 {
//		  	key = evt.which;
//		 }		
//			 
//			 if (key < 122 || key  96) && (key < 65  ||  key > 91) 
//			 {
//				 return false
//				 }
//			else
//			{
//				return true
//				}
//////				{
//////					if (key == 8  || key == 46 || key == 32 || key == 59 || key == 225 || key == 233 || key == 237 || key == 243 || key == 250 )
//////					{
//////						return true;
//////						
//////						}	
////
////				}
////				else
////				{	
////					return true;					
////				}	
//				
//				
//	
//	}

function submitform()
{
envio=0
	
	if (document.getElementById("nombre").value == "")
	{
		envio=1
		}
		
		
	if  (document.getElementById("email").value == "") 
	{
		envio = isEmailAddress(document.getElementById("email").value)
		}
		
		
	if (document.getElementById("ctca").value== "")
	{
		envio=1
		}
		
		
	if (document.getElementById("number").value== "")
	{
		envio=1
		}		
		
		
	if (envio==1)
	{
		document.getElementById("ctca").focus();
		document.getElementById("number").focus();
		document.getElementById("nombre").focus();
		document.getElementById("email").focus();	
		document.getElementById("number").focus();
		}

   //document.myform.submit();
}





function isEmailAddress( nombre_del_elemento ) 
{ 
var s = nombre_del_elemento; 
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/; 
if (s.length == 0 ) return true; 
   if (filter.test(s)) 
      return 0; 
   else 
	return 1; 
} 


function validaNro(Campo,evt) 
{
	if(window.event) // IE
	 {
	  key = evt.keyCode;
	 }
	  else if(evt.which) // Netscape/Firefox/Opera
	 {
	  key = evt.which;
	 }		


if ((key > 47 && key < 58 ))
	{			
	 if (document.getElementById(Campo).maxLength <= document.getElementById(Campo).value.length )
	 {
		 
		 document.getElementById(campoTelDos).focus();
		 }
	}
	else
	{	
	if (key == 8)
	{
		return true
		}
	else
	{
		return false
		}
		
	
	}
}

// BEGIN: OPEN BROWSER WINDOW
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// END: OPEN BROWSER WINDOW


// EJECUTA LAS ACCIONES DE LOS VALIDADORES
$(document).ready(function() {
			// SUCCESS AJAX CALL, replace "success: false," by:     success : function() { callSuccessFunction() }, 

			$("#formID").validationEngine({
				success :  false,
				failure : function() {}
			})
			//$.validationEngine.buildPrompt("#date","This is an example","error")	 		 // Exterior prompt build example
			//$.validationEngine.closePrompt(".date") 
			// Exterior prompt close example
			$('a').click( function(){controlVentanaDos = "no"; });
		});
// FIN EJECUTA LAS ACCIONES DE LOS VALIDADORES



// ABRE POPUP CUANDO EL USUARIO CIERRA LA LANDING
var tecla = "";
function MM_openBrWindowDos(theURL,winName,features) { //v2.0
	if (tecla != 116 && controlVentanaDos=="yes"){
		if (controlCierre == ""){
			window.open(theURL,winName,features);
		}
	}
}

function cambiarValor() {
	controlVentanaDos = "no";
}

window.onbeforeunload = function() {
	//alert('...');
}

document.onkeydown = tecladown;

function tecladown(Event){
 	if(Event==null){ Event=event; }
	if (Event && Event.keyCode == 116){ tecla = 116; return false; }
}