
	<!--    Esconder de Navegadores Anteriores

	 function muestrainformacion() {
		div = document.getElementById('informacion');
		div2 = document.getElementById('quejas');
		div.style.display ='';
		div2.style.display ='none';
	  }

	 function muestraquejas() {
		div = document.getElementById('informacion');
		div2 = document.getElementById('quejas');
		div.style.display ='none';
		div2.style.display ='';
	  }

	 function validateFields2(){

		var theForm = document.FL_PORTAL_CONTACTO;
		var returnFlag = true;
		var msg;
		var br;
		var yesNo;
		br="\n";
		if (theForm.p_nombre.value == ""){
			alert("Favor de especificar en NOMBRE");
			theForm.p_nombre.focus();
			theForm.p_nombre.select();
			return false;
		}
		if (theForm.p_email.value == ""){
			alert("Favor de especificar el E-MAIL");
			theForm.p_email.focus();
			theForm.p_email.select();
			return false;
		}
		if (!(isEmail(theForm.p_email.value))){
			alert("El E-MAIL es incorrecto");
			theForm.p_email.focus();
			theForm.p_email.select();
			return false;
		}
		if (theForm.p_puesto.value == ""){
			alert("Favor de especificar el PUESTO");
			theForm.p_puesto.focus();
			theForm.p_puesto.select();
			return false;
		}
		if (theForm.p_email1.value == ""){
			alert("Favor de especificar el E-MAIL");
			theForm.p_email1.focus();
			theForm.p_email1.select();
			return false;
		}
		if (theForm.p_email.value != theForm.p_email1.value ){
			alert("El correo electronico no coincide. Verfique y vuelva a intentar.");
			theForm.p_email.focus();			theForm.p_email.select();
			return false;
		}
		if (theForm.p_telefono.value == ""){
			alert("Favor de especificar el TELEFONO");
			theForm.p_telefono.focus();
			theForm.p_telefono.select();
			return false;
		}


		if (theForm.p_empresa.value == ""){
			alert("Favor de especificar la EMPRESA");
			theForm.p_empresa.focus();
			theForm.p_empresa.select();
			return false;
		}
		if (theForm.p_asunto.value == ""){
			alert("Favor de especificar el ASUNTO");
			theForm.p_asunto.focus();
			theForm.p_asunto.select();
			return false;
		}
		if (theForm.p_mensaje.value == ""){
			alert("Favor de especificar el MENSAJE");
			theForm.p_mensaje.focus();
			theForm.p_mensaje.select();
			return false;
		}
		if (theForm.p_mensaje.value.length>500){
			alert("El MENSAJE solo puede contener como maximo 500 caracteres.");
			theForm.p_mensaje.focus();
			theForm.p_mensaje.select();
			return false;
		}

		yesNo = confirm("P R E C A U C I O N: A partir de este paso ya no será posible cambiar sus datos, favor de verificar. "+br+br+"¿ Desea enviar los datos ?");
		if (yesNo == false){
		   return false;
		}

		theForm.submit();
		return returnFlag;
	}

	function isEmail(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("El E-mail es incorrecto");
		    return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			//alert("El E-mail es incorrecto");
		    return false;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			//alert("El E-mail es incorrecto");
		    return false;
		}
		if (str.indexOf(at,(lat+1))!=-1){
			//alert("El E-mail es incorrecto");
		    return false;
		}
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			//alert("El E-mail es incorrecto");
		    return false;
		}
		if (str.indexOf(dot,(lat+2))==-1){
			//alert("El E-mail es incorrecto");
		    return false;
		}
		if (str.indexOf(" ")!=-1){
			//alert("El E-mail es incorrecto");
		    return false;
		}
		return true;
	}
		
function validateFields(){

	var theForm = document.FRM_ADD_DATA;
	var returnFlagX = true;
	var banderax = 0;


if (theForm.p_nombre_cliente.value=="") {
	   alert("Favor de especificar el NOMBRE");
	   theForm.p_nombre_cliente.focus();
	   theForm.p_nombre_cliente.select();
	   return false;
	}


if (theForm.p_telefono.value!=""){
	if(!IsNumeric(theForm.p_telefono.value)){
       alert("El TELEFONO debe contener solo valores numericos 0,1,2...,9 y/o (,),-. ");
	theForm.p_telefono.focus();
	theForm.p_telefono.select();
	return false;
   }
 }


if (theForm.p_email.value=="") {
	   alert("Favor de especificar el EMAIL");
	   theForm.p_email.focus();
	   theForm.p_email.select();
	   return false;
	}
else{
	if( !isEmailAddress(theForm.p_email, '')) return false;
     }

if (theForm.p_descripcion.value=="") {
	   alert("Favor de especificar la DESCRIPCIÓN DEL REPORTE");
	   theForm.p_descripcion.focus();
	   theForm.p_descripcion.select();
	   return false;
	}

if (theForm.p_lugar.value=="") {
	   alert("Favor de especificar el LUGAR EN DONDE OCURRIO EL REPORTE");
	   theForm.p_lugar.focus();
	   theForm.p_lugar.select();
	   return false;
	}

if (theForm.p_fecha.value=="") {
	   alert("Favor de especificar el FECHA Y HORA DE CUANDO OCURRIO EL REPORTE");
	   theForm.p_fecha.focus();
	   theForm.p_fecha.select();
	   return false;
}else{
     if ( !ValidarFecha(theForm.p_fecha.value) ) return false;

  }

        //theForm.submit();
	saveComplaint();
	return returnFlagX;

}


