(function($, window, undefined) { $(function() {
var slideDuration = 6000,
	easing = 'easeOutQuad',
	$mc = $('#maincontent');
	
if (!$mc.length)
	return;

// MAINSLIDER
(function() {
var $slider = $('#mainslider'),
	$slider_items = $slider.children(),
	$slider_control = $('#mainslider_controller'),
	$slider_control_items = $slider_control.children(),	
	$logo = $("#logo"),
	$logos = $logo.children(),
	$menu = $('#ja-mainnavwrap'),
	act = 0,
	l = $slider_items.length,
	lock = false,
	timer,
	
	slide = function(next) {
		if (!lock || $.isNumeric(next)) {			
			var $act = $slider_items.eq(act),
				next = $.isNumeric(next) ? next : act + 1;
						
			if (next == act)
			 return;			 			 
						
			if (next >= l) next = 0;
			var $next = $slider_items.eq(next);
		
			$slider_items.not($act).not($next).stop().css({ display: 'none' });
			
			$act.stop().css({ display: 'block', opacity: 1 }).animate({ opacity: 0 }, 500, easing, function() { $(this).css({ display: 'none' }); });
			$next.stop().css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, 500, easing);
			$slider_control_items.eq(act).find('div').css({ display: 'block', opacity: 1 }).animate({ opacity: 0 }, 500, easing);
			$slider_control_items.eq(next).find('div').css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, 500, easing);		
			$logos.eq(act).css({ display: 'block', opacity: 1 }).animate({ opacity: 0 }, 500, easing);
			$logos.eq(next).css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, 500, easing);
			$menu.stop().animate({ backgroundColor: $next.data('color') });						
						
			act = next;
		}	
	
		if (timer) clearTimeout(timer);
		timer = setTimeout(function() { slide(); }, slideDuration);	
	};
	
$slider.add($slider_control)
	.unbind('mouseenter.lockslide, mouseleave.lockslide')
	.bind('mouseenter.lockslide', function() { lock = true; })
	.bind('mouseleave.lockslide', function() { lock = false; });
	
$slider_control.undelegate('a', 'click.changeslide')
	.delegate('a', 'click.changeslide', function(e) {
		e.preventDefault();
	
		var $this = $(this);
		slide($this.parent().children().index($this));
	});	
	
timer = setTimeout(function() { slide(); }, slideDuration);
})();


// SERVICESLIDER
(function() {
var $slider = $('#servicesslider'),
	$slider_items = $slider.children(),
	$slider_control = $('#servicesslider_controller'),
	$slider_control_items = $slider_control.find('a'),		
	act = 0,
	l = $slider_items.length,
	lock = false,
	timer,
	
	slide = function(next) {
		if (!lock || $.isNumeric(next)) {			
			var $act = $slider_items.eq(act),
				next = $.isNumeric(next) ? next : act + 1;
						
			if (next == act)
			 return;			 			 
						
			if (next >= l) next = 0;
			var $next = $slider_items.eq(next);
		
			$slider_items.not($act).not($next).stop().css({ display: 'none' });
			
			$act.stop().css({ display: 'block', opacity: 1 }).animate({ opacity: 0 }, 500, easing, function() { $(this).css({ display: 'none' }); });
			$next.stop().css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, 500, easing);
			$slider_control_items.eq(act).find('div').css({ display: 'block', opacity: 1 }).animate({ opacity: 0 }, 500, easing);
			$slider_control_items.eq(next).find('div').css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, 500, easing);								
						
			act = next;
		}	
	
		if (timer) clearTimeout(timer);
		timer = setTimeout(function() { slide(); }, slideDuration);	
	};
	
$slider.add($slider_control)
	.unbind('mouseenter.lockslide, mouseleave.lockslide')
	.bind('mouseenter.lockslide', function() { lock = true; })
	.bind('mouseleave.lockslide', function() { lock = false; });
	
$slider_control.undelegate('a', 'click.changeslide')
	.delegate('a', 'click.changeslide', function(e) {
		e.preventDefault();
	
		var $this = $(this);
		slide($slider_control_items.index($this));
	});	
	
timer = setTimeout(function() { slide(); }, slideDuration);
})();
	
	
	
