//CAJETINES
	function appendOptionLast(elSel,val) {
			var elOptNew = document.createElement('option');
			elOptNew.text = val
			elOptNew.value = val
			try {
				elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
			} catch(ex) {
				elSel.add(elOptNew); // IE only
			}
		}

		function removeOptionLast(elSel) {
			if (elSel.length > 0) {
				elSel.remove(elSel.length - 1);
			}
		}
		
		function doCompletionAdNi(form,origen){
			var ad = 5;
			var ni = 3;
			//Zonas
			if (origen==null || origen=='dest'){
				if (document.getElementById(form+':destinos').value=='Z53'){ad = 4;ni = 3;}
				if (document.getElementById(form+':destinos').value=='Z54'){ad = 3;ni = 2;}
				if (document.getElementById(form+':destinos').value=='Z55'){ad = 6;ni = 5;}
				if (document.getElementById(form+':destinos').value=='Z62'){ad = 3;ni = 0;}
				if (document.getElementById(form+':destinos').value=='Z63'){ad = 4;ni = 3;}
				if (document.getElementById(form+':destinos').value=='Z57'){ad = 3;ni = 2;}
				if (document.getElementById(form+':destinos').value=='Z59'){ad = 3;ni = 2;}
				if (document.getElementById(form+':destinos').value=='Z61'){ad = 2;ni = 1;}
				if (document.getElementById(form+':destinos').value=='Z60'){ad = 2;ni = 1;}
				if (document.getElementById(form+':destinos').value=='Z58'){ad = 2;ni = 1;}
				//Destinos
				if (document.getElementById(form+':destinos').value=='82'){ad = 3;ni = 4;}
				if (document.getElementById(form+':destinos').value=='83'){ad = 3;ni = 3;}
				if (document.getElementById(form+':destinos').value=='84'){ad = 4;ni = 3;}
				if (document.getElementById(form+':destinos').value=='104'){ad = 4;ni = 3;}
				if (document.getElementById(form+':destinos').value=='89'){ad = 3;ni = 2;}
				if (document.getElementById(form+':destinos').value=='87'){ad = 3;ni = 2;}
				if (document.getElementById(form+':destinos').value=='91'){ad = 6;ni = 5;}
				if (document.getElementById(form+':destinos').value=='90'){ad = 4;ni = 3;}
				if (document.getElementById(form+':destinos').value=='92'){ad = 3;ni = 3;}
				if (document.getElementById(form+':destinos').value=='99'){ad = 3;ni = 0;}
				if (document.getElementById(form+':destinos').value=='100'){ad = 4;ni = 3;}
				if (document.getElementById(form+':destinos').value=='93'){ad = 3;ni = 2;}
				if (document.getElementById(form+':destinos').value=='94'){ad = 3;ni = 2;}
				if (document.getElementById(form+':destinos').value=='96'){ad = 3;ni = 2;}
				if (document.getElementById(form+':destinos').value=='98'){ad = 2;ni = 1;}
				if (document.getElementById(form+':destinos').value=='97'){ad = 2;ni = 1;}
				if (document.getElementById(form+':destinos').value=='95'){ad = 2;ni = 1;}
			}
			if (origen==null || origen!='dest'){//Hoteles
				if (document.getElementById(form+':hoteles').value=='2773'){ad = 3;ni = 4;}
				if (document.getElementById(form+':hoteles').value=='11288'){ad = 3;ni = 2;}
				if (document.getElementById(form+':hoteles').value=='2866'){ad = 3;ni = 3;}
				if (document.getElementById(form+':hoteles').value=='4521'){ad = 3;ni = 4;}
				if (document.getElementById(form+':hoteles').value=='4522'){ad = 3;ni = 4;}
				if (document.getElementById(form+':hoteles').value=='10452'){ad = 3;ni = 2;}
				if (document.getElementById(form+':hoteles').value=='4514'){ad = 4;ni = 3;}
				if (document.getElementById(form+':hoteles').value=='2740'){ad = 3;ni = 2;}
				if (document.getElementById(form+':hoteles').value=='2629'){ad = 3;ni = 2;}
				if (document.getElementById(form+':hoteles').value=='6260'){ad = 4;ni = 3;}
				if (document.getElementById(form+':hoteles').value=='6320'){ad = 6;ni = 5;}
				if (document.getElementById(form+':hoteles').value=='11428'){ad = 6;ni = 5;}
				if (document.getElementById(form+':hoteles').value=='4652'){ad = 3;ni = 3;}
				if (document.getElementById(form+':hoteles').value=='10696'){ad = 3;ni = 2;}
				if (document.getElementById(form+':hoteles').value=='10968'){ad = 3;ni = 2;}
				if (document.getElementById(form+':hoteles').value=='11289'){ad = 2;ni = 1;}
				if (document.getElementById(form+':hoteles').value=='11379'){ad = 3;ni = 2;}
				if (document.getElementById(form+':hoteles').value=='11291'){ad = 2;ni = 1;}
				if (document.getElementById(form+':hoteles').value=='11290'){ad = 2;ni = 1;}
				if (document.getElementById(form+':hoteles').value=='6510'){ad = 3;ni = 0;}
				if (document.getElementById(form+':hoteles').value=='2415'){ad = 4;ni = 3;}
				if (document.getElementById(form+':hoteles').value=='7357'){ad = 5;ni = 3;}
				if (document.getElementById(form+':hoteles').value=='11287'){ad = 2;ni = 2;}
			}
			difad = document.getElementById('cajetin_adultos1').length - ad;
			difni = document.getElementById('cajetin_ninos1').length - 1 - ni;
			
			//alert (ad+"   ---   "+ni+"      difad : "+difad+"    difni:"+difni)
			
			if (difad>0){
				for (i=0;i<difad;i++){
					removeOptionLast(document.getElementById('cajetin_adultos1'));
					removeOptionLast(document.getElementById('cajetin_adultos2'));
					removeOptionLast(document.getElementById('cajetin_adultos3'));
				}
			}
			if (difad<0){
				for (i=difad;i<0;i++){
					appendOptionLast(document.getElementById('cajetin_adultos1'),(document.getElementById('cajetin_adultos1').length+1));
					appendOptionLast(document.getElementById('cajetin_adultos2'),(document.getElementById('cajetin_adultos2').length+1));
					appendOptionLast(document.getElementById('cajetin_adultos3'),(document.getElementById('cajetin_adultos3').length+1));
				}
			}

			if (difni>0){
				for (i=0;i<difni;i++){
					removeOptionLast(document.getElementById('cajetin_ninos1'));
					removeOptionLast(document.getElementById('cajetin_ninos2'));
					removeOptionLast(document.getElementById('cajetin_ninos3'));
				}
			}
			if (difni<0){
				for (i=difni;i<0;i++){
					appendOptionLast(document.getElementById('cajetin_ninos1'),(document.getElementById('cajetin_ninos1').length));
					appendOptionLast(document.getElementById('cajetin_ninos2'),(document.getElementById('cajetin_ninos2').length));
					appendOptionLast(document.getElementById('cajetin_ninos3'),(document.getElementById('cajetin_ninos3').length));
				}
			}
			updateCajetin();
			
		}
		
		function doCompletionOfAdNi(form,origen){
			var ad = 5;
			var ni = 3;
			//Zonas
			if (origen==null || origen=='dest'){
				if (document.getElementById(form+':odestinos').value=='Z53'){ad = 4;ni = 3;}
				if (document.getElementById(form+':odestinos').value=='Z54'){ad = 3;ni = 2;}
				if (document.getElementById(form+':odestinos').value=='Z55'){ad = 6;ni = 5;}
				if (document.getElementById(form+':odestinos').value=='Z62'){ad = 3;ni = 0;}
				if (document.getElementById(form+':odestinos').value=='Z63'){ad = 4;ni = 3;}
				if (document.getElementById(form+':odestinos').value=='Z57'){ad = 3;ni = 2;}
				if (document.getElementById(form+':odestinos').value=='Z59'){ad = 3;ni = 2;}
				if (document.getElementById(form+':odestinos').value=='Z61'){ad = 2;ni = 1;}
				if (document.getElementById(form+':odestinos').value=='Z60'){ad = 2;ni = 1;}
				if (document.getElementById(form+':odestinos').value=='Z58'){ad = 2;ni = 1;}
				//Destinos
				if (document.getElementById(form+':odestinos').value=='82'){ad = 3;ni = 4;}
				if (document.getElementById(form+':odestinos').value=='83'){ad = 3;ni = 3;}
				if (document.getElementById(form+':odestinos').value=='84'){ad = 4;ni = 3;}
				if (document.getElementById(form+':odestinos').value=='104'){ad = 4;ni = 3;}
				if (document.getElementById(form+':odestinos').value=='89'){ad = 3;ni = 2;}
				if (document.getElementById(form+':odestinos').value=='87'){ad = 3;ni = 2;}
				if (document.getElementById(form+':odestinos').value=='91'){ad = 6;ni = 5;}
				if (document.getElementById(form+':odestinos').value=='90'){ad = 4;ni = 3;}
				if (document.getElementById(form+':odestinos').value=='92'){ad = 3;ni = 3;}
				if (document.getElementById(form+':odestinos').value=='99'){ad = 3;ni = 0;}
				if (document.getElementById(form+':odestinos').value=='100'){ad = 4;ni = 3;}
				if (document.getElementById(form+':odestinos').value=='93'){ad = 3;ni = 2;}
				if (document.getElementById(form+':odestinos').value=='94'){ad = 3;ni = 2;}
				if (document.getElementById(form+':odestinos').value=='96'){ad = 3;ni = 2;}
				if (document.getElementById(form+':odestinos').value=='98'){ad = 2;ni = 1;}
				if (document.getElementById(form+':odestinos').value=='97'){ad = 2;ni = 1;}
				if (document.getElementById(form+':odestinos').value=='95'){ad = 2;ni = 1;}
			}
			//Hoteles
			if (origen==null || origen!='dest'){
				if (document.getElementById(form+':ohoteles').value=='2773'){ad = 3;ni = 4;}
				if (document.getElementById(form+':ohoteles').value=='11288'){ad = 3;ni = 2;}
				if (document.getElementById(form+':ohoteles').value=='2866'){ad = 3;ni = 3;}
				if (document.getElementById(form+':ohoteles').value=='4521'){ad = 3;ni = 4;}
				if (document.getElementById(form+':ohoteles').value=='4522'){ad = 3;ni = 4;}
				if (document.getElementById(form+':ohoteles').value=='10452'){ad = 3;ni = 2;}
				if (document.getElementById(form+':ohoteles').value=='4514'){ad = 4;ni = 3;}
				if (document.getElementById(form+':ohoteles').value=='2740'){ad = 3;ni = 2;}
				if (document.getElementById(form+':ohoteles').value=='2629'){ad = 3;ni = 2;}
				if (document.getElementById(form+':ohoteles').value=='6260'){ad = 4;ni = 3;}
				if (document.getElementById(form+':ohoteles').value=='6320'){ad = 6;ni = 5;}
				if (document.getElementById(form+':ohoteles').value=='11428'){ad = 6;ni = 5;}
				if (document.getElementById(form+':ohoteles').value=='4652'){ad = 3;ni = 3;}
				if (document.getElementById(form+':ohoteles').value=='10696'){ad = 3;ni = 2;}
				if (document.getElementById(form+':ohoteles').value=='10968'){ad = 3;ni = 2;}
				if (document.getElementById(form+':ohoteles').value=='11289'){ad = 2;ni = 1;}
				if (document.getElementById(form+':ohoteles').value=='11379'){ad = 3;ni = 2;}
				if (document.getElementById(form+':ohoteles').value=='11291'){ad = 2;ni = 1;}
				if (document.getElementById(form+':ohoteles').value=='11290'){ad = 2;ni = 1;}
				if (document.getElementById(form+':ohoteles').value=='6510'){ad = 3;ni = 0;}
				if (document.getElementById(form+':ohoteles').value=='2415'){ad = 4;ni = 3;}
				if (document.getElementById(form+':ohoteles').value=='7357'){ad = 4;ni = 3;}
				if (document.getElementById(form+':ohoteles').value=='11287'){ad = 2;ni = 2;}
			}
			difad = document.getElementById('cajetin_adultos1').length - ad;
			difni = document.getElementById('cajetin_ninos1').length - 1 - ni;
			
			if (difad>0){
				for (i=0;i<difad;i++){
					removeOptionLast(document.getElementById('cajetin_adultos1'));
					removeOptionLast(document.getElementById('cajetin_adultos2'));
					removeOptionLast(document.getElementById('cajetin_adultos3'));
				}
			}
			if (difad<0){
				for (i=difad;i<0;i++){
					appendOptionLast(document.getElementById('cajetin_adultos1'),(document.getElementById('cajetin_adultos1').length+1));
					appendOptionLast(document.getElementById('cajetin_adultos2'),(document.getElementById('cajetin_adultos2').length+1));
					appendOptionLast(document.getElementById('cajetin_adultos3'),(document.getElementById('cajetin_adultos3').length+1));
				}
			}

			if (difni>0){
				for (i=0;i<difni;i++){
					removeOptionLast(document.getElementById('cajetin_ninos1'));
					removeOptionLast(document.getElementById('cajetin_ninos2'));
					removeOptionLast(document.getElementById('cajetin_ninos3'));
				}
			}
			if (difni<0){
				for (i=difni;i<0;i++){
					appendOptionLast(document.getElementById('cajetin_ninos1'),(document.getElementById('cajetin_ninos1').length));
					appendOptionLast(document.getElementById('cajetin_ninos2'),(document.getElementById('cajetin_ninos2').length));
					appendOptionLast(document.getElementById('cajetin_ninos3'),(document.getElementById('cajetin_ninos3').length));
				}
			}
			
		}
		
