var hide_media = true;
var hide_gallery = true;
var hide_guide = true;
var hide_vademecum = true;
var is_open = false;

function scrollme()
{
if(is_open)
{
				if($('#content_scroll').length)
				{
					$('#content_scroll').jScrollPane({showArrows: true, scrollbarWidth:12, dragMaxHeight:12, topCapHeight: 30});
					$('#content_scroll')[0].scrollTo($(this).offset().top-160);
				}
				if($('#content_scroll2').length)
				{
					$('#content_scroll2').jScrollPane({showArrows: true, scrollbarWidth:12, dragMaxHeight:12});
					$('#content_scroll2')[0].scrollTo($(this).offset().top-160);
				}
}
}
$(document).ready(function() {
	$('#media_link').click(function(eve) {
		$('#menu_media').toggle("slow");
		eve.preventDefault();
	});
	$('#gallery_link').click(function(eve) {
		$('#menu_gallery').toggle("slow");
		eve.preventDefault();
	});
	$('#guide_link').click(function(eve) {
		$('#menu_guide').toggle("slow");
		eve.preventDefault();
	});
	$('#vademecum_link').click(function(eve) {
		$('#menu_vademecum').toggle("slow");
		eve.preventDefault();
	});
	if(hide_media)
	{
		$('#menu_media').hide();
	}
	if(hide_gallery)
	{
		$('#menu_gallery').hide();
	}
	if(hide_guide)
	{
		$('#menu_guide').hide();
	}
	if(hide_vademecum)
	{
		$('#menu_vademecum').hide();
	}
	$('div.text_text a img').each(function()
	{
		if($(this).parent().attr('href').slice($(this).parent().attr('href').length-3) != 'pdf' && $(this).parent().attr('href') != '/pano/lobby0.html')
		{
			($(this).parent()).attr("rel", "shadowbox[page]");
		}
	});
	$('#back').click(function(eve)
	{
		var bfound = false;
		var b = null;
		if($('div.roll_item').length)
		{
			$('div.roll_item').each(function(index)
			{
				b = $(this).find('div.roll_content').slice(0,1);
				if(b.is(':visible'))
				{
					bfound = true;
					b.hide();
				}
			});
			if(!bfound)
			{
				history.back();
			}
		}
		else
		{
			history.back();
		}
		eve.preventDefault();
	});
	var found = false;
	$('div.menu a').each(function(index)
	{
		var href = $(this).attr('href');
		if(href == document.location.href.slice(document.location.href.indexOf('/', 8)))
		{
			found = true;
			$(this).addClass('orange');
		}
	});
	if(!found)
	{
		$('div.menu a').slice(0,1).addClass('orange');
	}
	var last = null;
	$('div.roll_item').each(function(index)
	{
		$(this).find('span.roll_header').click(function(eve)
		{
			is_open = false;
			if(!$(this).parent().find('div.roll_content').slice(0,1).is(':visible'))
			{
				is_open = true;
				if(last != null)
				{	
					last.hide('slow', scrollme);
				}
				$(this).parent().find('div.roll_content').show('slow',scrollme);
				last = $(this).parent().find('div.roll_content').slice(0,1);
			}
			else
			{
				$(this).parent().find('div.roll_content').hide('slow', scrollme);
			}

		});
		if(hide_gallery)
		{
		$(this).find('div.roll_content').hide();
		}
	});
	$('#content_scroll').jScrollPane({showArrows: true, scrollbarWidth:12, dragMaxHeight:12, topCapHeight: 30});
	$('#content_scroll2').jScrollPane({showArrows: true, scrollbarWidth:12, dragMaxHeight:12});
	if(document.getElementById("map") != null)
	{
	  var lat=52.172567; 
	  var lng=21.025106; 
	  var zoom=15; 

	    if (GBrowserIsCompatible()) { 
	      var map = new GMap2(document.getElementById("map")); 
	      map.setCenter(new GLatLng(lat, lng), zoom); 
	      var point = new GLatLng(lat, lng);
	  	  map.addOverlay(new GMarker(point));
	      map.setUIToDefault();
	    }
	    GLoad();
	}
	Shadowbox.init({
	   handleOversize: "resize",
       modal: true
	});
});

