// LOAD/CREATE IMG
function showImage(id) {
	$('#background').addClass('loading');
	var img = new Image();
	$(img).load(function () {
		$(this).hide();
		var iwidth = this.width; 
		var iheight = this.height;
		var x = $(window).width();
		var y = $(window).height();
		var modX = x/iwidth;	
		var modY = y/iheight;
		if (modX>modY) {
			iwidth=(iwidth*modX);
			iheight=(iheight*modX);
		} else {
			iwidth=(iwidth*modY);
			iheight=(iheight*modY);
		}
		$(this).css({marginLeft: - ( iwidth - x )/2,marginTop:  - ( iheight - y )/2,width: iwidth,height: iheight});		    				     
		$('#background').removeClass('loading').append(this);
		$(this).addClass('resizedimage').show();
	}).error(function () {
	// error?
	}).attr('src', images_full[id]);					
};	

// RE-RENDER DIMENSIONS CURRENT IMAGE
function onWindowResize(){
		// DIMENSIONS IMAGE
		var iwidth = $('#background img.resizedimage').width(); 
		var iheight = $('#background img.resizedimage').height();
		var x = $(window).width();
		var y = $(window).height();
		// DOING MAGIC!
		var modX = x/iwidth;	
		var modY = y/iheight;
		if (modX>modY) {
			iwidth=(iwidth*modX);
			iheight=(iheight*modX);
		} else {
			iwidth=(iwidth*modY);
			iheight=(iheight*modY);
		}
		$('#background img.resizedimage').css({marginLeft: - ( iwidth - x )/2,marginTop:  - ( iheight - y )/2,width: iwidth,height: iheight});
}

// CHECK IF SCROLLBAR IS NEEDED
function checkScrollbar() {
	if ( $(".jScrollPaneTrack").length > 0 )
		{ // Do nothing 
		} else {
		$("#text").css({borderRight: "1px Solid #fff"});
		}
};

// ON WINDOW RESIZE
$(window).bind('resize', function(){
	onWindowResize();
})


// ON DOCUMENT READY
$(document).ready(function(){
	
	//$('#wrapper').hide();
	
	$(document).pngFix();
	
	//$('#wrapper').fadeIn("slow");
	
	$('#innertext').jScrollPane({
		scrollbarWidth: 5,
		showArrows: false,
		arrowSize: 5,
		scrollbarMargin: 0,
		dragMaxHeight: 50,
		reinitialiseOnImageLoad: true
	});
	
	checkScrollbar(); // Always below jScrollPane
	
	$("#innertext a:has(img)").fancybox({ 
		 'overlayShow': false,
		 'padding': 0,
		 'hideOnContentClick': true,
		 'imageScale': true 
	});
	
	$("#reservation").fancybox({
		'frameHeight': 400,
		'frameWidth': 350,
		'overlayShow': false,
		'padding': 0 
	});
	
	var googleHeight = $(window).height() * 0.8;
	var googleWidth = $(window).width() * 0.8;
	
	$("#google_maps").fancybox({
	'frameHeight': googleHeight,
	'frameWidth': googleWidth,
	'overlayShow': false,
	'padding': 0 
	});  
		
});