// PARTNERSLIDER
(function() {
var $slider = $('#partnerbox'),
	$left = $slider.find('.left').children(),
	$right = $slider.find('.right').children(),
	itemHeight = $left.children().first().outerHeight(true), 
	lock = false,
	timer,
	
	slide = function() {
		if (!lock) {
			var $leftChildren = $left.children(),
				$rightChildren = $right.children();
				
			if ($leftChildren.length > 3) {
				var $leftItem = $leftChildren.first(),
					$leftItemLast = $leftChildren.last();
					
				$left.stop().animate({ top: -1 * itemHeight + 'px' }, 700, 'easeInOutQuad', function() {
					$left.css({ top: 0 });
					$leftItem.appendTo($left);
				});
				$leftItem.stop().animate({ opacity: 0 }, 500, 'swing');
				$leftItemLast.stop().css({ opacity: 0 }).animate({ opacity: 1 }, 1000, 'swing');
			} 
			
			if ($leftChildren.length > 3) {
				setTimeout(function() {				
					var $rightItem = $rightChildren.first(),
						$rightItemLast = $rightChildren.last();
						
					$right.stop().animate({ top: -1 * itemHeight + 'px' }, 700, 'easeInOutQuad', function() {
						$right.css({ top: 0 });
						$rightItem.appendTo($right);
					});
					$rightItem.stop().animate({ opacity: 0 }, 500, 'swing');
					$rightItemLast.stop().css({ opacity: 0 }).animate({ opacity: 1 }, 1000, 'swing');				
				}, 300);
			}							
		}	
	
		if (timer) clearTimeout(timer);
		timer = setTimeout(function() { slide(); }, slideDuration);	
	};	
	
$slider
	.unbind('mouseenter.lockslide, mouseleave.lockslide')
	.bind('mouseenter.lockslide', function() { lock = true; })
	.bind('mouseleave.lockslide', function() { lock = false; });	
	
timer = setTimeout(function() { slide(); }, slideDuration);
})();
	
})})(jQuery, window);

(function($) {
	/*
	 Color animation jQuery-plugin
	 http://www.bitstorm.org/jquery/color-animation/
	 Copyright 2011 Edwin Martin <edwin@bitstorm.org>
	 Released under the MIT and GPL licenses.
	*/
	(function(d){function i(){var b=d("script:first"),a=b.css("color"),c=false;if(/^rgba/.test(a))c=true;else try{c=a!=b.css("color","rgba(0, 0, 0, 0.5)").css("color");b.css("color",a)}catch(e){}return c}function g(b,a,c){var e="rgb"+(d.support.rgba?"a":"")+"("+parseInt(b[0]+c*(a[0]-b[0]),10)+","+parseInt(b[1]+c*(a[1]-b[1]),10)+","+parseInt(b[2]+c*(a[2]-b[2]),10);if(d.support.rgba)e+=","+(b&&a?parseFloat(b[3]+c*(a[3]-b[3])):1);e+=")";return e}function f(b){var a,c;if(a=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(b))c=
	[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16),1];else if(a=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(b))c=[parseInt(a[1],16)*17,parseInt(a[2],16)*17,parseInt(a[3],16)*17,1];else if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))c=[parseInt(a[1]),parseInt(a[2]),parseInt(a[3]),1];else if(a=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(b))c=[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),parseFloat(a[4])];return c}
	d.extend(true,d,{support:{rgba:i()}});var h=["color","backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","outlineColor"];d.each(h,function(b,a){d.fx.step[a]=function(c){if(!c.init){c.a=f(d(c.elem).css(a));c.end=f(c.end);c.init=true}c.elem.style[a]=g(c.a,c.end,c.pos)}});d.fx.step.borderColor=function(b){if(!b.init)b.end=f(b.end);var a=h.slice(2,6);d.each(a,function(c,e){b.init||(b[e]={a:f(d(b.elem).css(e))});b.elem.style[e]=g(b[e].a,b.end,b.pos)});b.init=true}})(jQuery);

	// t: current time, b: begInnIng value, c: change In value, d: duration
	$.easing.jswing = $.easing.swing;
	
	$.extend($.easing,
	{
		def: 'easeOutQuad',
		swing: function (x, t, b, c, d) {
			//alert($.easing.default);
			return $.easing[$.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 - $.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 $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
			return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
		}
	});  
})(jQuery);
									   
