//Funcion que inicializa el objeto ajax


function initAjax()
{
   var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}

   
   // var ajax=false;
    
   // ajax = new ActiveXObject("Microsoft.XMLHTTP"); //para explorer
    
    //if ( (ajax == null) && typeof(XMLHttpRequest) != 'undefined' ) 
    //{
      //  ajax = new XMLHttpRequest(); //para mozilla
    //}
    
    //if ( ajax == null ) alert('no hay ajax');
    
    //return ajax;

function Salir_onclick()		
{
	document.location.href = "logout.asp";
}


//Funcion que coloca en el divId el resultado del archivo url
function Ajax ( url , divId ) {
    var ajax = initAjax() ;    
    var obj = document.getElementById( divId ) ;
    ajax.open ( "GET" , url ) ;
    ajax.onreadystatechange = function() {
        if (ajax.readyState == 4 && ajax.status == 200) {
            obj.innerHTML = ajax.responseText;
        }
    }
    
    ajax.send(null);
    
}
function FunJs_Cal(HoraSN, Fecha)
{
	if (HoraSN!='S'){HoraSN='N'; var HH='200px'}	//Si no carga hh-mm, seteo en 'N'
	else {var HH='220px'}
	miwin= window.showModalDialog('Calendario.ASP?HoraSN='+HoraSN+'&DateValue=' + Fecha  ,null,'center:1; dialogWidth:175px; dialogHeight:'+HH );
	if (miwin==null){return '';}
	else {return miwin;}
}
var ventanaLocalidad = null;
function SeleccionarLocalidad(txtobj)
{ 
	var ventanaLocalidad = null;        
	if ( ( ventanaLocalidad == null ) || ( ventanaLocalidad.closed ) ) { 
		window.Localidad = txtobj;
		ventanaLocalidad = window.open('LocalidadSelector.asp', 'Selector', 'scrollbar=no,toolbar=no,width=500px,height=200px,top=0px,status=1');
	}else{
		ventanaLocalidad.focus();
	}
}  
function IsCUIT(sCUIT)
            {
            // Si el CUIT viene con los guiones lo convierte a 11 dígitos
			if (sCUIT.length == 13 && sCUIT.charAt(2) == "-" && sCUIT.charAt(11) == "-")
            {
				sCUIT = sCUIT.substr(0, 2) + sCUIT.substr(3, 8) + sCUIT.substr(12, 1);
            }
            if (IsNonNegativeInt(sCUIT))
            {
            var iCheckSum = parseInt(sCUIT.charAt(0)) * 5
            + parseInt(sCUIT.charAt(1)) * 4

            + parseInt(sCUIT.charAt(2)) * 3

            + parseInt(sCUIT.charAt(3)) * 2

            + parseInt(sCUIT.charAt(4)) * 7

            + parseInt(sCUIT.charAt(5)) * 6

            + parseInt(sCUIT.charAt(6)) * 5

            + parseInt(sCUIT.charAt(7)) * 4

            + parseInt(sCUIT.charAt(8)) * 3

            + parseInt(sCUIT.charAt(9)) * 2

            + parseInt(sCUIT.charAt(10));

            return (iCheckSum % 11 == 0);

            }

    return false;

            }
function IsNonNegativeInt(iNumber){
    if (IsNumeric(iNumber)) {
		return parseInt(iNumber) > 0;
            /*for (var iCount = 0; iCount < iNumber.length; iCount++){
				if (iNumber.charAt(iCount) < "0" || iNumber.charAt(iCount) > "9")
				{
					return true;
				}else{
				return false;
				}
			}
			*/
	}
}			
/*function IsNumeric(iNumber){
   if (iNumber == ""){
       return false;
   }else{
       return (!isNaN(iNumber));
    }   
  }*/
  
function IsNumeric(strString)// check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return true;
//     test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
  }

cartel = new Array()
imagen = new Array()
imagenb = new Array()
for (i = 0; i < 12; i ++)
{
  cartel[i] = new Image()
  imagen[i] = new Image()
  imagenb[i] = new Image()
}
          
transpa=new Image()
flecha=new Image()

transpa.src="/images/home/iconos/pixel.gif"
flecha.src="/images/home/iconos/flecha.gif"
cartel[1].src="/images/home/iconos/hometxt.gif"
cartel[2].src="/images/home/iconos/ayudatxt.gif"
cartel[3].src="/images/home/iconos/favoritostxt.gif"
cartel[4].src="/images/home/iconos/recomendatxt.gif"
cartel[5].src="/images/home/iconos/iniciotxt.gif"

imagen[1].src="/images/home/iconos/home.gif"
imagenb[1].src="/images/home/iconos/home1.gif"
imagen[2].src="/images/home/iconos/ayuda.gif"
imagenb[2].src="/images/home/iconos/ayuda1.gif"
imagen[3].src="/images/home/iconos/favoritos.gif"
imagenb[3].src="/images/home/iconos/favoritos1.gif"
imagen[4].src="/images/home/iconos/recomenda.gif"
imagenb[4].src="/images/home/iconos/recomenda1.gif"
imagen[5].src="/images/home/iconos/inicio.gif"
imagenb[5].src="/images/home/iconos/inicio1.gif"

