/*
 * Invocacin asicrnica al server (funcin de envo de publicidad). Adicionalmente muestra mensajes descriptivos.
 */
var CARGA_MOVILE_JS = false;

function ajaxRequestSend(url, params, method, isHome, idioma,hotel)
{
	var ajax;
	//document.getElementById("msgBuscando").style.display = "block";
	
	
	ajax = nuevoAjax();
	if (method == "GET")
	{
		params = params + "&lang=" + idioma;
		if (isHome == true)
		{
			params = params + "&isHome=1";
		}
		nroRandom = Math.random();
		params = params + "&elimCache=" + nroRandom;
		ajax.open(method, url + '?' + params, true);

		ajax.onreadystatechange=function() 
		{
			if (ajax.readyState == 4) 
			{
				rta = ajax.responseText;
				//alert(rta);
				datos = rta.split('<<RES>>');
				rta = datos[0];
				cantRes = datos[1];
				
				if ((rta != 'false') && (cantRes > 0))
				{		
					strFunc = "";
				
						//document.getElementById("cuerpo").innerHTML = rta;
						document.getElementById("contenido").innerHTML = rta;
						document.getElementById("buscando").style.visibility='hidden';
						strFunc = 'xMoveTo("cabeceraMovile", 480, (xScrollTop() + 27));';

					window.onscroll= function(){ eval(strFunc); };
				}
				else
				{
					if( hotel == 'comte') idhotel = 1;
					if( hotel == 'xons_platja') idhotel = 3;
					if( hotel == 'xons_valencia') idhotel = 2;
					
					var uri = '/index.php?action=mostrar_contenido&id_seccion=67&lang='+idioma+'&hotel='+idhotel;
					document.getElementById("ifrm").src = uri;
					//document.getElementById("ifrm").src ='/'+hotel+'/ing/popUp_busqueda.htm';
				}

				if (document.getElementById("msgBuscando"))
					document.getElementById("msgBuscando").style.display = "none";	
			}
		}
		ajax.send(null);
	}
	else
	{
		alert("Mtodo "+ method +" no implementado.")
	}
}

/* cabecera_visible.js compiled from X 4.01 with XC 0.29b. Distributed under GNU LGPL. For copyrights, license, documentation and more visit Cross-Browser.com */
var xOp7Up,xOp6Dn,xIE4Up,xIE4,xIE5,xNN4,xUA=navigator.userAgent.toLowerCase();
if(window.opera){var i=xUA.indexOf('opera');if(i!=-1){var v=parseInt(xUA.charAt(i+6));xOp7Up=v>=7;xOp6Dn=v<7;}}else if(navigator.vendor!='KDE' && document.all && xUA.indexOf('msie')!=-1){xIE4Up=parseFloat(navigator.appVersion)>=4;xIE4=xUA.indexOf('msie 4')!=-1;xIE5=xUA.indexOf('msie 5')!=-1;}else if(document.layers){xNN4=true;}xMac=xUA.indexOf('mac')!=-1;function xDef(){for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}return true;}function xGetElementById(e){if(typeof(e)=='string') {if(document.getElementById) e=document.getElementById(e);else if(document.all) e=document.all[e];else e=null;}return e;}function xLeft(e, iX){if(!(e=xGetElementById(e))) return 0;var css=xDef(e.style);if (css && xStr(e.style.left)) {if(xNum(iX)) e.style.left=iX+'px';else {iX=parseInt(e.style.left);if(isNaN(iX)) iX=0;}}else if(css && xDef(e.style.pixelLeft)) {if(xNum(iX)) e.style.pixelLeft=iX;else iX=e.style.pixelLeft;}return iX;}function xMoveTo(e,x,y){xLeft(e,x);xTop(e,y);}function xNum(){for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}return true;}function xScrollTop(e, bWin){var offset=0;if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {var w = window;if (bWin && e) w = e;if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;else if(w.document.body && xDef(w.document.body.scrollTop)) offset=w.document.body.scrollTop;}else {e = xGetElementById(e);if (e && xNum(e.scrollTop)) offset = e.scrollTop;}return offset;}function xStr(s){for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}return true;}function xTop(e, iY){if(!(e=xGetElementById(e))) return 0;var css=xDef(e.style);if(css && xStr(e.style.top)) {if(xNum(iY)) e.style.top=iY+'px';else {iY=parseInt(e.style.top);if(isNaN(iY)) iY=0;}}else if(css && xDef(e.style.pixelTop)) {if(xNum(iY)) e.style.pixelTop=iY;else iY=e.style.pixelTop;}return iY;}


function nuevoAjax()
{
	var xmlhttp = false;
 	try 
 	{
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} 
 	catch (e) 
 	{
 		try 
 		{
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} 
 		catch (E) 
 		{
 			xmlhttp = false;
 		}
  	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
	{
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function processParamsFormReservas()
{
	strRet = "action=reservaBuscar&mesEntrada=" + document.reserva.mesEntrada.value;
	strRet = strRet + "&diaEntrada=" + document.reserva.diaEntrada.value;
	strRet = strRet + "&mesSalida=" + document.reserva.mesSalida.value;
	strRet = strRet + "&diaSalida=" + document.reserva.diaSalida.value;
	strRet = strRet + "&adults=" + document.reserva.adults.value;
	strRet = strRet + "&nens=" + document.reserva.nens.value;
	strRet = strRet + "&hotel=" + document.reserva.hotel.value;
	return strRet;
}

function reservaPaso1(msgItems)
{
	
	var arrElems = document.getElementsByName("dataItem");
	var strItems = "";
	
	for (i = 0; i < arrElems.length; i++)
	{
		keyItem = arrElems[i].value;
		cantItem = document.getElementById("cant_" + keyItem).value;
		if (cantItem > 0)
		{
			str_val = keyItem.toString().replace(/_/g, "<<S2>>");
			str_precio = document.getElementById("precio_" + keyItem).value;
			str_val = str_val + "<<S2>>" + str_precio + "<<S2>>" + cantItem;
			strItems = strItems == "" ? str_val : strItems + "<<S1>>" + str_val;
		}
		// tih, pen, id_hotel, tipoPaq, idPaq, precioReserva, cant 		
	}
	
	if (strItems == "")
	{
		alert(msgItems);
		return false;	
	}
		
/*
	document.getElementById('formreserva').tih.value = tih;
	document.getElementById('formreserva').pen.value = pen;
	document.getElementById('formreserva').precioReserva.value = precioReserva;
	document.getElementById('formreserva').idHotel.value = id_hotel;
	document.getElementById('formreserva').Tipus.value = tipoPaq;
	document.getElementById('formreserva').CTP.value = idPaq;
*/
	document.getElementById('formreserva').itemsReservados.value = strItems;
	document.getElementById('formreserva').submit();
}

function ver(iden){
	if(document.getElementById(iden).style.display == "none")
	{
		document.getElementById(iden).style.display = "";
	}
	else
	{
		document.getElementById(iden).style.display = "none";
	}
}

var vent;
function openPopUp(id_habitacion)
{	
	if (vent)
		vent.close();
		
	vent = window.open('/index.php?action=openPopUp&id_habitacion='+id_habitacion,'','toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no');
}

function selectedIndexForValue(objSel, valSel)
{
	for(var no = 0; no < objSel.options.length; no++)
	{
		if(objSel.options[no].value == valSel){
			objSel.selectedIndex=no;
			break;
		}				
	}	
}
