if ($(window.location == 'http://photography.adamkobrin.com/2010/')) {
            $("#caAccordionMenu_photographyLink").css('display','none');
            $("#photographyNoLink").css('display','block');
        };
var subBanner = '#subBanner';
	
$(window).load(function() {
	var sideBoxes = '#caAccordionMenu,#caTextBox';
	var mute_playButton = '#mute_playButton';
	var bgFade = '#pageHeader, #photographyWrapper, p#caCopyrightPhotographyPage';
	var buttonLink = '#buttonLink';
	var buttonHover = '#buttonHover';
	var audio = '#music';
	var play = '#play';
	var mute = '#mute';
		
	$(mute_playButton).mouseover(function() {
		$(buttonLink).hide();
		$(buttonHover).show();
	});
				
	$(mute_playButton).mouseout(function() {
		$(buttonHover).hide();
		$(buttonLink).show();
	});
				
	$(mute_playButton).toggle(
		function() {
			//$(bgFade).fadeTo("4000", 0.5);
			//$("#mute_playButton,#subBanner").fadeTo("2000", 0.7);
			//$(sideBoxes).fadeTo("4000", .8)
			$(audio).attr({src: "/ca/audio/Itchy_low.mp3", autostart: "true", loop: "true", volume: "20", hidden: "false", width: "0", height: "0", style: "display: none;"});
			$(play).hide();
			$(mute).show();
			$(audio).show();
		},
		function() {
			//$(bgFade).fadeTo("4000", 1);
			//$(sideBoxes).fadeTo("4000", 1)
			//$("#mute_playButton,#subBanner").fadeTo("2000", 1);
			$(mute).hide();
			$(play).show();
			$(audio).hide();
	});

	// ******HOVER INTENT******
			
	$("#akLogo_noSub_195px").hoverIntent({
		sensitivity: 30, 
		interval: 120, 
		over: logoOver, 
		timeout: 1, 
		out: logoOut
	});
}); //******END WINDOW.LOAD ***************
	
		
$(document).ready(function(){
	var sideBoxes = '#caAccordionMenu,#caTextBox';
	var navTabs	= '#tab1,#tab2,#tab3,#tab4'		
	var subBanner_Pos = $(subBanner).css('marginTop'); //read CSS property "top"
	subBanner_Pos = parseInt(subBanner_Pos,10);	//remove non-numeric characters

	$('#caLogoShort, #underline').fadeIn();
	$(sideBoxes).fadeIn(600);
	$('#akLogo_Sub_Blue').fadeIn();
	$(subBanner).animate({opacity: '1'},850).fadeIn(500, function(){
		$('#currentMonthYear.blue').fadeIn();
	});	
		startHomeSlideshow();		
	$(navTabs).css('opacity','0');
	$('ul#tabs').animate({opacity: 1.0}, 100).fadeIn(300, function() {
		$('#tab1').animate({opacity: '1'},100, function() {
			$('#tab2').animate({opacity: '1'},150, function() {
				$('#tab3').animate({opacity: '1'},150, function() {
					$('#tab4').animate({opacity: '1'}, 150)
				});
			});
		});	
	});
//**********TABS************
		
	$('#tab1').removeAttr('href').click(function() {
		tab1_click();
	});
	
	$('#tab3').removeAttr('href').bind('click', function() {
		//tab3_click();
		return false;
	});
	
	$('#tab4').removeAttr('href').bind('click', function() {
		tab4_click();
	});
		
	function tab1_click() {
			var mute_playButton = '#mute_playButton';
			var $topStuff = $('#topLogo, #underline, #caBanner, #currentMonthYear.blue');
		$(navTabs).unbind('click');
			contentReset1();
		if($('#submitform').hasClass('formHidden')) {
			$(sideBoxes).css({width: '170px'}).animate({opacity: '0'},410).animate({opacity: '1'}, 1500, 'easeOutQuint');
		};
		$('#caTextBox').css({paddingTop:'12px', paddingLeft:'15px', width: '154px'});
		$('#submitform').fadeOut();
		$(mute_playButton).hide().fadeOut(function(){
			$(this).animate({left:'0', top:'475px'}).fadeIn(1000);
		});
		$(subBanner).fadeOut(function() {
			$(this).css({marginLeft: '237px', top: '42px'}).animate({opacity: '1'},500).fadeIn(1000);
		})
			rebind_tab2();
			rebind_tab3();
			rebind_tab4();
		$('#slideshowBoxPhotography').show();
		$('#photographySlideshow').fadeIn();
			startHomeSlideshow();
		$('#tab1').removeClass('tabs_clickable').addClass('tabs_current').css('backgroundColor','#fff').unbind();
		$('#tab1 span#downArrow').fadeIn();
		$('#submitform').addClass('formHidden');
			tabReset();
		$(navTabs).hide().fadeOut(function() {
				setTimeout("$('#tab1').fadeIn(600)",1400);
				setTimeout("$('#tab2').fadeIn(600)",1500);
				setTimeout("$('#tab3').fadeIn(600)",1600);
				setTimeout("$('#tab4').fadeIn(600)",1700);
			});
		setTimeout("$('#tab1').removeClass('tabs_clickable').addClass('tabs_current').css('backgroundColor','#fff').unbind()",150);
		$('#tab1 span#downArrow').fadeIn();
	}
			
	function tab3_click() {
			var mute_playButton = '#mute_playButton';
			var $topStuff = $('#topLogo, #underline, #caBanner, #currentMonthYear.blue');
		$(navTabs).unbind('click');
		$('#submitform').addClass('formHidden');
		$topStuff.fadeOut();
		$('#submitform').fadeOut();
		$(mute_playButton).fadeOut(function(){
			$(this).animate({left:'-225px', top:'400px'}).animate({opacity: '1'},1500, function(){
				$(this).fadeIn(1000);
			});
		});
		$(subBanner).fadeOut(function() {
			$(this).css({marginLeft: '295px', top: '-8px'}).animate({opacity: '1'},300).fadeIn(800);
		});
		$('#slideshowPhotographyBorder').animate({top: '-70px', left: '-227px', width: '984px', height: '604px'}, 1300, 'easeOutQuint',function(){
			$(this).animate({backgroundColor: '#fff'}, 800, function() {
				rebind_tab1();
				rebind_tab2();
				rebind_tab4();
				$('#galleryPage #content').fadeIn();
			});
		});
			tabReset();
		$(navTabs).hide().fadeOut(function() {
			$('#tabs').css({top: '-68px', left: '-228px', width: '978px'});
			setTimeout("$('#tab1').fadeIn(600)",1400);
			setTimeout("$('#tab2').fadeIn(600)",1500);
			setTimeout("$('#tab3').fadeIn(600)",1600);
			setTimeout("$('#tab4').fadeIn(600)",1700);
		});
		$(sideBoxes).animate({width: '0', opacity: '0'}, 500, 'easeOutQuint');
		$('#slideshowBoxPhotography').hide();
		$('#photographySlideshow, #photographyWrapper').fadeOut();
			stopHomeSlideshow();
			//clickRebind();
	//This breaks in jquery 1.4, not sure why. Using 1.3 for now...
		setTimeout("$('#tab3').removeClass('tabs_clickable').addClass('tabs_current').css('backgroundColor','#fff').unbind()",150);
		$('#tab3 span#downArrow').fadeIn();
	}
	
	function tab4_click() {
			var $topStuff = $('#topLogo, #underline, #caBanner, #currentMonthYear.blue');
			var $content =$('#contentRetouching');
			var mute_playButton = '#mute_playButton';
		$(navTabs).unbind('click');
			contentReset1();
		$(sideBoxes).css({opacity: '1', width: '170px'});
		$(mute_playButton).hide().fadeOut(function(){
			$(this).animate({left:'0', top:'475px'}).fadeIn(1000);
		});
		$('#caTextBox').css({paddingTop:'12px', paddingLeft:'15px', width: '154px'});
		$(subBanner).fadeIn(function() {
			$(this).animate({marginLeft: '237px', top: '42px'},50).animate({opacity: '1'},500).fadeIn(1000);
		});
			tabReset();
			stopHomeSlideshow();
		$('#slideshowPhotographyBorder').animate({backgroundColor: '#cc9'}, function(){
			rebind_tab1();
			rebind_tab2();
			rebind_tab3();
		});
			$('#contactPage').fadeIn();
			$('#submitform').fadeIn().removeClass('formHidden').hide().animate({opacity: '1'},600, function(){
   				$(this).fadeIn(400,function(){
   					$('input:text:first').focus(); //makes "name" field active on mailing list form
   				});
   			});
   	$(navTabs).hide().fadeOut(function() {
			$('#tabs').css({top: '-68px', left: '-228px', width: '978px'});
			setTimeout("$('#tab1').fadeIn(600)",1400);
			setTimeout("$('#tab2').fadeIn(600)",1500);
			setTimeout("$('#tab3').fadeIn(600)",1600);
			setTimeout("$('#tab4').fadeIn(600)",1700);
		});
		$('#submitform textarea').text('');
		setTimeout("$('#tab4').removeClass('tabs_clickable').addClass('tabs_current').css('backgroundColor','#fff').unbind()",150);
		$('#tab4 span#downArrow').fadeIn();
	}
			
//******* TAB REBINDS **********************
//*****************************************
	function rebind_tab1() {
		$('#tab1').bind('click', function() {
			tab1_click();
		});
	}
	
	function rebind_tab2() {
		$('#tab2').bind('click', function() {
			tab2_click();
		});
	}
	
	function rebind_tab3() {
		$('#tab3').bind('click', function() {
			tab3_click();
		});
	}
	
	function rebind_tab4() {
		$('#tab4').bind('click', function() {
			tab4_click();
		});
	}
//***************************************************	
	
	function contentReset1() {
			var $topStuff = $('#topLogo, #underline, #caBanner, #currentMonthYear.blue');
		$topStuff.fadeIn();
		$('#photographyWrapper').fadeIn();
		$('#slideshowPhotographyBorder').animate({top: '-17px', left: '-15px', width: '746px', height: '539px'}, 400, 'easeOutQuint').css({backgroundColor: 'transparent'});
		$('#tabs').fadeOut('fast',function() {
			$(this).css({top: '-15px', left: '-15px', width: '740px'}).animate({opacity: '1'},400).fadeIn(100);
		});
		$('#galleryPage #content').fadeOut();
	}

	
	function tabReset() {
		$('.tabs_current').attr('class','tabs_clickable').attr('style', '');
		$('.tabs_clickable').css({opacity: '0'});
		setTimeout("$('.tabs_clickable').animate({opacity: '1'},900)", 100);
		$('li a span#downArrow').fadeOut();
	}
	
	function startHomeSlideshow() {
		$('#slideshowBoxPhotography').css('opacity','0').fadeIn(2000, function() {
		$(this).append('<embed id="photographySlideshow" src="../ca/img/photographySlideshow/_flash/photographySlideshow_2010.swf" autostart="true" loop="true" hidden="false" width="750" height="503"/>').animate({opacity:'0'},1000, function(){
				$('#progBar').fadeOut();
			}).animate({opacity: '1'},2000);
		});
	}
	
	function stopHomeSlideshow() {
		$('#slideshowBoxPhotography embed').remove();
	}
	
});
