$(document).pngie();

var safeInfoWindow=function(options){var defaults,o,myDebug,infowindow,dcss,dhtml,w,h,html;defaults={DrawingCanvasID:"safeInfoWindowDrawingCanvasDiv",content:"",disableAutoPan:false,maxWidth:300};myDebug=function(o){if((typeof(window.console)!=='undefined')&&(typeof(window.console.log)!=='undefined')){window.console.log(o);}};if((typeof(jQuery)==='undefined')){myDebug('safeInfowindow: ERROR: jQuery not found. Returning null.');return null;}
if((typeof(google)==='undefined')||(typeof(google.maps)==='undefined')||(typeof(google.maps.InfoWindow)==='undefined')){myDebug('safeInfowindow: ERROR: Google Maps API not found. Returning null.');return null;}
o={};jQuery.extend(o,defaults,options);if(jQuery('#'+o.DrawingCanvasID).length===0)
{dcss="<style type='text/css'>\n#"+o.DrawingCanvasID+" {height: 0 !important; overflow: visible !important; position: absolute !important; top: -9999px !important; left:-9999px !important;}\n#"+o.DrawingCanvasID+" ."+o.DrawingCanvasID+"_content {overflow: auto !important; display: block !important; float:left !important; border:none !important; margin: 0 !important; padding: 0 !important;}\n."+o.DrawingCanvasID+"_clearfix:after { visibility: hidden; display: block; font-size: 0; content: \" \"; clear: both; height: 0; }\n* html ."+o.DrawingCanvasID+"_clearfix { zoom: 1; } \n*:first-child+html ."+o.DrawingCanvasID+"_clearfix { zoom: 1; }\n</style>";dhtml="<div id='"+o.DrawingCanvasID+"'><div class='"+o.DrawingCanvasID+"_content'></div><div style='clear:both;'>&nbsp;</div></div>";jQuery('head').append(dcss);jQuery('body').prepend(dhtml);}
jQuery('#'+o.DrawingCanvasID+' .'+o.DrawingCanvasID+'_content').html(o.content);w=jQuery('#'+o.DrawingCanvasID+' .'+o.DrawingCanvasID+'_content').width();h=jQuery('#'+o.DrawingCanvasID+' .'+o.DrawingCanvasID+'_content').height();o.maxWidth=w;html="<div style='width: "+w+"px; height: "+h+"px; overflow: hidden;'>"+o.content+"</div>";o.content=html;o.maxWidth=w;myDebug('safeInfoWindow options:');myDebug(o);infowindow=new google.maps.InfoWindow(o);return infowindow;};

// GOOGLE MAP
function initialize(domain) {

	var locations, DomainID, all_locations;
	DomainID = parseInt(domain, 10);
	all_locations = [
		['<div class="infowindow"><h2 style="float:left; width:300px;">RELAIS SPA CHESSY <img src="http://images.fastbooking.com/FBCOM/commons/4etoiles.gif" style="width: 56px; height: 16px;"></h2><br style="display:block; width: 10px; clear:both;" />1 rue des Grands Pr&eacute;s - Chessy 77700 France<br/> <br/><img src="http://images.fastbooking.com/IMG/FR/FRFR2335_1.jpg" align="bottom" style="height: 50px; width: 89px;">&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.fastbooking.co.uk/DIRECTORY/crs.phtml?clusterName=FRRSDHSPAChessy" target="_blank" style="margin-top:-20px;">'+mauiLang('Book Now')+'</a></div>', 48.856778, 2.772763, 1, 15, '/themes/relais-spa/images/blue-pushpin_maps.png'],
		['<div class="infowindow"><h2 style="float:left; width:380px;">RELAIS SPA PARIS-ROISSY CDG <img src="http://images.fastbooking.com/FBCOM/commons/4etoiles.gif" style="width: 56px; height: 16px;"></h2><br style="display:block; width: 10px; clear:both;" />8 All&eacute;e du Verger - Roissy en France 95700 France<br /><br /><img src="http://images.fastbooking.com/IMG/FR/FRFR2380_1.jpg" align="bottom" style="height: 50px; width: 89px;">&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.fastbooking.co.uk/DIRECTORY/crs.phtml?clusterName=FRRSDHSPARoissy" style="margin-top:-20px;" target="search">'+mauiLang('Book Now')+'</a></div>', 48.99964786093985, 2.5185728073120117, 1, 15, '/themes/relais-spa/images/blue-pushpin_maps.png']
	
	];
	
	if (DomainID==2)
		{
			locations = [		
							all_locations[0]
						];
		}
	else 
		{
			if (DomainID == 3)
				{
					locations = [		
									all_locations[1]
								];					
				}
		}
		
	var map = new google.maps.Map(document.getElementById('map_canvas'), {
		zoom: locations[0][4],
		center: new google.maps.LatLng(locations[0][1], locations[0][2]),
		mapTypeId: google.maps.MapTypeId.HYBRID
	});

	var infowindow = [];

	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,
			icon: locations[i][5]
});

