// buscar envio en TYT

function esnumero_con_0(campo){
   if (campo=="")
     return false;
   
   if (campo=="0")
     return true;
  
   if(isNaN(campo)) 
     return false;
   else
     return true; 
}

function espacios(campo){
  reemplazar = / /g;
  campo= campo.replace(reemplazar, "");
  return campo;
}


function esnumero_sin_0(campo){
   if (campo=="")
     return false;
   
   if (campo=="0")
     return false;
  
   if(isNaN(campo)) 
     return false;
   else
     return true; 
} 

  

function ceros(campo){
  reemplazar = /^0*/g;
  campo= campo.replace(reemplazar, "");
  return campo;
} 

function buscar_envio_tyt(num){
  num=num.toUpperCase();
  //scr_aven("//10.200.6.247/proyecto/proyecto_bestado/pag/proybegral.asp?n_envio=" + num,700,400,1);  
  ventana=window.open("../pagina_tyt.php?envio=" + num,"ven","toolbar=0,location=0,resizable=1,scrollbars=1,directories=0,status=1,menubar=0,width=700,height=500,top=20,left=20");  
}

function buscar_envio_tyt_masivo(num){
  num=num.toUpperCase();
  //scr_aven("//10.200.6.247/proyecto/proyecto_bestado/pag/proybegral.asp?n_envio=" + num,700,400,1);
  ventana=window.open("../pagina_tyt_masivo.php?envio=" + num,"ven","toolbar=0,location=0,resizable=1,scrollbars=1,directories=0,status=1,menubar=0,width=700,height=500,top=20,left=20");
}

//calendario
function calendario(campo){
  var fecha = new Date();
  scr_aven("../demon/demon_calendario.php?campo=" + campo + "&ano=" + fecha.getYear() +  "&mes=" +  (fecha.getMonth()+1),150,170,0);
} 

//resize de las ventanas
function scr_tv(ancho,alto){
  window.resizeTo(ancho,alto);
  window.moveTo((screen.width-document.body.clientWidth)/2,(screen.height-document.body.clientHeight)/2);
}

//centrar ventana, centra la ventana al medio de la pantalla
function scr_cv(ancho,alto){
   window.moveTo((screen.width-ancho)/2,(screen.height-alto)/2);
}

//abre una ventana centrada y con efecto
function scr_av(pagina,ancho,alto) {  
    var ventana = window.open(pagina,"","left=" + (screen.width-ancho)/2 + ",top=" + (screen.height-alto)/2 + ",width=10,height=10,scrollbars=auto");
    for (y=1;y<alto;y+=15)
      ventana.resizeTo("1",y );
    for (x = 1; x < ancho; x += 15) 
      ventana.resizeTo(x,y );
}


//abre una ventana centrada, con efecto y en la pos 2000, y con scrollbars
function scr_avm(pagina,ancho,alto,scroll) {                                                                                               
	var ventana = window.open(pagina,"","left=0,top=2000,width=10,height=10,scrollbars=" + scroll);
    /*for (y=1;y<alto;y+=15)
      ventana.resizeTo("1",y );
    for (x = 1; x < ancho; x += 15) 
      ventana.resizeTo(x,y );*/
}

//centrar ventana
function scr_avc(ancho,alto) {                                                                                               
  window.moveTo((screen.width-ancho)/2,(screen.height-alto)/2 );
}




function dt(){
  if (event.keyCode==123)
    window.close();
}  



function scr_ve(guia){
    var i=0;
    var a=0;
    var b=0;
	var total;
	
    if (guia.value.length==13){
      while (i<12){
        a=a+parseInt(guia.value.substring(i  ,i+1));
        b=b+parseInt(guia.value.substring(i+1,i+2));
        i=i+2;
      }
	  
	  total=(10-((a+(b*3))%10));
	 // alert(total);
	  if (total==10)
	    total=0;

      if  (parseInt(guia.value.substring(12,13))!=total)
        return false;
	  else
	   	return true;
    }
    else
     return false
  }
  
  //abrir ventana nuevo
