$(document).ready(function() {

// ----------------------------------------------------
// opens document ready function, edit below this line

	// disables text selection
	// user jQuery plug in
	$(function() {
		 $('.unselectable').disableTextSelect();
	});

	// cycles the ticker
	tickerCycle = function(){
		var tickerEls = $("#tickerHome").find(".tickerContent li").length - 1; // array of all the ticker elements
		var i = 0;
		moveTicker = function() {
			$("#tickerHome").find(".tickerContent li").eq(i).fadeOut();
			if ( i == tickerEls ) { i = 0; } else { i = i+1; }
			$("#tickerHome").find(".tickerContent li").eq(i).fadeIn();
		}
		var intervalID;
		cycleTicker = function() { 
			intervalID = setInterval(moveTicker, 6000);
		}
        moveTicker();
        cycleTicker();
	}

	// wait until page has loaded before starting tickerCycle
	$(window).load(function(){
		tickerCycle();
	});
	
	


	// subnav dropdowns
	$('li.dropmenu').hover(function() {
		var trigger = $(this);
		allowDropMenu = true;
        $(this).delay( 500, function () {
        	if ( allowDropMenu == true ) {
				$('div', trigger).show();
				$(trigger).addClass("active");
        	}
        });
	},
	function() {
		allowDropMenu = false;
		$('div', this).hide();
		$(this).removeClass("active");
	});
	
	$('.dropmenu div ul li').hover(function() {
		$(".dropmenu > a").addClass("active");
		$('ul:first', this).each(function() {
			$(this).css('top', $(this).parent().position().top );
			$(this).css('left', $(this).parent().position().left + $(this).parent().width() );
			$(this).show();
	 	});
	},
	function() {
	 	$('ul:first', this).hide();
	});
	
	
	// 'More' link downdown in sub nav
	
	$("#moreDropDown").click(function(){
		$("#moreDropDown a").blur(); // gets rid of outline around link
		$("#moreDropDown").toggleClass("active");
		if ( $("#moreDropDown").hasClass("active") ) {
			$("#moreDropDown span").attr("class","").addClass("arrowUpRit");
		} else {
			$("#moreDropDown span").attr("class","").addClass("arrowDownRit");
		}
		$("#subNavMore").toggle();
		return false;
	});
	
	
	
	
	
	// toggle the sub token content on Token page
	
	$(".tokenTotalToggle").live("click", function(){
		var el = $(this);
		$(el).parent("td").parent("tr").next("tr.breakdown").toggle();
		$(this).toggleClass("btnExpand").toggleClass("btnCollapse");
		return false;
	});
	
	// toggles content below trigger (contained by one element)
    $(".toggleNext").live("click", function(){
        var el = $(this);
        $(el).parents("li").eq(0).find(".toggleContent").toggle();
        $(this).toggleClass("btnExpand").toggleClass("btnCollapse");
        buttonHTML = $(this).html();
        if( buttonHTML == "hide") { $(this).html("show"); }
        if( buttonHTML == "show") { $(this).html("hide"); }
        return false;
    });


    // toggles ID of element defined by 2nd class in trigger link
	// class="toggleEl toggle-idOfElementToToggle"
	// id cannot have dashes
	$(".toggleEl").click(function() {
		var triggerClasses = $(this).attr("class");
		var target = triggerClasses.split(" ")[1];
		var target = target.split("-")[1];
		$("#"+target).toggle();
		$(this).toggleClass("active");
		
		if ( $(this).find("span").hasClass("arrowDownRit") ) {
			$(this).find("span").removeClass("arrowDownRit")	
			$(this).find("span").addClass("arrowUpRit")	
		} else {
			$(this).find("span").removeClass("arrowUpRit")	
			$(this).find("span").addClass("arrowDownRit")	
		}
		
		var triggerHTML = $(this).find("span").html();
		if (triggerHTML == "View More") {
			$(this).find("span").html("View Less");
		} else if( triggerHTML == "View Less") {
			$(this).find("span").html("View More");
		}
		
		return false;
	});


    clearFormErrors = function ( form ) {
        $( form ).find( "p.error" ).remove();
        $( form ).find( "div.globalError" ).remove();
    }

	/**
	 * A method for parsing a FormValidationResult JSON 
	 * @param jsonResponse the validation response containing field and global error messages if any
	 * @param form the form element being validated
	 * @param successCallbackFunction a function to call upon success instead REGARDLESS of any successURL specified in the JSON
	 */
	showJsonFormErrors = function ( jsonResponse, form, successCallbackFunction ) {
		// Expecting a JSON response back
		var results = eval( '(' + jsonResponse + ')' );
		if ( results.success == "false" ) {

			// add global error div
			$( form ).prepend("<div class='globalError'></div>");

			// parse the json for the errors and display them
			for ( globalError in results.formErrors.globalErrors ) {
				$( form ).find( ".globalError" ).prepend("<p class='error'>" + results.formErrors.globalErrors[globalError].error +"</p>")
			}
			for ( fieldError in results.formErrors.fieldErrors ) {
				var fieldName = results.formErrors.fieldErrors[fieldError].fieldName;
				var errorMessage = results.formErrors.fieldErrors[fieldError].error;
				$( form ).find( '#' + fieldName ).parent().after("<p class='error'>" + errorMessage +"</p>");
			}
			$.scrollTo( $( form ).find( ".globalError" ), 500, { offset:-30 }); // scroll up to the global error
			return false;

		} else {

			// if a success callback function was passed in, execute that instead of using the JSON successURL
			if ( typeof successCallbackFunction != "undefined" ) {
				successCallbackFunction();
			} else {
				// if we are successful go to the success URL if specified
				if ( results.successUrl ) {
					location.href = results.successUrl;

				// otherwise just reload the page
				} else {
					location.reload();
				}
			}
			return true;
		}
	}


    /**
     *
     */
 
    guestPassFormSubmit = function() {
        // remove any old error messages
        clearFormErrors( $("#guestPassForm") );

        $.post( "/myShockwave/sendGuestPass.jsp",
            {
                friendEmail: $("#guestPassForm #friendEmail").val(),
                friendName: $("#guestPassForm #friendName").val(),
                yourName: $("#guestPassForm #yourName").val(),
                message: $("#guestPassForm #message").val()
            },
            function ( data, textStatus ) {
                showJsonFormErrors( data, $('#guestPassForm') );
            }
        );
        return false;

    }

    guestPassActivationFormSubmit = function() {
        // remove any old error messages
        clearFormErrors( $("#guestPassActivationForm") );

        $.post( "/member/activateGuestPassSubmit.jsp",
            {
                guestPassId: $("#guestPassActivationForm #guestPassId").val(),
                email: $("#guestPassActivationForm #email").val(),
                screenName: $("#guestPassActivationForm #screenName").val(),
                password: $("#guestPassActivationForm #password").val(),
                confirmPassword: $("#guestPassActivationForm #confirmPassword").val(),
                month: $("#guestPassActivationForm #month").val(),
                day: $("#guestPassActivationForm #day").val(),
                year: $("#guestPassActivationForm #year").val(),
				country: $("#guestPassActivationForm #country").val(),
				state: $("#guestPassActivationForm #state").val(),
				gamesEmails: $("#guestPassActivationForm #gamesEmails").attr("checked"),
                termsOfService: $("#guestPassActivationForm #termsOfService").attr("checked")
            },
            function ( data, textStatus ) {
                showJsonFormErrors( data, $('#guestPassActivationForm') );
            }
        );
        return false;

    }


    registrationFormSubmit = function() {
        // remove any old error messages
        clearFormErrors( $("#registrationForm") );

        // make a post request to login controller
        $.post( "/member/signUp.jsp",
            {
                emailAddress: $("#registrationForm #emailAddress").val(),
                retypeEmailAddress: $("#registrationForm #retypeEmailAddress").val(),
                month: $("#registrationForm #month").val(),
                day: $("#registrationForm #day").val(),
                year: $("#registrationForm #year").val(),
                screenName: $("#registrationForm #screenName").val(),
                password: $("#registrationForm #password").val(),
                retypePassword: $("#registrationForm #retypePassword").val(),
                country: $("#registrationForm #country").val(),
				state: $("#registrationForm #state").val(),
				newsletterSubscription: $("#registrationForm #newsletterSubscription").attr("checked"),
                thirdPartyNewsletterSubscription: $("#registrationForm #thirdPartyNewsletterSubscription").attr("checked"),
                rememberMe: $("#registrationForm #rememberMe").attr("checked"),
                gender: $("#registrationForm input[@name='gender']:checked").val(),
                friendId: $("#registrationForm #friendId").val()
            },
            function ( data, textStatus ) {
                showJsonFormErrors( data, $('#registrationForm') );
            }
        );
        return false;

    }

	cancelSubscriptionSubmit = function( trigger ) {
		$(trigger).parent().html("Cancelling your subsciption...");
		return true;
	}


	passwordFormSubmit = function() {
        // remove any old error messages
        clearFormErrors( $("#changePasswordForm") );

        // make a post request to login controller
        $.post( "/myShockwave/accountSettings/changePassword.jsp",
            {
                oldPassword: $("#changePasswordForm #oldPassword").val(),
                newPassword: $("#changePasswordForm #newPassword").val(),
                newPassword1: $("#changePasswordForm #newPassword1").val()
            },
            function ( data, textStatus ) {
                showJsonFormErrors( data, $('#changePasswordForm') );
            }
        );
        return false;
    }

    shareGameFormSubmit = function() {
        // remove any old error messages
        clearFormErrors( $("#shareGameForm") );

        // make a post request to login controller
        $.post( "/games/shareGame.jsp",
            {
                yourName: $("#shareGameForm #yourName").val(),
                yourEmail: $("#shareGameForm #yourEmail").val(),
                recipientEmails: $("#shareGameForm #recipientEmails").val(),
                message: $("#shareGameForm #message").val(),
                keyword: $("#shareGameForm #keyword").val()
            },
            function ( data, textStatus ) {
                showJsonFormErrors( data, $('#shareGameForm') );
            }
        );
        return false;

    }


    inviteFriendsSubmit = function() {

        // remove any old error messages
        clearFormErrors( $("#inviteFriendForm" ) );
        $( "#inviteFriendsDiv" ).hide();

        // make a post request to login controller
        $.post( "/myShockwave/friends/inviteFriends.jsp",
            {
                myName: $("#inviteFriendForm #myName").val(),
                recipientEmails: $("#inviteFriendForm #recipientEmails").val(),
                personalMessage: $("#inviteFriendForm #personalMessage").val()
            },
            function ( data, textStatus ) {
                showJsonFormErrors( data, $('#inviteFriendForm') );
                $( "#inviteFriendsDiv" ).show();
            }
        );
    }

	// AJAX FORM SUBMISSIONS (TODO: update all above implementations to use this new framework)
	$("#contactUsForm").bind('submit', function() {
		clearFormErrors( $("#contactUsForm") );
		$(this).ajaxSubmit( function( data ) {
			showJsonFormErrors( data, $('#contactUsForm') );
		});
		return false;
	});
	$("#contactUsForm.inGameForm").unbind('submit');
	$("#contactUsForm.inGameForm").bind('submit', function() {
		if ( $('form #computerBrowser').val() == '' ) {
			alert("Please indicate your browser");
			return false;
		};
		if ( $('form #computerOS').val() == '' ) {
			alert("Please indicate what your computer uses");
			return false;
		};
		if ( $('form #contactNotes').val() == '' ) {
			alert("Please provide a suggestion");
			return false;
		};
		if ( $('form #subject').val() == '' ) {
			alert("Please provide a issue type ");
			return false;
		};

		$(this).ajaxSubmit( function( data ) {
			// just reset the form
			alert( "thank you for your feedback");
			$('form #subject option:first').attr('selected', 'selected');
			$('form #contactNotes').val('');
		});
		return false;
	});
	$("#photoSubmitForm").bind('submit', function() {
		clearFormErrors( $("#photoSubmitForm") );
		$(this).ajaxSubmit( function( data ) {
			showJsonFormErrors( data, $('#photoSubmitForm') );
		});
		return false;
	});
	$("#developersForm").bind('submit', function() {
		clearFormErrors( $("#developersForm") );
		$(this).ajaxSubmit( function( data ) {
			showJsonFormErrors( data, $('#developersForm') );
		});
		return false;
	});
    $("#billingInfoForm").bind('submit', function() {
        clearFormErrors( $("#billingInfoForm") );
        $(this).ajaxSubmit( function( data ) {
            showJsonFormErrors( data, $('#billingInfoForm') );
        });
        return false;
    });
    $("#friendsSettingForm").bind('submit', function() {
        clearFormErrors( $("#friendsSettingForm") );
        $(this).ajaxSubmit( function( data ) {
            showJsonFormErrors( data, $('#friendsSettingForm') );
        });
        return false;
    });
    $("#newsletterForm").bind('submit', function() {
        clearFormErrors( $("#newsletterForm") );
        $(this).ajaxSubmit( function( data ) {
            showJsonFormErrors( data, $('#newsletterForm') );
        });
        return false;
    });
	$("#staffReviewForm").bind('submit', function() {
		clearFormErrors( $("#staffReviewForm") );
		$(this).ajaxSubmit( function( data ) {
			showJsonFormErrors( data, $('#staffReviewForm') );
		});
		return false;
	});

    $("#personalInfoForm").bind('submit', function() {
        clearFormErrors( $("#personalInfoForm") );
        $(this).ajaxSubmit( function( data ) {
            showJsonFormErrors( data, $('#personalInfoForm') );
        });
        return false;
    });

    submitGameChallengeForm = function() {
		var recipientEmailAddresses =  $( "#gameChallengeForm" ).find( "#recipientEmails" ).val();
		clearFormErrors( $("#gameChallengeForm") );
        $("#gameChallengeForm").ajaxSubmit( function( data ) {
			showJsonFormErrors( data, $('#gameChallengeForm'), function() {
				showChallengeConfirm( recipientEmailAddresses )
			});
        });
        return false;
    }


	// tag picker on game landing pages
	// uses hidden checkmarks
	$(".tagPick3 label").click(function(){
		var target = $(this);

		var n = $(".tagPick3 label.active").length; // get number of active tags
		
 		if ( $(target).hasClass("active") ) {
 			$(target).removeClass("active");
 			$(".tagPick3label").css("color","#666");
 		} else if (n < 3) {
 			$(target).addClass("active");
 		} else {
 			$(".tagPick3label").css("color","red");
 			return false; // to prevent checkmark
 		}
		
	});

	// a helper method to update when a review is tagged as helpful or not
    reviewHelpful = function( reviewId, isHelpful, isStaffReview ) {
        $.post( "/helpful.jsp?id=" + reviewId + "&rating=" + isHelpful + "&s=" + isStaffReview );
        var yesVotes = $("#reviewHelpful_" + reviewId + " span:eq(0)").html();
        var totalVotes = $("#reviewHelpful_" + reviewId + " span:eq(1)").html();
        if ( isHelpful ) {
            yesVotes = yesVotes * 1 + 1;
        }
        totalVotes = totalVotes * 1 + 1;
        var results = "<div class='results' style='display:none;'><span>" + yesVotes + "</span> of <span>" + totalVotes + "</span> found this review helpful</div><div class='results'><span>Thank you for voting!</span></div>";
        $("#reviewHelpful_" + reviewId ).html( results );
        $(this).delay( 2000, function () {
            $("#reviewHelpful_" + reviewId + " .results" ).toggle( "slow" );
        });
        return false;
    }
	



    // =============================
    // Online Game page functions
    // =============================

	//jump to the user's score in the High Scores Tab
	// finds the elements
	jumpToScore = function(trigger){
        var targetObj = $(trigger).parents(".podInnerBox").prev("div"); // get container element that scrolls
		var containerHeight = $(targetObj).height(); // get height of container
        var targetTDHeight = $(targetObj).find("td").height(); // get height of td within container
		var finalScrollToPos = (containerHeight/2) - (targetTDHeight/2) - 3; // do the math to get it to center
		$(targetObj).scrollTo('tr.highlight', 500, { offset:-finalScrollToPos }); // make the scrollTo call
		return false;	
	};


    // =============================
    // Online Homepage functions
    // =============================

    /**
     * AJAX loads the tabs in Today's Hottest Games so it only runs once per page view,
     * then re-initializes the hover boxes for the games
     * @param tab the tab to load
     * @param url the ajax url to load into the tab
     */
    loadGames = function( tab, url ) {
        ajaxTabLoad ( tab, url, true, function() {
            initHoverBox();
        });
    };
    
    // editing profile questions
    $("#profileQuestionsEdit").click(function(){
    	$(this).hide();
    	$("#podProfileQuestions .podInnerBox input, #moreProfileQuestions, #profileQuestionsCancel, #profileQuestionsSave").show();
    	$("#podProfileQuestions .podInnerBox p").hide();
    	$("#podProfileQuestions .podInnerBox p.nohide, #podProfileQuestions .podInnerBox h3").show();
    	$("#podProfileQuestions .toggleEl").hide();
    	return false;
    })
    $("#profileQuestionsSave").click(function(){
    	return false;
    })
    $("#profileQuestionsCancel").click(function(){
    	$("#podProfileQuestions .podInnerBox p, #profileQuestionsEdit").show();
    	$("#podProfileQuestions .podInnerBox input, #profileQuestionsCancel, #profileQuestionsSave, #podProfileQuestions .podInnerBox h3.titleHide").hide();
    	if ( $("#moreProfileQuestions").css("display") == "block") {
    		$("#moreProfileQuestions").hide();
    	}
    	$("#podProfileQuestions .toggleEl").show().html("View More");
    	return false;
    })
    
    
    // editing the profile headline
    $("#profileHeadlineEdit").click(function(){
    	$(this).hide();
    	$("#profileHeadline").hide();
    	$("#profileHeadlineActionWrap, #profileHeadlineField").show();
    	return false;
    });
    $("#profileHeadlineSave").click(function(){
    	return false;
    })
    $("#profileHeadlineCancel").click(function(){
    	$("#profileHeadline, #profileHeadlineEdit").show();
    	$("#profileHeadlineActionWrap, #profileHeadlineField").hide();
    	return false;
    })


	//token statement month change jump menu.
	tokenStatementMonthJump = function( month ) {
		ajaxLoad( '/myShockwave/tokens/tokenData.jsp?mon=' + month, $('#tokensData') );
	}

	/**
	 * Function to launch a daughter window
	 * @param url the URL to load into the daughter window
	 * @param width the width to open up the window
	 * @param height the height to open up the window
	 * @param resizable optional "yes/no" of whether or not to make the window resizable
	 * @param winName optional predefined name of the window
	 */
	launchWindow = function( url, width, height, resizable, winName ) {
		// If a window name was not specified, randomly create one
		if ( !winName ) {
			winName = "asw_d" + (Math.floor(Math.random() + 100000));
		}
		var newWin = window.open( url, winName, "width=" + width + ",height=" + height + ",resizable=" + resizable );
		newWin.focus();
		return newWin;
	}

	// =============================
    // Sweepstakes Picker functions
    // =============================

    /**
     * First function forces only numeric characters for inputs
     * Input detects key up and calculates value for total cost
     */
	$('.ticketPicker input').numeric();

	$(".ticketPicker input").keyup(function()  {
		var userTickets = $(this).attr("value");
		var costTotal = $(this).parents("form").find(".fltR .icon16Lft");
		if ( userTickets == null || userTickets == 0 ) {
			$(costTotal).html("0");
		} else {
			$(costTotal).html(userTickets*100);
		}
	});



    // =============================
    // Multi Trophy Hover Select
    // =============================

    /**
     * Adds/removes 'active' state to list items to highlight them
     * Uses the index of the hovered item and show the corresponding content on the left
     */
	$('#podGameTrophies .multiTrophy li').mouseover(function() {
		var trigger = $(this);
		var hoverItems = $(this).parent("ul").find("li");
		var triggerIndex =  $(hoverItems).index(trigger);
		var targetItems = $(this).parent("ul").parent("div").find(".podInnerBox");

		$(hoverItems).removeClass("active");
		$(this).addClass("active");
		
		$(targetItems).hide();
		$(targetItems).eq(triggerIndex).show();
		
	});

	// scrollTo function in help section
	$(".btt").click(function(){
		$.scrollTo("0",500);
		return false;
	});

	// expands the container around the chat window
	// prevents it from causing the page to be too wide
	chatWindow = function(state) {
		if (state == "expand"){
			$("#podChat").addClass("expand");
		} else {
			$(this).delay(400, function(){
				$("#podChat").removeClass("expand");
			});
		}
	}

	// expands the tools on the game landing pages
	toggleTool = function(trigger, target) {
		var triggerArrow = $(trigger).find("span");
		var triggerLi = $(trigger).parent("li");
		if ( $(triggerArrow).hasClass("arrowDownRit") ) {
			$(".toolBar span.arrowUpRit").each(function(i){
				$(this).removeClass("arrowUpRit").addClass("arrowDownRit");
				$(".toolBar li").removeClass("active");
			});
			$(".toolShelf").hide();
			$(triggerArrow).removeClass("arrowDownRit").addClass("arrowUpRit");
			$(triggerLi).addClass("active");
		} else {
			$(triggerArrow).removeClass("arrowUpRit").addClass("arrowDownRit");
			$(triggerLi).removeClass("active");
		}
		$(target).toggle();
	}

	// select all the text in the input field for easy copying
	$("#copyURL input, #embedGame input").focus(function(){
		this.select();
	});

	//billing country drop down on cart pages
	$("#cart select#billingCountry").change(function(){
		var trigger = $(this);
		var target = $(trigger).parents("li").eq(0).next("li")
		var selectValue = $("#cart select#billingCountry").val();
		if (selectValue == "ca") {
			$(target).show();
		} else {
			$(target).hide();
		}
	});

	//shipping country drop down on cart pages
	$("#cart select#shippingCountry").change(function(){
		var trigger = $(this);
		var target = $(trigger).parents("li").eq(0).next("li")
		var selectValue = $("#cart select#shippingCountry").val();
		if (selectValue == "ca") {
			$(target).show();
		} else {
			$(target).hide();
		}
	});

	//opens a pop up for club games
	showGameHelp = function(destURL) {
		var strWindowFeatures = 'menubar=no,location=no,resizable=yes,scrollbars=yes,status=yes,width=650,height=500';	
  		window.open(destURL,'mywindow',strWindowFeatures);
	}


	// this tests to see how far the user has scrolled
	// if far enough down will set the active game face to 'fixed'
	// so that it scrolls along with the user
    setGameFaceLocation = function(windowScrollPos) {
		if ( windowScrollPos > (gameFaceOffset.top - 10) ) {
			$("#podMyGameFace").css({position:"fixed",top:"10px",left:gameFaceOffset.left});
		} else {
			$("#podMyGameFace").css("position","static");		
		}
    }

	// this fires on page load to position the selected game face
	if ( $("#podMyGameFace").length > 0 ) {
		gameFaceOffset = $("#podMyGameFace").offset();
		windowScrollPos = $(window).scrollTop();
		setGameFaceLocation(windowScrollPos);
	
		// fires with any scroll
		$(window).scroll(function () { 
			var windowScrollPos = $(window).scrollTop();
			setGameFaceLocation(windowScrollPos);
		});
	}
	
	// used on the Game Face page to swap out img, change active state
	updateGameFace = function( trigger, avatarId ) {
		$.get( "/myShockwave/gameFace/makePublic.jsp?avatarId=" + avatarId );  // post the updated avatar to the server
		var triggerLink = $(trigger).parent("span").html(); // gets html of the trigger link to pass to the newly active link
		var activeItem = $("#avatars li.active"); // gets currently active element

		// if there is no active item, check to make sure we don't have a voki avatar as active anymore
		if ( activeItem.length <= 0 ) {
			$("#podVokiIcons li.active").removeClass("active");
		}

		var targetListItem = $(trigger).parents("li:eq(0)"); // gets parent li of item being picked
		var targetSource = $(trigger).parents("li:eq(0)").find("img").attr("src"); // find source of img of item being picked
		
		$(activeItem).removeClass("active").find("span").html(triggerLink); // switches the old active item to an inactive state, sets HTML
		$(targetListItem).addClass("active").find("span").html("My Public Game Face"); // turns on the newly picked item as active, sets HTML

		// replace the image if there's one to replace
		if ( $("#podMyGameFace .vokiWrap img").length > 0 ) {
			$("#podMyGameFace .vokiWrap img").attr("src",targetSource); // sets the source of My Public Game Face img to the item picked

		//otherwise remove the voki and add it
		} else {
			$("#podMyGameFace .vokiWrap").empty();
			$("#podMyGameFace .vokiWrap").append("<img src='" + targetSource + "' alt='' />");
		}
	}
	
	//show shipping address on club payment form; spring form tags rewrite and append "1"
	$("#shipToSameAddress1").click(function(){
		$("#shippingInputs").toggle();
	})

	if ( $("#sisUpsell").length ) {
		setTimeout( function() {
			$("#sisUpsell").fadeOut("fast");
		}, 15000);
	}
	
	//On free sign up & guest pass form, show state dropdown if country selected is United States
	$("#freeSignUpForm #country:input, #sendGuestPass #country:input").change(function(){
		var countryValue = $(this).val();
		if (countryValue == "us") {
			$("#dropdownState").show();
		} else {
			$("#dropdownState").hide();
		}
	})


	// mama bar more link, using jQuery due to conflict
	$(".brand-mamabar-more-link").hover(
      function () {
        $(this).addClass("brand-mamabar-more-link-hover");
      }, 
      function () {
        $(this).removeClass("brand-mamabar-more-link-hover");
      }
    );

	

// closes document ready function, edit above this line
// -----------------------------------------------------
});