// JavaScript Document
var SEP_AND = "|&|";
var SEP_IGUAL = "|=|";
var TOTAL_DIAS = 16;

function loadTab(){
	//Pro
	this.sHTML = '';
	this.sScript = '';
	this.bHideLoad = true;
	
	//Fun
	this.init = function(sPathHTML, sPathScript, bHideLoad){
		this.sHTML = sPathHTML;
		this.sScript = sPathScript;
		this.bHideLoad = (!bHideLoad)? false : true;
		this.loadHTML();
	}
	this.loadHTML = function(){
		this.showLoading();
		this.req.pedir(this.sHTML, 'nada=si');
	}
	this.loadScript = function(){
		var e = document.createElement('script');
		document.body.appendChild(e);
		e.type = 'text/javascript';
		e.src = this.sScript;
		if(this.bHideLoad) this.hideLoading();
	}
	//
	this.showLoading = function(){
		var c = $('blockGeneral');
		/*c.style.height = (HBody() + 10) + 'px';*/
		c.style.visibility = 'visible';
		c = $('cargador');
		c.style.top = (YPos() + Math.floor((HScreen() - 41) / 2)) + 'px';
		c.style.left = (XPos() + Math.floor((WScreen() - 121) / 2)) + 'px';
		c.style.visibility = 'visible';
	}
	this.hideLoading = function(){
//		$('blockGeneral').style.visibility = 
		$('cargador').style.visibility = 'hidden';
	}
	
	//Obj
	this.req = new Request();
	this.req.listener = function(){
		var d = this.req.respuestaXML, e = null;
		
		if(!d){ alert("Ha ocurrido un error."); 
					alert(this.req.respuestaHTML);
		}
		else{
			e = document.createElement('span');
			document.body.appendChild(e);
			e.innerHTML = d.firstChild.data;
			this.loadScript();
		}
		
		e = null;
	}.closure(this);
}

function WScreen(){ return (Nav.esIE)? document.documentElement.clientWidth : window.innerWidth; }
function HScreen(){ return (Nav.esIE)? document.documentElement.clientHeight : window.innerHeight; }
function YPos(){ return (Nav.esIE)? document.documentElement.scrollTop : window.pageYOffset; }
function XPos(){ return (Nav.esIE)? document.documentElement.scrollLeft : window.pageXOffset; }
function HBody(){ return document.documentElement.scrollHeight; }

var mostrarMenu = function(menu){
	var men =  $(menu);
	if(menu){
		if(men.style.display == 'block')men.style.display = 'none';
		else men.style.display = 'block';
	}
	else alert('No existe el menu indicado.');
}
var ubicarContenido = function(objeto){
	var top = Math.round((550-objeto.offsetHeight)/2);
	var left = Math.round((1000-objeto.offsetWidth)/2);	
	objeto.style.top = top+"px";
	objeto.style.left = left+"px";	
}

var mostrarBlockeador = function(display){
	var blockeador = $('blockeador');
	if(blockeador){
		if(display){
			if(Nav.esIE || Nav.esIE7) blockeador.style.filter = 'alpha(opacity=45)';
			else blockeador.style.MozOpacity = ".45";			
			d = getBodyWHAvaible();
			if(d.h == 0)d = getWindowDims();

			blockeador.style.width = d.w+"px";
			blockeador.style.height = d.h+"px"
			blockeador.style.display = "block";
		}
		else blockeador.style.display = "none";
	}
}



//ENCUESTA
var argEncuesta = null;
oEncuesta = {'pedirEncuesta':function(){
	var oLTab = null;
	if(!!argEncuesta) return false;
	oLTab = new loadTab();
	argEncuesta = arguments;
	if(argEncuesta[argEncuesta.length-1]){
		StopEvent(argEncuesta[argEncuesta.length-1]);
		argEncuesta[argEncuesta.length-1] = null;
	}
	oLTab.init('requests/cargar.php?file=../oEncuesta.php', DIR_ROOT + 'viajeros/js/oEncuesta.js', true);
}}

//FORMULARIO
var argFormulario = null;
oFormulario = {'abrir':function(){
	var oLTab = null;
	if(!!argFormulario) return false;
	oLTab = new loadTab();
	argFormulario = arguments;
	oLTab.init('requests/cargar.php?file=../oFormulario.php&noEncode=true', DIR_ROOT + 'viajeros/js/oFormulario.js', true);
}}

//MENSAJE
var argMensaje = null;
oMensaje = {'abrir':function(){
	var oLTab = null;
	if(arguments[1])StopEvent(arguments[1]);
	if(!!argMensaje || $('totalMensajes').innerHTML == 0) return false;
	oLTab = new loadTab();
	argMensaje = arguments;

	oLTab.init('requests/cargar.php?file=../oMensaje.php&noEncode=true', 'js/oMensaje.js', true);
}}

//LOCALIZADOR
var argLocalizador = null;
oLocalizador = {'abrir':function(){
	var oLTab = null;
	if(arguments[1])StopEvent(arguments[1]);
	if(!!argLocalizador || $('totalBusquedas').innerHTML == 0) return false;
	oLTab = new loadTab();
	argLocalizador = arguments;
	oLTab.init('requests/cargar.php?file=../oLocalizador.php&noEncode=true', 'js/oLocalizador.js', true);
}}

//VIAJEROS
var argAgenda = null;
oAgenda = {'abrir':function(){
	var oLTab = null;
	if(!!argAgenda) return false;
	oLTab = new loadTab();
	argAgenda = arguments;
	oLTab.init('requests/cargar.php?file=../oAgenda.php&noEncode=true', 'js/oAgenda.js', true);
}}

//FOTOS
var argFoto = null;
oFoto = {'abrir':function(){
	var oLTab = null;
	if(arguments[2])StopEvent(arguments[2]);
	if(!!argFoto || $('totalFotos').innerHTML == 0) return false;
	oLTab = new loadTab();
	argFoto = arguments;
	oLTab.init('requests/cargar.php?file=../oFoto.php&noEncode=true', 'js/oFoto.js', true);
}}

//VIDEOS
var argVideo = null;
oVideo = {'abrir':function(){
	var oLTab = null;
	if(arguments[2])StopEvent(arguments[2]);
	if(!!argVideo || $('totalVideos').innerHTML == 0) return false;
	oLTab = new loadTab();
	argVideo = arguments;

	oLTab.init('requests/cargar.php?file=../oVideo.php&noEncode=true', 'js/oVideo.js', true);
}}