function updateCajetin(){
		var numHab = document.getElementById('cajetin_numHabitaciones').value;
		updateCajetinHab(1, true);
		updateCajetinHab(2, numHab>1);
		updateCajetinHab(3, numHab>2);
}; 
	
function updateCajetinHab(numHab, show){
		if(show){
			
			document.getElementById('cajetin:hab'+numHab).style.display='';
			var numNinos = document.getElementById('cajetin_ninos'+numHab).value;
			 document.getElementById('cajetin:hab'+numHab+':edad1').style.display= (numNinos < 1 ?'none':'');
			document.getElementById('cajetin:hab'+numHab+':edad2').style.display= (numNinos < 2?'none':'');	
			document.getElementById('cajetin:hab'+numHab+':edad3').style.display= (numNinos < 3?'none':'');	
			document.getElementById('cajetin:hab'+numHab+':edad4').style.display= (numNinos < 4?'none':'');	
			document.getElementById('cajetin:hab'+numHab+':edad5').style.display= (numNinos < 5?'none':'');	
		} else {
			document.getElementById('cajetin:hab'+numHab).style.display='none';
			document.getElementById('cajetin:hab'+numHab+':edad1').style.display='none';
			document.getElementById('cajetin:hab'+numHab+':edad2').style.display='none';
			document.getElementById('cajetin:hab'+numHab+':edad3').style.display='none';
			document.getElementById('cajetin:hab'+numHab+':edad4').style.display='none';
			document.getElementById('cajetin:hab'+numHab+':edad5').style.display='none';
		}
			
	};
	function select_innerHTML(objeto,innerHTML){
		/******
		* select_innerHTML - corrige o bug do InnerHTML em selects no IE
		* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
		* Versio: 2.1 - 04/09/2007
		* Autor: Micox - Niron Jos C. Guimares - micoxjcg@yahoo.com.br
		* @objeto(tipo HTMLobject): o select a ser alterado
		* @innerHTML(tipo string): o novo valor do innerHTML
		*******/
		    objeto.innerHTML = ""
		    var selTemp = document.createElement("micoxselect")
		    var opt;
		    selTemp.id="micoxselect1"
		    document.body.appendChild(selTemp)
		    selTemp = document.getElementById("micoxselect1")
		    selTemp.style.display="none"
		    if(innerHTML.toLowerCase().indexOf("<option")<0){
		      innerHTML = "<option>" + innerHTML + "</option>"
		    }
		    innerHTML = innerHTML.toLowerCase().replace(/<option/g,"<span").replace(/<\/option/g,"</span")

			selTemp.innerHTML = innerHTML


		    for(var i=0;i<selTemp.childNodes.length;i++){
		  var spantemp = selTemp.childNodes[i];

		        if(spantemp.tagName){
		            opt = document.createElement("OPTION")

		   if(document.all){ //IE
		    objeto.add(opt)
		   }else{
		    objeto.appendChild(opt)
		   }

		   //getting attributes
		   for(var j=0; j<spantemp.attributes.length ; j++){
		    var attrName = spantemp.attributes[j].nodeName;
		    var attrVal = spantemp.attributes[j].nodeValue;
		    if(attrVal){
		     try{
		      opt.setAttribute(attrName,attrVal);
		      opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
		     }catch(e){}
		    }
		   }
		   //getting styles
		   if(spantemp.style){
		    for(var y in spantemp.style){
		     try{opt.style[y] = spantemp.style[y];}catch(e){}
		    }
		   }
		   //value and text
		   opt.value = spantemp.getAttribute("value").toUpperCase();
		   if (opt.value!='--'){
			opt.text = spantemp.innerHTML.toUpperCase();
		   }else{
		    opt.text = spantemp.innerHTML;
		   }
		   //IE
		   opt.selected = spantemp.getAttribute('selected');
		   opt.className = spantemp.className;
		  }
		 }
		 document.body.removeChild(selTemp)
		 selTemp = null
		}

		function initRequest() {
		       if (window.XMLHttpRequest) {
		           return new XMLHttpRequest();
		       } else if (window.ActiveXObject) {
		           isIE = true;
		           return new ActiveXObject("Microsoft.XMLHTTP");
		       }
		   }

		   function doCompletion(form,hotel,lng){
			   if (null==document.getElementById(form +':destinos')){
				   form_temp = form;
				   form='beta2_inc:'+form_temp;
				   if (null==document.getElementById(form +':destinos')){
					   form='beta:'+form_temp;
				   }
			   }
			   if (document.getElementById(form +':destinos').value == "") {
		           clearTable();
		       } else {
		    	   var hot="";
		    	   if (hotel!=null && hotel!=0){
		    		   hot = "&hotel="+hotel;
		    	   } else {
		    		   hot = "&hotel=-1";
		    	   }
		    	   var ln = "";
		    	   if (lng!=null){
		    		   ln ="&lng="+lng;
		    	   }
		           var url = "/hoteles.hotelesglobales?destino=" + escape(document.getElementById(form +':destinos').value)+hot+ln;
		           var req = initRequest();
		           req.onreadystatechange = function() {
		               if (req.readyState == 4) {
		                   if (req.status == 200) {
		                       idHotel = parseMessages(req.responseXML, form +':hoteles');
		                       if (window.ActiveXObject) hotel_fix(form, idHotel);
		                   } else if (req.status == 204){
		                       clearTable();
		                   }
		               }
		           };
		           req.open("GET", url, true);
		           req.send(null);
		       }
		   }
		   
		   function doCompletionOffers(form,hotel,lng) {
			      if (document.getElementById(form+':odestinos').value == "") {
			           clearTable();
			       } else {
			    	   var hot="";
			    	   if (hotel!=null && hotel!=0){
			    		   hot = "&hotel="+hotel;
			    	   } else {
			    		   hot = "&hotel=-1";
			    	   }
			    	   var ln = "";
			    	   if (lng!=null){
			    		   ln ="&lng="+lng;
			    	   }
			    	   var url = "/hoteles.hotelesglobales?oferta=" + escape(document.getElementById(form+':cargar').value) + "&destino=" + escape(document.getElementById(form+':odestinos').value)+hot+ln;
			           var req = initRequest();
			           req.onreadystatechange = function() {
			               if (req.readyState == 4) {
			                   if (req.status == 200) {
			                       parseMessages(req.responseXML, form+':ohoteles');
			                   } else if (req.status == 204){
			                       clearTable();
			                   }
			               }
			           };
			           req.open("GET", url, true);
			           req.send(null);
			       }
			   }

		   function parseMessages(responseXML, field) {
			   	var idHotel = 0;
				var hoteles = responseXML.getElementsByTagName("hoteles")[0];
				if (hoteles!=null){
			   	document.getElementById(field).innerHTML = '';
			    var inner='';
			      for (loop = 0; hoteles.childNodes.length > loop; loop++) {
						var opcion = hoteles.childNodes[loop];
						var id = opcion.getElementsByTagName("id")[0].childNodes[0].nodeValue;
						if (id=='0'){
							id='';
						}
						var value = opcion.getElementsByTagName("value")[0].childNodes[0].nodeValue;
						var sel = opcion.getElementsByTagName("sel")[0].childNodes[0].nodeValue;
					   if (sel == '--') sel = "";
					   if (sel=="selected") idHotel = id;
					   if (window.ActiveXObject) {
							inner=inner+"<option value='"+id+"' "+sel+">"+value+"</option>";
						} else {
			         	document.getElementById(field).innerHTML = document.getElementById(field).innerHTML+ '<option value="'+id+'" '+sel+'>'+value+'</option>';
			         }
					}
					if (window.ActiveXObject) {
						select_innerHTML(document.getElementById(field),inner);
					}
				}
				return idHotel;
		   }
		   
		   function hotel_fix(form, id){
				var select = document.getElementById(form+':hoteles');
				for(i=0;i<select.options.length;i++){
					if(select.options[i].value==id){
						select.options[i].selected=true;
						select.selectedIndex=i;
					}else{
						select.options[i].selected=false;
					}
				}
			}
		   
