//pretty photo
	$(document).ready(function(){
	//	$("a[rel^='prettyPhoto']").prettyPhoto();
	});


	      // jQuery(function() {
	      // 
	      // 	        jQuery("#infoware_menu").lavaLamp({
	      // 
	      // 	        fx: "backout", 
	      // 
	      // 	        speed: 700,
	      // 
	      // 	        click: function(event, menuItem) {
	      // 
	      // 	        return true;
	      // 
	      // 	            }
	      // 
	      // 	           });
	      // 
	      // 	        });
	
//Lalvalamp
    // $(function() {
    //       $("#infoware_menu, #2, #3").lavaLamp({
    //           fx: "backout",
    //           speed: 700,
    //           click: function(event, menuItem) {
    //               return true;
    //           }
    //       });
    //   });


	 $(function() {
	        $('ul#menu-menu_principale').lavaLamp();
	    });
	
	

//image effects 
	$(document).ready(function(){
			var image_e= $(".image.portfolio, .image.product_image");
			image_e.mouseover(function(){$(this).stop().animate({ opacity:0.6
					}, 400);
			}).mouseout(function(){
				image_e.stop().animate({ 
					opacity:1
					}, 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
}

//Slider Old

// $(document).ready(function(){
//   var currentPosition = 0;
//   var slideWidth = 920;
//   var slides = $('.slide');
//   var numberOfSlides = slides.length;
// 
//   // Remove scrollbar in JS
//   $('#slidesContainer').css('overflow', 'hidden');
// 
//   // Wrap all .slides with #slideInner div
//   slides
//     .wrapAll('<div id="slideInner"><\/div>')
//     // Float left to display horizontally, readjust .slides width
//         .css({
//       'float' : 'left',
//       'width' : slideWidth
//     });
// 
//   // Set #slideInner width equal to total width of all slides
//   $('#slideInner').css('width', slideWidth * numberOfSlides);
// 
//   // Insert controls in the DOM
//   $('#slideshow')
//     .prepend('<span class="control" id="leftControl">Sinistra<\/span>')
//     .append('<span class="control" id="rightControl">Destra<\/span>');
// 
//   // Hide left arrow control on first load
//   manageControls(currentPosition);
// 
//   // Create event listeners for .controls clicks
//   $('.control')
//     .bind('click', function(){
//     // Determine new position
//         currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
//     
//         // Hide / show controls
//     manageControls(currentPosition);
//     // Move slideInner using margin-left
//     $('#slideInner').animate({
//       'marginLeft' : slideWidth*(-currentPosition)
//     });
//   });
// 
//   // manageControls: Hides and Shows controls depending on currentPosition
//   function manageControls(position){
//     // Hide left arrow if position is first slide
//         if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
//         // Hide right arrow if position is last slide
//     if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
//   }     
//   });



// Cycle Slide

$(document).ready( function($) {
	
	// jQuery('.slide').cycle({
	// 		fx: 'scrollHorz', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	// 		easing: 'easeInOutQuad',
	// 		cleartype:  1,		
	// 		timeout: 6000,
	// 		speed:600,
	// 		pause: 0
	// 		// pager:'.slide-nav',	
	// 		// 	next:'#next-slide',
	// 		// 	prev:'#prev-slide'
	// 
	// 	});
	// 
 });


//Menu
$(document).ready( function($) {

  // This hides all the sub menus on page load
  $('ul#menu-menu_servizi ul.sub-menu').hide();
  // This makes sure that all the sub menus are open when applicable
  $('ul#menu-menu_servizi li.current-menu-item').children().show();
  // This keeps the nav open to the item that you are navigating to.
  $('ul#menu-menu_servizi li.current-menu-item').parents().show(); 

  $('ul#menu-menu_servizi ul li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
		$(this).parent().siblings("li:has(ul)").find("ul").slideUp('normal');
        $('ul#menu-menu_servizi li ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  $('ul#menu-menu_servizi  li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('ul#menu-menu_servizi  ul').slideUp('normal');
        $('ul#menu-menu_servizi li ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );	

});

//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(){
		$("a[rel=fancybox]").fancybox({
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'titlePosition' 	: 'over',
	'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
		return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
	}
		});
		
			$(".fancybox").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
			});
		
		
		
		
});

		// 
		// $('#at_ex1').click(function (){
		// 	//$(this).animate( {scale: '+=0.33'},{queue: false, duration: 1000}); 
		// 	$(this).animate({rotate: '30deg', scale: '1.25'}, 1000);
		// 
		// });
		// 
$(document).ready(function(){		
		$(".child_page_single img").hover(
		   function() {
		      	$(this).animate({rotate: '360deg', scale: '1.25'}, 1000);
		   },
		   function() {
		      	$(this).animate({rotate: '0deg', scale: '1'}, 1000);
		   }
		);
		
});


// setInterval(function () {$('.child_page_single img').animate({rotate: '+=10deg'}, 0);}, 100);

