var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS";},searchString:function(data){for(var i=0;i<data.length;i++){var dataString=data[i].string;var dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!=-1)
return data[i].identity;}
else if(dataProp)
return data[i].identity;}},searchVersion:function(dataString){var index=dataString.indexOf(this.versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+this.versionSearchString.length+1));},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};BrowserDetect.init();;



//Colorbox
	$(document).ready(function(){
		$("a[rel='colorbox']").colorbox({transition:"fade"});
	});




	$(document).ready(function(){
		
			$(".grigio_griglia").mouseover(function(){
		$(this).css("background-color","#000").find("h3.titolo_griglia_nome a").css("color", "#FFF");


					}).mouseout(function(){
		$(this).css("background-color","#EBEDEA").find("h3.titolo_griglia_nome a").css("color", "#000");
						//$(this).css("background-color","#EBEDEA").next("a").css("color", "#000");
						//$(".grigio_griglia h3.titolo_griglia_nome a").css("color", "#000");

					});
	});


// //image effects 
// 	$(document).ready(function(){
// 			var image_e= $(".imgportfolio");
// 			image_e.mouseover(function(){$(this).stop().animate({ opacity:0.4
// 					}, 400);
// 			}).mouseout(function(){
// 				image_e.stop().animate({ 
// 					opacity:1
// 					}, 400 );
// 			});
// 	});



//image effects 
	$(document).ready(function(){
		$('.image-fade .over').css({opacity:0});
		
		//$('.image-fade').find(".over")


		$('.image-fade').mouseover(function(){
		$(this).find(".over").stop().animate({opacity:1 }, 400);


}).mouseout(function(){
			
		$(this).find(".over").stop().animate({opacity:0 }, 400);
					
						});

	});




	
//img preload
$(function () {
			$('.loadpie').hide();//hide all the images on the page
		});
		
		var i = 0;//initialize
		var int=0;//Internet Explorer Fix
		$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
			var int = setInterval("doThis(i)",500);//500 is the fade in speed in milliseconds
		});

		function doThis() {
			var imgs = $('.loadpie').length;//count the number of images on the page
			if (i >= imgs) {// Loop the images
				clearInterval(int);//When it reaches the last image the loop ends
			}
			$('loadpie:hidden').eq(0).fadeIn(500);//fades in the hidden images one by one
			i++;//add 1 to the count
		}




//preloading 
$(function () {
	//$('.preload').hide();//hide all the images on the page
	$('.play,.magnifier').css({opacity:0});
	$('.preload').css({opacity:0});
	$('.preload').addClass("animated");
	$('.play,.magnifier').addClass("animated_icon");
});


var i = 0;//initialize
var cint=0;//Internet Explorer Fix
$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
	var cint = setInterval("doThis(i)",70);//500 is the fade in speed in milliseconds

});

function doThis() {
	var images = $('.preload').length;//count the number of images on the page
	if (i >= images) {// Loop the images
		clearInterval(cint);//When it reaches the last image the loop ends
	}
	$('.preload:hidden').eq(i).fadeIn(500);//fades in the hidden images one by one
	$('.animated_icon').eq(0).animate({opacity:1},{"duration": 500});
	$('.animated').eq(0).animate({opacity:1},{"duration": 500});
	$('.animated').eq(0).removeClass("animated");
	$('.animated_icon').eq(0).removeClass("animated_icon");
	i++;//add 1 to the count
}

//Twitter last
 $(document).ready(function(){
        $(".twittata").tweet({
            username: "crearevalore",
            join_text: "auto",
            avatar_size: 30,
            count: 2,
            auto_join_text_default: "we said,",
            auto_join_text_ed: "we",
            auto_join_text_ing: "we were",
            auto_join_text_reply: "we replied to",
            auto_join_text_url: "we were checking out",
            loading_text: "caricamento tweets..."
        });
    });

//Porfolio Filter
$(document).ready(function() {
	$('ul#filter a').click(function() {
		$(this).css('outline','none');
		$('ul#filter .current').removeClass('current');
		$(this).parent().addClass('current');
		
		//var filterVal = $(this).text().toLowerCase().replace(' ','-');
		var filterVal = $(this).attr("title");
				
		if(filterVal == 'tutti') {
			$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			
			$('ul#portfolio li').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('normal').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}
		
		return false;
	});
});




//Pulsanti Color
// $(document).ready(function(){
// $(".sprite_btn_color.btn_color_grigio div.fucsia_background").css({'opacity':'0'});
// 	$('a.sprite_btn_color.btn_color_grigio').hover(
// 		
// 		
// 		
// 		//$(".sprite_btn_color.btn_color_grigio span.txt_btn").text();
// 		var testolink = $(this).find('span.txt_btn').text();
// 		console.log(testolink);
// 		function() {
// 			 $(".sprite_btn_color.btn_color_grigio div.fucsia_background").stop().fadeTo(250, 1);
// 		},
// 		function() {
// 		 $(".sprite_btn_color.btn_color_grigio div.fucsia_background").stop().fadeTo(250, 0);
// 		}
// 	)
// 	
// 
// });


