/*---------------------------------------------
COUFON
---------------------------------------------*/
Cufon.replace('h2, h3, h6, p.desc', { fontFamily: 'TitilliumText22L-Thin', hover: true }); 
Cufon.replace('h5, label, .font_folio_tit', { fontFamily: 'TitilliumText22L-Light', hover: true }); 
Cufon.replace('.font_folio, .award, .testo_news, .preventivo, .sito_tit, .n_sito', { fontFamily: 'TitilliumText22L-Regular', hover: true }); 
Cufon.replace('h1', { fontFamily: 'TitilliumText22L-Medium', hover: true }); 
Cufon.replace('#footer_news', { fontFamily: 'TitilliumText22L-Bold', hover: true });



/*---------------------------------------------
SLIDE SCHEDE WORK
---------------------------------------------*/
$(document).ready(function()	
	{	
	
		$(".work_container a").click(function() {
		  var largeImg = new Image();
		  var toLoad = $(this).attr('href');
		  $('#loader').remove();
		  var parentId = ($(this).parents("div.work_container").attr('id'));
		  p = $(this).parents("div."+parentId);
		  loader = '<div id="loader" class="'+parentId+' loader">Loading...</div>';
		  $(this).parents("."+parentId).append(""+loader);
		  $('#loader.'+parentId).fadeIn('normal');
		  $('div#'+parentId+' a').removeClass('selected');
          $(this).addClass('selected');
		  $(largeImg)
			.load(function () {
				id = '#largeImg_'+parentId;
				$(id).fadeOut('normal', loadContent);					
				
				function loadContent() {
					$(this).attr({ src: toLoad });
					$('#largeImg_'+parentId).fadeIn('normal',hideLoader());
					
				}
		
				function hideLoader() {
					$('#loader.'+parentId).fadeOut('slow');					
				}

			})
			
			
			.attr({ src: toLoad})
			
			
			;
			
		  return false;
		  
		});
	
		$("img.largeImage").click(function() {
					toLoad = $(this).attr('src');
					var tmpArr = toLoad.split('index.html');
					var imgSrc = tmpArr[tmpArr.length-1];
					tmpArr = imgSrc.split('.');
					imgSrc = tmpArr[0];
					var imgSrcArr = imgSrc.split('_');
					var imgNumber = imgSrcArr[imgSrcArr.length-1];
					imgSrc = imgSrc.replace(imgNumber,'');
					imgNumber = parseInt(imgNumber);
					imgNumber++;
					if(imgNumber<10)
					{
						imgNumber = "0"+imgNumber;
					}
					nextImgSrc = imgSrc + imgNumber;
					nextLink = $('a[href*='+nextImgSrc+']');
					if( typeof(nextLink.attr('href'))=="undefined")//last image
					{
						imgSrc = imgSrc+"01";
						nextLink = $('a[href*='+imgSrc+']');
					}
					nextLink.click();
					});
		
	
	
		
	});

/*---------------------------------------------
TOOLTIP
---------------------------------------------*/

$(document).ready(function(){

	$(".visit a").hover(function() {
		$(this).next("em").animate({opacity: "show", left: "-200"}, "slow");
	}, function() {
		$(this).next("em").animate({opacity: "hide", left: "-240"}, "fast");
	});


});


/*---------------------------------------------
FADE
---------------------------------------------*/

$(document).ready(function(){
	$(".a").hover(
	function() {
		$(this).stop().animate({"opacity": "0"}, "slow");
	},
	function() {
		$(this).stop().animate({"opacity": "3"}, "slow");
	});
	
});

/*---------------------------------------------
ACCORDION
---------------------------------------------*/
$(function(){
  $("ul#prjcats li ul").hide(); 
  $("ul#prjcats>li>a").click(function() {
        $(this).addClass("current");
        var $subnav = $(this).next();
                if($subnav.is(":visible")) {
                $subnav.animate({height: "toggle"}, 750, "easeInOutExpo").prev().removeClass("current");
                }
                if(!$subnav.is(":visible")) {
                $("ul#prjcats li ul:visible").animate({height: "toggle"}, 750, "easeInOutExpo").prev().removeClass("current");
                $subnav.animate({height: "toggle"}, 750, "easeInOutExpo");
                }
                return false;
        });
});     


/*---------------------------------------------
CONTACT FORM
---------------------------------------------*/

$(document).ready(function(){
        $("#contactform").validate();
});

/*---------------------------------------------
BUZZ
---------------------------------------------*/


var truckSound = new buzz.sound( 'sound/Click_m', { formats: [  "mp3", "wav"  ] } );
$( function() {
$( '#navigation li, .fb, twitter_ic, .sk' ).mouseenter( function() {truckSound.play(); });

});


