	
$(document).ready(function() { 
		
				


	// ---- Generic Stuff ----------------------------------------------------------------------------------------------------------

		$('#main .hentry:last').addClass('last');
		$('#main .block:last').attr('id','last');
		
		
		$('<span class="tl" /><span class="tr" /><span class="bl" /><span class="br" />').appendTo('.box');
		
		if($('.social').length > 0){
			$('<span class="tl" /><span class="tr" />').appendTo('.box-inner');
			$('<span class="bl" /><span class="br" />').appendTo('#footer .box-inner');
		} else {
			$('<span class="tl" /><span class="tr" /><span class="bl" /><span class="br" />').appendTo('.box-inner');
		}
		$('<span class="bl" /><span class="br" />').appendTo('#social');
		$('<span class="bl" /><span class="br" />').appendTo('#banner-inner .box-inner');

		
		$('#main-menu li').hover(function(){
			$(this).addClass('hover');
		},function(){
			$(this).removeClass('hover');
			Cufon.replace('.impact', { fontFamily: 'impact', hover: true });
		});
		
		$('#main .submit input').hover(function(){
			$(this).addClass('hover');
		},function(){
			$(this).removeClass('hover');
		});
		

		
	// ---- Slideshow   ----------------------------------------------------------------------------------------------------------
		
		
		$('<div id="nav" />').appendTo('#slideshow');
		$('#slideshow').cycle({
	        fx:     'wipe',
	        speed:  '280',
	        timeout: 5500,
	        pager:  '#nav',
			slideExpr: 'img'
	    });
	    
	    $('#webcams-slideshow').cycle({
	        fx:     'scrollUp',
	        speed:  'slow',
	        timeout: 12000,
			slideExpr: 'a'
	    });
		
		$("a[rel^='prettyPhoto']").prettyPhoto();

	
		
	// ---- PreFilled   ----------------------------------------------------------------------------------------------------------
			
		$.fn.preFilled = function() {
		$(this).focus(function(){
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
			$(this).addClass('focus');				   
		}).blur(function(){
			if( !this.value.length ) {
				this.value = this.defaultValue;
				$(this).removeClass('focus');
			}
			
		});
		};
		
		$("#search-field,#main .ddfm input").preFilled();

	
		
		
		// ---- Slideshow  ----------------------------------------------------------------------------------------------------------
		
		/*** 
		Simple jQuery Slideshow Script
		Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
		***/

		var currentID = $('#slideshow .slide').attr('id');
		$('#slideshow-nav a[href$='+currentID+']').addClass('active');
		
		slideSwitch = function () {
			var $active = $('#slideshow .slide.active');
			if ( $active.length == 0 ) $active = $('#slideshow .slide:last');
			var $next =  $active.next().length ? $active.next() : $('#slideshow .slide:first');
			$active.addClass('last-active');
			$next.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 1000, function() {
					$active.removeClass('active last-active');
					//$active.css({opacity: 0.0});
				});
			$('#slideshow-nav a').removeClass('active');
			var currentID = $next.attr('id');
			$('#slideshow-nav a[href$='+currentID+']').addClass('active');
		}
		
		$('#slideshow-nav a').click(function(){
			clearInterval(sliderIntervalID);
			$('#slideshow-nav a').removeClass('active');		
			$(this).addClass('active');			
			var clickedSlide = $(this).attr('href').replace("#","");
			var $active = $('#slideshow .slide.active');
			$('#slideshow .slide').removeClass('active').addClass('last-active');
			$('#slideshow .slide').each(function(){
				if($(this).attr('id') == clickedSlide){
					$(this).css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function() {
					$active.removeClass('active last-active');
					//$active.css({opacity: 0.0});
				});
				}
			});

			return false;
		});
	
		var sliderIntervalID = setInterval("slideSwitch()",6000); 
		
		
// ---- Actions  ----------------------------------------------------------------------------------------------------------

		
		if($('#body-aux').hasClass('it')){
			$('<ul id="actions"><li id="print"><a href="#" title="Stampa questa pagina">Stampa questa pagina</a></li><li id="email"><a href="#" title="Invia ad un amico - Apre il tuo client di posta">Invia ad un amico</a></li></ul>').appendTo('#social'); 
			$('#email a').click(function(){mailpageit();}); 
		}
		else {
			$('<ul id="actions"><li id="print"><a href="#" title="Print this page">Print this page</a></li><li id="email"><a href="#" title="Forward to a friend - Opens your mail client">Forward to a friend</a></li></ul>').appendTo('#social'); 
			$('#email a').click(function(){mailpageen();}); 
		}
		
		$('#print a').click(function(){window.print();});
		
		function mailpageit(){
			mail_str = "mailto:?subject=Dai un'occhiata a " + document.title;
			mail_str += "&body=Ho pensato che potessi essere interessato a questo sito " + document.title;
			mail_str += ". Puoi vederlo all'indirizzo " + location.href;
			location.href = mail_str;
			return false;
		};
		function mailpageen(){
			mail_str = "mailto:?subject=Take a peek at " + document.title;
			mail_str += "&body=I though you might be interested in this website " + document.title;
			mail_str += ". You can view it at " + location.href;
			location.href = mail_str;
			return false;
		};	
	
	

});



		
