// We namespace jQuery, just in case we need to use
// other javascript libraries
(function ($) {

	// When the document is ready
	$(document).ready(function() {

		/* Frontpage contests modal window */
		// Instantiate a generic dialog box which we will use to load the forms into.
		var $dialog = $("<div id='simple-dialog'></div>").dialog({
			modal: true,
			autoOpen: false
		})
		
		// Contest modal dialog
		$(".simple-dialog").click(
			function() {
				// Update the dialog accordingly
				$dialog.dialog({	
					title: $(this).attr("title"),
					width: "460px",
					position: ['center', 'top']
				})
				
				// Load the contest content and populate the dialog window
				$dialog.load("/sites/default/files/static/contest.html")
				
				// Open the dialog
				$dialog.dialog("open")
				
				// Prevent normal link navigation via anchor
				return false
			}
		)
/*
		//Hide (Collapse) the toggle containers on load
		$(".collapsible-container").hide();
	
		//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
		$("h3.collapsible").click(function(){
			$(this).toggleClass("active").next().slideToggle("slow");
			return false; //Prevent the browser jump to the link anchor
		});
	
		// validate the form input
		$("form#contest-form").validate()
*/
	})
})(jQuery);

