$(document).ready(function() {
	$('.back').css({'display':'none'}).fadeTo(1, 0);
	
	$('.frame').find('p').each(function() { Cufon.replace($(this), "Futura"); });
	Cufon.replace($('.frame').find('h1'), "Futura");
	Cufon.replace($('.frame').find('h5'), "Futura");
	
	$('#home_vids').find('p:first').css({'margin-right': '22px'});
	
	
	
	
	$('.next').click(function() {
		var cont = $(this).parent().parent();
		var obj = $(this).parent();
		
		$(cont).animate({ 'left':'-=526px' }, 500, function() {
			//if the rel of what we just clicked is 1, fade in abck button
			if ( $(obj).attr('rel') == '1' ) {
				$('.back').css({'display':'block'}).fadeTo(350, 1);
			}
			
			// if were too far, go back!
			if ( removePx( $(this).css('left')) < -2631 ) {$(this).animate({'left':'-2630px'}, 200); }
		});
	});
	
	
	$('.back').click(function() {	
		var cont = $('#home_container');
			
		$(cont).animate({ 'left':'+=526px' }, 500, function() {

			if ( removePx( $(cont).css('left')) >= 0 ) {
				$('.back').fadeTo(200, 0).fadeTo(500, 0).css({'display':'none', 'opacity' : '0'});
			} 
			
			//if were to far go back!
			if ( removePx( $(cont).css('left')) > 0 ) { $(this).animate({'left':'0px'}, 200); }
		});
	});	
});


function removePx(number) {
	var out = number.replace('px', ''); 
	return (out * 1);
}