function initTabs() {
	$(".tab_content").hide(); //Hide all content
	if(location.hash != "") {
		var target = location.hash.split("#")[1];
		$(location.hash).show(); //Show first tab content
		$("ul.tabs li:has(a[href=#"+target+"])").addClass("active").show();
		
	} else {
		$("ul.tabs li:first").addClass("active").show(); //Activate first tab
		$(".tab_content:first").show(); //Show first tab content
		
		//children
		$(".tab_container-children li:first").addClass("active").show(); //Activate first child tab
		$(".tab_container-children .tab_content:first").show(); //Show first child tab content
	}
	
	//On Click Event
	$("ul.tabs li").click(function(e) {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		
		//children
		$(activeTab).find('li:first').addClass("active"); //Add "active" class to selected tab
		var activeTabChild = $(activeTab).find("a").attr("href"); //Show first tab content
		$(activeTabChild).show(); //Fade in the active content
		
		$(activeTab).fadeIn(); //Fade in the active content
		
		e.preventDefault();
	});
}

function initTabsChild() {
	$(".tab_container-children .tab_content").hide(); //Hide all content
	if(location.hash != "") {
		var target = location.hash.split("#")[1];
		$(location.hash).show(); //Show first tab content
		$("ul.tabs-children li:has(a[href=#"+target+"])").addClass("active").show();
	} else {
		$("ul.tabs-children li:first").addClass("active").show(); //Activate first tab
		$(".tab_container-children .tab_content:first").show(); //Show first tab content
	}
	
	//On Click Event
	$("ul.tabs-children li").click(function(e) {
		$("ul.tabs-children li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_container-children .tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		e.preventDefault();
	});
}

$(document).ready(function() {
	
	initTabs();
	initTabsChild();
	
	$('.mainnav li:last-child').addClass('last');
	$('.footernav li:last-child a').css({'background':'none'});
	$('.tblrates tr:odd, .tblrates2 tr:odd').addClass('odd');
			
	$(".gallery").carouFredSel({
			circular	: false,
			infinite	: false,
			auto 		: false,
			width: 670,
			height: 750,
			items: 1,
			prev : {
				button		: "#photogallery_prev",
				key		: "left",
				items		: 1
	
			},
			next : {
				button		: "#photogallery_next",
				key		: "right",
				items		: 1
			},
			pagination : {
				container	: "#photogallery_paging",
				keys		: true
			}
	});
		
		$("a[rel=gallery]").fancybox({
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'autoScale'	: false,
			'hideOnContentClick' : true,
			'overlayShow' : true,
			'overlayOpacity' : 0.9,
			'overlayColor' : '#000'
		});
		$("a.floorplan").fancybox({
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'autoScale'	: false,
			'hideOnContentClick' : true,
			'overlayShow' : true,
			'overlayOpacity' : 0.9,
			'overlayColor' : '#000',
			'width' : 750,
			'height' : 470,
			'type' : 'iframe'
		});
		
		$('#arrivaldate').DatePicker({
			mode: 'single',
			format:'d-m-Y',
			date: $('#arrivaldate').val(),
			current: $('#arrivaldate').val(),
			starts: 1,
			position: 'r',
			onChange: function(formated, dates){
				$('#arrivaldate').val(formated);
				$('#arrivaldate').DatePickerHide();
			}
		});
		$('#departuredate').DatePicker({
			mode: 'single',
			format:'d-m-Y',
			date: $('#departuredate').val(),
			current: $('#departuredate').val(),
			starts: 1,
			position: 'r',
			onChange: function(formated, dates){
				$('#departuredate').val(formated);
				$('#departuredate').DatePickerHide();
			}
		});
		
		$("ul.mainnav").superfish({hoverClass:'sfHover', pathClass:'active', pathLevels:0, delay:800, animation:{opacity:'show'}, speed:'def', autoArrows:1, dropShadows:1})
		jQuery.event.special.hover.delay = 100;
		jQuery.event.special.hover.speed = 100;
		
		//page peel corner
		$("#pageflip").hover(function() {
		$("#pageflip img , .msg_block").stop()
			.animate({
				width: '188px', 
				height: '200px'
			}, 500); 
		} , function() {
		$("#pageflip img").stop() 
			.animate({
				width: '127px', 
				height: '133px'
			}, 220);
		$(".msg_block").stop() 
			.animate({
				width: '125px', 
				height: '127px'
			}, 200);
	});
		
		$('#slideshow').jqFancyTransitions({ 
			width: 900, 
			height: 430, 
			effect: 'curtain', 
			position: 'alternate', 
			direction: 'fountainAlternate' 
		});
		
		
});