function isNumeric(item){
	var rt=event.keyCode;
	if ((rt>=48 && rt<=57)||rt==190||rt==8||rt==46||rt==45||rt==40||rt==41)
	{ 
		return true
	}else{
	   alert('Este campo solo acepta valores numericos 0,1,2,3...9');
	   return false;
	}
}

//Validar EMAIL
function isEmailAddress(theElement, nombre_del_elemento )
					{
					var s = theElement.value;
					var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
					if (s.length == 0 ) return true;
					if (filter.test(s))
					   return true;
					else
					   alert("Ingrese una dirección de correo válida");
					 
                                          theElement.focus();
					  return false;
					}




function ValidarFecha(Cadena){

			   //dd-mm-yyyy   
			    var Fecha= new String(Cadena)   // Crea un string   
			    var RealFecha= new Date()   // Para sacar la fecha de hoy   

			    // Cadena Minuto   
			    var Minuto = new String(Fecha.substring(Fecha.indexOf(":")+1,Fecha.length ))     
			    // Cadena Hora   
			    var Hora= new String(Fecha.substring(Fecha.lastIndexOf(" ")+1,Fecha.indexOf(":") ))     
	 
			    // Cadena Año   
			    var Ano= new String(Fecha.substring(Fecha.lastIndexOf("-")+1,Fecha.indexOf(" ") ))     
			    // Cadena Mes   
			    var Mes= new String(Fecha.substring(Fecha.indexOf("-")+1,Fecha.lastIndexOf("-")))   
			    // Cadena Día   
			    var Dia= new String(Fecha.substring(0,Fecha.indexOf("-") ))   
		

			    // Valido el año
			    if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900){   
	                      alert("Año inválido")  
			        return false   
			    }   
			    // Valido el Mes   
			    if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12){   
			        alert("Mes inválido")   
			        return false   
			    }   
			    // Valido el Dia   
			    if (isNaN(Dia) || parseInt(Dia, 10)<1 || parseInt(Dia, 10)>31){   
			        alert("Día inválido")   
			        return false   
			    }   
			    if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {   
			        if (Mes==2 && Dia > 28 || Dia>30) {   
			            alert("Día inválido")   
			            return false   
			       }   
			    }   

			  // Valido la Hora
			    if (isNaN(Hora) || parseFloat(Hora)<1 || parseFloat(Hora)>23){   
			        alert("Hora inválida")   
			        return false   
			    }   

			    // Valido el Minuto
			    if (isNaN(Minuto) || parseFloat(Minuto)<1 || parseFloat(Minuto)>59){   
			        alert("Minuto inválido")   
			        return false   
			    }   
			       
			    return true     
		};


function saveComplaint(){  
      var theForm = document.forms["FRM_ADD_DATA"];
      var myPage = "http://www.fl.com.mx/portal/pls/portal/msi_mac_ptl.save_request_internet";
      var XmlHttpProc = GetXmlHttpObject();
      var attribs = "";
      var sep = "";

      for(var i=0;i<theForm.elements.length;i++){
         if (theForm.elements[i].type!="button"){
            attribs+=sep+theForm.elements[i].name+"="+convertToWeb(theForm.elements[i].value);
	    sep="&";
	 }
      }
	//window.open(myPage+"?"+attribs);
       var XmlHttp = GetXmlHttpObject();
	    XmlHttp.onreadystatechange=
	              function(){
                          if (XmlHttp.readyState==4 || XmlHttp.readyState=="complete"){
 	                         if (XmlHttp.responseText!=""){
							     var resultado = XmlHttp.responseXML.getElementsByTagName("RESULTADO")[0].firstChild.nodeValue;
							     var mensaje = XmlHttp.responseXML.getElementsByTagName("MENSAJE")[0].firstChild.nodeValue;
							     alert(mensaje);
			                }
                         }
                      };
       XmlHttp.open("POST",myPage,true);
       XmlHttp.send(attribs);
  };

