﻿/* --------------------------------------------------------
 * Easing
-------------------------------------------------------- */
/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
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;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */

/* --------------------------------------------------------
 * Carousel
-------------------------------------------------------- */
(function($){$.fn.carousel=function(settings){settings=$.extend({width:0,height:0,interval:2000,autoPlay:false,easing:null,animSpeed:1000,startIndex:0,addNavigation:false,vertical:false,rotate:true,flashStatus:null},settings);return this.each(function(){carouselMethods.init(settings,$(this));});};var carouselMethods=(function(){var $s={};var initSettings={};var container=null;var carousel=null;var size=0;var timer=null;var itemIndex=0;var fullscreen=false;function moveSlide(dir,isEnd){if($s.vertical){if(typeof dir==='number'){if($s.animSpeed===0){carousel.css({top:'-'+dir*$s.height+'px'});}
else{carousel.animate({top:'-'+dir*$s.height+'px'},$s.animSpeed,$s.easing);}}
else if(dir==='next'){if(isEnd===false){if($s.animSpeed===0){carousel.css({top:'-'+$s.height*itemIndex+'px'});}
else{carousel.animate({top:'-='+$s.height+'px'},$s.animSpeed,$s.easing);}}
else{if($s.animSpeed===0){carousel.css({top:'0'});}
else{carousel.animate({top:'-='+$s.height+'px'},$s.animSpeed,$s.easing,function(){carousel.css({top:'0px'});});}}}
else if(dir==='prev'){if(isEnd===false){if($s.animSpeed===0){carousel.css({top:'-'+$s.height*itemIndex+'px'});}
else{carousel.animate({top:'+='+$s.height+'px'},$s.animSpeed,$s.easing);}}
else{if($s.animSpeed===0){carousel.css({top:'-='+((size*$s.height)-$s.height)+'px'});}
else{carousel.css({top:'-'+((size*$s.height)-$s.height)+'px'}).animate({top:'+='+$s.height+'px'},$s.animSpeed,$s.easing);}}}}
else{if(typeof dir==='number'){if($s.animSpeed===0){carousel.css({left:'-'+dir*$s.width+'px'});}
else{carousel.animate({left:'-'+dir*$s.width+'px'},$s.animSpeed,$s.easing);}}
else if(dir==='next'){if(isEnd===false){if($s.animSpeed===0){carousel.fadeOut('slow',function(){carousel.css({left:'-'+$s.width*itemIndex+'px'});carousel.fadeIn('slow');});}
else{carousel.animate({left:'-='+$s.width+'px'},$s.animSpeed,$s.easing);}}
else{if($s.animSpeed===0){carousel.fadeOut('slow',function(){carousel.css({left:'0'});carousel.fadeIn('slow');});}
else{carousel.animate({left:'-='+$s.width+'px'},$s.animSpeed,$s.easing,function(){carousel.css({left:'0px'});});}}}
else if(dir==='prev'){if(isEnd===false){if($s.animSpeed===0){carousel.css({left:'-'+$s.width*itemIndex+'px'});}
else{carousel.animate({left:'+='+$s.width+'px'},$s.animSpeed,$s.easing);}}
else{if($s.animSpeed===0){carousel.css({left:'-'+$s.width*(size-1)+'px'});}
else{carousel.css({left:'-'+$s.width*(size-1)+'px'}).animate({left:'+='+$s.width+'px'},$s.animSpeed,$s.easing);}}}}};function isEnd(index){if(itemIndex===index){return true;}
else return false;};function next(){var end=isEnd(size-2);if(end===true&&$s.rotate===false)return;setActiveNav(itemIndex,itemIndex+1);itemIndex++;if(end){moveSlide('next',end);itemIndex=0;setActiveNav(itemIndex,0);}
else{moveSlide('next',end);}};function prev(){var end=isEnd(0);if(end===true&&$s.rotate===false)return;setActiveNav(itemIndex,itemIndex-1);itemIndex--;if(end){moveSlide('prev',end);itemIndex=size-2;setActiveNav(itemIndex,size-2);}
else{moveSlide('prev',end);}};function play(){timer=setInterval(function(){next();},$s.interval);};function pause(){clearInterval(timer);};function getStartSlide(){if($s.startIndex===-1){var rand=Math.random();rand=rand*(size-2);$s.startIndex=Math.round(rand);setItemIndex($s.startIndex);return $s.width*$s.startIndex;}
else if($s.startIndex>0){setItemIndex($s.startIndex);return $s.width*($s.startIndex-1);}
else return 0;};function setItemIndex(index){itemIndex=index;};function toggleFullscreen(){if(fullscreen){console.log(initSettings.width);fullscreen=false;$s.width=initSettings.width;$s.height=initSettings.height;}
else{fullscreen=true;$s.width=$(window).width();$s.height=$(window).height();}
setActiveNav(itemIndex,0);setItemIndex(0);setStyles();};function setStyles(){if(fullscreen){container.css({position:'absolute',left:'0',top:'0',overflow:'hidden',width:$s.width+'px',height:$s.height+'px'});}
else{container.css({position:'relative',overflow:'hidden',width:$s.width+'px',height:$s.height+'px'});}
if($s.vertical){carousel.css({position:'absolute',top:'0',left:'0',whiteSpace:'nowrap',height:(size*$s.height)+'px',width:$s.width+'px'});carousel.find('li').css({width:$s.width+'px',height:$s.height+'px',overflow:'hidden'});}
else{carousel.css({position:'absolute',top:'0',left:'-'+getStartSlide()+'px',whiteSpace:'nowrap',height:$s.height+'px',width:(size*$s.width)+'px'});carousel.find('li').css({width:$s.width+'px',height:$s.height+'px',float:'left',overflow:'hidden'});}};function gotoSlide(index){index=parseInt(index);moveSlide(index,false);setActiveNav(itemIndex,index);setItemIndex(index);};function setActiveNav(oldIndex,newIndex){container.find('ul.nav a[href='+oldIndex+']').parent('li:eq(0)').removeClass('current');container.find('ul.nav a[href='+newIndex+']').parent('li:eq(0)').addClass('current');};function setNavigation(){var ul=document.createElement('ul');var readableNames=false;if(carousel.find('li:eq(0)[title]').length>0){readableNames=true;}
for(var i=0;i<size-1;i++){var li=document.createElement('li');var a=document.createElement('a');if(readableNames){$(a).attr('href',i).text(carousel.find('li').eq(i).attr('title'));}
else{$(a).attr('href',i).text(i+1);}
li.appendChild(a);ul.appendChild(li);}
$(ul).css({position:'absolute',zIndex:'1000',bottom:'0',left:'0'}).addClass('nav').appendTo(container).find('a').each(function(){$(this).click(function(e){e.preventDefault();gotoSlide($(this).attr('href'));});if(parseInt($(this).attr('href'))===itemIndex){$(this).parent('li:eq(0)').addClass('current');}});};function init(settings,$this){$s=settings;initSettings=settings;container=$this;carousel=$this.find('ul:eq(0)');$this.find('li:eq(0)').clone().appendTo(carousel);size=$this.find('li').size();setStyles();setNavigation();if(!$s.addNavigation){container.find('.nav').hide();}
if($s.autoPlay){play();}};return{init:init,prev:prev,next:next,play:play,pause:pause,toggleFullscreen:toggleFullscreen};})();$.carouselNext=function(opt){opt=$.extend({callback:undefined},opt);carouselMethods.next();if(typeof opt.callback!=='undefined'){opt.callback();}};$.carouselPrev=function(opt){opt=$.extend({callback:undefined},opt);carouselMethods.prev();if(typeof opt.callback!=='undefined'){opt.callback();}};$.carouselPlay=function(opt){opt=$.extend({callback:undefined},opt);carouselMethods.play();if(typeof opt.callback!=='undefined'){opt.callback();}};$.carouselPause=function(opt){opt=$.extend({callback:undefined},opt);carouselMethods.pause();if(typeof opt.callback!=='undefined'){opt.callback();}};$.carouselFullscreen=function(opt){opt=$.extend({callback:undefined},opt);carouselMethods.toggleFullscreen();if(typeof opt.callback!=='undefined'){opt.callback();}};})(jQuery);
/* --------------------------------------------------------
 * Newsticker
-------------------------------------------------------- */
(function($){$.fn.newsticker=function(settings){settings=$.extend({interval:5000,animSpeed:2000,easing:null,json:null},settings);var $u={container:null,items:0,size:0,current:0,old:0,timer:null};var ticker={play:function(){$u.timer=setInterval(ticker.swap,settings.interval);},paus:function(){clearInterval($u.timer);},swap:function(){$u.current=($u.old+1)%$u.size;$u.items.eq($u.old).fadeOut(function(){$u.items.eq($u.current).fadeIn();});$u.old=$u.current;}};function createList(json){var ul=$('<ul></ul>');for(var i=0,j=json.items.length;i<j;i++){var title=json.items[i].Headline;var link=json.items[i].Link;var li=$('<li></li>');var a=$('<a></a>');$(a).attr('href',link).html(title);li.html(a);ul.append(li);}
$u.container.html(ul);};return this.each(function(){$u.container=$(this);if(settings.json!==null){createList(settings.json);}
$u.items=$(this).find('li');$u.items.not(':first').hide();$u.size=$u.items.size();$u.container.mouseover(ticker.paus);$u.container.mouseout(ticker.play);ticker.play();});};})(jQuery);

/* --------------------------------------------------------
 * 
-------------------------------------------------------- */
$(document).ready(function() {
	
	$('#carousel').carousel({
		width: 950,
		height: 455,
		interval: 8000,
		autoPlay: true,
		easing: 'easeInOutQuad',
		animSpeed: 0,
		addNavigation: true,
		vertical: false,
		rotate: true
	}).find('ul.nav a').click($.carouselPause);
	$("div.carouselContainer, div.carouselContainer li").show();
	$('#newsticker').newsticker();
	$(".extraNavLinks #clients").insertAfter("#carousel .nav li:last");
	$(".extraNavLinks #users").insertAfter("#clients");
});