
(function(j$) {
    j$(document).ready(function() {

        //switch pictures
        j$("#promo_bottom_links a").click(function() {
            j$("#promo_bottom_links a").removeClass("on");
            j$(this).addClass("on");
            return false;
        });
        j$("#promo_rotator #dnn_ctr897_ModuleContent").cycle({
            timeout: 7000,
            speed: 500,
            before: onBefore,
            pause: true,
            next: '#next',
            prev: '#prev'
        });
        function onBefore() {
            j$('#desc').html(this.alt);
        }


	// Global "Enter" keypress override of default <form> action to submit.
	j$("input").keypress(function(event) {
	    if (event.which === 13)
	    {
		event.preventDefault();
	    }
	});


        //searchbox default text
        j$("#search_tb input[type*='text']").val("keyword(s)");
        j$("#search_tb input[type*='text']").focus(function() {
            if (j$("#search_tb input[type*='text']").val() == "keyword(s)") {
                j$("#search_tb input[type*='text']").val("");
            }
        });
        j$("#search_tb input[type*='text']").blur(function() {
            if (j$("#search_tb input[type*='text']").val() == "") {
                j$("#search_tb input[type*='text']").val("keyword(s)");
            }
        });

        //email this page functionality
        var url = window.location.href;
        var nohttp = url.split('//')[1];
        j$("#emailLink").attr("href", "/EmailThisPage?link=" + nohttp);

        //facebox for the flicker slideshow on community page
        j$('a[rel*=facebox]').click(function(event) {
            var self = j$(this);
            var referencedContent = j$(self.attr("href"));

            if (referencedContent.length > 0) {
                jQuery.facebox("");
                j$("#facebox .content").append(referencedContent.show());
                j$("#facebox").appendTo(j$(document.forms[0]));
            }
            else {
                jQuery.facebox.reveal();
            }
        });

        //Espa�ol 'tilde' Fix
        j$('#sub_header_title.EnEspanol h1').html("En Espa&#241;ol");

        //Keypress fix for the Events Module
        j$("input[id$='txtSearchKeyword']").keypress(function(event) { //Calendar
            if (event.which == 13) {
                event.preventDefault();
                j$("input[id$='imgBtnSearch']").click();
            }
        });
		
		//Keypress fix for the UltraVideoGallery Module.
		j$("input[id$='SearchInput_txtKeyword']").keypress(function(event) {
			if (event.which == 13) {
                event.preventDefault();
				event.stopPropagation();
                j$("input[id$='SearchInput_btnSearch']").click();
            }
		});
        
        //Keypress fix for the Forum Module
        j$(".afminisearchbox").attr("onkeydown", "function() { return false; };").keydown(function(event) {
            if (event.which == 13) {
                __doPostBack(j$(".afsearchgo").find("a[id$='lnkSearch']").attr("id").replace(new RegExp("_", "g"), "$"), "");
            }
        });
    });
})(jQuery.noConflict());
