//Script_FuncionesEspeciales
function reemplazar(texto,letra1,letra2){
var text1=new String(texto)
var largot1=text1.length
var newtext=new String()
var i
for (i = 1; i < (largot1); i++) 
     {
		newtext=text1.replace(letra1,letra2)
		text1=newtext
      }
return newtext

}
function createlist(texto){
var text1=new String(texto)
var lista=new Array()
var newtext=new String()
newtext=""
lista=text1.split(",")
var i
for (i = 0; i < (lista.length); i++) 
     {
		if (newtext=="")
			newtext="'" + lista[i] + "'"
		else
			newtext=",'" + lista[i] + "'"
      }
return newtext
}
function longitud(cadena){
      var newcadena=new String()
      newcadena=cadena
      cnt=newcadena.length
      return cnt
}
function esnum(valor){ 
      valor = parseInt(valor);
      if (isNaN(valor))
         {return false}
	  else{return true}
}
function esmail(texto){
      var arrova1, arrova2, dominio
      texto=new String(texto)
      arrova1=texto.indexOf("@")
      arrova2=texto.lastIndexOf("@")
      dominio=texto.lastIndexOf(".")
      if ((arrova1 == -1) || (dominio == -1))
         return false
      else
      {  
         if (arrova1==arrova2)
         {
            if ((arrova1<=0) || (arrova1==(texto.length-1)))
              return false
          
            if ((dominio<=0) || (dominio==(texto.length-1)))
		      return false
          
            if (dominio>arrova1)
              return true
            else
              return false
         }
         else
           return false
      }
}
function esimagen(texto){
     var archivo=new String(texto)
     var archivo2=new String(archivo.toLowerCase())
     var extension
     var sw
     var tipoimagen=new Array(".jpg",".bmp",".gif",".jpeg")         
     extension=archivo2.substring(archivo2.length-4,archivo2.length)
     sw=0
	 for (i = 0; i < (tipoimagen.length); i++) 
	     {
	     if (tipoimagen[i]==extension)
	         {sw=1;
	          return true}
	      }
	 if (sw==0)
	    {
	    return false
	    }	 
}
function estelefono(texto){
	var codpais=new String(texto.substring(1,2))
	var codciudad=new String(texto.substring(4,3))
	var nrotelefono=new String(texto.substring(8,7))
	var sw=0
	if (esnum(codpais)==false)
	   sw=1
	if (esnum(codciudad)==false)
	   sw=1
	if (esnum(nrotelefono)==false)
	   sw=1
	
	if (sw==0)
	   return true
	else
	   return false
}
function estjtacdto(numero){
	var nrotjta=new String(numero)
	var largo=nrotjta.length
	var nro
	
	if (largo<15)
		return false
		
	for (i = 0; i < (largo); i++)
		{
		nro=nrotjta.substr(i,1)
		if (esnum(nro)==false)
			return false
		}	
}
function esvcetjta(mesanno){
	var vcetxt=new String(mesanno)
	var mestxt=vcetxt.substr(0,2)
	var annotxt=vcetxt.substr(3,2)
	var septxt=vcetxt.substr(2,1)
	if (longitud(mestxt)<2)
		return false
	if (longitud(annotxt)<2)
		return false
	if (esnum(mestxt)==false)
		return false
	if (esnum(annotxt)==false)
		return false
	if (septxt!="/")
		return false
	if (mestxt>12)
		return false
}
function esfecha(cadena){
    var fecha = new String()
    fecha = cadena    
    var array_fecha = new Array(3)
    array_fecha=fecha.split("/")
    var msj="" 
    if (array_fecha.length!=3) 
       msj="Fecha incorrecta"
    
    var ano
	ano = parseInt(array_fecha[2]); 
    if (isNaN(ano)) 
       msj="Fecha incorrecta"

    var mes
    mes = parseInt(array_fecha[0]);
    if (isNaN(mes)) 
       msj="Fecha incorrecta"
    
    var dia 
    dia = parseInt(array_fecha[1]); 
    if (isNaN(dia)) 
       msj="Fecha incorrecta"

    if (ano<1900)
       msj="Fecha incorrecta"
    
    if (dia<0 || dia>31)
       msj="Fecha incorrecta"
    
    if (mes<0 || mes>12)
       msj="Fecha incorrecta"
    else
    {
       if ((mes==4) || (mes==6) || (mes==9) || (mes==11))
       {  if (dia>30) 
           msj="Fecha incorrecta"
       }    
       else
       {
          if ((mes==2) && (ano%4==0) && (dia>30))
            msj="Fecha incorrecta"
          else
          {
             if ((mes==2) && (ano%4!=0) && (dia>29))
               msj="Fecha incorrecta"
          }        
       }
    }
    if (msj!="")
    {  
      alert(msj)
      return false
    }
    else
      return true  
}

function esfechaesp(cadena){
    var fecha = new String()
    fecha = cadena    
    var array_fecha = new Array(3)
    array_fecha=fecha.split("/")
    var msj="" 
    if (array_fecha.length!=3) 
       msj="Fecha incorrecta"
    
    var ano
	ano = parseInt(array_fecha[2]); 
    if (isNaN(ano)) 
       msj="Fecha incorrecta"

    var mes
    mes = parseInt(array_fecha[1]);
    if (isNaN(mes)) 
       msj="Fecha incorrecta"
    
    var dia 
    dia = parseInt(array_fecha[0]); 
    if (isNaN(dia)) 
       msj="Fecha incorrecta"

    if (ano<1900)
       msj="Fecha incorrecta"
    
    if (dia<0 || dia>31)
       msj="Fecha incorrecta"
    
    if (mes<0 || mes>12)
       msj="Fecha incorrecta"
    else
    {
       if ((mes==4) || (mes==6) || (mes==9) || (mes==11))
       {  if (dia>30) 
           msj="Fecha incorrecta"
       }    
       else
       {
          if ((mes==2) && (ano%4==0) && (dia>30))
            msj="Fecha incorrecta"
          else
          {
             if ((mes==2) && (ano%4!=0) && (dia>29))
               msj="Fecha incorrecta"
          }        
       }
    }
    if (msj!="")
    {  
      alert(msj)
      return false
    }
    else
      return true  
}

