$(document).ready(function() {
	
	$("div.offer-front").append('<div class="float-fixer">');
	
	$('div.box').wrapInner('<div class="inside">').wrapInner('<div class="outside">');
	$('ul#footer-menu li:gt(0)').prepend('&#124;');
	
	$("div.offer-front:last , ul.tabs li:last").css ({'margin' : '0px'});
	$("div.offer-front").css ({'cursor' : 'pointer'});
	$("div.offer-front").click(function(){
	     window.location=$(this).find("a").attr("href");
	     return false;
	});
	
	$("div#guestbook-notice").click(function(){
	     window.location=$(this).find("a:last").attr("href");
	     return false;
	});
	
	// $("textarea#Richieste").hide();
	// $("label.Richieste").css({'width' : '246px'});
	// $("label.Richieste").click(function (){
		// $("textarea#Richieste").toggle("slow");
	// });
	
	//Swap Image on Click for Page-gallery
	$("ul.tabs li a").click(function() {
	  var mainImage = $(this).attr("href"); //Find Image Name
	  $('div.panes img').fadeOut(500, function () {
					//Set new attribute values to the main photo and once loaded
					$('<img />').attr ('src' , mainImage).load( function (){
						//remove old image and append new with fade in
						$('div.panes img').remove();
						$('div.panes').append($(this).hide().fadeIn(500));
					});
				});
	  return false;
	});
	
	//Swap Image on Click for normal Gallery
	$("ul.gallery-preview li a").click(function() {
	  var smallImage = $(this).attr("href"); //Find Image Name
	  $("div#main-image img").load(smallImage, function() {
			$(this).fadeOut(600, function() {
						$(this).attr({ src: smallImage });
					}).fadeIn(300);
				});
	  return false;
	});
	
	$('ul.gallery-preview li a:gt(1)').click(function (){
		var elements = $("ul.gallery-preview li").size();
		var elementsWidth = elements * 55;
		var scrollerRight = $("div#thumbs-wrapper").width();
		var position = $("ul.gallery-preview").position();
		var hasMore = (scrollerRight - elementsWidth) - position.left + 55;
		var scrollAmount = $('ul.gallery-preview').width() - $('div#thumbs-wrapper').width();
		var currentPos = parseInt($('ul.gallery-preview').css('left'));
		var nextPos = currentPos - 55;
		if (hasMore < 0) {
			$('ul.gallery-preview').animate({'left' : nextPos});
		}
	})
	
	$('div.fader').innerfade({
		speed: 'slow',
		timeout: 4000,
		type: 'sequence',
		containerheight: '18px' 
	});
	
	$("div.galleria").slideViewerPro({
		thumbs: 6,
		galBorderWidth: 0,
		thumbsBorderWidth: 0,
	});
	
});
