﻿
    document.oncontextmenu = function() {return false;};

	/*
   funcion : trim
   Descripcion: Funcion que limpia los espacios que tiene una cadena tanto inicial como final
   Parametros: p_Cadena el string a evaluar
   Devuelve:   la cadena limpia
*/
   function trim(p_Cadena) {
      worker = new String(p_Cadena);

      if (worker.indexOf(" ") != -1) {
         if (worker.indexOf(" ") == 0) {
            worker = worker.substring(1,worker.length);
            trim(worker);
         }
      }
   
      if (worker.lastIndexOf(" ") != -1) {
         if (worker.lastIndexOf(" ") >= worker.length-1) {
            worker = worker.substring(0,worker.length-1);
            trim(worker);
        }
      }
      return worker;
   }

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("La direccion de correo es erronea")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("La direccion de correo es erronea")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("La direccion de correo es erronea")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("La direccion de correo es erronea")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("La direccion de correo es erronea")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("La direccion de correo es erronea")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("La direccion de correo es erronea")
		    return false
		 }

 		 return true					
	}

function ValidateForm(objName,pmsg){
	var jsObject=document.getElementById(objName);
	
	if ((jsObject.value==null)||(trim(jsObject.value)=="")){
		alert(pmsg);
		jsObject.focus();
		return false
	}
	return true
 }
 
function ValidateEmail(pObj){
	if ((pObj.value==null)||(trim(pObj.value)=="")){
		alert("Favor de indicar su correo");
		return false
	}
	if (echeck(pObj.value)==false){
		pObj.value=""
		return false
	}
	return true
 }
 

 
 
 
 


