//<?
 function Hora(){
 	var hoy = new Date();
    var H = hoy.getHours();
    var M = hoy.getMinutes();
    var S = hoy.getSeconds();

    if (H<10){
    	H = "0" + H
    }
    if (M<10){
    	M = "0" + M
    }
    if (S<10){
    	S = "0" + S
    }

	return (H + ":" + M )//+ ":" + S)
 }

 function Fecha(){
    var hoy = new Date();
    var A = hoy.getYear();
    var D = hoy.getDay() //hoy.getDate();
    var M = hoy.getMonth()+1;

    if (M<10){
    	M = "0" + M
    }
    if (D<10){
    	D= "0" + D
    }
  return (D + "-" + M + "-" + A)
 }

 function FechaLarga(){

 	var dia = new Array(
    				"Domingo",
                    "Lunes",
                    "Martes",
                    "Miércoles",
                    "Jueves",
                    "Viernes",
                    "Sábado");

	var mes = new Array(
    				"Enero",
                    "Febrero",
                    "Marzo",
                    "Abril",
                    "Mayo",
                    "Junio",
                    "Julio",
                    "Agosto",
                    "Septiembre",
                    "Octubre",
                    "Noviembre",
                    "Diciembre");

 	var hoy = new Date();
    var A   = hoy.getYear() ;
    var DS  = hoy.getDay();
    var D   = hoy.getDate();
    var M   = hoy.getMonth();

    if (D<10){
    	D= "0" + D
    }

	if (A<1900)
		A+=1900

	fec = dia[DS] + ", " + D + " de " + mes[M] + " de " + A
  return (fec)
 }

 function Valorchk(chk,v,f){
 	if (chk.checked){
    	chk.value=v
    } else {
    	chk.value=f
    }
 }

 function sptrim(texto){
        l = texto.length
        fin=l
    	ini=0

        if (texto=="") {
        	return ""
        }
        for (i=0;i<l;i++){
        	ch = texto.substr(i,1)
            if ( ch !=" "){
            	ini=i
                break
            }
        }

        if(i==l){
        	return ""
        }

		for (i=l-1;i>=0;i--){
        	ch = texto.substr(i,1)
            if (ch != " "){
            	fin=i
                break
            }
        }

        l2 = fin - ini + 1
        texto2 = texto.substr(ini,l2)
        return texto2
    }

function val(num){
	if (sptrim(num)==""){
    	return 0
    } else {
    	num = sptrim(num)
        m = num.substr(0,1);
        if (m=="-"){
          num = num.substr(1,num.length-1);
          m1 = true
        } else {
          m1 = false
        }

	    hayletra=true
        p=1
        n=0
        for(i=num.length-1;i >= 0;i--){
	 	  hayletra=true
          for (j=0;j<10;j++){
          	if (num.substr(i,1)==j){
	          n = n + p * j
              p = p*10;
	    	  hayletra=false
              break
            }
          }
          if (hayletra){
          	break
          }
        }

      if (!hayletra){
      	if (m1){
        	n=n*-1
        }
      	return n
      } else {
      	return 0
      }
    }

}

function prende(which2){
	theobject=which2
	highlighting=setInterval("highlightit(theobject)",50)
}

function apaga(which2,opaco){
	clearInterval(highlighting)
	if (which2.style.MozOpacity) {
		which2.style.MozOpacity=(opaco/100.0)
    } else if (which2.filters) {
		which2.filters.alpha.opacity=opaco
    }
}

function highlightit(cur2){
	if (cur2.style.MozOpacity<1)
		cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
	else if (cur2.filters&&cur2.filters.alpha.opacity<100)
		cur2.filters.alpha.opacity+=10
	else if (window.highlighting)
		clearInterval(highlighting)
}

function sptrim(texto){
        l = texto.length
        fin=l
    	ini=0

        if (texto=="") {
        	return ""
        }
        for (i=0;i<l;i++){
        	ch = texto.substr(i,1)
            if ( ch !=" "){
            	ini=i
                break
            }
        }

        if(i==l){
        	return ""
        }

		for (i=l-1;i>=0;i--){
        	ch = texto.substr(i,1)
            if (ch != " "){
            	fin=i
                break
            }
        }

        l2 = fin - ini + 1
        texto2 = texto.substr(ini,l2)
        return texto2
}


function validaMail(obj){
	valor=sptrim(obj.value)
	if (valor==""){
		alert("Ingrese su Correo Electrónico.")
		obj.focus()
		return false
	}

	if (valor.indexOf('@')==-1 || valor.indexOf('.')==-1) {
		alert("Ingrese un Correo Electrónico válido.")
		obj.focus();
		return false;		
	}
	
	return true
}

