$(document).ready(function() {

	init();
	
	if(navigator.appName == "Microsoft Internet Explorer") {
		$('body').css('overflow', 'visible');
	}
	
	setTimeout(function() {
		setInterval("animateHero()", 9800);
	}, 800);
	
	getTwitters('twitter_feed', {
		id: 'zone1media', 
	    prefix: '<a href="http://twitter.com/zone1media" class="thumb_link">&nbsp;</a>', 
	    clearContents: true,
	    count: 5, 
	    withFriends: true,
	    ignoreReplies: false,
	    newwindow: true,
		callback: function() {
			$('#twitter_feed_holder').css('background', '#353735');
			$('#twitter_feed ul').fadeIn(500);
		}
	});
	
	$('.blank').click(function() {
		var href = $(this).attr('href');
		window.open(href);
		
		return false;
	});
	
	var eq = 0;
	setInterval(function() {
		$('#examples a').css('color', '#4c5353');
		$('#examples a').eq(eq).css('color', '#e5389c');
		
		eq = (eq == $('#examples a').length - 1) ? 0 : eq + 1;
	}, 800);
	
	
});

$(window).ready(function() {
	
	setTimeout(function() {
		$('#wrapper').animate({
			'opacity' : 1
		}, 1000);
	}, 400);
	
});


function init() {
	resetHero();
	setTimeout("animateHero()", 500);
}

function resetHero() {
	$('.hero-img').css('left', ($(window).width() + 1000)+"px").hide().eq(0).show();
	$('.hero-tag').css('left', ($(window).width() + 1000)+"px").hide().eq(0).show();
	$('.hero-desc').css('left', ($(window).width() + 1000)+"px").hide().eq(0).show();
}

function animateHero() {
	var index = $('.hero-img:visible').index();
	
	$('.hero-tag:visible, .hero-desc:visible').animate({
		left : "0px" 
	}, {
	    duration : 900, 
	    easing   : 'easeOutQuint'
	});
	
	$('.hero-img:visible').animate({
		left : "0px" 
	}, {
	    duration : 1000, 
	    easing   : 'easeOutQuint',
	    complete : function() { 
	    
	    	setTimeout(function() {
	    		$('.hero-tag:visible, .hero-desc:visible').animate({
	    			left : "-"+($(window).width() + 1000)+"px"  
	    		}, {
	    		    duration : 1000, 
	    		    easing   : 'easeInQuint'
	    		});
	    		
	    	}, 7400);
	    	
	    	setTimeout(function() {
	    		    		
	    		$('.hero-img:visible').animate({
	    			left : "-"+($(window).width() + 1000)+"px" 
	    		}, {
	    		    duration : 1000, 
	    		    easing   : 'easeInQuint',
	    		    complete : function() {
	    		    	
	    		    	if(index == ($('.hero-img').length - 1)) {
	    		    		resetHero();
	    		    	} else {
	    		    		$('.hero-img').eq(index).hide();
	    		    		$('.hero-img').eq(index + 1).show();
	    		    		
	    		    		$('.hero-tag').eq(index).hide();
	    		    		$('.hero-tag').eq(index + 1).show();
	    		    		
	    		    		$('.hero-desc').eq(index).hide();
	    		    		$('.hero-desc').eq(index + 1).show();
	    		    	}
	    		    }
	    		});
	    		
	    	}, 7500);
	    }
	});
}