function jqToggleLayer( elementID, speed, toggleMenu, showHide ) {
	/*
	* showHide = optional, must be 'show' or 'hide'. 
	*/
	//alert( showHide );
	if ( showHide == null ) {
		var elementDisplay = $("#" + elementID).css("display");
		if ( elementDisplay == "none" ) {
			$("#" + elementID).show(speed);
		} else {
			$("#" + elementID).hide();
		}
		if ( toggleMenu ) {
			jqToggleLayer ( "leftcontent", "", 0 );
		}
	} else {
		if ( showHide == "show" ) {
			$("#" + elementID).show(speed);
		} else {
			$("#" + elementID).hide();
		}
	}
}

function jqSlideLayer( elementID, speed, toggleMenu, showHide ) {
	//using jquery, but this should have been toggle (it didn't allow item to be hidden)
	//$("#" + elementID).show( "clip", speed );
	//using jqueryui to toggle
	// this was set to just toggle and then toggleMenu
	// changed to use showHide 2009-07-21
	
	if ( showHide == null ) {
		$("#" + elementID).toggle( "blind", speed );
	} else {
		if ( showHide == "show" ) {
			$("#" + elementID).show( "blind", speed );
		} else {
			$("#" + elementID).hide();
		}
	}
	
	if ( toggleMenu ) {
		jqToggleLayer ( "leftcontent", "", 0 );
	}
}

function jqSetSelection ( elementID, valueText, checkID, windowID ) {
	/*
	* elementID = the ID of the element (as opposed to numeric location)
	* valueText = the ID of the option (as opposed to numeric)
	* checkID = the ID of the green check
	* windowID = if supplied, this is the ID to close
	*
	* actually, checkID and elementID should ALWAYS be the same
	* this function is similar to the function used for personalized tags
	* set dropdown menu (using the element number OR id) to the value given
	* close the window if required
	* make the green check visible after changing the selection
	*/
	
	var greenCheck = "greenCheck" + checkID;
	elementID = "select" + elementID;
	//document.getElementById(elementID).value = valueText;
	// turns out it is better to loop through the menu
	// and choose the item with the appropriate value..
	
	$("#" + elementID + " option").each(function(i){
		if ( $(this).attr("id") == valueText ) {
			$(this).attr( "selected", "selected" ); // select the right option
			$("#" + elementID).change(); // fire the change event manually
		} else {
			$(this).removeAttr( "selected" ); // deselect the current option
		}
	});
	
	
	jqSlideLayer ( greenCheck, 'fast', 0, 'show' );	
	if ( windowID ) {		
		if ( windowID == "JQUIDialog" ) {
			$("#JQUIDialog").dialog( "close" );
		} else if ( windowID == "JQUIDialog2" ) {
			$("#JQUIDialog2").dialog( "close" );
		} else if ( windowID == "JQUIDialogv2" ) {
			$("#JQUIDialogv2").dialog( "close" );
		} else if ( windowID == "attInfo" ) {
			$("#attInfo").dialog( "close" );
		} else {
			jqToggleLayer( windowID, '', 1 );
		}
	}
}