// JavaScript Document
$(document).ready( function() {

$(".carroussel a").click(function() {
       
        var $new_image = $(this).attr("rel");
        
        $(".image_block img").attr("src",$new_image);
		$(".carroussel a").removeClass("active");
		$(this).addClass("active");
        
    }); 
	
	
	
	$("a#newsletter_link").fancybox({
			'padding' : 0,
			'overlayColor' : '#000',
			'onStart'  : function(){
				$("#fancybox-wrap").addClass("smallbox");
				},
			'onClosed' : function(){
				$("#fancybox-wrap").removeClass("smallbox");
				}
	});
	
	$("a.no_special_offers_link").fancybox({
			'padding' : 0,
			'overlayColor' : '#000',
			'onStart'  : function(){
				$("#fancybox-wrap").addClass("smallbox");
				},
			'onClosed' : function(){
				$("#fancybox-wrap").removeClass("smallbox");
				}
	});
	
	
	$("a#no_reservations_link").fancybox({
			'padding' : 0,
			'overlayColor' : '#000',							 
			'onStart'  : function(){
				$("#fancybox-wrap").addClass("smallbox");
				},
			'onClosed' : function(){
				$("#fancybox-wrap").removeClass("smallbox");
				}
	});
	
	
	$("a.galleries").fancybox({
			'padding' : 20,
			'overlayColor' : '#333',
			'overlayOpacity': 0.9,
			'margin' : 100,
			'scrolling' : 'no',
			'onStart'  : function(){
				$("#fancybox-wrap").addClass("gallerybox");
				},
			'onClosed' : function(){
				$("#fancybox-wrap").removeClass("gallerybox");
				},
			'titleFormat' :  function(title, currentArray, currentIndex, currentOpts) {
				// console.log();
				// console.log($(this));
				// var name = currentOpts.orig.attr('name'); 
				var name = $(currentArray[currentIndex]).attr('name');
                return '<h2>' + title + '</h2><p>' + name + '</p>'; 
				}
	});



});


$(document).ready( function() {
	
	$('.sublinks_block li .text p').hide();
	$('.sublinks_block li .text a.details').hide();
	
	$('.sublinks_block li').hover(
    function()
    {
        $(this).find('.text p').show();
		$(this).find('.text a.details').show();
    },
    function ()
    {
        $(this).find('.text p').hide();
		$(this).find('.text a.details').hide();
    }
  );


})








$(document).ready( function() {
$('input.error').parent().addClass('error');
$('textarea.error').parent().addClass('error');
});

$(document).ready( function() {
	$("SELECT").selectBox();
	
	$('.carroussel li img').hover(
    function()
    {
        $(this).stop().animate({opacity: 1.0}, 200);
    },
    function ()
    {
        $(this).stop().animate({opacity: 0.8}, 200);
    }
  );

	

	
	// Datepicker
$('.datepicker').datepicker( { dateFormat: 'dd/mm/yy',minDate:0 });

$('.reservation_form_container input').clearDefault();	

/*$('.reservation_btn.hover').hover(function(){
$('.reservation_form_container').css("display", "block");	 
},
function(){
$('.reservation_form_container').css("display", "none");
});*/
			
$('.reservation_loader').click(function(){
$('.reservation_form_container').toggle();
})
			
});	

$(window).load(function() {
    $('#slider').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:500, // Slide transition speed
        pauseTime:3000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:false, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:false, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
	
	
	
	
	/*function formatTitle(title, currentArray, currentIndex, currentOpts) { 
				var name = currentOpts.orig.attr('name'); 
                return '<h2>' + title + '</h2><p>' + name + '</p>'; 
        } */
	
	
	
		$(function() {
	
			$.simpleWeather({
				location: 'beirut, lebanon',
				unit: 'c',
				success: function(weather) {
					
					html = weather.temp+'&deg; '+weather.units.temp;
					
					
					$("#currentWeather").html(html);
					$("#weatherImg").attr("src", 'images/weather/'+weather.code+'.png');
					$("#weatherImg").width(50);
					$("#weatherImg").css("display" , "block");
					$("#weatherLocation").html(weather.city);
					
				},
				error: function(error) {
					$("#currentWeather").html('error');
				}
			});
	
	
})
	
});

(function($){
	$.fn.clearDefault = function(){
		return this.each(function(){
			var default_value = $(this).val();
			$(this).focus(function(){
				if ($(this).val() == default_value) $(this).val("");
			});
			$(this).blur(function(){
				if ($(this).val() == "") $(this).val(default_value);
			});
		});
	};
})(jQuery);

