
//Función para obtener el objeto XMLHttp
//dependiendo del navegador.
function getRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} 
}

//Funcion que nos devuelve el top visible de la página
function getY(){
	if (window.pageYOffset){
		return window.pageYOffset;
	}
	if(document.documentElement && document.documentElement.scrollTop){
		return document.documentElement.scrollTop;
	}
	if(document.body){
		return document.body.scrollTop;
	}
	return 0;
}

function centerH(){
	if( document.body &&  document.body.clientWidth  ) 
    	w = document.body.clientWidth/2;
  	else
		w = window.innerWidth/2;

	return w;
}

function centerV(){
	if( document.body &&  document.body.clientHeight  ) 
        h = document.body.clientHeight/2;
	else
		h = window.innerHeight/2;
		
	return h;
}

//Función para eliminar los espacios en blanco 
//del lado izquierdo y derecho de una cadena de caracteres
function allTrim(s){
	s = s.replace(/^\s+|\s+$/gi,'');
	return s;
}

//Función para validar el email
function validMail(email){
	var valido = false;
	valido = email.search(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/);
	return valido;
}

//función para obtener el ancho de la ventana.
function getWidth() {
    var helper;
    if (null == (helper = document.getElementById('styleSwapHelper'))) {
        var helper = document.createElement('div');
        helper.style.position = 'absolute';
        helper.style.margin = '0';
        helper.style.padding = '0';
        helper.style.right = '0';
        helper.style.width = '10px';
        document.getElementsByTagName('body')[0].appendChild(helper);
    }
    return helper.offsetLeft + 10;
}

//función para obtener el alto de la ventana.
function getHeight() {
    if (self.innerHeight) { // MOS
        y = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientWidth) { // IE6 Strict
        y = document.documentElement.clientHeight;	
    } else if (document.body.clientHeight) { // IE quirks
        y = document.body.clientHeight;
    }

	return y;
}

//Función para mostrar los mensajes de Error
function showErrScreen(msg){
	x = parseInt(getWidth());
	y = parseInt(getHeight());	
	ly = document.getElementById('lyBlock'); 
	ly.style.display='block';
	ly.style.width = x + "px";
	ly.style.height = y + "px";	
	
	lyM = document.getElementById('lyMsg');
	lyM.style.display='block';
	c = parseInt(centerH()) - 175;
	lyM.style.left = c + "px";
	lyM.style.top = "100px";
	document.getElementById('msgAlert').innerHTML = msg;
}

//Función para ocultar el mensaje de Error
function hideErrScreen(){
    lyM = document.getElementById('lyMsg');
	lyM.style.display='none';
	
    ly = document.getElementById('lyBlock'); 
	ly.style.display='none';	
	

}


//devuelve la posicion horizontal del ratón
function posX(ev){
  var posic = 0;
  if(document.all){
	  posic = 1 + event.screenX;
  }
  return posic;
}

function ValidaFecha(Cadena){  
    var Fecha= new String(Cadena);
    var RealFecha= new Date();
	
    var Ano= new String(Fecha.substring(Fecha.lastIndexOf("/")+1,Fecha.length));  
    var Mes= new String(Fecha.substring(Fecha.indexOf("/")+1,Fecha.lastIndexOf("/")));  
    var Dia= new String(Fecha.substring(0,Fecha.indexOf("/")));  
  
    if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900){  
        return false;  
    }
	
    if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12){  
        return false;  
    }  
    if (isNaN(Dia) || parseInt(Dia, 10)<1 || parseInt(Dia, 10)>31){  
        return false;  
    }
	
    if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {  
        if (Mes==2 && Dia > 28 || Dia>30) {  
            return false;  
        }  
    }  
      
  return true;    
}

function showFondo(){
	x = parseInt(getWidth());
	y = parseInt(getHeight());	
	ly = document.getElementById('div_fondo'); 	
	ly.style.display='block';
	ly.style.width = x + "px";
	ly.style.height = y + "px";			
}


function onlyNumber(objeto,e){
  var keynum;
  var keychar;
  var numcheck;
     
  if(window.event){ /*/ IE*/
	keynum = e.keyCode
  } else if(e.which){ /*/ Netscape/Firefox/Opera/*/
	keynum = e.which
  }


  if((keynum>=35 && keynum<=37) || (keynum==8||keynum==9||keynum==39)) {
    return true;
  }
    
  if((keynum>=48&&keynum<=57) || (keynum>=96&&keynum<=105)){
    return true;
  } else {
    return false;
  }
    
}

/*
function getMuni(){
 dep = document.getElementById('lsDepto').value;
 alert(dep);
}*/

function getExtensionFile(nomFile){
  extension = (nomFile.substring(nomFile.lastIndexOf("."))).toLowerCase();
  return extension;
}



