
var CA = {};

$(function(){
    jQuery.CA.tagline();
    jQuery.CA.signInHere();
    jQuery.CA.Compactor(".faq", "h3", "p");
    jQuery.CA.subNav();
    jQuery.CA.addToFavorites();
    jQuery.CA.hearRadioAds();
    jQuery.CA.sendToFriend(".sendToFriend", "#sendToFriendBox", "#friendEmailAddress", ".cancelEmailFriend");
    jQuery.CA.sendToFriend(".tellAFriend", "#tellAFriendBox", "#tellfriendEmailAddress",".cancelTellEmailFriend");
    jQuery.CA.FreeAnalysis();
    jQuery.CA.FlashPlayer(".takeTour", "a", "/Content/ClearAmbition.html");
    jQuery.CA.FlashPlayer("#takeTourLink", "img", "/Content/ClearAmbition.html");
    jQuery.CA.FlashPlayer("#landingQSGButton", "img", "/Content/Q_StartUserGuide.html");
    jQuery.CA.here();
    //jQuery.CA.SituationSummaryPopLink();
    jQuery.CA.ImageRotator();
    jQuery.CA.ForgotPassword();
});

jQuery.CA = {

   here : function()
    {
        $("#mainNav").find("a").each(function()
            {
                if( location.href.indexOf(this.href) != -1) 
                    {
                        $(this).addClass("on");
                    }
            }
        );	
	},

   FlashPlayer : function(wrapper, link, url)
    {
        $(wrapper).find(link).click(function()
            {
                $("#tourBox").find("iframe").attr("src", url);
                $("#tourBox").find("iframe").fadeIn("slow");
                $("#tourBox").fadeIn("slow", function()
                    {
                        $(".closeTourBox").click(function()
                            {
                                $("#tourBox").fadeOut("slow", function()
                                    {
                                        $(this).css({display: "none"});
                                    }
                                );
                                $("#tourBox").find("iframe").fadeOut("slow", function()
                                    {
                                        $("#tourBox").find("iframe").attr("src", "");
                                    }
                                );
                            }
                        );
                    }
                );
            }
        );
    },

   FreeAnalysis : function()
    {
        $("#tryFreeAnalysis").find("a").click(function()
            {
                $("#startFreeAnalysis").animate({width: "713px"}, 1500, function()
                    {
                        $("#cancelFA").click(function()
                            {
                                $("#startFreeAnalysis").animate({width: "0px"}, 1500, function()
                                    {
                                        jQuery.CA.FreeAnalysis();
                                    }
                                 );
                            }
                         );
                    }
                 );
                return false;
            }
            
         );
    },


   tagline : function()
	{
		$("#tagline1").fadeIn(6000, function()
			{
				$("#tagline1").fadeOut(3000);
				$("#tagline2").fadeIn(6000, function()
					{
						$("#tagline2").fadeOut(3000, function()
							{
								jQuery.CA.tagline();
							}
						);
					}
				);
			}
		);
	},


   signInHere : function()
	{
		$("#signIn").toggle(function()
			{
				$("#login").fadeIn("fast");
			}, function()
			{
				$("#login").fadeOut("fast");
			}
		);
		return false;
	},
   
   
   Compactor : function ( list, link, item ) 
    {
	    if ($(list).length > 0 && location.hash) 
	        {
		        here = location.hash;
		        $(here).parent("div:hidden").prev().click();
		        $(here).next(":hidden").slideDown("fast");
	        }
	    $(list).find(link).addClass("link")
		.hover( function () 
		    {
			    $(this).addClass(" linkOver");
			}, function () 
			{
			    $(this).removeClass("linkOver");
		    }
		).toggle( function () 
		    {
			    $(this).addClass(" linkOn").next(item+":hidden").slideDown("fast");
			}, function () 
			{
			    $(this).removeClass("linkOn").next(item+":visible").slideUp("fast");
	        }
	    );
    },


   subNav : function(link)
    {
        $("#sideBarNav").find("a").click(function()
            {
                $("#subNav").slideDown("slow");
                $("#main").find("#timeLine").css("display", "none"); // hide flash
                return false;
            }
        );
      
        $(".findOutMore").find("a").click(function()
        {
            if($(this).attr("href")== "#")
                {
                    $("#subNav").slideDown("slow");
                    $("#main").find("#timeLine").css("display", "none"); // hide flash
                }
            }
        );

        $("#sideBarNav").find("a").click(function() // use the class name in the links to hi-jack the id name in the checkbox list
            {
                var link = $(this).attr("class");
                $("#"+link).attr("checked", "checked");
            }
        );
      
      
      // USE FOR THE TELL US ABOUT YOURSELF SLIDE DOWN MENU -- IF ADULT SEEKING SELECTED AND ONE OF THE FOLLOW CHECKBOXES IS SELECTED -- HIJACK THE LINK HERE TO THE HIJACKED PAGES
        $("#subNavSubmit").click(function()
            {
            if($("#selectURL").val()== "none")
                {
                alert("Please select your current status...");
                return false;
                }     
            else if($("#selectURL").val()== "careerchgrs.aspx" && $("#semiRetire").attr("checked") == true )
                {
                location = "retired.aspx";
                return false;
                }
            else if($("#selectURL").val()== "careerchgrs.aspx" && $("#goBackToWork").attr("checked") == true )
                {
                location = "reentry.aspx";
                return false;
                }
            else if($("#selectURL").val()== "careerchgrs.aspx" && $("#getAJob").attr("checked") == true || $("#changeCareers").attr("checked") == true )
                {
                location = "careerchgrs.aspx";
                return false;
                }                           
            else
                {
                location = $("#selectURL").val();
                return false;
                }
            }
        );
      
      $("#closeSubNav").click(function()
         { 
            $("#subNav").slideUp("slow");
            $("#main").find("#timeLine").css("display", "block"); // show flash
         }
      );

   },

	
   addToFavorites : function()
	{
		$(".addToFav").click(function()
			{
				if (window.sidebar) 
					{ // Mozilla Firefox Bookmark
						window.sidebar.addPanel(document.title, location.href,"");
					} 
				else if( window.external ) 
					{ // IE Favorite
						window.external.AddFavorite( location.href, document.title); 
					}
				else if(window.opera && window.print) 
					{ // Opera Hotlist
						return true; 
					}
			return false;
			}
		);
	},
	
   hearRadioAds : function()
   {
        $(".hearRadioAds").click(function()
            {
                $("#hearRadioAds").load("hearRadioAds.html"); 
                $("#hearRadioAdsWrap").css({display: "block"});
                $("#closeRadioAds").click(function()
                    {
                        $("#hearRadioAdsWrap").css({display: "none"});
                    }
                 );
         return false;
            }
         );
   },
	
	
   sendToFriend : function(typeOfFriend, typeOfBox, friendEmailAddress, cancel )
	{
		$(typeOfFriend).click(function()
			{
				$(typeOfBox).slideDown("slow");
            return false;
			}
		);

        // disable the return key to not effect other forms on the page
        $(typeOfBox).find("input[@type=text]").bind("keypress", function(e) 
            {
                if (e.keyCode == 13) 
                    {
                        return false;
                    }
            }
         );
		
		$(typeOfBox).find("a").click(function()
			{
				var friendAddress = $(friendEmailAddress).val();
				$(this).attr("href", "mailto:"+friendAddress+"?subject=You May Find This Career Planning Info Helpful&body=I just visited a great career and education planning web site that you might find helpful as well.  %0A%0A Here is the web address: www.ClearAmbition.com.");
				$(typeOfBox).fadeOut("slow");
				$(typeOfBox).find("input[@type=text]").val("");
			}
		);
		
		$(cancel).click(function()
			{
				$(typeOfBox).slideUp("slow");
			}
		);
	},


   SituationSummaryPopLink : function()
    {
        $("#SituationSummaryPopLink").click(function()
            {
                
                $(".closeSS").css({display: "block"});
                //var popLink = $(this).attr("href");
                //$(this).parent("td").append('<div class="closeSS" onclick="jQuery.CA.closeSS();">Close</div><div id="popBoxSS"><iframe src="'+popLink+'" width="720" height="800" border="0"></iframe></div>');
                //$("#popBoxSS").find("iframe").attr("src", popLink);
                $("#popBoxSS").slideDown("slow");
                return false;
                
            }
        );
    },


   closeSS : function()
    {
        //$("#popBoxSS").parent("td").html(""); 
        $("#popBoxSS").slideUp("slow");
        $(".closeSS").css({display: "none"});
    },
    
    
   ImageRotator : function()
    {
        $("#mainPhoto").append("<img class='rotate' src='img/student_with_backpack.jpg'><img class='rotate' src='img/Woman_Reentering_Workforce.jpg'><img class='rotate' src='img/Student_Group.jpg'><img class='rotate' src='img/Semi_Retired Man.jpg'><img class='rotate' src='img/Confused_Young_woman.jpg'>");
        jQuery.CA.changeEm();
    },
    
   changeEm : function()
    {
        $("#mainPhoto").find("img:first").fadeOut(9000).next("img").fadeIn(9000, function()
            {
                $(this).fadeOut(6000).next("img").fadeIn(6000, function()
                    {
                        $(this).fadeOut(6000).next("img").fadeIn(6000, function()
                            {
                                $(this).fadeOut(6000).next("img").fadeIn(6000, function()
                                    {
                                        $(this).fadeOut(6000).next("img").fadeIn(6000, function() 
                                            {
                                                $(this).fadeOut(6000);
                                                $("#mainPhoto").find("img:first").fadeIn(6000, function()
                                                    {
                                                        jQuery.CA.changeEm();
                                                    }
                                                );
                                                
                                            }
                                        );
                                    }
                                );
                            }
                        );
                    }
                 );
            }
         );
     },
     
     
   ForgotPassword : function()
    {
        $(".passWord").find("a").click(function()
            {
                $("#fgpw").slideDown("slow", function()
                    {
                        $(".close").click(function()
                            {
                                $("#fgpw").slideUp("slow");
                            }
                        );
                    }
                );
                return false;
            }
        );
    }     
    
    
}