if (i == 0) {
    infowindow[0] = safeInfoWindow({ 'maxWidth': 500,
        content: locations[0][0]
    });
    infowindow[0].open(map, marker);
}

		google.maps.event.addListener(marker, 'click', (function(marker, i) {
			return function() {
				//infowindow[].setContent(locations[i][0]);
				if (typeof(infowindow[i]) === 'undefined')
					{
						infowindow[i]=safeInfoWindow({
													'maxWidth': 500, 
													 content:locations[i][0]
												    });
					}
				infowindow[i].open(map, marker);
			}
		})(marker, i));
	};
}


$(document).ready(function(){
						   
	// Internal Slideshow + Thumbnails control
	var loopEnd 		= $("ul.internal_gallery").children("li").size();
	var myImages 		= new Array();
	var currentChild 	= $("ul.internal_gallery li:first");
	var bc 				= $('ul.thumbs'); 
 	
	for (count=1; count <= loopEnd; count++) {
		myImages[count] = currentChild.children("span").html();
		currentChild = currentChild.next();
	}
	var $container = $('ul.internal_gallery').cycle({ 
		fx:     'scrollHorz', 
		speed:   300
	}); 
	
	$container.children().each(function(i) {
		$('<li><img src="' + myImages[i+1] +'" alt="" title="" width="100" height="100" /></li>')
		.appendTo(bc)
		.click(function() {
			$container.cycle(i);
			return false; 
		}); 
	});
	// -- End
	
	// credits
	
	$('#footer_content li.cat_11 a').attr('target','_blank');
	$('.site_map li.cat-id-11 a').attr('target','_blank');
	
	// GROUOP SLIDE
	$('#left_slide').cycle();
	$('#right_slide').cycle();

	// FLASH HOTEL SINGOLO
	$('#gallery').cycle();

	// GALLERY BOTTOM HOTEL SINGOLO
	$('#item_gallery a').fancybox({
		titleShow: true,
		titlePosition: 'inside'
	});

	// GALLERY CATEGORY
	$('#photogallery a').fancybox();

	// Personalizzazione select booking form
	$('.my-dropdown').sSelect();
	// $('#hotel_list .my-dropdown').sSelect();

	// SHOW LEFT OFFER IN SINGOL DOMAIN
	if($('#show_offer_wrapper').length > 0){
		$('#show_offer').click(function(e){
			e.preventDefault();
			$('#show_offer').hide();
			$('#filtered_offers').hide();
			$('#all_offers').show();
		})
	}

	// Guest comments pager
	$('#guestcomments .pager').find('a').live('click', function () {
		var that = $(this);
		$('#guestcomments-container').height($('#guestcomments-container').height()).addClass('loading');
		$('#guestcomments').fadeOut(200, function () {
			$(this).load(that.attr('href') + ' #guestcomments > *', function  () {
				$(this).fadeIn(200);
				$('#guestcomments-container').height('auto').removeClass('loading');
			});
		});
		return false;
	});

	// NASCONDO TUUTE LE RISPOSTE DELLE FAQ
	$(".faq_body").each(function() {	
		$(this).css("display","none");
	});
	// VISUALIZZO LA RISPOSTA DELLA FAQ
	$("#faq .story .full_box .moreinfo a").click(function(){
		var hidden_id = parseInt($(this).parent('.moreinfo').attr('id').replace('h_', ''), 10); 
		$("#faq .story .full_box .moreinfo").each(function() {
			$('.faq_body').hide(800);
			$('#faq .story .full_box .moreinfo a').removeClass('current');
		});
		$(this).addClass('current');
		$('#risp_'+hidden_id).show(500);
		return false;
	});

	if($('#map_canvas').length > 0){
		if ($('#gmaps_trigger').length > 0)
			{
				initialize($('#gmaps_trigger').attr('rel'));
			}
	}

	
}); //fine document ready






