//////////// FUNCIONES PARA LISTA DE PRECIOS /////////////////
	var descuento_ = "false";
	function inicializa_var_descuento(){
		descuento_ = "false";
	}
	
	//seccion sin terminar/////
	function busca_productos(tipo_bus,clave){
		var descuento = "false";
		if(document.getElementById("descuento_")){
			if(document.getElementById("descuento_").checked){
				descuento_ = "true";
			}
		}
		var parametros = "genera_lista_de_precios_.php?acc=99&tip_bus="+tipo_bus+"&descuento_="+descuento_+"&clave_="+clave;
		window.location.href = parametros;
	}
		
	function genera_reporte_pagina(mv,md,sf,pag_,clave,tip_rep){
		var descuento = "false";
		//alert('desde script '+tip_rep);
		if(document.getElementById("descuento_")){
			if(document.getElementById("descuento_").checked){
				descuento_ = "true";
			}
		}
		document.getElementById("area_descarga_").innerHTML = "";
		setTimeout("",1000);
		a_(97,"&mv="+mv+"&md="+md+"&sf="+sf+"&pag_="+pag_+"&tip_rep="+tip_rep+"&descuento_="+descuento_+"&clave="+clave);
	}
	
	function genera_reporte_completo(mv,md,sf,clave,tip_rep){
		//alert('desde script '+tip_rep);
		var descuento = "false";
		if(document.getElementById("descuento_")){
			if(document.getElementById("descuento_").checked){
				descuento = "true";
			}
		}
		document.getElementById("area_descarga_").innerHTML = "";
		a_(96,"&mv="+mv+"&md="+md+"&sf="+sf+"&tip_rep="+tip_rep+"&descuento_="+descuento+"&clave="+clave);
	}
	
	var archivo_download = ""; 
	function descarga_pdf_(){
		if(archivo_download != ""){
			mipopup = window.open(archivo_download,"miwin","");
		}else{
			alert('Ocurrio un error al generar la descarga del archivo');
		}
	}
	
	function descargar_archivo(archivo_){
	 	mipopup = window.open(archivo_,"miwin","");
	}
/***************Detalles de pedidos anteriores******************************/
var xmlHttp;
function GetXmlHttpObject(handler)   
{ 

if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  objXMLHttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
return objXMLHttp;
   
}   

function muestradetalles(url, qStr,mostraren)   
{   
   if (url.length==0)   
   {   
       document.getElementById(mostraren).innerHTML="";   
       return;   
   }   
   xmlHttp=GetXmlHttpObject()   
   if (xmlHttp==null)   
   {   
       alert ("Browser does not support HTTP Request");   
       return;   
   }   
   url=url;   
   params=qStr+"&sid="+Math.random();   
   xmlHttp.open("POST", url, true);
   xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   xmlHttp.setRequestHeader("Content-length", params.length);
   xmlHttp.setRequestHeader("Connection", "close");

//Send the proper header information along with the request
xmlHttp.onreadystatechange = function() {//Call a function when the state changes.
	
	if (xmlHttp.readyState==1) {
			document.getElementById(mostraren).innerHTML = "Cargando..";
	}
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		//alert(xmlHttp.responseText);
		document.getElementById(mostraren).innerHTML= xmlHttp.responseText;  
	}
}
xmlHttp.send(params);
 

}
/**************************fin detalle de pedidos anteriores***********************************/
	
//////////////////////////////////////////////////////////////

function a_(a__,param3){
  var xmlHttp_2;  try{
    xmlHttp_2=new XMLHttpRequest();}catch (e){
    try{xmlHttp_2=new ActiveXObject("Msxml2.XMLHTTP");}catch (e){try{xmlHttp_2=new ActiveXObject("Microsoft.XMLHTTP");} catch (e){alert("Tu navegador no soporta AJAX!");  return false;}}}xmlHttp_2.onreadystatechange=function()
      {
     //document.myForm.descripcion.value='...';
	  if(xmlHttp_2.readyState==4){
	   /////////////////////////////
	   eval(xmlHttp_2.responseText);
      // document.getElementById("DIVresultado").innerHTML="";
	   /////////////////////////////
        }
      }
	 var mR=parseInt(Math.random()*99999999);
    xmlHttp_2.open("GET","a_.php?a_="+a__+param3,true);
    xmlHttp_2.send(null);

}
var color_ = 0;


function startUpload(){    
	document.getElementById('f1_upload_process').style.visibility = 'visible';  
	  return true;
}