function ComparaFecha(){  
      var theForm = document.forms["FindRequest"];
      var myPage = "http://www.fl.com.mx/portal/pls/portal/msi_mac_ptl.Validate_Date";
      var XmlHttpProc = GetXmlHttpObject();
      var attribs = "p_fecha_ini="+theForm.p_fecha_ini;
	   attribs = attribs+"&p_fecha_final="+theForm.p_fecha_final;


	window.open(myPage+"?"+attribs);
       var XmlHttp = GetXmlHttpObject();
	    XmlHttp.onreadystatechange=
	              function(){
                          if (XmlHttp.readyState==4 || XmlHttp.readyState=="complete"){
 	                         if (XmlHttp.responseText!=""){
							     var resultado = XmlHttp.responseXML.getElementsByTagName("RESULTADO")[0].firstChild.nodeValue;
							     var mensaje = XmlHttp.responseXML.getElementsByTagName("MENSAJE")[0].firstChild.nodeValue;
							     alert(mensaje);
			                }
                         }
                      };
       XmlHttp.open("POST",myPage,true);
       XmlHttp.send(attribs);
     if(mensaje=="OK")
      return true;
     else 
      return false;
  };


function GetXmlHttpObject(handler)
{ 
   var objXMLHttp=null;
   if (window.XMLHttpRequest){
      objXMLHttp=new XMLHttpRequest();
   }else if (window.ActiveXObject){
      objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
   //objXMLHttp.setRequestHeader("charset","utf-8");
   //objXMLHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');  
   return objXMLHttp;
};

function convertToWeb(pString){
   var cadena = pString;
   while (cadena.indexOf("%")>-1)
   {
      cadena = cadena.replace("%","*25");
   }
   while (cadena.indexOf("*25")>-1)
   {
      cadena = cadena.replace("*25","%25");
   }
   while (cadena.indexOf("+")>-1)
   {
      cadena = cadena.replace("+","%2B");
   }
   while (cadena.indexOf("&")>-1)
   {
   cadena = cadena.replace("&","%26");
   }
   while (cadena.indexOf("?")>-1)
   {
   cadena = cadena.replace("?","%3F");
   }
   return cadena;
};


function IsNumeric(strString){
   var strValidChars = "0123456789()-*";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) 
	 return false;
   for (i = 0; i < strString.length && blnResult == true; i++){
	 strChar = strString.charAt(i);
      	 if (strValidChars.indexOf(strChar) == -1){
	         blnResult = false;
          }
      }
     return blnResult;
   }

function ClearForm(){
	var theForm = document.FRM_ADD_DATA;
	var returnFlagX = true;
	var banderax = 0;

	theForm.p_nombre_cliente.value="";
	//theForm.p_domicilio_cliente.value="";
	theForm.p_telefono.value=""
	theForm.p_email.value="";
	theForm.p_descripcion.value="";
	theForm.p_lugar.value="";
	theForm.p_fecha.value="";
	theForm.p_tracto.value="";
	theForm.p_operador.value="";
  }

function validateFecha(){  
      var theForm = document.forms["FRM_ADD_DATA"];
      if (theForm.p_fecha.value != ""){
 	   var myPage = "http://www.fl.com.mx/portal/pls/portal/msi_mac_ptl.Validate_RegDate";
	   var XmlHttpProc = GetXmlHttpObject();
	   var attribs = "p_fecha="+theForm.p_fecha.value;
	   var mensaje = "" ;

	   //window.open(myPage+"?"+attribs);
           var XmlHttp = GetXmlHttpObject();
	     XmlHttp.onreadystatechange=
	             function(){
                         if (XmlHttp.readyState==4 || XmlHttp.readyState=="complete"){
 	                        if (XmlHttp.responseText!=""){
						     var resultado = XmlHttp.responseXML.getElementsByTagName("RESULTADO")[0].firstChild.nodeValue;
						     mensaje = XmlHttp.responseXML.getElementsByTagName("MENSAJE")[0].firstChild.nodeValue;
			                }
                         }
                       };
         XmlHttp.open("POST",myPage,false);
         XmlHttp.send(attribs);
        if(mensaje=="OK")
          return true;
        else 
          return false;
      }else
        return true;
 
  };

 function MaxLeng(){
	var rt=event.keyCode;
	var theForm = document.FL_PORTAL_CONTACTO;
	if (theForm.p_mensaje.value.length>500){
	   if (rt==8||rt==46){
		  return true;
	   }else{
		  alert("El MENSAJE solo puede contener como maximo 500 caracteres.");
		  return false;
	   }
	}
  };