// $(document).ready(function(){
// 	$(".sprite_btn_color.btn_color_grigio div.fucsia_background").css({'opacity':'0'});
// 	
// 		$("a.sprite_btn_color.btn_color_grigio").mouseover(function(){
// 		var linkTesto = $(this).find('span.txt_btn').text();
// 		$(this).find('span.txt_btn_su').detach();
// 		
// 		$(".sprite_btn_color.btn_color_grigio div.fucsia_background").stop().fadeTo(250, 1);
// 
// 				}).mouseout(function(){
// 				
// 				$(".sprite_btn_color.btn_color_grigio div.fucsia_background").stop().fadeTo(250, 0);
// 				$('<span class="txt_btn_su">Test</span>').delay(2000).insertBefore('.sprite_btn_color.btn_color_grigio div.fucsia_background');
// 				});
// });
// 

// 
// 

// 
// $(document).ready(function(){
// 	function projectOver(e)
// 	{
// 		$('.over',$(e.target).parent()).stop(true, true).animate({opacity: .75},500);
// 		$('p',$(e.target).parent()).addClass('thumb_text_over');
// 	}
// 	function projectOut(e)
// 	{
// 		$('.over',$(e.target).parent()).stop(true, true).animate({opacity: 0},500);
// 		$('p',$(e.target).parent()).removeClass('thumb_text_over');
// 	}
// 	$('a','. image-fade').bind('mouseenter', projectOver);
// 	$('a','. image-fade').bind('mouseleave', projectOut);
// 	
// });






$(document).ready(function(){
	// $('a','.thumb_progetto').bind('mouseenter', projectOver);
	// $('a','.thumb_progetto').bind('mouseleave', projectOut);

	
		$("a.sprite_btn_color").mouseover(function(){
		var linkTesto = $(this).find('span.txt_btn').text();
		//$(this).find('span.txt_btn_su').detach();
		
		
		
		if ($(this).hasClass('violaHover')) {
	   
			$(this).switchClass( "btn_color_grigio", "fucsia_background", 200 ).removeAttr("style");;
	
	
		 } else if ($(this).hasClass('arancioHover')) {
			
			$(this).switchClass( "btn_color_grigio", "arancio_background", 200 ).removeAttr("style");;

		  }
	

		

	

				}).mouseout(function(){
				
					
						if ($(this).hasClass('violaHover')) {

					$(this).switchClass( "fucsia_background", "btn_color_grigio", 200 ).removeAttr("style");;

					 
					 } else if ($(this).hasClass('arancioHover')) {

						$(this).switchClass( "arancio_background", "btn_color_grigio", 200 ).removeAttr("style");;

					  }
					
				
					
						// if ($(this).hasClass('violaHover') {
						// 					 $( ".sprite_btn_color.btn_color_grigio" ).switchClass( "fucsia_background", "btn_color_grigio", 1000 );
						// 
						// 					} 
						// 					else if ($(this).hasClass('qweqweqw') {
						// 					   alert('Less than 2.');
						// 					}
						// 					else {
						// 					    //alert(myNum);
						// 					}
				
					
				});
});

//aviaslider
jQuery(document).ready(function(){
	$('#frontpage-slider').aviaSlider({	
		blockSize: {height: 80, width:80},
		transition: 'slide',
		display: 'all',
		transitionOrder: ['diagonaltop', 'diagonalbottom','topleft', 'bottomright', 'random']
	});
});


jQuery(document).ready(function(){
	$('#portfolio-single-slider').aviaSlider({	
		//blockSize: {height: 'full', width:40},
		//	display: 'topleft',
			transition: 'fade',
			//betweenBlockDelay:80,
			animationSpeed: 800,
			//switchMovement: true,
			// slideControlls: 'items',
			// 	appendControlls: '.aviaslider'
			// 	
	});
});