function stopUpload(success){  
	var result = '';     
	 if (success == 1){         
	 	document.getElementById('result').innerHTML ='<span class="msg">El archivo fue cargado satisfactoriamente!<\/span><br/><br/>'; 
 	    //setTimeout("location.reload(true);",1);
		}
	 else if(success == 2){
		document.getElementById('result').innerHTML ='<span class="emsg">Archivo Incorrecto!<\/span><br/><br/>';
	}
	else {   
		document.getElementById('result').innerHTML ='<span class="emsg">Error al subir el archivo!<\/span><br/><br/>';      
		}      
	document.getElementById('f1_upload_process').style.visibility = 'hidden';      return true;   
}

function trim(s){
s = s.replace(/\s+/gi, ' '); //sacar espacios repetidos dejando solo uno
s = s.replace(/^\s+|\s+$/gi, ''); //sacar espacios blanco principio y final

return s;
}


function agrega(){
  if(color_==0){
    color_=1;
  }else{
    color_=0;
  }
  var cantidad = /(^\d*)$/;
 /* if(!cantidad.test(document.myForm.cantidad.value)){
	alert('Cantidad Incorrecta');
} */
  
//  if(document.myForm.codigo.value!=''&&document.myForm.codigo.value!=' '&&document.myForm.cantidad.value&&document.myForm.descripcion.value!=''&&document.myForm.descripcion.value!='...'){
  if(document.myForm.codigo.value!=''&&document.myForm.codigo.value!=' '&& trim(document.myForm.cantidad.value)!='' && cantidad.test(document.myForm.cantidad.value)&&document.myForm.descripcion.value!=''&&document.myForm.descripcion.value!='...'){
    a_(2,'&c_='+document.myForm.codigo.value+'&v_='+document.myForm.cantidad.value+'&cl_='+color_);
  }else{
	alert("El c\u00F3digo \u00F3 cantidad capturados son incorrectos");  
  }
}

function agregacantidad(form){
  if(color_==0){
    color_=1;
  }else{
    color_=0;
  }
  var cantidad = /(^\d*)$/
  //alert(form.codigo.value+","+form.cantidad.value+","+form.descripcion.value);
	parent.document.myForm.codigo.value=form.codigo.value;
	parent.document.myForm.cantidad.value=form.cantidad.value;
	parent.document.myForm.descripcion.value=form.descripcion.value;
  //alert(parent.document.myForm.codigo.value+","+parent.document.myForm.cantidad.value+","+parent.document.myForm.descripcion.value);

// if(form.codigo.value!=''&&form.codigo.value!=' '&&form.cantidad.value&&form.descripcion.value!=''&&form.descripcion.value!='...'){
 if(form.codigo.value!=''&&form.codigo.value!=' '&&cantidad.test(form.cantidad.value)&&form.descripcion.value!=''&&form.descripcion.value!='...'){
    a_(22,'&c_='+parent.document.myForm.codigo.value+'&v_='+parent.document.myForm.cantidad.value+'&cl_='+color_);
  }else{
	alert("El c\u00F3digo \u00F3 cantidad capturados son incorrectos");  
  }
  
}




