/*
 * Invocacin asicrnica al server (funcin de envo de publicidad). Adicionalmente muestra mensajes descriptivos.
 */

function ajaxRequestSend(url, params, method, idioma, functionRet)
{
	var ajax;
	//document.getElementById("msgBuscando").style.display = "block";
	
	
	ajax = nuevoAjax();
	if (method == "GET")
	{
		params = params + "&lang=" + idioma;
		
		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);
				eval(functionRet+'(\''+rta+'\');');
			}
		}
		
		ajax.send(null);
	}
	else
	{
		alert("Mtodo "+ method +" no implementado.")
	}
	
	
}

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;
	return strRet;
}

function reservaPaso1(tih, pen, precioReserva, id_hotel, tipoPaq, idPaq)
{
	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').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;
		}				
	}	
}
