$(document).ready(function () {

	// WRAPPER HEIGHT
	var LWH = $('#left_wrapper').outerHeight();
	var RWH = $('#right_wrapper').outerHeight() - 100;
	if(LWH < (RWH)){
		$("#main_wrapper").css("height", RWH);
	};

	// STYLE SELECT
	$('.my-dropdown').sSelect({ddMaxHeight: '90px'});

	// SLIDESHOW
	$('#slideshow').cycle();

	// GALLERY
	$('a[rel=group]').fancybox();

	// HIGHLIGHT
	$('#highlight').cycle({
		next:'#nexthighlight',
		prev:'#prevhighlight'
	});

	// LANGUAGE MENU - DROPDOWN
	$('#language_menu span').click(function(){
		$('#language_menu ul').slideToggle();
	});

	// BOOKING FORM - IATA CODE - remove label over input
	$('#bf span#txt_accesscode').click(function(){
		$('#bf span#txt_accesscode').hide();
	});

	// CREDITS LINK - redirect to external page
	$("#footer_menu li a.cat_8").click( function(e){
		e.preventDefault();
		window.open('http://www.fastbooking.net/');
	});

	// LIST ITEM (OFFER)
	urlParams = decodeURI( window.location.search.substring(4) );
	if((urlParams != false | urlParams != '') && parseInt(urlParams)){
		$('#itemlist-id'+urlParams+' a.showmore').hide();
		$('#itemlist-id'+urlParams+' .service').show();
		$('#itemlist-id'+urlParams+' .text.full').show();
		$('#itemlist-id'+urlParams+' .list_textwrap').animate({width: 470}, 2000);
		$('#itemlist-id'+urlParams+' img.thumb').animate({width: 230}, 2000);
		var LWH = $('#left_wrapper').outerHeight();
		var RWH = $('#right_wrapper').outerHeight() - 100;
		if(LWH < (RWH)){$("#main_wrapper").css("height", RWH)}; // ricalcolo l'altezza della colonna di destra
	};
	$('#items_list a.showmore').click(function(e){
		e.preventDefault();
		var itemlistID = $(this).attr('id').replace("linkitemlistid-", "");
		$(this).hide();
		$('#itemlist-id'+itemlistID+' .service').show();
		$('#itemlist-id'+itemlistID+' .closebtn').show();
		$('#itemlist-id'+itemlistID+' .text.full').show();
		$('#itemlist-id'+itemlistID+' .list_textwrap').animate({width: 470}, 2000);
		$('#itemlist-id'+itemlistID+' img.thumb').animate({width: 230}, 2000);
		var LWH = $('#left_wrapper').outerHeight();
		var RWH = $('#right_wrapper').outerHeight() - 100;
		if(LWH < (RWH)){$("#main_wrapper").css("height", RWH)}; // ricalcolo l'altezza della colonna di destra
	});
	$('#items_list div.closebtn a').click(function(e){
		e.preventDefault();
		var itemlistID = $(this).parent().attr('id').replace("closeitemlistid-", "");
		$(this).parent().hide();
		$('#itemlist-id'+itemlistID+' a.showmore').show();
		$('#itemlist-id'+itemlistID+' .service').hide();
		$('#itemlist-id'+itemlistID+' .text.full').hide();
		$('#itemlist-id'+itemlistID+' .list_textwrap').animate({width: 520}, 2000);
		$('#itemlist-id'+itemlistID+' img.thumb').animate({width: 180}, 2000);
		var LWH = $('#left_wrapper').outerHeight();
		var RWH = $('#right_wrapper').outerHeight() - 100;
		if(LWH < (RWH)){$("#main_wrapper").css("height", RWH)}; // ricalcolo l'altezza della colonna di destra
	});


}); // close document.ready


// GOOGLE MAP
function initialize() {

	var locations = [
		['<div style="width:250px;height:140px"><b>Scheppers Hotel</b><br /><br />Via Bogliasco 36<br />00165 Roma - Italy<br />Tel. +39 (0)6 66019053/54/19<br />Fax +39 (0)6 66414220<br /><a style="color:#0000AA;" href="mailto:info@scheppershotel.it">info@scheppershotel.it</a><br /><br /><h2><a href="javascript:;" onclick="hhotelDispopriceFHP(\'ITROMScheppershtl\', \'\', \'\', \'\', \'\', \'\', \'\', \'\');">Book now!</a></h2></div>', 41.888897, 12.399937, 2]
	];

	var map = new google.maps.Map(document.getElementById('map_canvas'), {
		zoom: 13,
		center: new google.maps.LatLng(41.906065, 12.399259),
		mapTypeId: google.maps.MapTypeId.ROADMAP
	});

	var infowindow = new google.maps.InfoWindow({
		'maxWidth': 500
	});

	var marker, i;

	for (i = 0; i < locations.length; i++) {
		marker = new google.maps.Marker({
			position: new google.maps.LatLng(locations[i][1], locations[i][2]),
			map: map
		});
		
		infowindow.setContent(locations[i][0]);
		infowindow.open(map,marker);
		google.maps.event.addListener(marker, 'click', (function(marker, i) {
			return function() {
				infowindow.setContent(locations[i][0]);
				infowindow.open(map, marker);
			}
		})(marker, i));
	};
}

$(window).load( function() {
	if($('#map_canvas').length > 0){
		initialize();
	}
}); // close window.load
