


// 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");
};
	
$(document).ready(function() {
	
	// 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
	$("#df_b_comp").click(function () {
		$("#win_comp").slideToggle(300);
		return false;
	});
	
	
	// Menu desplegable
	$("#itemSup").click(function () {
		//$(".collapsed").slideToggle(300);
		$(this).next(".collCont").slideToggle(300);
		return false;
	});
	
	
	// Rates conditions y mas info
	$(".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");
		});
	}
	
	
	// 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_form_friend .close").click(
		 function () { 
			winFormFriendHide();
		  }
	);
	
	// 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 () {
		 $("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' : 140 });
		}else {
			  $(".win_form_friend").css({'top' : 140 });
		}
		$(".win_form_friend").css({'left': 440});
		$(".win_form_friend").fadeIn(500);
		$("#body_off").slideDown("slow");
		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;
	});	*/
	
	/* Colorbox - Videos */

	//$(".youtube").colorbox({iframe:true, innerWidth:425, innerHeight:344});
	
	/*
	 * $("#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"
	});
	*/
});
