//home page slider

	$(document).ready(function(){
		$("#sm").cycle({
				auto: true,
				next:"#nextBtn",
				prev:"#prevBtn"
			});
		//$("#slider_area").easySlider({
		//		//auto: true, 
		//		//continuous: true
		//	});
		 var stack = [];
    for (var i = 3; i < 5; i++) { 
        var img = new Image(); 
        img.src = 'backgrounds/bg' + i + '.jpg';
	//alert (img.src)
        $(img).bind('load', function() {
            stack.push(this); 
        }); 
    }
    $('#backgrounds').cycle({ 
        timeout:  10000,
	speed:2000,
        before:   onBefore 
    });
    function onBefore(curr, next, opts) { 
        if (opts.addSlide) 
            while(stack.length) 
                opts.addSlide(stack.pop());  
    };
    
    $('#slider_con ul li a, #prevBtn, #nextBtn').mouseenter(function(){$('#prevBtn, #nextBtn, #slider1next, #slider1prev').show()}).mouseleave(function(){$('#prevBtn, #nextBtn, #slider1next, #slider1prev').hide()});
    
	});

//navigation
	$(document).ready(function(){
			ddsmoothmenu.init({
				mainmenuid: "dropdown_menu", //menu DIV id
				orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
				classname: 'dropdown', //class added to menu's outer DIV
				//customtheme: ["#1c5a80", "#18374a"],
				contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
			})
			
 	});

//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 );
			});
			$('.videoICOHome').mouseover(function(){$(this).stop().animate({ opacity:1
					}, 400);
			}).mouseout(function(){
				$('.videoICOHome').stop().animate({ 
					opacity:0
					}, 400 );
			});
	});
	
$(document).ready(function(){
	$('.patent').colorbox();
		$('.video').colorbox({iframe:true, innerWidth:425, innerHeight:344});
				$('.bigpic').colorbox({iframe:true, innerWidth:425, innerHeight:344});
				$('.bigbigpic').colorbox();
				$('.productPicture').cycle({timeout:5000});
		var numOfPic = $('.productPicture img').length;
		if(numOfPic < 2 ){
			$('.productPicture img').css('margin','0');
		}

	});

	 
//validate contact form
$(document).ready(function(){

      // show a simple loading indicator
      var loader = jQuery('<img src="images/loading.gif" alt="loading..." />')
              .appendTo(".loading")
              .hide();
      jQuery().ajaxStart(function() {
              loader.show();
      }).ajaxStop(function() {
              loader.hide();
      }).ajaxError(function(a, b, e) {
              throw e;
      });
      
      jQuery.validator.messages.required = "";
      var v = jQuery("#validate_form").validate({
              submitHandler: function(form) {
                      jQuery(form).ajaxSubmit({
                              target: "#result"
                      });
              }
      });
      
      jQuery("#resetta").click(function() {
              v.resetForm();
      });
 });



//add text shadow
   $(document).ready(function() {
	var leftBarHeight = $('#main').height();
	$('.sidebar_content').css('height', leftBarHeight);  
	   //$(".shadow").css({'text-shadow' : '1px 1px #fff'});
    });

//ie8 fix - remove passive horizontal scrollbar ie8
   $(document).ready(function() {
	   $("body").css({'overflow-x' : 'hidden'});
    });
       $(document).ready(function(){
	$('.parDesc').hide();
	$('.parHeader').hover(function(){
		var parSel = $(this).attr('rel');
		if($(this).hasClass('selected')){
			$('.parDesc[rel="'+parSel+'"]').hide();
			$('.parDesc[rel="'+parSel+'"]').css('position','absolute');
			$('.parHeader').removeClass('selected');
		}else{
		$('.parDesc').hide();
		$('.parDesc').css('position','static');
		$('.parDesc[rel="'+parSel+'"]').css('position','static');
		$('.parDesc[rel="'+parSel+'"]').show();
		$('.parHeader').removeClass('selected');
		$(this).addClass('selected');
		}
		});
	var leftBarHeight = $('#main').outerHeight();
	$('.sidebar_content').css('min-height', leftBarHeight);
	
	$('ul.listamacchine li a').hover(function(){
		$(this).find(".item_name").animate({opacity:1,bottom:'30px'},200);
	} , function(){ $(this).find(".item_name").animate({opacity:0,bottom:'0px'},200);
	});
});
