﻿$(function() {
	var f = $("#content");
	f.html(f.html().replace(/<p>&nbsp;<\/p>/g, ""));

	$('div.category').hide();

	//Events
	$('a.category').click(function() {
		$('div.category').hide();
		$('div.category[id=' + this.className.split(" ")[1] + ']').toggle();
	});

	$('#searchsubmit').click(function() {
		search();
		return false;
	});

	$('input#s').bind("keydown", function(e) {
		if (e.keyCode == 13) {
			search();
			return false;
		}
	});

	//Links
	$(function() { // Run this code when the document's done loading    

		// Apply this code to each link with class="popup"
		$("a.popup").each(function(i) {

			// Add an onClick behavior to this link
			$(this).click(function(event) {

				// Prevent the browser's default onClick handler
				event.preventDefault();

				// Grab parameters using jQuery's data() method
				var params = $(this).data("popup") || {};

				// Use the target attribute as the window name
				if ($(this).attr("target")) {
					params.windowName = $(this).attr("target");
				}

				// Pop up the window
				var windowObject = UTIL.popup.open(this.href, params);

				// Save the window object for other code to use
				$(this).data("windowObject", windowObject);
			});
		});
	});
});

function search() {
	var q = $('input#s').val();

	if (q.length > 0) {
		window.location.href = "/search-results.aspx" + "?q=" + q;
	}
}
