$(function() {
	var move = 0;
	//Rollover
	$('#portfolio_link').mouseover(function() {
		$(this).stop().animate({
			'margin-right' : '-5px'
		}, 500, 'easeOutExpo');
	}).mouseout(function() {
		$(this).stop().animate({
			'margin-right' : '0'
		}, 500, 'easeOutExpo');		
	}).click(function(e) {
		$("#site_slider").animate({
			'left' : '-2000px'
		}, 1000, 'easeInOutExpo');
		$('#site').css('overflow', 'visible');
		move = 0;
		return false;
	});
	$('#back_home').mouseover(function() {
		$(this).stop().animate({
			'margin-left' : '-5px'
		}, 500, 'easeOutExpo');
	}).mouseout(function() {
		$(this).stop().animate({
			'margin-left' : '0'
		}, 500, 'easeOutExpo');		
	}).click(function() {
		$("#site_slider").animate({
			'left' : '0'
		}, 1000, 'easeInOutExpo');
		$('#site').css('overflow', 'hidden');	
		move = 0;	
		return false;
	});
	
	//fade img
    var img = new Image();
    $("#cap").append(img);
	$("#cap img").hide().load(function() {
	       $('#spin').hide();
	       $(this).fadeIn();
	 }).attr('src', "portfolio/cap_last.jpg").css('margin-left', '-1px');
	
	$('.img_wrapper').each(function(i) {
		var img = new Image();
		$(this).append(img);
		$(this).find("img").hide().load(function() { 
	    $(this).fadeIn();
	 	}).attr('src', "portfolio/cap_"+$(this).attr("id")+".jpg");
	});	
	

	$('.img_wrapper img').css(
	{
		'position': 'absolute',
		'top'     : '0',
		'left'    : '0'
	});
	
	
	$(document).bind('mousewheel', function(event, delta) {
	 
	  move -= (delta * 50);
    
	  if(move < 0) move = 0;
	  if(move > 8000) move = 8000;
	  $(document).scrollLeft(move);
      event.preventDefault();
   });
	
});
