// JavaScript Document
	function objetus() {
			 try {
					 objeto = new ActiveXObject("Msxml2.XMLHTTP");
			} catch ( e) {
					 try {
							 objeto= new ActiveXObject (" Microsoft.XMLHTTP");
					 } catch (E) {
							  objeto= false;
					}
			}
			if (! objeto && typeof XMLHttpRequest!= 'undefined') {
					 objeto = new XMLHttpRequest();
			}
			return objeto;
	  }

function suma_habitacion_oferta(miform) {
	  
		var aleatorio=Math.random();
		
		var campoconcat = miform+"habitaciones_oferta";
		var quedanconcat = miform+"quedan";
		var loadingconcat = miform+"loadingDiv_oferta";
		var hotelconcat = miform+"id_hotel";
		var quedan = document.getElementById(quedanconcat).value;
		var hab_actual=document.getElementById(campoconcat).value; 
		var hotel=document.getElementById(hotelconcat).value; 
		var variables = '';
		var i;
		var lashabitaciones = new Array() 
		for(i=1;i<=hab_actual;i++){
			var habconcat = miform+"num_pers_oferta"+i;
			
			lashabitaciones[i]=document.getElementById(habconcat).value;
			
			variables = variables+"&habitaciones["+i+"]="+document.getElementById(habconcat).value;
		}
		
		if(document.getElementById(campoconcat).value<=(quedan-1))
		{
			document.getElementById(campoconcat).value++;
			
		var hab_actual=document.getElementById(campoconcat).value; 
		
		
	  	var url = "numero_habitaciones_oferta.php?"+variables+"&num="+hab_actual+"&id_oferta="+miform+"&id_hotel="+hotel+"&";
		var params = "nocache="+aleatorio+"";
		
		var http = objetus();
		
		http.open("GET", url+"?"+params, true);
		
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", "text/html");
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		
		http.onreadystatechange = function() {//Call a function when the state changes.
		if (http.readyState == 1) { // Cargando...
document.getElementById(loadingconcat).style.display = 'block';
document.getElementById(miform).style.display='none';
}
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById(loadingconcat).style.display = 'none';
				document.getElementById(miform).style.display='block';
				document.getElementById(miform).innerHTML = http.responseText;
				document.getElementById(campoconcat).value = hab_actual;
				if(document.getElementById(miform+'saS'))
					selecciona(miform+'saS',miform+'precio_sa','SA',miform)
				if(document.getElementById(miform+'asS'))
					selecciona(miform+'adS',miform+'precio_ad','AD',miform)
				if(document.getElementById(miform+'mpS'))
					selecciona(miform+'mpS',miform+'precio_mp','MP',miform)
				if(document.getElementById(miform+'pcS'))
					selecciona(miform+'pcS',miform+'precio_pc','PC',miform)
			}

		}
		http.send(null);
		} /* menor que 10 */
		else
			alert("Sólo quedan "+quedan+" habitaciones disponibles para esta oferta"); 
	  }

function resta_habitacion_oferta(miform) {
	  
		var aleatorio=Math.random();
		var campoconcat = miform+"habitaciones_oferta";
		var loadingconcat = miform+"loadingDiv_oferta";
				var hotelconcat = miform+"id_hotel";
				var hotel=document.getElementById(hotelconcat).value;

		if(document.getElementById(campoconcat).value>1)
		{
		   document.getElementById(campoconcat).value--;
				var hab_actual=document.getElementById(campoconcat).value; 
	  	var url = "numero_habitaciones_oferta.php?num="+hab_actual+"&id_oferta="+miform+"&id_hotel="+hotel+"&";
		var params = "nocache="+aleatorio+"";
		


		var http = objetus();
		
		http.open("GET", url+"?"+params, true);
		
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", "text/html");
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		
		http.onreadystatechange = function() {//Call a function when the state changes.
		if (http.readyState == 1) { // Cargando...
document.getElementById(loadingconcat).style.display = 'block';
document.getElementById(miform).style.display='none';
}
			if(http.readyState == 4 && http.status == 200) {

				document.getElementById(loadingconcat).style.display = 'none';
				document.getElementById(miform).style.display='block';
				document.getElementById(miform).innerHTML = http.responseText;
				document.getElementById(campoconcat).value = hab_actual;
				if(document.getElementById(miform+'saS'))
					selecciona(miform+'saS',miform+'precio_sa','SA',miform)
				if(document.getElementById(miform+'asS'))
					selecciona(miform+'adS',miform+'precio_ad','AD',miform)
				if(document.getElementById(miform+'mpS'))
					selecciona(miform+'mpS',miform+'precio_mp','MP',miform)
				if(document.getElementById(miform+'pcS'))
					selecciona(miform+'pcS',miform+'precio_pc','PC',miform)
			}

		}
		http.send(null);
		}
}
function cambia_tarifa(miform) {
	  
		var aleatorio=Math.random();
		var totalconcat = miform+"habitaciones_oferta";
		var habitaciones=document.getElementById(totalconcat).value; 
				var loadingconcat = miform+"loadingDiv_oferta";

		var idconcat = miform+"oferta-derecha";
		
		var hotelconcat = miform+"id_hotel";
		var hotel=document.getElementById(hotelconcat).value;
		
		var variables = '';
		var i;
		var lashabitaciones = new Array() 
		for(i=1;i<=habitaciones;i++){
			var habconcat = miform+"num_pers_oferta"+i;
			lashabitaciones[i]=document.getElementById(habconcat).value;
			variables = variables+"&habitaciones["+i+"]="+document.getElementById(habconcat).value;
		}
		
	  	var url = "cambia_tarifa.php?"+variables+"&numhabitaciones="+habitaciones+"&id_oferta="+miform+"&id_hotel="+hotel+"&";
		var params = "nocache="+aleatorio+"";
		

		var http = objetus();
		
		http.open("GET", url+""+params, true);
		
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", "text/html");
		//http.setRequestHeader("Content-length", params.length);
		//http.setRequestHeader("Connection", "close");
		
		http.onreadystatechange = function() {//Call a function when the state changes.
		
		if (http.readyState == 1) { // Cargando...
document.getElementById(loadingconcat).style.display = 'block';
document.getElementById(idconcat).style.display='none';
}
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById(loadingconcat).style.display = 'none';
				document.getElementById(idconcat).style.display='block';
				document.getElementById(idconcat).innerHTML = http.responseText;
				
				if(document.getElementById(miform+'saS'))
					selecciona(miform+'saS',miform+'precio_sa','SA',miform)
				if(document.getElementById(miform+'asS'))
					selecciona(miform+'adS',miform+'precio_ad','AD',miform)
				if(document.getElementById(miform+'mpS'))
					selecciona(miform+'mpS',miform+'precio_mp','MP',miform)
				if(document.getElementById(miform+'pcS'))
					selecciona(miform+'pcS',miform+'precio_pc','PC',miform);


			}

		}
		http.send(null);
	  }
