/**
 * 
 */
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});



(function($) {
	if(!document.defaultView || !document.defaultView.getComputedStyle){ // IE6-IE8
		var oldCurCSS = jQuery.curCSS;
		jQuery.curCSS = function(elem, name, force){
			if(name === 'background-position'){
				name = 'backgroundPosition';
			}
			if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
				return oldCurCSS.apply(this, arguments);
			}
			var style = elem.style;
			if ( !force && style && style[ name ] ){
				return style[ name ];
			}
			return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
		};
	}
	
	var oldAnim = $.fn.animate;
	$.fn.animate = function(prop){
		if('background-position' in prop){
			prop.backgroundPosition = prop['background-position'];
			delete prop['background-position'];
		}
		if('backgroundPosition' in prop){
			prop.backgroundPosition = '('+ prop.backgroundPosition;
		}
		return oldAnim.apply(this, arguments);
	};
	
	function toArray(strg){
		strg = strg.replace(/left|top/g,'0px');
		strg = strg.replace(/right|bottom/g,'100%');
		strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
		var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
		return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
	}
	
	$.fx.step. backgroundPosition = function(fx) {
		if (!fx.bgPosReady) {
			var start = $.curCSS(fx.elem,'backgroundPosition');
			
			if(!start){//FF2 no inline-style fallback
				start = '0px 0px';
			}
			
			start = toArray(start);
			
			fx.start = [start[0],start[2]];
			
			var end = toArray(fx.options.curAnim.backgroundPosition);
			fx.end = [end[0],end[2]];
			
			fx.unit = [end[1],end[3]];
			fx.bgPosReady = true;
		}
		//return;
		var nowPosX = [];
		nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
		nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
		fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

	};
})(jQuery);

jQuery(function(){
	jQuery("#zoneSlide").hover(function(){
		jQuery(this).stop().animate({top:"-200px"},{queue:false,duration:400});
		jQuery(".slideTitle em").css("background-position","left top");
	}, function() {
		jQuery(this).stop().animate({top:"-60px"},{queue:false,duration:400});
		jQuery(".slideTitle em").css("background-position","left bottom");
	});
});
jQuery(function(){
	jQuery("ul.nav a").hover(function(){
		oldPos = jQuery(this).css('backgroundPosition');
		var tabTmp = oldPos.split(' ');
		var newPos = tabTmp[0]+" -18px";
		/*var newPos = oldPos.replace(" 0%", " -18px"); 
		newPos = newPos.replace(" 0px", " -18px"); */
		jQuery(this).stop().animate({"backgroundPosition":newPos},{queue:false,duration:300});
	}, function() {
		if(!jQuery(this).parent().hasClass('current-menu-item')){
			var tabTmp = oldPos.split(' ');
			var newPos = tabTmp[0]+" 0px";
			//var oldPos = jQuery(this).css('backgroundPosition');
			//var newPos = oldPos.replace("-18px","0%"); 
		jQuery(this)./*stop().*/animate({"backgroundPosition":newPos},{queue:true,duration:300});
		}
	});
	
	
});

