
	var ShowFolio = {
		cur : 0,
		items : [],
		player : null,
		timer : null,
		init : function ()
		{
			this.items = $('.slideshow li');
			
			if( $('#featured').length )
			{
				this.items.shuffle();
				this.items = $('.slideshow li');
				//this.items.removeClass('show');
				//this.items.eq( Math.floor( Math.random()*this.items.length ) ).addClass('show');
				var li = $('#featured li.show');
				this.cur = this.items.index(li);
			}
			
			if( this.items.length > 1 )
			{
				$('.setaleft').bind('click',this.prev).mouseenter(this.clearTimer).mouseleave(this.createTimer);
				$('.setaright').bind('click',this.next).mouseenter(this.clearTimer).mouseleave(this.createTimer);
				$('.slideshow').mouseenter(this.clearTimer).mouseleave(this.createTimer);
				this.items.each(function(i,el)
				{
				 	//$(el).find('img').bind('click',ShowFolio.next);
				});
			} else {
				$('.setaleft').hide();
				$('.setaright').hide();
			}
			
			
			this.createTimer();
		},
		
		createTimer : function (e)
		{
			if( ! $('#featured').length || ShowFolio.timer != null ) return;
			
			ShowFolio.timer = setInterval(ShowFolio.next, 4000);
			
		},
		
		clearTimer : function (e)
		{
			//alert('over');
			
			if( ShowFolio.timer == null ) return;
			
			clearInterval(ShowFolio.timer);
			ShowFolio.timer = null;
		},
		
		next : function (e)
		{
			if(e) e.preventDefault();
			ShowFolio.items.removeClass('show');
			ShowFolio.cur = ShowFolio.cur < ShowFolio.items.length -1 ? ShowFolio.cur +1 : 0;
			ShowFolio.items.eq(ShowFolio.cur).addClass('show').fadeTo(0,0).fadeTo(500,1);
			ShowFolio.stopPlayer();
		},
		
		prev: function (e)
		{
			if(e) e.preventDefault();
			ShowFolio.items.removeClass('show');
			ShowFolio.cur = ShowFolio.cur > 0 ? ShowFolio.cur -1 : ShowFolio.items.length -1;
			ShowFolio.items.eq(ShowFolio.cur).addClass('show').fadeTo(0,0).fadeTo(500,1);
			ShowFolio.stopPlayer();
		},
		
		stopPlayer: function ()
		{

		}
		
	};
	
	
	jQuery(document).ready(function($){
		
		ShowFolio.init();
		
		if( $('body.home').length )
		{
			$('#lang_menu a')
				.animate({'backgroundColor':'#f60'},500).animate({'backgroundColor':'#333'},500)
				.animate({'backgroundColor':'#f60'},500).animate({'backgroundColor':'#333'},500)
				.animate({'backgroundColor':'#f60'},500).animate({'backgroundColor':'#333'},500)
				.animate({'backgroundColor':'#f60'},500).animate({'backgroundColor':'#333'},500)
				.animate({'backgroundColor':'#f60'},500)
				.animate({'backgroundColor':'#333'},500, function(){ $(this).attr('style',''); })
			;
			
		}
		
		var $ssiframe = jQuery(".slideshow iframe");
		var $window = jQuery(window);
		
		if( $ssiframe.length ){
			$window.resize( function(e){
				if( $window.width() <= 480 ){
					$ssiframe.height( $window.width()*9/21 );
				}else{
					$ssiframe.height(340);
				}
			} );
			$window.resize();
		}
		
		if( // se estiver no WINDOWS XP desabilita Droid Sans
			(navigator.userAgent.indexOf('Windows NT 5.1') != -1) || 
			(navigator.userAgent.indexOf('Windows NT 5.2') != -1)
		)
		{
			$('body').css('fontFamily', "Arial, Helvetica, sans-serif");
		}
		
		if ( Modernizr.opacity )
		{
			$('.supertag').css('opacity',.8)
		}
		
		
	});
	
/**
 * jQuery Shuffle (http://mktgdept.com/jquery-shuffle)
 * A jQuery plugin for shuffling a set of elements
 *
 * v0.0.1 - 13 November 2009
 *
 * Copyright (c) 2009 Chad Smith (http://twitter.com/chadsmith)
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-license.php
 *
 * Shuffle elements using: $(selector).shuffle() or $.shuffle(selector)
 *
 **/
		(function(d){d.fn.shuffle=function(c){c=[];return this.each(function(){c.push(d(this).clone(true))}).each(function(a,b){d(b).replaceWith(c[a=Math.floor(Math.random()*c.length)]);c.splice(a,1)})};d.shuffle=function(a){return d(a).shuffle()}})(jQuery);

