if (!Array.prototype.forEach)
{
	Array.prototype.forEach = function(fun /*, thisp */)
	{
		"use strict";

		if (this === void 0 || this === null)
			throw new TypeError();

		var t = Object(this);
		var len = t.length >>> 0;
		
		if (typeof fun !== "function")
			throw new TypeError();

		var thisp = arguments[1];
		
		for (var i = 0; i < len; i++)
		{
			if (i in t)
			fun.call(thisp, t[i], i, t);
		}
	};
}

var BIG_CAROUSEL	= {
	animationEase												: 'easeInOutQuint',
	animationIntervalTime										: 6000,
	animationTime												: 1000,
	checkInterval												: null,
	hasjQuery													: true,
	i															: 1,
	jqueryQueue													: [ ],
	m															: null,
	t															: null,
	u															: null,
	w															: null,
	
	checkForjQuery												: function()
	{
		if ( typeof jQuery != 'undefined' )
		{
			clearInterval( BIG_CAROUSEL.checkInterval );

			BIG_CAROUSEL.jqueryQueue.forEach( function(o)
			{
				o.f.apply( null, o.a );
			});
		}
	},
	
	startCarousel												: function()
	{
		if ( !BIG_CAROUSEL.hasjQuery )
		{
			BIG_CAROUSEL.jqueryQueue.push( BIG_CAROUSEL.startCarousel );
			
			return;
		}
		
		jQuery( '#carousel-triggers li a' ).click( function()
		{
			// BIG_CAROUSEL.jumpToSlide( $( this ).parent().index() );
			
			$( 'li a', BIG_CAROUSEL.u ).eq( $( this ).parent().index() ).click();
			
			window.location.href	= $( 'li a', BIG_CAROUSEL.u ).eq( $( this ).parent().index() ).attr( 'href' );
			
			return false;
		});
		
		jQuery( '.big_carousel .leftarrow, .big_carousel .rightarrow' ).click( function()
		{
			if ( $( this ).hasClass( 'leftarrow' ) )
			{
				var s	= BIG_CAROUSEL.i - 2;

				if ( s < 0 )
				{
					s	= BIG_CAROUSEL.m - 1;
				}
			}
			else
			{
				var s	= BIG_CAROUSEL.i;

				if ( s > BIG_CAROUSEL.m - 1 )
				{
					s	= 0;
				}
			}
			
			BIG_CAROUSEL.jumpToSlide( s );
			
			return false;
		});
		
		var c	= jQuery( '.big_carousel' );

		if ( c.length > 0 )
		{
			BIG_CAROUSEL.m	= jQuery( 'li', c ).length;
			BIG_CAROUSEL.u	= jQuery( 'ul', c );
			BIG_CAROUSEL.w	= jQuery( 'li:first', c ).outerWidth();

			BIG_CAROUSEL.u.width( BIG_CAROUSEL.m * BIG_CAROUSEL.w );
			
			BIG_CAROUSEL.t	= setTimeout( BIG_CAROUSEL.slideCarousel, BIG_CAROUSEL.animationIntervalTime );
		}
	},
	
	slideCarousel												: function()
	{
		clearTimeout( BIG_CAROUSEL.t );
		
		if ( BIG_CAROUSEL.i >= BIG_CAROUSEL.m )
		{
			BIG_CAROUSEL.i   = 0;
		}

		BIG_CAROUSEL.u.stop( true, true ).animate({
			'margin-left'   : BIG_CAROUSEL.i * BIG_CAROUSEL.w * -1 + 'px'
		}, BIG_CAROUSEL.animationTime, BIG_CAROUSEL.animationEase );
		
		BIG_CAROUSEL.i++;
		
		BIG_CAROUSEL.t	= setTimeout( BIG_CAROUSEL.slideCarousel, BIG_CAROUSEL.animationIntervalTime );
	},
	
	jumpToSlide													: function(i)
	{
		clearTimeout( BIG_CAROUSEL.t );
		
		BIG_CAROUSEL.i	= i;
		
		BIG_CAROUSEL.slideCarousel();
	}
};

BIG_CAROUSEL.checkForjQuery();

if ( typeof jQuery == 'undefined' )
{
	BIG_CAROUSEL.checkInterval	= setInterval( BIG_CAROUSEL.checkForjQuery, 250 );
	
	document.write( '<scr' + 'ipt src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></scr' + 'ipt>' );
	document.write( '<scr' + 'ipt src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></scr' + 'ipt>' );
}
