$(document).ready(function(){
	//SETS FUNCTION TO DETECT IE6
	function isIE6(){
		IE6 = (navigator.appVersion.indexOf("MSIE 6.")==-1) ? false : true;
		return IE6;
	}
						
	/*////////SHARE THIS HOVER EFFECTS////////*/
	$('.share-twitter').mouseenter(function() {
		$('.share-facebook').stop(true, true).fadeTo('medium', 0.4);
		$('.share-email').stop(true, true).fadeTo('medium', 0.4);
	});
	
	$('.share-twitter').mouseleave(function() {
		$('.share-facebook').stop(true, true).fadeTo('medium', 1);
		$('.share-email').stop(true, true).fadeTo('medium', 1);
	});
		
	$('.share-facebook').mouseenter(function() {
		$('.share-twitter').stop(true, true).fadeTo('medium', 0.4);
		$('.share-email').stop(true, true).fadeTo('medium', 0.4);
	});
	
	$('.share-facebook').mouseleave(function() {
		$('.share-twitter').stop(true, true).fadeTo('medium', 1);
		$('.share-email').stop(true, true).fadeTo('medium', 1);
	});
	
	$('.share-email').mouseenter(function() {
		$('.share-twitter').stop(true, true).fadeTo('medium', 0.4);
		$('.share-facebook').stop(true, true).fadeTo('medium', 0.4);
	});
	
	$('.share-email').mouseleave(function() {
		$('.share-twitter').stop(true, true).fadeTo('medium', 1);
		$('.share-facebook').stop(true, true).fadeTo('medium', 1);
	});
	

	/*//////// SCROLL BUTTON MOUSE OVER ////////*/	
    $(".up-arrow-enabled").mouseenter(function(e) {
        $(this).attr('src', "/media/images/scrollarrow_up_rollover.gif");
    }).mouseleave(function(e) {
        $(this).attr('src', "/media/images/scrollarrow_up_active.gif");
    });
    $(".down-arrow-enabled").mouseenter(function(e) {
        $(this).attr('src', "/media/images/scrollarrow_down_rollover.gif");
    }).mouseleave(function(e) {
        $(this).attr('src', "/media/images/scrollarrow_down_active.gif");
    });

	
	/*////////ABOUT ATMOSPHERE BUTTON HOVER////////*/	
	/*
	var aboutDelay = 3500;

	
	$('a.about-atmosphere-button').stop(true,true).delay(aboutDelay).mouseenter(function(){
		$(this).animate({ left: 68}, 1000);
	});
	
	$('a.about-atmosphere-button').stop(true,true).mouseleave(function(){
		$(this).animate({ left: 0}, 600);
	});
	*/
	
	/*////////VISIT SITE BUTTON HOVER////////*/	
	/*
	$('.visit-site-case').mouseenter(function() {
		$(this).animate({ left: 15}, 1000);	
	});
	
	$('.visit-site-case').mouseleave(function() {
		$(this).animate({ left: 0}, 1000);	
	});
	*/
	
	/*////////FEATURED PROJECT THUMB ANIMATION////////*/	
	$('p.watch-fade').hide();
	
	
	$('.fade-thumb').mouseenter(function () {
		$(this).find('a.more-button').stop(true, true).animate({ right: 67}, 500);
		$(this).find('p.watch-fade').stop(true, true).slideDown('slow');
		$(this).find('img.project-thumb').stop(true,true).fadeTo('medium', 0.6);
		
	});
	
	$('.fade-thumb').mouseleave(function () {
		$(this).find('a.more-button').stop(true, true).animate({ right: 32}, 500);
		$(this).find('p.watch-fade').stop(true, true).slideUp('slow');
		$(this).find('img.project-thumb').stop(true,true).fadeTo('medium', 1);
		
	});
	
	/*////////OUR WORK SUB-NAV DROP DOWN////////*/	
	/*
	 * dropdown hover state in sub-nav menus headers was getting moved.
	 * for IE6, there are no outline hover state for filter menu headers.
	 *  
	 */
	if(isIE6()){
		 var dropDelay = 100;
		
		$('.dropdown-hide').hide();
		$('.hide-hover-state').hide();
		
		$('li.subnav-trigger').mouseenter(function() {
			$(this).find('.dropdown-hide').stop(true, true).delay(dropDelay).slideDown('slow');
		});
		
		$('li.subnav-trigger').mouseleave(function() {
			$(this).find('.dropdown-hide').stop(true, true).slideUp('slow');
		});

	}
	else {
		var dropDelay = 100;
	
		$('.dropdown-hide').hide();
		$('.hide-hover-state').hide();
		
		$('li.subnav-trigger').mouseenter(function() {
			$(this).find('.dropdown-hide').stop(true, true).delay(dropDelay).slideDown('slow');
			$(this).find('.hide-hover-state').stop(true, true).delay(dropDelay).fadeTo('medium', 1);
		});
		
		$('li.subnav-trigger').mouseleave(function() {
			$(this).find('.dropdown-hide').stop(true, true).slideUp('slow');
			$(this).find('#drop-hover-state').stop(true, true).fadeTo('medium', 0);
		});
	}
	
	/*////////OUR COMPANY ICONS EFFECTS////////*/	
	$('.fade-client-thumb').fadeTo('slow', 0.4);
	$('ul.clients li #left').mouseenter(function() {        
		$(this).find('.fade-client-thumb').stop(true,true).fadeTo('medium',1);    
	});
	$('ul.clients li #left').mouseleave(function() {        
		$(this).find('.fade-client-thumb').stop(true,true).fadeTo('slow', 0.4);    
	});
	$('ul.clients li #right').mouseenter(function() {        
		$(this).find('.fade-client-thumb').stop(true,true).fadeTo('medium',1);    
	});        
	$('ul.clients li #right').mouseleave(function() {        
		$(this).find('.fade-client-thumb').stop(true,true).fadeTo('slow', 0.4);    
	});   	
	
	/*JS FOR POP UPS IN THE SLIDER CONTROLS*/
	/*
	 * for IE6, there are not rollover icons for hero image area. 
	 */
	if(isIE6()){
		$('.pop-hide').hide();
	}
 	else {
		$('.pop-hide').hide();
		$('ul.each-slide li').mouseenter(function() {
			$(this).find('.pop-hide').stop(true, true).slideDown('fast');	
		
		});
		
		$('ul.each-slide li').mouseleave(function() {
			$(this).find('.pop-hide').stop(true, true).slideUp('fast');	
		
		});
	}

	/*//////////SOCIAL MEDIA DECK EFFECTS/////////*/
	//open slide animations
	if(isIE6())
	{
		$('.close-slide-button').hide();
		$('.open-slide').click(function() {
			$('.close-slide-button').css({'top':'-378px'});
			$('#social-wrapper').animate({"margin-left":0}, 500, 'easeOutQuad', 
				function() {
					$('.close-slide-button').slideDown('fast');
				});
			$('.slider-cta').fadeTo('slow', 0);		
			$('.open-slide-button').slideUp('fast', 'easeOutElastic');				 
		});
		$('.close-slide-button').click(function() {
			$('.close-slide-button').animate({"top":0}, 1000, 'easeOutBounce',
				function() {
					$('.close-slide-button').hide();
					$('#social-wrapper').animate({"margin-left":-962},500, 'easeOutQuad',
						function() {	
						$('.slider-cta').fadeTo('fast', 1);
						$('.open-slide-button').slideDown('fast');
						$('.close-slide-button').hide();
						
				});
			});	
		});
		
	 }
	 else {	
		$('.close-slide-button').hide();
		$('.open-slide').click(function() {
			$('.close-slide-button').css({'top':'-5px'});
			$('#social-wrapper').animate({"margin-left":0},500, 'easeOutQuad', 
				function() {
					$('.close-slide-button').slideDown('fast');
				});
			$('.slider-cta').fadeTo('slow', 0);		
			$('.open-slide-button').slideUp('fast', 'easeOutElastic');				 
		});
		$('.close-slide-button').click(function() {
			$('.close-slide-button').animate({"top":380}, 1000, 'easeOutBounce',
				function() {
					$('.close-slide-button').hide();
					$('#social-wrapper').animate({"margin-left":-962},500, 'easeOutQuad',
						function() {	
						$('.slider-cta').fadeTo('fast', 1);
						$('.open-slide-button').slideDown('fast');
						$('.close-slide-button').hide();
						
				});
			});	
		});
	}	
	
	$(document).click(function(e){
		if($(e.target).parents().index($('#social-wrapper')) == -1){
			if($('.open-slide-button').css('display') == 'none'){
				$('.close-slide-button').trigger('click');
			}
		}
	});

	/* generic IE FIXES
	 * 
	 * for png there are no more rollover states, we use a blank
	 * gif to alleviate the double images showing in IE6.
	 * 
	 */
	if(isIE6()) {
		/*featured work hover state fix*/
		var moreImage = '<img src="/images/ie6/more_button.gif/">';
		$('.more-button').append(moreImage);
	
		/*main slider arrows fix*/
		var rightArrow = '<img src="/images/ie6/controls_right.gif/">';
		$('a.right').append(rightArrow);
	
		var leftArrow = '<img src="/images/ie6/controls_left.gif/">';
		$('a.left').append(leftArrow);
		
		/*main slider counter fix*/
		var sliderCounter = '<img src="/images/ie6/slide_counter.gif/">';
		$('#main-banner ul.each-slide li a').append(sliderCounter);
		/*visit site button fix*/

		/*visit site button fix*/
		var visitSite = '<img src="/images/ie6/visit_site.gif/">';
		$('a.visit-site-button').append(visitSite);

		/*view all button fix*/
		var viewAll = '<img src="/images/ie6/view_all.jpg/">';
		$('a.view-all-button').append(viewAll);

		/*close video button*/
		var closeVideo = '<img src="/images/ie6/close_video_button.gif">';
		$('.close-video').append(closeVideo);
		
		/*watch video button fix*/
		var watchVideo = '<img src="/images/ie6/watch_video.gif/">';
		$('a.video-show-button').append(watchVideo);
		
		/*scroll button fixes*/
		//$('#up-arrow').html("");
		//var upArrow = '<img src="/images/ie6/up_arrow.gif/">';
		//$('#up-arrow').append(upArrow);
		
		//$('#down-arrow').html("");
		//var downArrow = '<img src="/images/ie6/down_arrow.gif/">';
		//$('#down-arrow').append(downArrow);
			
		/*about atmosphere button fix*/
		var aboutAtmo = '<img src="/images/ie6/about_atmosphere.gif">';
		$('a.about-atmosphere-button').append(aboutAtmo);
			
				
		/*removes numbers from our work controls*/
		$('#generic-work-list-wrapper ul.each-slide').html("");
		
		/*featured work drop down fix*/
		$('.hide-hover-state').css({display:'none'});
	}
});

