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;
		});
		
		$('#gnav a')
			.hover(function() {
			
				var $triggerId=$(this).attr('rel')-1;
				var $imgWidth=670;
				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');
}
		
/* 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;
		
		/*
$('#reel a')
			.hover(function() {
				$(this).find('span').stop().animate({opacity: .7}, 200).show();
			}, function() {
				$(this).find('span').stop().animate({opacity: 0}, 200);
			});
*/
		
		/* 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');
				
			});
		
	}
		
	

	
	
	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);
			
	})
		
	} 
	
/* SWITCH LANGUAGES	 */

function switchLanguage(lang) {
   var $u = location.href.split('/');
   if(lang =="es") {
      $u.splice(3, 0, lang); 
   } else {
     $u.splice(3, 1) ;
  }

   location.href = $u.join('/');

}





  	 
  	
  	  
$(document).ready(function() {
	slideShow();
	imageGallery();
	caseStudyThumbs();
});