function estexto(cadena){
var texto=new String(cadena)
texto=texto.toLowerCase()
var largo=texto.length
var letra=new String()
var expresion
for (i=0;i<largo;i++)
	{
		
		letra=texto.substr(i,1)
		//evaluamos que el caracter no sea un numero
		if (letra!=" " && letra!=null)
			{
				expresion=/[0-9]/
				valexp=expresion.test(letra)
				//verificamos qu el caracter no sea un numero
				if (valexp==true)
					{return false}
				expresion=/[a-zA-Z]/				
				valexp=expresion.test(letra)
				//verificamos que el caracater sea una letra de la A a la Z en mayus o minus
				if (valexp==false)
					{return false}
			}
	}
return true
}


//Cerrar_VentanaActiva
function closewindow(){
	b=window.parent.self
	b.opener=window.parent.self
	b.close()
}


//Seguridad_VentanaActiva
function VerificaNombreVentana(NombreVentana){
if (window.name==NombreVentana)
	return true
else
	return false
}

function AbreVentana(NombreVentana,Pagina){
	a=window.open(Pagina,NombreVentana,"location=no, status=yes, menubar=no, copyHistory=no, resizable=yes, toolbar=no, z-lock=yes, alwaysRaised=yes, dependent=yes, directories=no, hotkeys=no, scrollbars=yes")
    if(a)
    { 	
	a.name=NombreVentana
	closewindow()
	a.focus()
	a.moveTo(0,0)
	a.resizeTo(screen.availWidth,screen.availHeight)
	}
	else
	{
	alert("Favor Habilite la opcion de Permitir elementos emergentes para este sitio,\n informe a su departamento de sistemas para configurarlo")
	closewindow()
	}
}


//Seguridad_Documento
function anularightclick(evento)
{if (evento==2)
	return alert("No esta permitido el boton derecho del mouse")
}
function anulakeys(evento)
{
if (evento.keyCode>111 && evento.keyCode<=124)
	{
	event.keyCode=8
	event.cancelBubble=true
	event.returnValue=false
	alert("No esta permitido el uso de Teclas de Funcion")
	}
if (evento.ctrlLeft)
	{
	event.keycode=8
	event.cancelBubble=true
	event.returnValue=false
	alert("No esta permitido el uso de Teclas CTRL+Letra")
	}
}
function anulastatus()
{
window.status="Copyright© 2004. Turismo Maso Internacional. All rights reserved"
return true
}


//Seguridad_Navegador
function VerificaNavegador(TipoVersion){
if (navigator.appVersion.indexOf(TipoVersion)>0)
	return true
}


//Seguridad_Frame
function VerificaFrame(DireccionPagina){
if (DireccionPagina!=top.location)
	return true
}
//

//
function CopiarElemento(id){
//window.clipboardData.clearData()
var n
n=document.getElementById(id).outerHTML
window.clipboardData.setData("Text",n)
}
//


//script control de menus
var cnt_sub=new Array()
var left_sub=new Array()
var cnt_menu=new Array()
var ttl_width=new Number()
var objsel=new String("")
function Fila_On(src,color_fondo,color_letra,espesor_letra)
{
src.bgColor=color_fondo; 
src.style.color=color_letra;
src.style.fontWeight=espesor_letra;
src.style.cursor="hand"
}
function Fila_Off(src,color_fondo,color_Letra,espesor_letra)
{
src.bgColor=color_fondo; 
src.style.color=color_Letra;
src.style.fontWeight=espesor_letra;
src.style.cursor="default"
}
function oculta(cnt_subm,nombremenu)
{
//var obj
//obj = nombremenu
//if (document.getElementById(nombremenu).style.visibility == "visible")
//alert(document.getElementById(nombremenu).style.visibility)
document.getElementById(nombremenu).style.visibility="hidden"
document.getElementById(nombremenu).style.top=0
//for (i = 1; i < (cnt_subm+1); i++) 
//    {obj = "sub" + nombremenu + i
//   if (document.getElementById(obj).style.visibility == "visible")
//       document.getElementById(obj).style.visibility="hidden"
//       document.getElementById(obj).style.top=0
//}
//muestraselect()
}
function muestra(obj, sup){
var left, height, top, total_left
left=document.getElementById(sup).offsetLeft
height=document.getElementById(sup).offsetHeight
top=document.getElementById(sup).offsetTop-2
document.getElementById(obj).style.left= left
document.getElementById(obj).style.visibility = "visible"
document.getElementById(obj).style.top=top+height+"px"
document.getElementById(obj).style.zIndex=0
//ocultaselect()
}
function irpage(linkpage){
window.location=linkpage
}
function addsub(idfila){
cnt_sub[cnt_sub.length+1]=idfila
}
function addposition_sub(idfila,width){
cnt_menu[cnt_menu.length+1]=idfila
ttl_width=ttl_width+width
left_sub[left_sub.length+1]=ttl_width-width
}
function ocultaselect()
{
sel=document.getElementsByTagName("SELECT")
for(i=0;i<sel.length;i++)
	{
	obj=sel.item(i)
	obj.style.visibility="hidden"
	}
}
function muestraselect()
{
sel2=document.getElementsByTagName("SELECT")
for(i=0;i<sel.length;i++)
	{
	obj=sel.item(i)
	obj.style.visibility="visible"
	}
}


//