function NumberFormat(num, inputDecimal)
{
this.VERSION = 'Number Format v1.5.4';
this.COMMA = ',';
this.PERIOD = '.';
this.DASH = '-'; 
this.LEFT_PAREN = '('; 
this.RIGHT_PAREN = ')'; 
this.LEFT_OUTSIDE = 0; 
this.LEFT_INSIDE = 1;  
this.RIGHT_INSIDE = 2;  
this.RIGHT_OUTSIDE = 3;  
this.LEFT_DASH = 0; 
this.RIGHT_DASH = 1; 
this.PARENTHESIS = 2; 
this.NO_ROUNDING = -1 
this.num;
this.numOriginal;
this.hasSeparators = false;  
this.separatorValue;  
this.inputDecimalValue; 
this.decimalValue;  
this.negativeFormat; 
this.negativeRed; 
this.hasCurrency;  
this.currencyPosition;  
this.currencyValue;  
this.places;
this.roundToPlaces; 
this.truncate; 
this.setNumber = setNumberNF;
this.toUnformatted = toUnformattedNF;
this.setInputDecimal = setInputDecimalNF; 
this.setSeparators = setSeparatorsNF; 
this.setCommas = setCommasNF;
this.setNegativeFormat = setNegativeFormatNF; 
this.setNegativeRed = setNegativeRedNF; 
this.setCurrency = setCurrencyNF;
this.setCurrencyPrefix = setCurrencyPrefixNF;
this.setCurrencyValue = setCurrencyValueNF; 
this.setCurrencyPosition = setCurrencyPositionNF; 
this.setPlaces = setPlacesNF;
this.toFormatted = toFormattedNF;
this.toPercentage = toPercentageNF;
this.getOriginal = getOriginalNF;
this.moveDecimalRight = moveDecimalRightNF;
this.moveDecimalLeft = moveDecimalLeftNF;
this.getRounded = getRoundedNF;
this.preserveZeros = preserveZerosNF;
this.justNumber = justNumberNF;
this.expandExponential = expandExponentialNF;
this.getZeros = getZerosNF;
this.moveDecimalAsString = moveDecimalAsStringNF;
this.moveDecimal = moveDecimalNF;
this.addSeparators = addSeparatorsNF;
if (inputDecimal == null) {
this.setNumber(num, this.PERIOD);
} else {
this.setNumber(num, inputDecimal); 
}
this.setCommas(true);
this.setNegativeFormat(this.LEFT_DASH); 
this.setNegativeRed(false); 
this.setCurrency(false); 
this.setCurrencyPrefix('$');
this.setPlaces(2);
}
function setInputDecimalNF(val)
{
this.inputDecimalValue = val;
}
function setNumberNF(num, inputDecimal)
{
if (inputDecimal != null) {
this.setInputDecimal(inputDecimal); 
}
this.numOriginal = num;
this.num = this.justNumber(num);
}
function toUnformattedNF()
{
return (this.num);
}
function getOriginalNF()
{
return (this.numOriginal);
}
function setNegativeFormatNF(format)
{
this.negativeFormat = format;
}
function setNegativeRedNF(isRed)
{
this.negativeRed = isRed;
}
function setSeparatorsNF(isC, separator, decimal)
{
this.hasSeparators = isC;
if (separator == null) separator = this.COMMA;
if (decimal == null) decimal = this.PERIOD;
if (separator == decimal) {
this.decimalValue = (decimal == this.PERIOD) ? this.COMMA : this.PERIOD;
} else {
this.decimalValue = decimal;
}
this.separatorValue = separator;
}
function setCommasNF(isC)
{
this.setSeparators(isC, this.COMMA, this.PERIOD);
}
function setCurrencyNF(isC)
{
this.hasCurrency = isC;
}
function setCurrencyValueNF(val)
{
this.currencyValue = val;
}
function setCurrencyPrefixNF(cp)
{
this.setCurrencyValue(cp);
this.setCurrencyPosition(this.LEFT_OUTSIDE);
}
function setCurrencyPositionNF(cp)
{
this.currencyPosition = cp
}
function setPlacesNF(p, tr)
{
this.roundToPlaces = !(p == this.NO_ROUNDING); 
this.truncate = (tr != null && tr); 
this.places = (p < 0) ? 0 : p; 
}
function addSeparatorsNF(nStr, inD, outD, sep)
{
nStr += '';
var dpos = nStr.indexOf(inD);
var nStrEnd = '';
if (dpos != -1) {
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
nStr = nStr.substring(0, dpos);
}
var rgx = /(\d+)(\d{3})/;
while (rgx.test(nStr)) {
nStr = nStr.replace(rgx, '$1' + sep + '$2');
}
return nStr + nStrEnd;
}
function toFormattedNF()
{	
var pos;
var nNum = this.num; 
var nStr;            
var splitString = new Array(2);   
if (this.roundToPlaces) {
nNum = this.getRounded(nNum);
nStr = this.preserveZeros(Math.abs(nNum)); 
} else {
nStr = this.expandExponential(Math.abs(nNum)); 
}
if (this.hasSeparators) {
nStr = this.addSeparators(nStr, this.PERIOD, this.decimalValue, this.separatorValue);
} else {
nStr = nStr.replace(new RegExp('\\' + this.PERIOD), this.decimalValue); 
}
var c0 = '';
var n0 = '';
var c1 = '';
var n1 = '';
var n2 = '';
var c2 = '';
var n3 = '';
var c3 = '';
var negSignL = (this.negativeFormat == this.PARENTHESIS) ? this.LEFT_PAREN : this.DASH;
var negSignR = (this.negativeFormat == this.PARENTHESIS) ? this.RIGHT_PAREN : this.DASH;
if (this.currencyPosition == this.LEFT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c0 = this.currencyValue;
} else if (this.currencyPosition == this.LEFT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c1 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c2 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c3 = this.currencyValue;
}
nStr = c0 + n0 + c1 + n1 + nStr + n2 + c2 + n3 + c3;
if (this.negativeRed && nNum < 0) {
nStr = '<font color="red">' + nStr + '</font>';
}
return (nStr);
}
function toPercentageNF()
{
nNum = this.num * 100;
nNum = this.getRounded(nNum);
return nNum + '%';
}
function getZerosNF(places)
{
var extraZ = '';
var i;
for (i=0; i<places; i++) {
extraZ += '0';
}
return extraZ;
}
function expandExponentialNF(origVal)
{
if (isNaN(origVal)) return origVal;
var newVal = parseFloat(origVal) + ''; 
var eLoc = newVal.toLowerCase().indexOf('e');
if (eLoc != -1) {
var plusLoc = newVal.toLowerCase().indexOf('+');
var negLoc = newVal.toLowerCase().indexOf('-', eLoc); 
var justNumber = newVal.substring(0, eLoc);
if (negLoc != -1) {
var places = newVal.substring(negLoc + 1, newVal.length);
justNumber = this.moveDecimalAsString(justNumber, true, parseInt(places));
} else {
if (plusLoc == -1) plusLoc = eLoc;
var places = newVal.substring(plusLoc + 1, newVal.length);
justNumber = this.moveDecimalAsString(justNumber, false, parseInt(places));
}
newVal = justNumber;
}
return newVal;
} 
function moveDecimalRightNF(val, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimal(val, false);
} else {
newVal = this.moveDecimal(val, false, places);
}
return newVal;
}
function moveDecimalLeftNF(val, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimal(val, true);
} else {
newVal = this.moveDecimal(val, true, places);
}
return newVal;
}
function moveDecimalAsStringNF(val, left, places)
{
var spaces = (arguments.length < 3) ? this.places : places;
if (spaces <= 0) return val; 
var newVal = val + '';
var extraZ = this.getZeros(spaces);
var re1 = new RegExp('([0-9.]+)');
if (left) {
newVal = newVal.replace(re1, extraZ + '$1');
var re2 = new RegExp('(-?)([0-9]*)([0-9]{' + spaces + '})(\\.?)');		
newVal = newVal.replace(re2, '$1$2.$3');
} else {
var reArray = re1.exec(newVal); 
if (reArray != null) {
newVal = newVal.substring(0,reArray.index) + reArray[1] + extraZ + newVal.substring(reArray.index + reArray[0].length); 
}
var re2 = new RegExp('(-?)([0-9]*)(\\.?)([0-9]{' + spaces + '})');
newVal = newVal.replace(re2, '$1$2$4.');
}
newVal = newVal.replace(/\.$/, ''); 
return newVal;
}
function moveDecimalNF(val, left, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimalAsString(val, left);
} else {
newVal = this.moveDecimalAsString(val, left, places);
}
return parseFloat(newVal);
}
function getRoundedNF(val)
{
val = this.moveDecimalRight(val);
if (this.truncate) {
val = val >= 0 ? Math.floor(val) : Math.ceil(val); 
} else {
val = Math.round(val);
}
val = this.moveDecimalLeft(val);
return val;
}
function preserveZerosNF(val)
{
var i;
val = this.expandExponential(val);
if (this.places <= 0) return val; 
var decimalPos = val.indexOf('.');
if (decimalPos == -1) {
val += '.';
for (i=0; i<this.places; i++) {
val += '0';
}
} else {
var actualDecimals = (val.length - 1) - decimalPos;
var difference = this.places - actualDecimals;
for (i=0; i<difference; i++) {
val += '0';
}
}
return val;
}
function justNumberNF(val)
{
newVal = val + '';
var isPercentage = false;
if (newVal.indexOf('%') != -1) {
newVal = newVal.replace(/\%/g, '');
isPercentage = true; 
}
var re = new RegExp('[^\\' + this.inputDecimalValue + '\\d\\-\\+\\(\\)eE]', 'g');	
newVal = newVal.replace(re, '');
var tempRe = new RegExp('[' + this.inputDecimalValue + ']', 'g');
var treArray = tempRe.exec(newVal); 
if (treArray != null) {
var tempRight = newVal.substring(treArray.index + treArray[0].length); 
newVal = newVal.substring(0,treArray.index) + this.PERIOD + tempRight.replace(tempRe, ''); 
}
if (newVal.charAt(newVal.length - 1) == this.DASH ) {
newVal = newVal.substring(0, newVal.length - 1);
newVal = '-' + newVal;
}
else if (newVal.charAt(0) == this.LEFT_PAREN
&& newVal.charAt(newVal.length - 1) == this.RIGHT_PAREN) {
newVal = newVal.substring(1, newVal.length - 1);
newVal = '-' + newVal;
}
newVal = parseFloat(newVal);
if (!isFinite(newVal)) {
newVal = 0;
}
if (isPercentage) {
newVal = this.moveDecimalLeft(newVal, 2);
}
return newVal;
}
function formatNumber(param_)
{
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(param_); 
num.setPlaces('2', false);
num.setCurrencyValue('$');
num.setCurrency(true);
num.setCurrencyPosition(num.LEFT_OUTSIDE);
num.setNegativeFormat(num.LEFT_DASH);
num.setNegativeRed(false);
num.setSeparators(true, ',', ',');
return num.toFormatted();

}

