//****************************************************************
//****************************************************************
//	COPYRIGHT 2008, Vertex Software
//****************************************************************
//****************************************************************

//----------------------------------------------------------------
//----------------------------------------------------------------
// For elements that use the js_toggle class, sets the
// default text to whatever test is defined for the field title
// attribute. When the user focuses on the field, the defaut text is
// removed. If the user does not chaneg the text and leaves the field,
// the default text is added back. Defautl text will NOT be posted back
// with form data.
//----------------------------------------------------------------
//----------------------------------------------------------------



//-----------------------------------------------------------
// toggle
//-----------------------------------------------------------
function toggle( element ) {
	var mToggleElementID = "";
	Initialize(element);
	

	//-----------------------------------------------------------
	// Initialize
	//-----------------------------------------------------------
	function Initialize( element ) {
		try {
			if (!element) return;
			var classes = element.className.split( /[ ]+/ );
			if (classes.length < 2) {
				alert( "Toggle Behavior: The ID of the element to be toggled is defined as the second class: class=\"js_toggle elementID\"" );
				return;
				}
			mToggleElementID = classes[1];
			if (!document.getElementById(mToggleElementID)) {
				window.status = ( "Toggle Behavior: Element not found - " + mToggleElementID );
				return;
				}
			$(element).click( onclick );
			}
		catch (error) {
			alert( "defaultText.Initialize: " + error.description  );
			}
		}


	//===========================================================
	// onclick
	//===========================================================
	function onclick( ) {
		try {
			var toggleElement = document.getElementById( mToggleElementID );
			if (!toggleElement) return true;
			$("#"+mToggleElementID).slideToggle("normal");
			}
		catch (error) {
			alert( "onclick: " + error.description  );
			}
		return  false;
		}



	}


AttachBehaviors("toggle");