
//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 showLoading(){
	var lyrMessage = document.getElementById('msgLoad');	
	var anchoPag=document.body.clientWidth;
	var x=(anchoPag-140);
	lyrMessage.style.left=x;
	lyrMessage.style.top=getY();
	lyrMessage.style.visibility='visible';
	//lyrMessage.style.top=(document.body.clientHeight-event.clientY-400);
	//document.write('<div id=\"msgLoad\" style=\"padding-left:5px;position: absolute; z-index: 10005; top: 5px; left: '+x+'px; width: 80px; height:10px; visibility: visible; font-size:10px; font-family:tahoma; background-color:#990000;color:#FFFFFF; font-weight:bold\">Loading...</div>');
}
//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){
	var valido = false;
	valido = email.search(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/);
	return valido;
}