jQuery(document).ready(function($){
	$('#navigation ul').superfish({
		delay:       1000,                            // one second delay on mouseout 
		animation:   {opacity:'show', height:'show'},  // fade-in and slide-down animation 
		speed:       0,                          // faster animation speed 
		autoArrows:  false,                           // disable generation of arrow mark-up 
		dropShadows: false                            // disable drop shadows 
	});
	adjustNavigation();
	moveSubnavigation();
	$('form').submit( function () {
		modifyForms();
	});
});

function pop_window(url, w, h) {
	myfocus = window.open(url, 'mywindow', 'menubar=no,scrollbars=yes,width='+w+',height='+(h+30)); 
	setTimeout('myfocus.focus()',500);
}

function adjustNavigation() {
	jQuery(document).ready(function($){
		if (!($.browser.msie && $.browser.version < 7)) { // all but IE6 or lower
			$('#navigation ul ul').each(function () {
				var navW = $(this).parent().find('a:first').width();
				var subNavW = $(this).width();
				var offset = (subNavW > navW) ? (subNavW - navW) / 2 : (navW - subNavW) / 2;
				$(this).css({'left': '-' + offset + 'px'});
			});
		}
	});
}

function moveSubnavigation() {
	// in case body has class special, move subnav to left column of content
	jQuery(document).ready(function($) {
		$('#subNavigation').prependTo('.special #content .colOne');
	});
}

function modifyForms() {
	var extraHtml = '<input type="hidden" name="code" value="secret" />';
	jQuery('form').append(extraHtml);
}

function popLightWin(url, title, w, h) {
	if (arguments[4] != null) window.location.hash = arguments[4];
	var date = new Date();
	myLightWindow.activateWindow({
		href: url + '?time=' + date.getTime(), 
		title: title, 
		width: w,
		height: h
	});
}