function scr_aven(pagina,ancho,alto,scroll) {  
    alto=alto-10;
	ancho=ancho-5;                                                                                             
    var ventana = window.open(pagina,"","statusbar=1,left=" + (screen.width-ancho)/2 + ",top=" + (screen.height-alto)/2 + ",width=" + ancho + ",height=" + alto + ",scrollbars=" + scroll);
}
         
		 
		 

  function buscar_xml(tabla,atributo,id){
    var xmldoc = new ActiveXObject("msxml");
    xmldoc.url = "../xml/xml_sac.xml"; 
    var reg_xml = xmldoc.root.children.item(tabla).children;
	var i=0;
	
	while (i<reg_xml.length){
	  if(reg_xml.item(i).text==id){
	    return reg_xml.item(i).getattribute(atributo);
	  }
	  i++;
	}  
  }

//***************carga data xml************************
  
  function insertar_xml(objeto,tabla,atributo,i){
    var xmldoc = new ActiveXObject("msxml");
    xmldoc.url = "../xml/xml_sac.xml"; 
    var reg_xml = xmldoc.root.children.item(tabla).children;
    fila=new Option(reg_xml.item(i).getattribute(atributo),reg_xml.item(i).text);
    objeto[objeto.length]=fila;
  }
  
  
  function cargar_xml(objeto,tabla,atributo){
    var xmldoc = new ActiveXObject("msxml");
    xmldoc.url = "../xml/xml_sac.xml"; 
	
    var reg_xml = xmldoc.root.children.item(tabla).children; 
	var i=0;
    while (i<reg_xml.length){                   
     insertar_xml(objeto,tabla,atributo,i)
	 i++;
	 }
  }
  

//mostrar efecto div
  function med(campo){
    campo.filters.alpha.opacity=100;
  }

//ocultar efecto div  
  function oed(campo){
    campo.filters.alpha.opacity=80;
  }
  
//funciones registradas
  
//se utiliza para controlar los menus, oculta los campos cobo box
function control_box(op,campo){
  if (op=="1")
	campo.style.visibility='visible';
  else
	campo.style.visibility='hidden';
}

function esnumero_con_0(campo){
   reemplazar = / /g;
   campo= campo.replace(reemplazar, "");

   if (campo=="")
     return false;

   if (campo=="0")
     return true;

   if(isNaN(campo))
     return false;
   else
     return true;
}

function espacios(campo){
  reemplazar = / /g;
  campo= campo.replace(reemplazar, "");
  return campo;
}



//mostrar_div
function scr_md(bloque){
  bloque.style.visibility="visible";
}

//ocultar_div
function scr_od(bloque){
  bloque.style.visibility="hidden";
}

//cierra una ventana con la tecla escape
function window_dt(){
    if (event.keyCode==27)
       window.close();
}


//captura tecla
function scr_ct(campo){
  if (event.keyCode==13)
     campo.focus();
}


  function scr_agregar_mail(key){
  	if (event.keyCode==13){
      if (document.all.form_mail.value!=""){
        document.all.form_mail.value=document.all.form_mail.value.toLowerCase();
	    var fila;
        fila=new Option(document.all.form_mail.value,document.all.form_mail.value);
        document.all.form_mails[document.all.form_mails.length]=fila;
	    document.all.form_mail.value="";
	  }
	}
  }
  
   function scr_remover_mail(){
     if (document.all.form_mails.length!=0){
	   if(document.all.form_mails.selectedIndex!=-1)
         document.all.form_mails.remove(document.all.form_mails.selectedIndex);
	 }
   }

  function scr_remover_mails(){
    if (document.all.form_mails.length!=0){
      while(document.all.form_mails.length!=0)
         document.all.form_mails.remove(document.all.form_mails.length-1);
	}
  }



