/*
 *	jquery.easyRotate 1.0 - 3-11-2010
 * author: Jordan Andree (jordan@noblegiant.com)
 * http://noblegiant.com
 *
 *	Written to ease the implementation of element rotation for cross-browser support
 *	Feel free to do whatever you want with this file
 *
 */
(function ($) {
	
	// base function
	$.fn.extend({
		easyRotate: function(options) {
		
			// default config 
			var defaults = {
				degrees: 0  
			};
			
			// extend the options
			var options = $.extend(defaults, options);
			
			// return function
			return this.each(function() {
					
				// the object 
				var obj = this;
				
				// the degrees param
				var deg = options.degrees;
								
				// calculations to get our matrix
				var deg2radians = Math.PI * 2 / 360;
				var rad = deg * deg2radians;
				var costheta = Math.cos(rad);
				var sintheta = Math.sin(rad);
			 
				// vars for cosin and sin
				var a = parseFloat(costheta).toFixed(8);
				var c = parseFloat(-sintheta).toFixed(8);
				var b = parseFloat(sintheta).toFixed(8);
				var d = parseFloat(costheta).toFixed(8);
				
				// the matrix string
				var matrix = "matrix(" + a + ", " + b + ", " + c + ", " + d + ", 0, 0);";
				
				// if IE filters are present
				if (obj.filters) {
					obj.style.filter = "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand');";
					obj.filters.item(0).M11 = costheta;
					obj.filters.item(0).M12 = -sintheta;
					obj.filters.item(0).M21 = sintheta;
					obj.filters.item(0).M22 = costheta;
					
				// else for Safari, Firefox, etc
				} else {
					obj.setAttribute("style", "position:absolute; -moz-transform:  " + matrix + 
														"; -webkit-transform:  " + matrix + 
														"; -o-transform: " + matrix + "");

														
				}
			});	
		}
	});
})(jQuery);



function append_mode_ajax(element)
{
	 var $target = $(element);
	 var href_value = $target.attr("href");
	 if(href_value.indexOf("?")>-1)href_value = href_value+"&mode=ajax";
	 else href_value = href_value+"?mode=ajax";
	 $target.attr("href",href_value) ;
}

$(document).ready(function() {
	var $links_to_scheda = $(".ajaxme");
	if ($links_to_scheda.length > 0) {
		for(var i = 0; i < $links_to_scheda.length; i++) {
			append_mode_ajax($links_to_scheda[i]);
		}
	}
	$("#body-chi-siamo").append('<div id="furgone"></div>' );
	
	$(".lev01").hover(
			 function () {
				 $(this).children(".wmenu-lev02").fadeIn(500);
			},
			function (){
				$(this).children(".wmenu-lev02").fadeOut(500);
			}
	);
});
function sposta_furgone()
{
	$('#furgone').animate({left: '+=10'}, {
    duration: 5, 
    specialEasing: {
      width: 'linear',
      height: 'easeOutBounce'
    }, 
    complete: function() {
       if(parseInt($('#furgone').css("right"),10)>0){
		   sposta_furgone();
		}
		//alert(parseInt($('#furgone').css("right"),10));
		if(parseInt($('#furgone').css("right"),10)<0){
			
			
			$('#furgone').css("left","auto");
			$('#furgone').css("right","0");
			$('#furgone').css("bottom","0");
			ruota_furgone();
		}
		
		
    }
  });
}
function ruota_furgone()
{
	$('#furgone').easyRotate({degrees: -90});
	//$('#furgone').css("bottom")=0
}
Shadowbox.init();

