// ======================================================================
// Site Javascript
// ======================================================================
// Catch form "return" key strokes and run appropriate function
function checkEnterKey(evt,func) {
	var evt = (evt) ? evt : ((event) ? event : null);
	var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	if ((evt.keyCode == 13) && (node.type=="text" || node.type=="password")) {
		eval(func);
	}
}

function getURL(url){
	window.location.href=url;
}

// Function to initialise the main front-end top nav menu
function initMainMenu() {
	$('ul.jd_menu').jdMenu({disableLinks:false});
	
	// Hide all menu items initially
	$('ul.jd_menu ul:visible').jdMenuHide();
	
	// Add menu hiding on document click
	$(document).bind('click',function(){
		$('ul.jd_menu ul:visible').jdMenuHide({onAnimate: onAnimate});
	});
}

jQuery(function(){
	jQuery('ul.jd_menu').jdMenu({onAnimate: onAnimate});
});
function onAnimate(show) {
	if (show) {
		jQuery(this)
			.css('visibility', 'hidden').show()
			.css('width', jQuery(this).innerWidth())
			.hide().css('visibility', 'visible')
			.fadeIn('normal');
	} else {
		jQuery(this).fadeOut('fast');
	}
}
// ======================================================================
// Global Javascript
// ======================================================================
// Universal window opener
function openWindow(url,w,h,scrollbars,name) {
	if (!name) { name = "popped"; }
	
	var popped = window.open(url,
							 name,
							 'width='+w+',height='+h+',resizable=1,scrollbars='+scrollbars);
	popped.focus();
}

function tidySeminarDetails(str) {
	str = str.replace(/(<br ?\/?>)/ig,"\r\n");
	str = str.replace(/(<([^>]+)>)/ig," ");
	return str;
}
