﻿Cufon.replace("h1, h2, h3", { fontFamily: "optima" });

$(document).ready(function() {
	
	// ~~~~~~~~~~ Equal width of submenu to that of main menu ~~~~~~~~~~ //
	setSubMenuWidth();
	function setSubMenuWidth() {
		$("#SubMenuControl_pnlMenuContainer > ul").css('padding', '0 ' + (Math.round(($("#MenuControl_pnlMenuContainer > ul:first-child").width() - $("#SubMenuControl_pnlMenuContainer > ul").width()) / 2)) + 'px');
	}
	
	// ~~~~~~~~~~ GraphicCollection XML -> homepage slideshow ~~~~~~~~~~ //
	if (0 < $('#homeVisual').length) {
		var homeVisualDiv = $('#homeVisual');
		// add prev and next buttons
		homeVisualDiv.before('<img src="/_images/galleryprev.gif" alt="Previous" id="prevHome" />');
		homeVisualDiv.after('<img src="/_images/gallerynext.gif" alt="Next" id="nextHome" />');
		// Initialize cycle plugin
		homeVisualDiv.cycle({
			fx:     'fade', 
			speed:  'slow', 
			timeout: 5000, 
			next:   '#nextHome', 
			prev:   '#prevHome',
			requeueOnImageNotLoaded: true
		});
		$('#prevHome, #nextHome').click(function() { 
			homeVisualDiv.cycle('pause'); 
		});
	}
	
	$("#hlBackButton").click(function(e) {
		e.preventDefault();
		history.back(); return false;
	});

})

/* Client side validation */
function ValidateGroups(source, arguments) {
    arguments.IsValid = $('.mailingsSubsribeControlsContainer .AspNet-CheckBoxList-Item input[type=checkbox]:checked').length > 0;
}
