// jQuery to create Accordian menu
$(document).ready(function(){
	
	/*********************************************************************
	  Handle dropdown menus
	*********************************************************************/
	
	$("ul.sf-menu").superfish();

	/*********************************************************************
	  Handle side menu
	*********************************************************************/
	
	//Hide all submenus
	$("#left ul").hide();
	
	//Show current submenu or first if non selected
	if ( currentMenu.length > 1 ) {
		$( '#' + currentMenu ).show();
	}
	else {
		$('#left ul:first').show();
	}
	
	//Handle clicking on div with expand class
	$('#left .expand').click( function() {
		//If it's not currently visible
		if ( $(this).next().attr('id') != $('#left ul:visible').attr('id') ) {
			//Slide sections up and down
			$('#left ul:visible').slideUp('normal');
			$(this).next().slideDown('normal');
		}
		//Return false so links in menu don't follow through
		return false;
	});
});

/*********************************************************************
  Set target for SEARCH form
*********************************************************************/
function setSearchTarget( target ) {
	$('#sitesearch').attrib('target', '_self');
	alert( $('#search-google:checked') );
	if ( $('#search-google:checked') ){
		$('#sitesearch').attrib('target', target);
	}
	return true;
}

/*********************************************************************
  Generic Popup
*********************************************************************/
function popup( name, url ) {
	var width = 680;
	var height = 520;

	if ( screen.width > 800 ) {
		var top 	= ( screen.height - height ) / 2;
		var left 	= ( screen.width - width ) / 2;
	} 
	else {
		var top 	= 0;
		var left 	= 0;
	}
	var openString = name + " = window.open('" + url + "','" + name + "','screenX=" + left + ",left=" + left + ",screenY=" + top + ",top=" + top + ",width=" + width + ",height=" + height + ",menubar=no,resizable=yes,titlebar=no,status=no,scrollbars=yes');";
	var focusString = "window." + name + ".focus();";
	eval( openString );
	eval( focusString )
}