//Menu


	$(document).ready(function(){
$("#menu li a").hover(
	function () {
		
		if (navigator.appName == 'Microsoft Internet Explorer' && BrowserDetect.version < 9){
			
			//#menu li:not(.current-cat-parent):not(.current-cat) a:hover .menubox
			//$(this).find(".menubox").not(".current-cat-parent").not(".current-cat").css('background-color', 'green');
			$(this).find(".menubox").parent().parent().addClass("fuck");
		}else{
			//$("#menu li:not(.current-cat-parent):not(.current-cat) a:hover .menubox").css("width", $(this).width()+"px").css("height", $(this).height()+"px");
		
		}
		
		var myclass = $(this).parent().attr('class');
		var mypath = "#menu ."+myclass.split(" ")[1];
		//$(mypath+":not(.current-cat-parent):not(.current-cat) .menubox").stop().animate({width:($(this).width()-20)+"px", height:($(this).height()-20)+"px", margin:'10px'},{queue:false, duration:800, specialEasing: {width: 'easeOutExpo', height: 'easeOutExpo', margin: 'easeOutExpo'}});
		
		if (navigator.appName == 'Microsoft Internet Explorer'){
			// $(mypath+":not(.current-cat-parent):not(.current-cat) .menutext").css("top", "50px");
			// 			$(mypath+":not(.current-cat-parent):not(.current-cat) .menutext").css("left", "0px");
		}
		
	}, 
	function () {
		
		var myclass = $(this).parent().attr('class');
		var mypath = "#menu ."+myclass.split(" ")[1];
		//$(mypath+":not(.current-cat-parent):not(.current-cat) .menubox").stop().animate({width:($(this).width())+"px", height:($(this).height())+"px", margin:'0px'},{queue:false, duration:0, specialEasing: {width: 'easeOutExpo', height: 'easeOutExpo', margin: 'easeOutExpo'}});
		
		if (navigator.appName == 'Microsoft Internet Explorer'){
			// $(mypath+":not(.current-cat-parent):not(.current-cat) .menutext").css("top", "85px");
			// 	$(mypath+":not(.current-cat-parent):not(.current-cat) .menutext").css("left", "-10px");
		}
		
	}
);


});


//Clean search value
(function($){
$.fn.clearDefault = function(){
    return this.each(function(){
        var default_value = $(this).val();
        $(this).focus(function(){
            if ($(this).val() == default_value) $(this).val("");
        });
        $(this).blur(function(){
            if ($(this).val() == "") $(this).val(default_value);
        });
    });
};
})(jQuery);

// Usage: $('input.clear-default').clearDefault();

$(document).ready(function(){
$('.search_bar form input').clearDefault();
});


$(document).ready(function() {

    $("span#analisigratis-rollover").css({'opacity' : '0', 'display' : 'block'});


    $('#analisigratis').hover(function() {
        $("span#analisigratis-rollover").stop().fadeTo(250, 1);
    },
    function() {
        $("span#analisigratis-rollover").stop().fadeTo(250, 0);
    });


    $("span#analisi_mobile-rollover").css({'opacity' : '0', 'display' : 'block'});
    $('#analisi_mobile').hover(function() {
        $("span#analisi_mobile-rollover").stop().fadeTo(250, 1);
    },
    function() {
        $("span#analisi_mobile-rollover").stop().fadeTo(250, 0);
    });


});

	$(document).ready(function(){
		//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
		//Vertical Sliding
		$('.boxgrid.slidedown').hover(function(){
			$(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:300});
		}, function() {
			$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
		});
		//Horizontal Sliding
		$('.boxgrid.slideright').hover(function(){
			$(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
		}, function() {
			$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});
		});
		//Diagnal Sliding
		$('.boxgrid.thecombo').hover(function(){
			$(".cover", this).stop().animate({top:'260px', left:'325px'},{queue:false,duration:300});
		}, function() {
			$(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
		});
		//Partial Sliding (Only show some of background)
		$('.boxgrid.peek').hover(function(){
			$(".cover", this).stop().animate({top:'90px'},{queue:false,duration:160});
		}, function() {
			$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
		});
		//Full Caption Sliding (Hidden to Visible)
		$('.boxgrid.captionfull').hover(function(){
			$(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});
		}, function() {
			$(".cover", this).stop().animate({top:'260px'},{queue:false,duration:160});
		});
		//Caption Sliding (Partially Hidden to Visible)
		$('.boxgrid.caption').hover(function(){
			$(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});
		}, function() {
			$(".cover", this).stop().animate({top:'220px'},{queue:false,duration:160});
		});
		
		
		
		/*= Function for the showcase page
			*************************************/
			$('ul#portfolio li').hover(
			   function(){
						$(this).find('.inner .title').slideDown('fast');
						$(this).find('.inner .post-categories').slideDown('fast');
				   },

				function(){
						$(this).find('.inner .title').slideUp('fast');
						$(this).find('.inner .post-categories').slideUp('fast');
				   }
			);//Closing hover
			
			
			/*= Function for the showcase page
				*************************************/
				$('.bianco_griglia').hover(
				   function(){
							$(this).find('.inner .title').slideDown('fast');
							//$(this).find('.inner .post-categories').slideDown('fast');
					   },

					function(){
							$(this).find('.inner .title').slideUp('fast');
							//$(this).find('.inner .post-categories').slideUp('fast');
					   }
				);//Closing hover
		
		
	});
	
	

	