jQuery(window).load(function(){
	jQuery("img.toFade").hover(function(){
		if(jQuery(this).hasClass('Light')){
			jQuery(this).fadeTo(200, 0.9);
		}else{jQuery(this).fadeTo(200, 0.7);}
	},function(){
		jQuery(this).fadeTo(100, 1);
	});
	/* DR changer les valeurs ici pour l'effet sur les images du portfolio*/
	var thumbnail = {
		imgIncrease : 10, /* agrandir img en pixels ( zoom) */
		effectDuration : 250, /* duree*/
		/*
		recup taille images
		*/
		imgWidth : parseInt(jQuery('.one_fourth a.doEffect').find('img').width()/*-10*/),
		imgHeight : parseInt(jQuery('.one_fourth a.doEffect').find('img').height()/*-10*/)

	};
	
	//appliquer taille css
	jQuery('.one_fourth, a.doEffect').css({
		'width' : thumbnail.imgWidth,
		'height' : thumbnail.imgHeight
	});
	jQuery('div.one_fourth a.doEffect').find('img').css({
		'width' : thumbnail.imgWidth,
		'height' : thumbnail.imgHeight/*,
		left: 0,
		top: 0*/
	});
	//hover sur list item...
	jQuery('.one_fourth').hover(function(){

		jQuery(this).find('img').stop().animate({

			/* augmenter la taille*/
			width: parseInt(thumbnail.imgWidth) + thumbnail.imgIncrease,
			height: parseInt(thumbnail.imgHeight) + thumbnail.imgIncrease,
			/* bouger le top et le left en fonction de l'augmentation de la taille */
			left: thumbnail.imgIncrease/2*(-1),
			top: thumbnail.imgIncrease/2*(-1)
		},{

			"duration": thumbnail.effectDuration,
			"queue": false

		});

		//montrer le caption
		jQuery(this).find('.caption:not(:animated)').slideDown(thumbnail.effectDuration);

	//la souris sort ?
	}, function(){

		//animer l'image.
		jQuery(this).find('img').animate({

			/* taille initiale*/
			width: thumbnail.imgWidth,
			height: thumbnail.imgHeight,
			/* left et top normaux */
			left: 0,
			top: 0

		}, thumbnail.effectDuration);

		//cache caption
		jQuery(this).find('.caption').slideUp(thumbnail.effectDuration);

	});
	
	jQuery(".scrollMe").click(function(e){
		e.preventDefault();
		var idPos=jQuery(this).attr('rel');
		var thePos=jQuery(idPos).position();
		//alert(thePos.left +" "+thePos.top);
		var theLeft=parseInt(jQuery("#zone_scroll").css('left'));
		jQuery("#main_sf_outer").stop().animate({"left":-(thePos.left+theLeft)+"px"},{queue:false,duration:800,easing:'easeInOutQuad'});
	});

});

(function($) {
	$.fn.lavaLamp = function(o) {
	    o = $.extend({ fx: "linear", speed: 500, click: function(){} }, o || {});

	    return this.each(function() {
	        var me = $(this), noop = function(){},
	            $back = $('<li class="back"><div class="left"></div></li>').appendTo(me),
	            $backPlus = $('<li class="backPlus"></li>').appendTo(me),
	            $li = $("li.lvl", this), curr = $("li.current", this)[0] || /*$($li[0]).addClass("current")[0]*/$($backPlus).addClass("current")[0];

	        $li.not(".back").hover(function() {
	            move(this);
	        }, noop);

	        $(this).hover(noop, function() {
	            move(curr);
	            $(this).children('a').css('color','#ffffff');
	        /*},function(){
	        	moveToHide();*/
	        });

	        $li.click(function(e) {
	            setCurr(this);
	            $li.each(function(){$(this).children('a').css('color','#363636').css("background","none");});
	            $(this).children('a').css('color','#ffffff').css("background","url('http://www.ikone-web.com/wp-content/themes/ikonweb/images/skin5/bg_filtre.jpg') repeat scroll right 0 transparent");
	            return o.click.apply(this, [e, this]);
	        });

	        setCurr(curr);

	        function setCurr(el) {
	        	var l=el.offsetLeft;
	        	var w=el.offsetWidth;
	        	if(l==0) w=0;
	            $back.css({ "left": l+"px", "width": w+"px" });
	            curr = el;
	        };


	        function move(el) {
	            $back.each(function() {
	                $(this).dequeue(); }
	            ).animate({
	                width: el.offsetWidth,
	                left: el.offsetLeft
	            }, o.speed, o.fx);
	        };
	        function moveToHide() {
	            $back.each(function() {
	                $(this).dequeue(); }
	            ).animate({
	                width: 0,
	                left: 0
	            }, o.speed, o.fx);
	        };
	    });
	};
	})(jQuery);