imagen[6].src="/phts/tips/home2001/b-registrate.gif"
imagenb[6].src="/phts/tips/home2001/b-registrate2.gif"
imagen[7].src="/phts/tips/home2001/b-usuario.gif"
imagenb[7].src="/phts/tips/home2001/b-usuario2.gif"

imagen[8].src="/phts/tips/home2001/b-desloguearse.gif"
imagenb[8].src="/phts/tips/home2001/b-desloguearse2.gif"

imagen[9].src="/phts/tips/home2001/b-loguearse.gif"
imagenb[9].src="/phts/tips/home2001/b-loguearse2.gif"

imagen[10].src="/phts/tips/home2001/top_olvide.gif"
imagenb[10].src="/phts/tips/home2001/top_olvide2.gif"

imagen[11].src="/phts/tips/home2001/top_registrate.gif"
imagenb[11].src="/phts/tips/home2001/top_registrate2.gif"


function arroba(cadena)
		{
		// Esta función trata de detectar direcciones de E-Mail Invalidas
		// aunque solo es un intento por hacerlo pues es muy dificil detectar todos los vicios.

		pos = cadena.indexOf("@");
		if ( ( pos == -1 )  || ( pos == 0 ) || ( pos == (cadena.length-1) )  || ( cadena.indexOf(".", pos) == -1 ) || ( cadena.indexOf("@",pos+1) != -1 )  )
			{
				alert("Correo Electronico Invalido, vuelva a ingresarlo.");
				return false;
			}
		return true;
	} 
// Esta función trata de detectar direcciones de E-Mail Invalidas	
function validarEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
   return (true)
  }else {
   alert("La dirección de email " + valor    + " es incorrecta.") 
   return (false);
  }
 }
 
function isDate(dateStr) {

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {
alert("Ingrese dd/mm/aaaa.");
return false;
}

day = matchArray[1]; // p@rse date into variables
month = matchArray[3];
year = matchArray[5];

if (month < 1 || month > 12) { // check month range
alert("El mes debe estar entre 1 y 12.");
return false;
}

if (day < 1 || day > 31) {
alert("El día debe estar en el rango 1-31.");
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("El mes "+month+" no tiene 31 días!")
return false;
}

if (month == 2) { // check for february 29th
	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	if (day > 29 || (day==29 && !isleap)) {
	alert("El mes de Febrero del año :  " + year + " no tiene " + day + " días!");
	return false;
	}
}
return true; // date is valid
}
 function Comparar_Fecha(Obj1,Obj2) 
{
String1 = document.FrmMiSubmit.TXTFCI.value;
String2 = document.FrmMiSubmit.TXTFCFIN.value;
// Si los dias y los meses llegan con un valor menor que 10 
// Se concatena un 0 a cada valor dentro del string 
if (String1.substring(1,2)=="/") {
String1="0"+String1
}
if (String1.substring(4,5)=="/"){
String1=String1.substring(0,3)+"0"+String1.substring(3,9)
}

if (String2.substring(1,2)=="/") {
String2="0"+String2
}
if (String2.substring(4,5)=="/"){
String2=String2.substring(0,3)+"0"+String2.substring(3,9)
}

dia1=String1.substring(0,2);
mes1=String1.substring(3,5);
anyo1=String1.substring(6,10);
dia2=String2.substring(0,2);
mes2=String2.substring(3,5);
anyo2=String2.substring(6,10);


if (dia1 == "08") // parseInt("08") == 10 base octogonal
dia1 = "8";
if (dia1 == '09') // parseInt("09") == 11 base octogonal
dia1 = "9";
if (mes1 == "08") // parseInt("08") == 10 base octogonal
mes1 = "8";
if (mes1 == "09") // parseInt("09") == 11 base octogonal
mes1 = "9";
if (dia2 == "08") // parseInt("08") == 10 base octogonal
dia2 = "8";
if (dia2 == '09') // parseInt("09") == 11 base octogonal
dia2 = "9";
if (mes2 == "08") // parseInt("08") == 10 base octogonal
mes2 = "8";
if (mes2 == "09") // parseInt("09") == 11 base octogonal
mes2 = "9";

dia1=parseInt(dia1);
dia2=parseInt(dia2);
mes1=parseInt(mes1);
mes2=parseInt(mes2);
anyo1=parseInt(anyo1);
anyo2=parseInt(anyo2);

if (anyo1>anyo2)
{
return false;
}

if ((anyo1==anyo2) && (mes1>mes2))
{
return false;
}
if ((anyo1==anyo2) && (mes1==mes2) && (dia1>dia2))
{
return false;
} 

return true;
} 
