﻿var $subBannerRetouching = $('#subBannerRetouching');
var $caFootnote = $('#caFootnote');
var $akLogo_Sub = $('#akLogo_Sub');
var $caCopyright = $('#caCopyright');
var $caMenu = $('#caMenu');
var $caTextBox = $('#caTextBox');
var $pricingCurrentTab = $('#pricingCurrentTab');
//var allTabs = '#homeTab, #pricingTab, #moreInfoTab, #contactTab';

	$(function(){
		$('#retouchWrapper').after('<img id="retouchWrapperTall" src="/ca/img/wrapper1000px_retouchTALL.jpg" style="position: absolute; display: none; left: -10px; top: -10px; margin-left: 0; margin-right: auto;" alt="" />');

		setTimeout('$caMenu.fadeIn(350)', 100);
		setTimeout('$caTextBox.fadeIn(500)', 500);
		resetRetouchContent();
		$("#caMenu_retouchingLink").hide();
		$("#retouchingNoLink").show();
		$(this).attr("href","#_retouching");
		//setTimeout('$("#caBanner").animate({opacity: ".1"}, 850)', 950);
		setTimeout("$subBannerRetouching.fadeIn(900)", 850);	
		$('#underline').fadeIn();
		setTimeout("$('#contentRetouching').fadeIn()", 800);
	
// *****************************
//   HOVER INTENT and FUNCTIONS
// *****************************

//Top Logo hover//
	$akLogo_Sub.hoverIntent({
		sensitivity: 3, 
		interval: 120, 
		over: logoOver, 
		timeout: 1, 
		out: logoOut
  	});
  	  	
//MoreSamples hover//		
	$('.moreSamplesLink').hoverIntent({
		sensitivity: 3,
		interval: 60,
		over: textShift,
		out: textShiftBack
	});
	function textShift (){
		//$('.moreSamplesLink p span:eq(0)').animate({marginLeft: "+=2px", color: "#660000", letterSpacing: "+=.01em"}, 500);
		//$('.moreSamplesLink p span:eq(1)').animate({marginLeft: "+=3px", color: "#660000", letterSpacing: "+=.01em"}, 500);
		$('.moreSamplesLink p span:eq(2)').fadeIn();
		setTimeout('$(".moreSamplesLink p span:eq(3)").fadeIn()', 200);
	}
	function textShiftBack (){
		//$('.moreSamplesLink p span:eq(0)').animate({marginLeft: "-=2px", color: "#330066", letterSpacing: "-=.01em"}, 700);
		//$('.moreSamplesLink p span:eq(1)').animate({marginLeft: "-=3px", color: "#330066", letterSpacing: "-=.01em"}, 700);
		$('.moreSamplesLink p span:eq(2),.moreSamplesLink p span:eq(3)').fadeOut();
	}

//end hoverIntent


	//***************
	//	  BANNER
	// **************	

		function resetRetouchContent() {
				var $content =$('#contentRetouching');
			$('.page1').css("display","block");
			$('#pricingPage, .page2,#retouchWrapperTall').css("display","none");
			$pricingCurrentTab.css("display","none").css({marginTop: "5px", left: "80px", fontSize: "13px"}, 800);
			$("a#pricingTab,#retouchWrapper").fadeIn();
			setTimeout('$caCopyright.css({top: "685px"})', 100);
			$content.css({height: "539px", top: "140px"}, 750);
		}

	
	/**************** Tabs*****************/			
			
		$('#pricingText1, #pricingText2, #pricingText3, #pricingText4').css({display: "none"});
		$('#pricingTab').click(function() {
					var $content =$('#contentRetouching');
				fadeAllPages();
				tabReset();
			$pricingCurrentTab.show().animate({marginTop: "60px", left: "50px", fontSize: "16px"}, 1100);
			$('a#pricingTab').fadeOut(100);
			setTimeout('$("#pricingPage").fadeIn(800)', 800);
			$('#homeTab,#contactTab').fadeIn(800);
			$("#retouchWrapperTall").fadeOut();
			$("#retouchWrapper").fadeIn();
			$subBannerRetouching.fadeIn(500);
			$caCopyright.animate({top: "685px"});
			$caMenu.animate({top: "134px"}, 500);
			$caTextBox.animate({top: "410px"}, 500);
			$content.animate({height: "539px", top: "140px"}, 750);
			setTimeout('$("#pricingText1").fadeIn(800)', 300);
			setTimeout('$("#pricingText2").fadeIn(800)', 800);
			setTimeout('$("#pricingText3").fadeIn(800)', 1300);
			setTimeout('$("#pricingText4").fadeIn(2000)', 1800);
			/*$("#pricingText4").append("<span id='eyeSlideshow'><img src='ca/img/eyeSlideshow/eye-b_SM.png' alt='' width='225'/><img src='ca/img/eyeSlideshow/eye-a_SM.png' alt='' width='225' /></span><script type='text/javascript' src='ca/ssi/_caRetouchingPricingEye.js'></script>");*/
			//$("#pricingPage #script").append('$("#pricingText4 p").hover(() {$(this).animate({color: "#00688B"});},function() {$(this).animate({color: "darkred"});});');
		});

		$('#contactTab.tabs_clickable').click(function() {
				fadeAllPages();
				contactFormAppear();
				tabReset();
			$(this).addClass('tabs_current').css('backgroundColor','#fff');
			$('li a#contactTab span#downArrow').fadeIn();
		});
		
		$('.contactFormLink').click(function() {
				fadeAllPages();
				contactFormAppear();
				tabReset();
			$('#contactTab.tabs_clickable').addClass('tabs_current').css('backgroundColor','#fff');
			$('li a#contactTab span#downArrow').fadeIn();
		});
		
		$('#mailingListButton').click(function() {
			$('.page1,.page2, #pricingPage, .moreInfoPage').fadeOut(400);
				contactFormAppear();
				tabReset();
			$('#submitform textarea').text('Join our mailing list. ');
			return false;
		});
		
		$('#moreInfoTab.tabs_clickable').click(function() {
				fadeAllPages();
				pricingTabReset();
				tabReset();
			$('#homeTab').fadeIn();
			$('.moreInfoPage').fadeIn();
			$(this).addClass('tabs_current').css('backgroundColor','#fff');
			$('li a#moreInfoTab span#downArrow').fadeIn();
		});

		$('#homeTab').click(function() {
				var $content =$('#contentRetouching');
			$(this).attr('class','tabs_current').css('backgroundColor','#fff');
				fadeAllPages();
			setTimeout('$("#retouchWrapperTall,#homeTab").fadeOut()',200);
			$("#retouchWrapper").fadeIn();
			$caCopyright.animate({top: "685px"});
			$caMenu.animate({top: "134px"}, 500);
			$caTextBox.animate({top: "410px"}, 500);
			$content.animate({height: "539px", top: "140px"}, 750);
		});
			
		$('#text1,#text2').css({display: "none"});
		$('.moreSamplesLink').click(function() {
				var $content =$('#contentRetouching');
			//$("body").animate({backgroundColor: "#029cd9"});
				fadeAllPages();
				pricingTabReset();
			$("#retouchWrapper").fadeOut(400);
			$("#retouchWrapperTall").fadeIn();
			$subBannerRetouching.fadeOut();
			$("#caBanner").css("opacity","0");
			$caCopyright.animate({top: "785px"});
			$caMenu.animate({top: "68px"}, 500);
			$caTextBox.animate({top: "342px"}, 500);
			$content.css({height: "715px", top: "60px"});
			setTimeout('$(".page2,#text1,#homeTab").fadeIn(800)', 1000);
			setTimeout('$("#text2").fadeIn(600)', 1500);
			//setTimeout('$("#contentPage2 img").fadeIn(2000)', 2000);
		});
			
			
		function contactFormAppear() {
					var $content =$('#contentRetouching');
				tabReset();
			$('#submitform textarea').text('');
				pricingTabReset();
			$("#retouchWrapperTall").fadeOut();
			$subBannerRetouching.fadeIn(500);
			$("#retouchWrapper").fadeIn();
			$("#caBanner").animate({opacity: ".08"});
			$caCopyright.animate({top: "685px"});
			$content.animate({height: "539px", top: "140px"}, 750);
			$(".contactPage,#homeTab").fadeIn();
			setTimeout('$("form#submitform").fadeIn(800)', 300);
			$('input:text:first').focus(); //makes "name" field active on mailing list form
		}
		
		function fadeAllPages() {
			$('.page1,.page2,.contactPage, #pricingPage, .moreInfoPage').fadeOut(400);
		}
		
		function pricingTabReset() {
			setTimeout("$pricingCurrentTab.fadeOut(500).animate({marginTop: '5px', left: '80px', fontSize: '13px'}, 800)",200);
			$("a#pricingTab").fadeIn();
		}
		
		function tabReset() {
			$('.tabs_current').attr('class','tabs_clickable').attr('style', '');
			$('li a span#downArrow').fadeOut();
		}
	});
	//END CODE//