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
	}
	
	//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
		$(activeTab).fadeIn(); //Fade in the active content
		e.preventDefault();
	});
}

var $ = jQuery.noConflict();
$(document).ready(function() {
initTabs();
	$('ul.mainnav > li').addClass('rootitem');
	$('ul.mainnav .sub-menu').hide();
	$('.rootitem.current-menu-item .sub-menu, .rootitem.current-menu-parent .sub-menu').show('fast',function() {
		$('#sub-nav').show();
	});
	
	//pagepeel
	$("#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);
	});
});
$(window).load(function() {
	$('#content  a ').hover(
		function () {
			$(this).animate({opacity:0.5});
		}, 
		function () {
			$(this).animate({opacity:1});
		}
	);
	$('#title-container').append($('.entry-title'));
	$('.full-width-r').prepend($('.entry-title-no-header'));
	$('.entry-title, .entry-title-no-header ').append('<span></span>');
	$(".tblrates tr:nth-child(odd)").addClass("odd");
	$(".gallery").carouFredSel({
		circular	: false,
		infinite	: false,
		auto 		: false,
		width: 900,
		height: 530,
		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' : '#0E2B3F'
	});
	$("a.vr").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'autoScale'	: false,
		'hideOnContentClick' : true,
		'overlayShow' : true,
		'overlayOpacity' : 0.9,
		'overlayColor' : '#0E2B3F',
		'width' : 790,
		'height' : 550,
		'type' : 'iframe'
	});
	$('.wpcf7-text, .captcha-field').wrap('<span class="inputwrap inputwrap-l"><span class="inputwrap inputwrap-r"></span></span>');
		$('#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();
				}
			});
	//$('.navigation li').has('ul').addClass('has-child');
	$("#slideshow img").hide().fadeIn(1000);
	
	$(".frontpage .execphpwidget, #slideshow").nivoSlider({
	effect:'fade',
	pauseTime:4000,
	directionNav:false,
	controlNav:false
	});
	
});
