
//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('msgLoad').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 showLoading(){
	var lyrMessage = document.getElementById('msgLoad');	
	lyrMessage.style.bottom=document.body.scrollTop;
	lyrMessage.style.left=0;
	lyrMessage.style.visibility='visible';
}
//Función para cerrar el div de loading
function hideLoading(){
	document.getElementById('msgLoad').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){
	if (recovery.email.value == '') {
		alert ('Escriba un Email!');
		recovery.email.focus();
		return false;
	}
	/*var valido = true;
	valido = email.search(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/);
	return valido;*/
}

//show OR hide funtion depends on if element is shown or hidden
function show(id) { 
	if (document.getElementById) { // DOM3 = IE5, NS6
		//hideAllMessages();			
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
		} else {
			document.getElementById(id).style.display = 'none';	
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
			} else {
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				document.all.id.style.display = 'none'; 
			}
		}
	}
}
function hide(id) { 
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "block"){
			document.getElementById(id).style.display = 'none';
		}
	}
}
