// JavaScript Document

//----- begin clear text field

function clearDefaultValue(element) {
    if (element.value == element.defaultValue) element.value = '';
}

//----- end clear text field
//----- begin show value text field

function showDefaultValue(element) {
    if (element.value == '') element.value = element.defaultValue;
}

//----- end clear text field

// #############################################################################
// Form element managers (used for 'check all' type systems

/**
* Sets all checkboxes, radio buttons or selects in a given form to a given state, with exceptions
*
* @param	object	Form object
* @param	string	Target element type (one of 'radio', 'select-one', 'checkbox')
* @param	string	Selected option in case of 'radio'
* @param	array	Array of element names to be excluded
* @param	mixed	Value to give to found elements
*/
function js_toggle_all(formobj, formtype, option, exclude, setto)
{
	for (var i =0; i < formobj.elements.length; i++)
	{
		var elm = formobj.elements[i];
		if (elm.type == formtype && PHP.in_array(elm.name, exclude, false) == -1)
		{
			switch (formtype)
			{
				case 'radio':
					if (elm.value == option) // option == '' evaluates true when option = 0
					{
						elm.checked = setto;
					}
				break;
				case 'select-one':
					elm.selectedIndex = setto;
				break;
				default:
					elm.checked = setto;
				break;
			}
		}
	}
}

/**
* Sets all <select> elements to the selectedIndex specified by the 'selectall' element
*
* @param	object	Form object
*/
function checkUncheckAll(theElement) {
  	var theForm = theElement.form, z = 0;
	for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  		theForm[z].checked = theElement.checked;
		}
	}
}

//form_user_message.php

function testSend(form) {
 if((trim(form.sendsubject.value)=='') &(trim(form.txtmessage.value)==''))
 	{ 
	alert('You can\'t send an empty message!');
	return false;
	}
	return true;
}