//BEGIN JQUERY

$(document).ready(function(){

	//ROLLOVER CONTENT

	$('.rollover').each(function(){
		$(this).children('.rollover_content').show();
		height = $(this).children().outerHeight();
		$(this).children('.rollover_content').css({top:'-'+height+'px'});		
	});
	
	$('.rollover').mouseenter(function(){
		$(this).children('.rollover_content').stop([]).animate({top:0},600,'easeInOutExpo');
	});
	$('.rollover').mouseleave(function(){
		xPos = $(this).children().outerHeight();
		$(this).children('.rollover_content').stop([]).animate({top:'-'+xPos+'px'},600,'easeInOutExpo');
	});
	
	
	//ROLLOVER CONTENT
	
	$('#slideshow').css({width:$('#slideshow img:first').width(), height:$('#slideshow img:first').width()}).children('img:first').addClass('current').siblings('img').hide();
	
	speed = 5000;
	current = 1;
	total = $('#slideshow img').size();
	var slideTimer = {};
	
	function slideShow(){
		tweetTimer = $.timer(speed,function(){
			if(current < total){
				$('#slideshow img.current').next('img').addClass('fadein').css({display:'block', opacity:0}).animate({opacity:1},400,function(){
					$(this).removeClass('fadein').addClass('current');
					$(this).prev('img').removeClass('current').hide();
					current++;
					slideShow();
				});
			}else{
				current = 1;
				$('#slideshow img:first').show();
				$('#slideshow img.current').addClass('fadein').animate({opacity:0},400,function(){
					$(this).removeClass('fadein').removeClass('current').hide();
					$('#slideshow img:first').addClass('current');
					slideShow();
				});
			}
		});
	}
	slideShow();
	
	
	//MORE LINKS
	$('#more').hide();
	
	clicky = true;
	
	$('a.read_more').click(function(){
		if(clicky == true){
			clicky = false;
			if($(this).text() == 'Read more'){
				$(this).addClass('less').text('Read less');
			}else{
				$(this).removeClass('less').text('Read more');
			}
			$(this).next('div#more').slideToggle('easeInOutExpo',function(){
				clicky = true;
			});
		}
		return false;
	});

});

//END JQUERY

//EXTRAS

jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	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;
	}
});

/*
 * jQuery Timer Plugin
 * http://www.evanbot.com/article/jquery-timer-plugin/23
 *
 * @version      1.0
 * @copyright    2009 Evan Byrne (http://www.evanbot.com)
 */

jQuery.timer = function(time,func,callback){
	var a = {timer:setTimeout(func,time),callback:null}
	if(typeof(callback) == 'function'){a.callback = callback;}
	return a;
};

jQuery.clearTimer = function(a){
	clearTimeout(a.timer);
	if(typeof(a.callback) == 'function'){a.callback();};
	return this;
};

