
//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 
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;
}

