$(document).ready(function(){

		$(".tool-tip-upsell").hide();
		$('.cambiar-habitacion').click(function() {
			  $('.tool-tip-upsell').fadeIn();
				return false;
			});
			$('tool-tip-upsell .btn-cerrar').click(function() {
			  $('.tool-tip-upsell').fadeOut();
				return false;
			});

		$(".tool-tip-motor").hide();
		$('.nueva-busqueda').click(function() {
			  $('.tool-tip-motor').fadeIn();
				return false;
			});
			$('tool-tip-motor .btn-cerrar').click(function() {
			  $('.tool-tip-motor').fadeOut();
				return false;
			});
			
		$(".tool-tip-incluye").hide();
			$(' .btn-que-incluye').click(function() {
			  $(this).parent().parent().find('.tool-tip-incluye').fadeIn();
				return false;
			});
			$(' .tool-tip-incluye .btn-cerrar').click(function() {
			  $(this).parent().parent().find('.tool-tip-incluye').hide();
				return false;
			});
		
		$(".tool-tip-info-hotel").hide();
			$(' .ver-hotel').click(function() {
			  $(this).parent().parent().find('.tool-tip-info-hotel').fadeIn();
				return false;
			});
			$(' .tool-tip-incluye .btn_cerrar').click(function() {
			  $(this).parent().parent().find('.tool-tip-info-hotel').hide();
				return false;
			});

	/* Funcion que permite la seleccion de pais */

		$("#pais ul").addClass("min");

		$("#pais ul").wrap('<div class="ccbx"></div>');

		$("#pais ul").parent().css({'position':'relative','height':'20px','zIndex':'50'});

		$("#pais ul").css({'position':'absolute','overflow':'hidden','height':'20px','zIndex':'51','display':'block'});

		$("#pais ul").after('<input type="hidden" name="country" id="country" value=""/>');

		$("#pais ul").find(":first").attr('id','flag');

		

		$("#pais ul").click(function(){

				if( $(this).hasClass('min')){

					$(this).removeClass("min");

					$(this).animate({height:'130px'},300);

				}else{

					$(this).addClass("min");

					$(this).animate({height:'20px'},100);

				}

			});	

			$("#pais ul").mouseleave(function(){

				$(this).animate({height:'20px'},100);

				$(this).addClass("min");

			});

			$("#pais ul").find("li a").click(function(){

				var deep = $(this).attr("href");

				var flag = $(this).attr("class");

				$(this).parent().parent().animate({height:'20px'},100);

				$(this).parent().parent().find("#flag").removeClass();

				$(this).parent().parent().find("#flag").addClass(flag);

				$("#country").val(deep);

				$(this).parent().parent().addClass("min");

				return false;

			});

			$('.ciudad').hover(function() {

			  $(this).find('.info-oferta').animate({

				left: '0'

			  }, 500, function() {

			  });

			},function() {

			  $(this).find('.info-oferta').animate({

				left: '-115'

			  }, 500, function() {

			  });

			});

			

			

			//Login

			$("#header .login-RICARDO").hide();

			$('#header .btn-ingresa-RICARDO').click(function() {

			  $(this).parent().parent().find('.login-RICARDO').fadeIn();

				return false;

			});

			$('#header .login-RICARDO .cerrar').click(function() {

			  $(this).parent().parent().find('.login-RICARDO').hide();

				return false;

			});

			

			

			$(".tool-tip-info-hotel").hide();

			$('.nombre a').click(function() {

				 $(".tool-tip-info-hotel").hide();

			  $(this).parent().parent().find('.tool-tip-info-hotel').fadeIn();

				return false;

			});

			/*$('td strong a').click(function() {

				 $(".tool-tip-info-hotel").hide();

			  $(this).parent().parent().find('.tool-tip-info-hotel').fadeIn();

				return false;

			});*/

			$('.btn_cerrar').click(function() {

			$(".tool-tip-info-hotel").hide();

				return false;

			});

			

			$('.oferta').hover(function() {

			  $(this).find('.info-oferta').animate({

				left: '0'

			  }, 500, function() {

			  });

			},function() {

			  $(this).find('.info-oferta').animate({

				left: '-115'

			  }, 500, function() {

			  });

			});

			

			$(".tool-tip-precio").hide();

			$('.precio .price').hover(function() {

			  $(this).parent().find('.tool-tip-precio').show();

			},function() {

			  $(this).parent().find('.tool-tip-precio').hide();

			});

			

			$(".tool-tip-incluye").hide();

			$('.precio .btn-que-incluye').click(function() {

			  $(this).parent().parent().find('.tool-tip-incluye').fadeIn();

				return false;

			});

			$('.precio .tool-tip-incluye .btn-cerrar').click(function() {

			  $(this).parent().parent().find('.tool-tip-incluye').hide();

				return false;

			});

			

			$(".tool-tip-itinerario").hide();

			$('.duracion .btn-itinerario').click(function() {

			  $(this).parent().parent().find('.tool-tip-itinerario').fadeIn();

				return false;

			});

			$('.tool-tip-itinerario .btn-cerrar').click(function() {

			  $(this).parent().parent().parent().find('.tool-tip-itinerario').hide();

				return false;

			});

			

			$(".tool-tip-texto").hide();

			$('.mas').click(function() {

			  $(this).parent().parent().find('.tool-tip-texto').fadeIn();

				return false;

			});

			$('.tool-tip-texto .btn-cerrar').click(function() {

			  $(this).parent().parent().parent().find('.tool-tip-texto').hide();

				return false;

			});

			

			$(".tool-tip-vuelo").hide();

			$('.tabla input').focus(function() {

				$(".tool-tip-vuelo").hide();

			  $(this).parent().find('.tool-tip-vuelo').fadeIn();			

			},function() {

			  $(this).parent().find('.tool-tip-vuelo').hide();

			});

			

			$(".hoteles-mundo").show();

			$('.radio_mun').click(function() {

				 $(".hoteles-mundo").show();

				 $(".hoteles-chile").hide();

			});

			$('.radio_chi').click(function() {

				 $(".hoteles-mundo").hide();

				 $(".hoteles-chile").show();

			});

			$(".hoteles-chile").hide();

			

			$("#con-reserva").hide();

			$('.btn_quebuscas').click(function() {

			$(this).addClass("activo");

			 $(".btn-reserva").removeClass("activo");

			 $("#con-reserva").hide();

			 $("#con-quebuscas").show();

			 return false;

			});

			$('.btn-reserva').click(function() {

				$(this).addClass("activo");

			 $(".btn_quebuscas").removeClass("activo");

			 $("#con-quebuscas").hide();

			 $("#con-reserva").show();

			 return false;

			});



			$(".sidebar").scrollable({

				items: ".franja",

				item: ".item",

				loop: true,

				size: 1,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage",

				prevPage: ".prevPage",

				speed:800

		}).circular().navigator({

				navi:".pages-highlights",

				indexed:true
				}).autoscroll({ 
				autoplay: true, interval: 10000 
			});

			$(".foto-seleccion").scrollable({

				items: ".franja",

				item: "img",

				loop: true,

				size: 1,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage",

				prevPage: ".prevPage",

				speed:700

			});

			

			$(".ingles").scrollable({

				items: ".franja",

				item: ".pais",

				loop: true,

				size: 2,

				clickable:false,

				keyboard:false,

				nextPage: ".btn-siguiente",

				prevPage: ".btn-anterior",

				speed:700

			});

			

			$(".jovenes").scrollable({

				items: ".franja-j",

				item: "a",

				loop: true,

				size: 1,

				clickable:false,

				keyboard:false,

				nextPage: ".btn-siguiente-j",

				prevPage: ".btn-anterior-j",

				speed:700

			});



			$("#baratas").scrollable({

				items: ".franja",

				item: ".oferta",

				loop: true,

				size: 2,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage-oferta",

				prevPage: ".prevPage-oferta",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			

			$(".mas-paquetes").scrollable({

				items: ".franja",

				item: ".destino",

				loop: true,

				size: 4,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage-oferta",

				prevPage: ".prevPage-oferta",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			

			$(".paquetes-verano").scrollable({

				items: ".franja",

				item: ".destino",

				loop: true,

				size: 3,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage-oferta",

				prevPage: ".prevPage-oferta",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			

			$(".mas-hoteles").scrollable({

				items: ".franja",

				item: ".pag",

				loop: true,

				size: 1,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage",

				prevPage: ".prevPage",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			

			$(".vuelos-varios.vuelos").scrollable({

				items: ".franja.vuelos",

				item: ".item.vuelos",

				loop: true,

				size: 3,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage.vuelos",

				prevPage: ".prevPage.vuelos",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			

			$(".vuelos-varios.hotel").scrollable({

				items: ".franja.hotel",

				item: ".item.hotel",

				loop: true,

				size: 3,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage.hotel",

				prevPage: ".prevPage.hotel",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			

			$(".vuelos-varios.paquete").scrollable({

				items: ".franja.paquete",

				item: ".item.paquete",

				loop: true,

				size: 3,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage.paquete",

				prevPage: ".prevPage.paquete",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			

			$(".vuelos-varios.actividad").scrollable({

				items: ".franja.actividad",

				item: ".item.actividad",

				loop: true,

				size: 3,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage.actividad",

				prevPage: ".prevPage.actividad",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			

			$(".varios-cruceros").scrollable({

				items: ".franja",

				item: ".tientate",

				loop: true,

				size: 4,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage-cruceros",

				prevPage: ".prevPage-cruceros",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			

			$(".varios-hoteles").scrollable({

				items: ".franja",

				item: ".tientate",

				loop: true,

				size: 4,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage-hoteles",

				prevPage: ".prevPage-hoteles",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			

			$(".varios-paquetes").scrollable({

				items: ".franja",

				item: ".tientate",

				loop: true,

				size: 2,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage-hoteles",

				prevPage: ".prevPage-hoteles",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			

			$(".dest-cruceros").scrollable({

				items: ".franja",

				item: ".item",

				loop: true,

				size: 1,

				clickable:false,

				keyboard:false,

				nextPage: ".nextPage-destcruceros",

				prevPage: ".prevPage-destcruceros",

				speed:700

			}).circular().navigator({

				navi:".pages-cruceros",

				indexed:true

			});					

			

			$(".varios-cruceros-b ").scrollable({

				items: " .franja-b",

				item: " .tientate-b",

				loop: true,

				size: 4,

				clickable:false,

				keyboard:false,

				nextPage: " .nextPage-cruceros-b",

				prevPage: " .prevPage-cruceros-b",

				speed:700

			}).circular().navigator({

				indexed:true

			});

			// mega drop down

			$(".drop").hide();

			$('li.mega').hover(

				function(){

						$(this).addClass("presion");

						$(this).find('.drop').slideDown(10);

						$(this).find('a').addClass("sel_a");

					},

				function(){

					$(this).removeClass("presion");

					$(this).find('.drop').slideUp(1);

					$(this).find('a').removeClass("sel_a");

					}

			);

			

			

		$("#slider").slider({

			value:100,

			min: 0,

			max: 500,

			step: 50,

			slide: function(event, ui) {

				$("#amount").val('$' + ui.value);

			}

		});

		$("#amount").val('$' + $("#slider").slider("value"));

	

	$(function() { 

    $("ul.tabs").tabs("div.panes > div"); 

	});

	

	$(".ui-slider-handle").append('<input type="text" class="" id="amount" style="border:0; color:#f6931f; font-weight:bold;" />');

	

	$("#menusup .mega").hover(function(){

		$(this).addClass("sel");

	},function(){

		$(this).removeClass("sel");

	});

	

	

	$("#menusup .mega:first").addClass("primero");

	$("#menusup .mega:last").addClass("ultimo");

    

    //AgregarHandlerALosControlesJQueryAutoCompletar("#cFormBusqueda_txtDinOrigen", "ej. Santiago (Chile)");   
    //AgregarHandlerALosControlesJQueryAutoCompletar("#cFormBusqueda_txtDinDestino","ej. Miami (Estados Unidos)");     
    //AgregarHandlerALosControlesJQueryAutoCompletar("#cFormBusqueda_txtOrigen", "ej. Santiago (Chile)");   
    //AgregarHandlerALosControlesJQueryAutoCompletar("#cFormBusqueda_txtDestino","ej. Miami (Estados Unidos)");     
    //AgregarHandlerALosControlesJQueryAutoCompletar("#cFormBusqueda_txtCiudad","ej. Miami (Estados Unidos)");     

 
	AgregarWaterMark("#cFormBusqueda_txtDinOrigen","marcaOrigen");
	AgregarWaterMark("#cFormBusqueda_txtDinDestino","marcaDestino");
	AgregarWaterMark("#cFormBusqueda_txtOrigen","marcaOrigen");
	AgregarWaterMark("#cFormBusqueda_txtDestino","marcaDestino");
	AgregarWaterMark("#cFormBusqueda_txtCiudad","marcaDestino");    





	

});



function AgregarWaterMark(obj,classCss)
{
    AMarca(obj,classCss); 
	$(obj).focus(function() {
        //ChequearMarca($(this));
		QMarca($(this),classCss);
		$(this).show();
    });
    $(obj).blur(function() {
        CMarca($(this),classCss);
    });  	

}
function CMarca(obj, classCss)
{
	if(HayMarca(obj))
		QMarca(obj,classCss);
    else
		AMarca(obj,classCss);       
}
function HayMarca(obj)
{
	var sValor = $(obj).val();
	//alert(sValor);
	return (sValor.length > 0) ;
}
function AMarca(obj,classCss)
{
	$(obj).addClass(classCss);
	$(obj).next().val("0");
}
function QMarca(obj,classCss)
{
	$(obj).removeClass(classCss);	
}




function AgregarHandlerALosControlesJQueryAutoCompletar(obj, textoTitle)

{

    $(obj).attr("title",textoTitle);   

    

    $(obj).focus(function() {

        //ChequearMarca($(this));

		QuitarMarca($(this));

		$(this).show();

    });

    $(obj).keyup(function() {

        ChequearMarca($(this));

    }).keyup();            

    $(obj).blur(function() {

        ChequearMarca($(this));

    });    

}

function ChequearMarca(obj)

{

        if(HayValorLindoYHermoso(obj))

            QuitarMarca(obj);

        else

            AgregarMarca(obj);        

}

function AgregarMarca(obj)

{

        $(obj).addClass('WaterMark');

        var mititulo = $(obj).attr("title");

        //alert(mititulo);

        $(obj).val(mititulo);

        $(obj).next().val("0");

}

function QuitarMarca(obj)

{

        $(obj).removeClass('WaterMark');

        var mititulo = $(obj).attr("title");

        var valorActual = $(obj).val(); 

        valorActual = valorActual.replace(mititulo,"");  

        $(obj).val(valorActual);

        

}



function HayValorLindoYHermoso(obj)

{

        var mititulo = $(obj).attr("title");

        var valorActual = $(obj).val();   

        valorActual = valorActual.replace(mititulo,"");         

        return (valorActual.length > 0) ;

}

