
//Función para obtener el objeto XMLHttp
//dependiendo del navegador.
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		document.getElementById('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object.  Consider upgrading your browser.';
	}
}

//Función para mostrar el div de loading en la esquina superior derecha
function mostrarLoad(lyrAct,mensaje){
	x = getWidth();
	y = getHeight();
	document.getElementById('div_fondo').style.visibility='visible';
	document.getElementById('div_fondo').style.width=x;
	document.getElementById('div_fondo').style.height=y;	
	var lyr = document.getElementById(lyrAct);	
	lyr.style.top = y/2-100;
	lyr.innerHTML = '<img src="/images1/load_total.gif"/><br><font color="#0066FF" style="font-size:10px;">'+mensaje+'</font>';
}
//Función para cerrar el div de loading
function ocultaLoad(lyrAct){
	document.getElementById(lyrAct).innerHTML='';
	document.getElementById('div_fondo').style.visibility='hidden';
}

//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 
function allTrim(s){
	s = s.replace(/^\s+|\s+$/gi,'');
	return s;
}

//Función para validar el email
function validaMail(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;
}

function mostrarLoad2(ly,msg){
	var lyAct = document.getElementById(ly);	
	lyAct.innerHTML = '<div align="center"><img src="/images1/load_greenf.gif"><br><font color="#92C005" style="font-size:10px;">'+msg+'</font></div>';	
}

function ocultaLoad2(ly){
	var lyAct = document.getElementById(ly);	
	lyAct.innerHTML = '';	
}

function showLoad(ly,msg){
	var lyAct = document.getElementById(ly);	
	lyAct.innerHTML = '<div align="center"><img src="/images1/load_square.gif"><br><font color="#666666" style="font-size:10px;">'+msg+'</font></div>';	
}

