/* ===== 'scripts.js' ===== */

// The document is loaded -->
onload = function(){
	ChangeFormValue();
	BackToPreviousPage();
	
}
// -->

// Return to the previous page -->
function BackToPreviousPage()
	{
		var obj = document.getElementById('BackToPage');	// link's id -->
		if (obj) {
			obj.onclick = function(){
				if (history.length > 1) {
					history.back();
					return false;
				}
				else{
					return true;
				}
			}
		}
	}
// -->

// Change contained in "value" -->
function ChangeFormValue()
	{
		var form = document.forms;	// array of all forms on page -->
		if (form.length > 0)
			{
				for (var i = 0; i < form.length; i++)
					{
						var check = 0;	// using for reset -->
						var array = form[i].elements;	// array of form's elements -->
						for (var j = 0; j < array.length; j++)
							{
								var el = array[j];	// element -->
								if (el.name == 'status')	// only "input name='status'" -->
									{
										check = el.value;
										break;
									}
							}
						if (check === '')
							{
								for (j = 0; j < array.length; j++)
									{
										el = array[j];	// element -->
										if (el.type == 'text' || el.tagName.toLowerCase() == 'textarea')	// only "input type='text'" & "textarea" -->
											{
												el.onfocus = function()
													{
														if (this.value == this.defaultValue)
															{
																this.value = '';
															}
													}
												el.onblur = function()
													{
														if (this.value == '')
															{
																this.value = this.defaultValue;
															}
													}
											}	
									}
								form[i].onsubmit = function()
									{
										return ResultValue(this.elements);	// arrays of elements -->
									}
							}
					}
			}
	}
// -->

// Check result -->
function ResultValue(array)
	{
		for (var i = 0; i < array.length; i++)
			{
				var el = array[i];	// element -->
				if (el.type == 'text' || el.tagName.toLowerCase() == 'textarea')	// only "input type='text'" & "textarea" -->
					{
						if (el.value == el.defaultValue)
							{
								el.value = '';
							}
					}
			}
		return true;	// "false" - not send the form, "true" - send the form -->
	}
// -->

/* --- © Tarik, 2010 --- */

/* ===== // 'scripts.js' // ===== */
