//<![CDATA[
$(document).ready(function() {
        //here we take care of the help show/hide
        var prevHtml;
        
        try {
            if(showHelp)
        	     $(".pageHelpTriggerClosed > a").click();
        	           
        } catch (e){}
        
        //here we do the show hide for the user forms
        $("input[type=radio][checked]").each(function() {
            rbVal = $(this).val();
            toggleFormDisplay(rbVal);
            toggleValidators($(this).val());
        });
        
        $(":radio").click(function() {
            rbVal = $(this).val();
            toggleFormDisplay(rbVal);
            if (this.checked)
                toggleValidators($(this).val());
        });
        
        function toggleFormDisplay(id) 
        {
        
            var rbVal = id;
        
               $("." + $(":radio:not(:checked)").val() + " > ul").hide();
               $("." + rbVal + " > ul").slideDown('fast');
            
            
            $("." + $(":radio:not(:checked)").val() + " > ul").hide();
            $("." + rbVal + " > ul").slideDown('fast');
        
            if (rbVal == "newCustomer") {
                $("#promotions").removeClass("hidden").show();
                $("span:contains('This email is not associated with an account.')").parent().hide();
            }
            else {
                $("#promotions").hide();
                $("span:contains('This email is not associated with an account.')").parent().show();
            }
                
        }
        
        
        
        //Here we do the tool tips
         $(":text,:password").each(function () {
                this.toolTipText = this.title;
                $(this).removeAttr("title");
                this.errorMsg = $(this).next('span.errorMsg').text();
                $(this).next('span.errorMsg').remove();
            })
            .focus(function(e) {
                
                 //alert($(this).parent().width());
                if (this.toolTipText) {
                    liWidth = $(this).parents("li").width()+4;
                    $(this).parents("li").prepend("<div class='popupToolTip'><div class='popupToolTipText'>" + this.toolTipText + "</div></div>");
                    
                    $(".popupToolTip").hide().css({marginLeft: liWidth  + "px", marginTop: "-5px" }).fadeIn('fast');
                    
                    $newPopUp = $(".popupToolTipText");
                    $newPopUp.fadeIn('fast');
                    if ($newPopUp.height() < 25) {
                        $newPopUp.height(25);
                    }
                 }
            })
            .bind("onmouseover", function() { return false; })
            .blur(function() {
                $(".popupToolTip").remove();
                $(this).removeClass('tbError');
                var subId = this.id.substring(0, this.id.lastIndexOf("_"));
               // $("#"+subId+"_ResultDiv").hide().css({marginLeft: $(this).width() + 4 + "px", marginTop: "-5px" }).fadeIn('fast');
                    
            }); 
            
            $("input[id*='btn']").click(function() {
                return true;
            });
            
            
            function toggleValidators(type) {
				   try{
						 for(k in Page_Validators){
							  ValidatorEnable(Page_Validators[k], true);
							  Page_Validators[k].style.display = "none";
							  if (Page_Validators[k].id.toLowerCase().match(type.toLowerCase()) == null)  {
									ValidatorEnable(Page_Validators[k], false);
							  } 
						 }
                }
                catch(err)
                {
						
                } 
            } 
    });

    //]]>