$(function(){

// vertially align bc_inner menu buttons
	$('.bc_inner .hot_mod.first').each(function(){
	var	innerItem = $(this).find('.hm_inner'),
		moreButton = $(this).find('a.more_btn'),
		itemHeight = innerItem.height() + parseInt(innerItem.css('paddingBottom')),
		buttonHeight = moreButton.outerHeight();
		moreButton.css({'top':Math.floor((itemHeight-buttonHeight)/2) + 'px'});
	});

// font-replacement (cufon)
	Cufon.replace('.btm_content .cufo');
	Cufon.replace('.btm_content .cufon');
	Cufon.replace('.form_description h2',{'fontSize':'30px'});
	Cufon.replace('.price',{fontSize:'60px'});

	$('.btm_content .cufo').show();
	$('.btm_content .cufon').show();
	$('.form_description h2').show();
	$('.price').show();


// main menu
	$('#global-menubar li:hover .submenu').css({display: 'none'})
	$('#global-menubar li').mouseenter(function(){
		$(this).children('.submenu').stop(true, true).fadeIn('fast');
		$(this).addClass('on');
	}).mouseleave(function(){
		$(this).children('.submenu').stop(true, true).fadeOut('fast');
		$(this).removeClass('on');
	});
	$('#global-menubar .submenu').css({
		opacity: '0.9'
	});

//map overlay

          $(".mid_nav a[rel]").overlay({ 
               'expose':'#f1f1f1', 
               'onLoad':function(){
			initializeGoogleMap()
			setTimeout(function(){$('.map-controls').slideDown();}, 1000)
		}
          });


// display the find hotels/apartments
	if($('form[name=find_hotels]').length > 0){
		$('form[name=find_hotels]').get(0).reset();
	}
    if($.browser.msie && Number($.browser.version) == 7) {
		$('.find_hotels').animate({'width':'690px'}, 5000, function(){
			$(this).find('#find_hotels').change(function() {
				location.href = $(this).val();
			});
		});
	} else {
		
		$('.find_hotels').css('opacity', 0).animate({'opacity':1,'width':'690px'}, 5000, function(){
			$(this).find('#find_hotels').change(function() {
				location.href = $(this).val();
			});
		});
	}

// datepicker 
	Date.firstDayOfWeek = 1;
	Date.format = 'dd/mm/yyyy';
	$('.resdatepicker').change(function(){
	DateArray = ($(this).val()).split('/');
		$('input[name=dateIn]').val(DateArray[1]+'/'+DateArray[0]+'/'+DateArray[2]);
	}).datePicker({clickInput:true}).val(new Date().asString()).trigger('change');


// font effects - outline, shadow
/*
	$(".popup h2").FontEffect({
		outline: true,
			outlineColor1   :"#666"
		//	shadow :true,
		//	shadowColor      :"#333", // The color of the shadow
		//	shadowOffsetTop  :1,      // The top offset position (px)
		//	shadowOffsetLeft :1      // The left offset position (px)
		//	shadowBlur       :1     // The shadow blur 1=none,2=low,3=high
		//	shadowOpacity    :0.1     // The opacity of the shadow (0=none,1=all)

	});
*/
// left scrollable items
$(".side_specials").scrollable({
	clickable:false,
	vertical: false,
	size: 1,
	speed:400,
	loop: true,
	items:".s_items"
}).navigator({
	 navi:'.s_navi',
	 activeClass:"on"
}).autoscroll({
	interval:7000
});


// custom selects
// custom select elements
//chrome agent detect:
var userAgent = navigator.userAgent.toLowerCase();
chr = /chrome/.test( userAgent );
	   if(!chr){$(".reservations_module select").selectbox();}
	$("#reserveForm").validate();

// hp specials info
	$('.image_area .popup .close').click(function(){
		if($(this).parent().hasClass('expanded')) {
			$(this).parent().animate({right: '-417px'}, 500, function() {
				$(this).removeClass('expanded');
			});
		} else {
			$(this).parent().animate({right: '0px'}, 500, function() {
				$(this).addClass('expanded');
			});
		}
	})
});
