// JavaScript Document
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
$(document).ready(function () {
	$.preLoadImages("stylesheet/images/fbOFF.png", "stylesheet/images/fbON.png", "stylesheet/images/twOFF.png", "stylesheet/images/twON.png", "stylesheet/images/liOFF.png", "stylesheet/images/liON.png");
	
/*$('#foot li').hover(function () {
	$(this).find('h3').css('color', '#65492f');},
	function () {
	$(this).find('h3').css('color', '#28384C');
	});
	*/
$('#lang').click(function () {
		window.location = "http://www.clan-group.com/new/eng"
	});
			/*$(".back").css("opacity","0");
			$(".lavaLampWithImage").hover(function () {
			$(".back").animate({
			opacity: 1.0
			}, 100);
			},
			function () {
			$(".back").animate({
			opacity: 0
			}, 100);
			});
            $("#one").lavaLamp({
                fx: "backout", 
                speed: 700,
            });*/
				//transitions
		//for more transition, goto http://gsgd.co.uk/sandbox/jquery/easing/
		var style = 'easeOutElastic';
		
		//Retrieve the selected item position and width
		var default_left = Math.round($('#lava li.selected').offset().left - $('#lava').offset().left);
		var default_width = $('#lava li.selected').width();

		//Set the floating bar position and width
		$('#box').css({left: default_left});
		$('#box .head').css({width: default_width});
		$('#box .head').css("opacity","0");

		//if mouseover the menu item
		$('#lava li').hover(function () {
			
			//Get the position and width of the menu item
			left = Math.round($(this).offset().left - $('#lava').offset().left);
			width = $(this).width(); 

			//Set the floating bar position, width and transition
			$('#box').stop().animate({left: left},{duration:1000, easing: style});	
			$('#box .head').stop().animate({width:width},{duration:1000, easing: style});	
			$('#box .head').stop().animate({ opacity: 1.0}, 100);
		
		//if user click on the menu
		}).click(function () {
			
			//reset the selected item
			$('#lava li').removeClass('selected');	
			
			//select the current item
			$(this).addClass('selected');
	
		});
		
		//If the mouse leave the menu, reset the floating bar to the selected item
		$('#lava').mouseleave(function () {

			//Retrieve the selected item position and width
			default_left = Math.round($('#lava li.selected').offset().left - $('#lava').offset().left);
			default_width = $('#lava li.selected').width();
			
			//Set the floating bar position, width and transition
			$('#box').stop().animate({left: default_left},{duration:1000, easing: style});	
			$('#box .head').stop().animate({width:default_width},{duration:1000, easing: style});
			$('#box .head').stop().animate({ opacity: 0}, 100);
			
		});
			$(".vertical").scrollable({ vertical: true, circular: true, mousewheel: true}).autoscroll({	interval: 4000 });
			$(".lavori_vertical").scrollable({ vertical: true, mousewheel: true});
			
$(".latest_img").css("opacity","0.3");
	/*$(".latest_img").reflect({height: 0.5, opacity: 0.2});*/
	// ON MOUSE OVER
	$(".latest_img").hover(function () {
											  
	// SET OPACITY TO 100%
	$(this).stop().animate({
	opacity: 1.0
	}, "fast");
	},
			
	// ON MOUSE OUT
	function () {
				
	// SET OPACITY BACK TO 50%
	$(this).stop().animate({
	opacity: 0.3
	}, "fast");
	});

$(".arrow_img").css("opacity","0.5");
	/*$(".latest_img").reflect({height: 0.5, opacity: 0.2});*/
	// ON MOUSE OVER
	$(".arrow_img").hover(function () {
											  
	// SET OPACITY TO 100%
	$(this).stop().animate({
	opacity: 1.0
	}, "fast");
	},
			
	// ON MOUSE OUT
	function () {
				
	// SET OPACITY BACK TO 50%
	$(this).stop().animate({
	opacity: 0.5
	}, "fast");
	});

	//img zoom at home page grid
	//move the image in pixel
	var move = 0;
	
	//zoom percentage, 1.2 =120%
	var zoom = 1.1;

	//On mouse over those thumbnail
	$('.zitem').hover(function() {
		
		//Set the width and height according to the zoom percentage
		width = $('.zitem').width() * zoom;
		height = $('.zitem').height() * zoom;
		
		//Move and zoom the image
		$(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
		
		//Display the caption
		$(this).find('div.caption').stop(false,true).fadeIn(200);
	},
	function() {
		//Reset the image
		$(this).find('img').stop(false,true).animate({'width':$('.zitem').width(), 'height':$('.zitem').height(), 'top':'0', 'left':'0'}, {duration:100});	

		//Hide the caption
		$(this).find('div.caption').stop(false,true).fadeOut(200);
});
	$(".sliding-element a").mouseover(function () {
$(this).stop().animate({ marginLeft: "10px" }, 200 );
});

$(".sliding-element a").mouseout(function () {
$(this).stop().animate({ marginLeft: "0px" }, 200 );
});
$('.eff').css("opacity","0.5");
$('.eff').hover(function () {
	$(this).stop().animate({opacity: 1.0}, "fast");},
	function () {
	$(this).stop().animate({opacity: 0.5}, "fast");
	$(this).find('img').stop().animate({bottom:0} ,{duration:400, easing: 'easeOutBounce'});
	});
$('.eff').click(
	function () {

		value = $(this).find('img').outerHeight() * -1;

		//for left/right if you have different width and height, 
		//commented out because we are using up/down in this example
		//value = $(this).find('img').outerWidth() * -1); 
		//$(this).stop().animate({opacity: 1.0}, "fast");
		//animate the image
		// you can change the sliding direction by changing bottom to left, right or top
		// if you changed this, you will have to change the position of the hover out as well
		$(this).find('img').stop().animate({bottom: value} ,{duration:600, easing: 'easeOutBounce'});	
		
	},
	function () {
		//$(this).stop().animate({opacity: 0.5}, "fast");
		//reset the image
		// the position property (bottom), it must be same with the on in the mouseover
		$(this).find('img').stop().animate({bottom:0} ,{duration:400, easing: 'easeOutBounce'});	
	
	});
$('.eff_who').hover(function () {
		value = $(this).find('.img').outerHeight() * -1;
		$(this).find('.img').stop().animate({bottom: value} ,{duration:600, easing: 'easeOutBounce'});
		},
	function () {
		$(this).find('.img').stop().animate({bottom:0} ,{duration:400, easing: 'easeOutBounce'});
		});
$('.eff_right').hover(function () {
		value = $(this).find('.img').outerHeight() * -1;
		$(this).find('.img').stop().animate({bottom: value} ,{duration:600, easing: 'easeOutBounce'});
		},
	function () {
		$(this).find('.img').stop().animate({bottom:0} ,{duration:400, easing: 'easeOutBounce'});
		});
$('.eff_small').hover(function () {
		value = $(this).find('.img').outerHeight() * -1;
		$(this).find('.img').stop().animate({bottom: value} ,{duration:600, easing: 'easeOutBounce'});
		},
	function () {
		$(this).find('.img').stop().animate({bottom:0} ,{duration:400, easing: 'easeOutBounce'});
		});
$("#dyna a[title]").tooltip({position:"top center", offset: [-5, 0], effect: 'slide'});
$("#readmore a[title]").tooltip({position:"top center", offset: [-5, 0], effect: 'slide'});
$("#stendino img[title]").tooltip({ position:"top center", offset: [40, 0], effect: "slide" });
$("#icons img[title]").tooltip({ position:"top center", offset: [20, 0], effect: "slide" });
$("#rect img[title]").tooltip({ offset: [10, 0], effect: "slide" });

$("#stendino img[rel]").overlay({effect: 'apple', expose: '#000', closeOnClick: false }); 
$("#nonProfit img[rel]").overlay({effect: 'apple', expose: '#000', closeOnClick: false });
$("#view").click(function () {if ($("#rect:first").is(":hidden")) {$("#rect").slideDown("slow");} else {$("#rect").slideUp();}});
});
$(function() {
		$( "#accordion" ).accordion({
			autoHeight: false,
			navigation: true
		});
	});
$(function() {
$('#mycarousel').jcarousel(/*{wrap: 'circular'}*/);	
$("#fbProfile img").hover( function(){ this.src = this.src.replace("OFF","ON"); }, function() {  this.src = this.src.replace("ON","OFF"); });
$("#twProfile img").hover( function(){ this.src = this.src.replace("OFF","ON"); }, function() {  this.src = this.src.replace("ON","OFF"); });
$("#liProfile img").hover( function(){ this.src = this.src.replace("OFF","ON"); }, function() {  this.src = this.src.replace("ON","OFF"); });
});
