

initHome = function(){
	//
	/// MAIN CAROUSEL
	//
	$("#introhome").hover(function() {
		$('#carousel_thumbs ul').animate({top: '0' }, 200);
	}, function() {
		 $('#carousel_thumbs ul').animate({top: '70' }, 300);
	});
	//
	function mycarousel_initCallback(carousel) {
		jQuery('#carousel_thumbs a').bind('click', function() {
			carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr("rel")));
			return false;
		});
	};
	//
	var mainScrollWidth = $('#carousel_thumbs ul li').length * 122;
	$('#carousel_thumbs ul').css({'width':mainScrollWidth});
	//
	var mainRatio = (mainScrollWidth-740);
	$("#introhome").mousemove(function(e){	
		var x = e.pageX - this.offsetLeft;			
		//
		var test = Math.round((x/500)*mainRatio)-50;
		$("#carousel_thumbs").scrollLeft(test);
			
	});
	
	//
	//
	jQuery('#mycarousel').jcarousel({
	   scroll: 1,
	   initCallback: mycarousel_initCallback, 
	   auto: 4,
		wrap: 'last'
	});
	//
	jQuery('#client_list').jcarousel({
		scroll: 1,
		auto: 4,
		wrap: 'last'
	});
	//
	$(".openMtv").colorbox({iframe:true, innerWidth:480, innerHeight:360});
	//
	//// TWITTER
	//
	$("#twitter_content").tweet({
		avatar_size: 32,
		count: 5,
		username: ["amckdance"],
		template: "{text}",
		loading_text: "searching twitter...",
		refresh_interval: 60
	}).bind("loaded",function(){$(this).find("a").attr("target","_blank");});
	//
	//// Works scroll
	//
	worksScrollWidth = $('#workshome #newsholder').width();
	
	var worksRatio = (worksScrollWidth-740);
			
	$("#newsscroll").mousemove(function(e){	
		var x = e.pageX - this.offsetLeft;			
		//
		var test = Math.round((x/640)*worksRatio)-50;
		$("#newsscroll").scrollLeft(test);
			
	});
	
};


// ============================================== //

		// DOM READY //

// ============================================== //

$(document).ready(function(){
	
	if($('#page_home').length){
		initHome();
	};
	
});