// Gallery Hide from Flash...
/*function winGalleryHide () {
	$(".win_gallery").fadeOut(500);
	$("#body_off").slideUp("slow");	
};
*/
// Gallery Hide from Flash...
function winFormFriendHide() {
	$(".win_form_friend").fadeOut(500);
	$("#body_off").slideUp("slow");
};
function winFormFriendHide2() {
	$(".win_form_friend2").fadeOut(500);
	$("#body_off").slideUp("slow");
};
$(document).ready(function() {
	
/* PRO */
	
	//Olvido contraseña
	
		$("#rv_b_send_passw").click(function() {
			$(".send_password").slideToggle(500);
		});

	
	// Modificar reserva
	$(".reserva_mod").click(function () {
		$("#cajetin_mod").slideToggle(300);
		$("#df_rv_info").slideToggle(300);
		return false;
	});
	
	// Win - Ventana idioma
	$("#df_b_lng").click(function () {
		$("#win_lng").slideToggle(300);
		return false;
	});
	
	// Ventana modificar reservas
	$("#df_edit_reserva").click(function () {
		$(".reserva").slideToggle(300);
		$(this).toggleClass("down");
		return false;
	});
	
	// Win - Ventana compartir Top
	$("#df_b_comp").click(function () {
		$("#win_comp").slideToggle(300);
		return false;
	});
	
	// Win - Ventana compartir List
	$(".df_b_comp").click(function () {
		$(this).next(".win_comp").slideToggle(300);
		return false;
	});
	
	// Win - Ventana compartir List
	$("#rv_b_cvc").click(function () {
		$("#win_cvc").slideToggle(300);
		return false;
	});
	
	// Menu desplegable
	$(".itemSup").click(function () {
		//$(".collapsed").slideToggle(300);
		$(this).next(".collCont").slideToggle(300);
		return false;
	});
	
	
	// Rates conditions y mas info
	if ( $("#reservas").length > 0 ) {
		$(".masInfo").click(
			function() {
				$(this).prev(".win").fadeIn(200);	
				return false;
			}	   
		);
	}
	
	// Info Room
	$("p .info_room").click(
		function() {
			$(this).parent().prev(".win").fadeIn(200);
			return false;
		}	   
	);
	
	// RV STEP 2
	// More Info
	$(".more_info").click(
		function() {
			$(this).prevAll(".win").fadeIn(200);
			return false;
		}	   
	);
	
	
	// Ver opciones extras
	$(".extra").change(function () {
		$(".selecTools").toggle();
		return false;
	});
	
	
	// VEr grafica
	$(".df_list_link_grafica").click(function () {
		$(".graficaBlock").slideToggle(300);
		return false;
	});
	
	
	
	// Body OFF
	/*if ( $("#body_off").length > 0 ) {
		$("#body_off").css({'width': $(document).width()});
		$("#body_off").css({'height': $(document).height()});	
	}*/
	// Window Resize...
	// gallery
	/*if ( $(".win_gallery").length > 0 ) {
		$(window).resize(function(){
			var w = $(".win_gallery").width()/2;
			var l = $(window).width()/2-w;
			$(".win_gallery").css({'left': l});
			$("#body_off").css({'width': $(window).width()});
			$("#body_off").css({'height': $(document).height()});
		});
	
		$("#body_off").click(function(){
			$(".win_gallery").fadeOut(500);
			$("#body_off").slideUp("slow");
			//$("select").css('visibility','visible');
		});
	}*/
	
	
	
	
	// Window Resize...
	// send
	if ( $(".win_form_friend").length > 0 ) {
		$(window).resize(function(){
			var w = $(".win_form_friend").width()/2;
			var l = $(window).width()/2-w;
			$(".win_form_friend").css({'left': l});
			$("#body_off").css({'width': $(window).width()});
			$("#body_off").css({'height': $(document).height()});
			
		});
		$("#body_off").click(function(){
			$(".win_form_friend").fadeOut(500);
			$("#body_off").slideUp("slow");
		});
	}
	
	// loading
	if ( $("#win_loading").length > 0 ) {
		$(window).resize(function(){
			$("#body_off").css({'width': $(window).width()});
			$("#body_off").css({'height': $(document).height()});
		});
	}
	
	// Cerrar las ventanas
	$(".win .close").click(
		function() {
			$(this).parent().parent(".win").fadeOut(150);
			return false;
		}
	);
	// Cerrar la ventana send friend
	$(".win win_form_friend .close").click(
		 function () { 
			winFormFriendHide();
		  }
	);
	// Cerrar la ventana send friend
	$(".win_form_friend2 .close").click(
		 function () { 
			winFormFriendHide2();
		  }
	);
	
	// RV STEP 3
	$("#rv_b_send_passw").toggle(
	  function () { 
		$(".send_password").slideDown(500);
		return false;
	  },
	  function () {		  
		$(".send_password").hide();
		return false;
	  }
	);
	
	// RV GALLERY LISTADO
	/*$(".df_list_link_gallery").click(function () {
		 $("html").animate({ scrollTop: 0 }, "slow");
		var t = $(this).position();
		var w = $(".win_gallery").width()/2;
		var l = $(window).width()/2-w;
		if(t.top < 400){
			  $(".win_gallery").css({'top' : t.top-250 });
		}else {
			  $(".win_gallery").css({'top' : t.top-400 });
		}
		$(".win_gallery").css({'left': l});
		$(".win_gallery").fadeIn(500);
		$("#body_off").slideDown("slow");
		return false;
	});
	// RV GALLERY HOTEL
	$(".df_link_gallery").click(function () {
		 $("html").animate({ scrollTop: 0 }, "slow");
		var t = $(this).position();
		var w = $(".win_gallery").width()/2;
		var l = $(window).width()/2-w;
		if(t.top < 400){
			  $(".win_gallery").css({'top' : t.top-250 });
		}else {
			  $(".win_gallery").css({'top' : t.top-400 });
		}
		$(".win_gallery").css({'left': l});
		$(".win_gallery").fadeIn(500);
		$("#body_off").slideDown("slow");
		return false;
	});*/
	// SEND FRIEND HOTEL
	$(".df_sendFriend").click(function () {
		$("#body_off").slideDown("slow");
		 $("html").animate({ scrollTop: 0 }, "slow");

		var t = $(this).position();
		var w = $(".win_form_friend").width()/2;
		var l = $(window).width()/2-w;
		if(t.top < 400){
			  $(".win_form_friend").css({'top' : t.top-250 });
		}else {
			  $(".win_form_friend").css({'top' : t.top-400 });
		}
		$(".win_form_friend").css({'left': l});
		$(".win_form_friend").fadeIn(500);
		
		return false;
	});

	$("#rv_b1-1-nodisp").click(function () {
		$("#calendars").slideDown(500);
		$("#other_hotels").slideDown(500);
		return false;
	});	
	
	
	function getAbsolutePath() {
		var loc = window.location;
		var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);
		return loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));
	}
	
	$("ul#menu .collapsed li a").click(function () {
		var alink = $(this).attr('href');
		var baseUrl = getAbsolutePath();
		location.href = baseUrl+alink;
		return false;
	});	
	
	
	//RV VER MAPA
	/*$(".vermapa").click(function () {
		$("#mapa").slideToggle(500);
		return false;
	});	
	$("#mapa .close").click(function () {
		$("#mapa").slideToggle(500);
		return false;
	});	*/

	$("#vermaparv").click(function () {
		$("#map").slideToggle(500);
		return false;
	});	
	
	
	/* SLIDESHOW */

	jQuery(function($) {
	var timer;
	function button1_click(event)
	{
		$(".slide").css("visibility","hidden");
		$("#image1").css("visibility","visible");
		$("#image1").css("opacity","0");
		$("#image1").animate({"opacity":1},300, "linear", null);
		$("ul.buttons li").removeClass("active");
		$("#image1").animate({"opacity":1},300, "linear", null);
		$("#button1").addClass("active");
		clearTimeout(timer);
		timer = setTimeout(eval("button2_click"),"5000");
		$("#image1").animate({"opacity":1},300, "linear", null);
	}
	
	function button2_click(event)
	{
		$(".slide").css("visibility","hidden");
		$("#image2").css("visibility","visible");
		$("#image2").css("opacity","0");
		$("#image2").animate({"opacity":1},300, "linear", null);
		$("ul.buttons li").removeClass("active");
		$("#image2").animate({"opacity":1},300, "linear", null);
		$("#button2").addClass("active");
		clearTimeout(timer);
		timer = setTimeout(eval("button3_click"),"5000");
		$("#image2").animate({"opacity":1},300, "linear", null);
	}
	
	function button3_click(event)
	{
		$(".slide").css("visibility","hidden");
		$("#image3").css("visibility","visible");
		$("#image3").css("opacity","0");
		$("#image3").animate({"opacity":1},300, "linear", null);
		$("ul.buttons li").removeClass("active");
		$("#image3").animate({"opacity":1},300, "linear", null);
		$("#button3").addClass("active");
		clearTimeout(timer);
		timer = setTimeout(eval("button4_click"),"5000");
		$("#image3").animate({"opacity":1},300, "linear", null);
	}
	
	function button4_click(event)
	{
		$(".slide").css("visibility","hidden");
		$("#image4").css("visibility","visible");
		$("#image4").css("opacity","0");
		$("#image4").animate({"opacity":1},300, "linear", null);
		$("ul.buttons li").removeClass("active");
		$("#image4").animate({"opacity":1},300, "linear", null);
		$("#button4").addClass("active");
		clearTimeout(timer);
		timer = setTimeout(eval("button5_click"),"5000");
		$("#image4").animate({"opacity":1},300, "linear", null);
	}
	
	function button5_click(event)
	{
		$(".slide").css("visibility","hidden");
		$("#image5").css("visibility","visible");
		$("#image5").css("opacity","0");
		$("#image5").animate({"opacity":1},300, "linear", null);
		$("ul.buttons li").removeClass("active");
		$("#image5").animate({"opacity":1},300, "linear", null);
		$("#button5").addClass("active");
		clearTimeout(timer);
		timer = setTimeout(eval("button1_click"),"5000");
		$("#image5").animate({"opacity":1},300, "linear", null);
	}
	
	function OnLoad(event)
	{
		clearTimeout(timer);
		timer = setTimeout(eval("button2_click"),"5000");
	}
	
	$('#button1').bind('click', button1_click);
	
	$('#button2').bind('click', button2_click);
	
	$('#button3').bind('click', button3_click);
	
	$('#button4').bind('click', button4_click);
	
	$('#button5').bind('click', button5_click);
	
	OnLoad();
	
	});
	
	$("#grupos-eventos #alpha .datepicker").datepicker({
		showOtherMonths: true,
		showOn: 'button',
		buttonImage: '/i/df_ico_calendar1.gif',
		buttonImageOnly: true,
		regional:'es',
		showAnim: "slideDown"
	});
	
	
	$(".breakdown .datepicker").datepicker({
		showOtherMonths: true,
		showOn: 'button',
		buttonImage: '/i/df_ico_calendar1.gif',
		buttonImageOnly: true,
		regional:'es',
		showAnim: "slideDown"
	});
	
	$("input[name='tipo_user']").change(function(){
		if ($("input[name='tipo_user']:checked").val() == '0'){
			$("#u_no_registrado").css('display','none');
			$("#u_registrado").css('display','block');
			$("#u_nuevoreg").css('display','none');
		}else if ($("input[name='tipo_user']:checked").val() == '1'){
			$("#u_no_registrado").css('display','none');
			$("#u_registrado").css('display','none');
			$("#u_nuevoreg").css('display','none');
		}else{
			$("#u_no_registrado").css('display','none');
			$("#u_registrado").css('display','none');
			$("#u_nuevoreg").css('display','block');
		}
	});
	
	// WIDNOWS RESIZE
	$(window).resize(function(){
		// Body OFF
		if ( $("#body_off").length > 0 ) {
			$("#body_off").css({'width': $(window).width()});
			$("#body_off").css({'height': $(document).height()});	
		}
	});
	
	//SLIDESHOW
	if ( $("#slideshow .slides").length > 0 ) {
		$('#slideshow').slides({
			container: 'slides',
			paginationClass: 'buttons',
			generateNextPrev: false,
			effect: 'fade',
			crossfade: true,
			preload: true,
			preloadImage: '/i/df_loading1.gif',
			play: 5000,
			pause: 2500,
			hoverPause: true
		});
	}		
	//Init
	// Body OFF
	if ( $("#body_off").length > 0 ) {
		$("#body_off").css({'width': $(window).width()});
		$("#body_off").css({'height': $(document).height()});	
	}
	//Gallery

	
	
	try{
	
	// NEW GALLERY
	// Centra en la pagina el div
	$('.win_gallery').css({'top': $(window).height()/2-305});
	$(window).resize(function(){
	$('.win_gallery').css({'top': $(window).height()/2-305});
	});
	
	$('.win_gallery').css({'left': $(window).width()/2-450});
	$(window).resize(function(){
	$('.win_gallery').css({'left': $(window).width()/2-450});
	});
	
	
	/*var name = ".win_gallery";  
	var menuYloc = null;  
		menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))  
			$(window).scroll(function () {  
			 var offset = menuYloc+$(document).scrollTop()+"px";  
			$(name).animate({top:offset},{duration:300,queue:false});  
			});  
	*/
	$('.df_b_gallery1').click(function(){
		$(".win_gallery").fadeIn(500);
		$("#body_off").slideDown("slow");
	});
	$("#body_off").click(function(){
		$(".win_gallery").fadeOut(500);
		$("#body_off").slideUp("slow");
	});
	$(".win_gallery .close").click(
		function() {
			$(this).parent().fadeOut(150);
			$("#body_off").slideUp("slow");
			return false;
		}
	);
	} catch(err)
	  {
		  //Handle errors here
		  }
});