/*NUEVO*/

function clear_textbox()
{
if (document.form1.textfield.value == "INGRESA LA AUTOPARTE QUE DESEAS BUSCAR")
document.form1.textfield.value = "";
}



/*INICIO COMENTARIOS*/

var xmlHttp;
function GetXmlHttpObject(handler)   
{ 

if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  objXMLHttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
return objXMLHttp;
   
}   

function htmlDataEnvioquejas(url, nombre,email,comentarios,otrosdatos) 
{   
    
//    alert(url+","+nombre+","+email+","+comentarios);
    
   if (url.length==0)   
   {   
       document.getElementById("muestraenvio").innerHTML="";   
       return;   
   }   
   xmlHttp=GetXmlHttpObject()   
   if (xmlHttp==null)   
   {   
       alert ("Browser does not support HTTP Request");   
       return;   
   }   
   
  if(nombre.replace(/\s/g,"") == ""){ 
  	alert("Favor de llenar tu nombre");
	var mytext = document.getElementById("nombre"); 
	mytext.focus(); 
	return false;
  } 

  if(email.replace(/\s/g,"")=="" || mailverifica(email.replace(/\s/g,""))==false){ 
  	alert("Favor de verificar tu e-mail");
	var mytext = document.getElementById("email"); 
	mytext.focus(); 
	return false;
  } 

	if(comentarios.replace(/\s/g,"") == ""){ 
  	alert("Favor de llenar tus comentarios");
	var mytext = document.getElementById("comentarios"); 
	mytext.focus(); 
	return false;
  } 
   
   url=url;   
   comentarios = comentarios.replace(/&/g, ';amp;');
   comentarios = comentarios.replace(/á/g, '&aacute;');
   comentarios = comentarios.replace(/é/g, '&eacute;');
   comentarios = comentarios.replace(/í/g, '&iacute;');
   comentarios = comentarios.replace(/ó/g, '&oacute;');
   comentarios = comentarios.replace(/ú/g, '&uacute;');
   comentarios = comentarios.replace(/Á/g, '&Aacute;');
   comentarios = comentarios.replace(/É/g, '&Eacute;');
   comentarios = comentarios.replace(/Í/g, '&Iacute;');
   comentarios = comentarios.replace(/Ó/g, '&Oacute;');
   comentarios = comentarios.replace(/Ú/g, '&Uacute;');
   comentarios = comentarios.replace(/Ñ/g, '&Ntilde;');
   comentarios = comentarios.replace(/ñ/g, '&ntilde;');
   comentarios = comentarios.replace(/¿/g, '&iquest;');
   comentarios = comentarios.replace(/Ü/g, '&Uuml;');
   comentarios = comentarios.replace(/ü/g, '&uuml; ');
   comentarios = comentarios.replace(/"/g, '&quot;');
   comentarios = comentarios.replace(/</g, '&lt;');
   comentarios = comentarios.replace(/>/g, '&gt;');
   
   comentarios="'"+comentarios+"'";

   xmlHttp.open("POST", url, true);
   params="nombre="+nombre+"&email="+email+"&comentarios="+comentarios+otrosdatos+"&sid="+Math.random();
   xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   xmlHttp.setRequestHeader("Connection", "close");

xmlHttp.onreadystatechange = function() {//Call a function when the state changes.
	
	if (xmlHttp.readyState==1) {
			document.getElementById("enviodecorreo").innerHTML = "<br /><br /><br /><br /><br /><br /><br /><br /><br /> <h3>Enviando Datos..</h3> <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />";
	}
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		//alert(xmlHttp.responseText);
		document.getElementById("enviodecorreo").innerHTML= xmlHttp.responseText;  
	}
}
xmlHttp.send(params);
 document.envioquejas.reset();

}  


function mailverifica(texto){ 

    var mailres = true;             
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-"; 
     
    var arroba = texto.indexOf("@",0); 
    if ((texto.lastIndexOf("@")) != arroba) arroba = -1; 
     
    var punto = texto.lastIndexOf("."); 
                 
     for (var contador = 0 ; contador < texto.length ; contador++){ 
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){ 
            mailres = false; 
            break; 
     } 
    } 

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1)) 
     mailres = true; 
    else 
     mailres = false; 
                 
    return mailres; 
} 


/*FIN COMENTARIOS*/
