function slideShow() {
		$('#main_view').each(function() {
			
			$(this).find('#image_reel a').append('<span></span>');
			
			var $windowWidth=$(this).find('#image_reel span').width();
			var $imgSum=$(this).find('#image_reel img').size();
			var $imgReelWidth=$windowWidth * $imgSum;
		});
		
		/* PRUEBASSSSSS
		$('#image_reel').animate({left: -2000}, 10000);
		
		$('#gnav a')
			.mouseover(function() {
				$('#image_reel').animate({left: -2000}, 10000);
			});
		*/
				
		$('#gnav a')
			.hover(function() {
			
				var $triggerId=$(this).attr('rel')-1;
				var $imgWidth=686;
				var $imgPos=$triggerId * $imgWidth;
				
				$('#image_reel').stop().animate({left : -$imgPos}, 1000);
/* 				alert($imgPos); */
				
				$(this).parent().parent().find('a').removeClass('active');
				$(this).addClass('active');
			});
			
			/* activate first link */
			
			$('#home #gnav a:first').addClass('active');
}
		/* Add the hover */
		/*
$('.paging a')
			.hover(function() {
				var $triggerId=$(this).attr('rel')-1;
				var $imgWidth=585;
				var $imgPos = $triggerId * $imgWidth;
				
				$('#reel').stop().animate({left: -$imgPos}, 1000);
				$(this).parent().find('a').removeClass('active');
				$(this).addClass('active');
				
			});
			
			
*/
/* Interior Slideshow */

	function imageGallery() {
		$('#reel').find('a').append('<span></span>');
		$('#reel a').find('span').css('opacity', '0');
		/* Set the variables */
		var $windowWidth=$('#reel span').width();
		var $imgSum=$('#reel img').size();
		var $imgReelWidth=$windowWidth*$imgSum;  
		
		/* Create the links */
		
		for (i=0; i<$imgSum; i++) { 
			var $curNum=i+1;
			$('.paging').append('<a href="#" rel="'+$curNum+'">'+$curNum+'</a>');
	 
			$('.paging a').hover(function() {
				var $triggerId=$(this).attr('rel')-1;
				var $imgWidth=$windowWidth;
				var $imgPos=$triggerId*$imgWidth;
				
				$('#reel').stop().animate({left: -$imgPos}, 1000);
				$(this).parent().find('a').removeClass('active');
				$(this).addClass('active');
				
			}); 
		}
		
		$('.paging a:first').addClass('active'); 
	}
		
	

	
	
	function listingPages() {
		
		$('.listing #content h2:first').css('marginTop', '100px');
	}
		
	function boxDropShow(){
        $(this).addClass('hover').find('ul').slideDown(300, function(){
            $(this).parents('li').addClass('hover'); // in case user mousesOn/Off the nav quicly
        });
	}
	   
    function boxDropHide (){
        $(this).find('ul').slideUp(300, function(){
            $(this).parents('li').removeClass('hover');
        });
  	 }
  	 
  	function caseStudyThumbs() {
  		var move=-10;
		var zoom=1.2;
	
	$('.case_study').hover(function() {
		width=$('.case_study').width() *zoom;
		height=$('.case_study').height() *zoom;
		
		$(this).find('img').stop(false, true).animate({'width': width, 'height': height, 'top':move, 'left':move}, {duration:200});
		
/* 		display caption */
		$(this).find('.caption').stop(false, true).fadeIn(200);
		}, function () {
			$(this).find('img').stop(false, true).animate({'width': $('.case_study').width(), 'height': $('.case_study').height(), 'top': '0', 'left': '0'}, {duration: 100});
			$(this).find('.caption').stop(false, true).fadeOut(200);
			
	})
		
	} 
	 
  	  
$(document).ready(function() {
  slideShow();
	imageGallery();  
	caseStudyThumbs();
});

