$(document).ready(function(){

	var devices = ['SymbianOS', 'Series60', 'Symbian/3', 'Series40'];
	var cufonflag = false;
	for(var i = 0; i<devices.length;i++) {
		if(navigator.userAgent.indexOf(devices[i]) != -1) {cufonflag = true;}
	}

	//Cufon
	if(!cufonflag) {
		Cufon.replace('.freplace', {forceHitArea:true});
		for(var i = 1; i < 6; i++) {
			Cufon.replace($('h' + i + '').not('.dontreplace'), {forceHitArea:true});
		}
	}
	//Search
	$(".keywords").focus(function() {
		if (this.value == this.defaultValue) {
			this.value = "";
		}
	}).blur(function() {
		if (! this.value.length) {
			this.value = this.defaultValue;
		}
	});
	//Front page

	if($('.front-slot-1 ul').children().size() > 1){
		$(".front-slot-1").carousel( { loop: true, autoSlide: true, autoSlideInterval: 5000, delayAutoSlide: 2000, effect: "fade", direction: "vertical"} );
	}
	if($('.front-slot-2 ul').children().size() > 1){
		$(".front-slot-2").carousel( { loop: true, autoSlide: true, autoSlideInterval: 5000, delayAutoSlide: 2000, effect: "fade", direction: "vertical"} );
	}
	if($('.front-slot-3 ul').children().size() > 1){
		$(".front-slot-3").carousel( { loop: true, autoSlide: true, autoSlideInterval: 5000, delayAutoSlide: 2000, effect: "fade", direction: "vertical"} );
		$('.slots li').css('display','inline');
	}
	//Section general
	$('.breadcrumb li:first-child').addClass("first-child");
	//Side navigation v. 2
	$('.sidenav-toggle').not('.selected > .sidenav-toggle').hide();
	$('.sidenav-control').not('.parent > .menu-item > .sidenav-control').css('cursor','default');
	$('.selected-menu-item .sidenav-control').not('.parent > .menu-item > .sidenav-control').attr('src', '/files/dextra/img/sidenav-closed-white.png');
	$('.parent > .menu-item > .sidenav-control').toggle(function(){
		if($(this).parent().hasClass('selected-menu-item')){
			$(this).attr('src', '/files/dextra/img/sidenav-open-white.png');
		} else {
			$(this).attr('src', '/files/dextra/img/sidenav-open-gray.png');
		}
		$(this).parent().next('.sidenav-toggle').show('fast');
	},function(){
		if($(this).parent().hasClass('selected-menu-item')){
			$(this).attr('src', '/files/dextra/img/sidenav-closed-white.png');
		} else {
			$(this).attr('src', '/files/dextra/img/sidenav-closed-gray.png');
		}
		$(this).parent().next('.sidenav-toggle').hide('fast');
	});	
	//Pngfix
	if ($.browser.msie && parseFloat($.browser.version) < 7) {
		$('body').css({
			behavior: "url('/files/dextra/js/csshover3.htc')"
		});
		$('.section-lift-wrap div, #main-nav a, .online-booking span').css({
			behavior: "url('/files/dextra/js/iepngfix.htc')"
		});
		$("img:not('#modal img')").each( function () {
			$(this).css({
				behavior: "url('/files/dextra/js/iepngfix.htc')"
			});
		});
	}
	var modHeight = $('#modal').height;
	$("a[rel='modal-booking']").colorbox({transition:"none",width:757, height:modHeight, inline:true, opacity:0.5, href:"#modal"},function(){$("#cboxClose").hide();});	
});
