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

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

// Change contained in "value" -->
function ChangeFormValue ()
	{
		var form = document.getElementById('MainFaqForm');	// form's id -->
		if (form)
			{
				var array = form.elements;	// array of form's elements -->
				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" -->
							{
								el.onfocus = function ()
									{
										if (this.value == this.defaultValue)
											{
												this.value = '';
											}
									}
								el.onblur = function ()
									{
										if (this.value == '')
											{
												this.value = this.defaultValue;
											}
									}
							}
					}
				
				form.onsubmit = function ()
					{
						ResultValue(array);	// 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 = '';
							}
					}
			}
	}
// -->

// Opening link in new tab -->
function NewTab ()
	{
		var image = document.getElementById('FullSizeImage');	// image's id -->
		if (image)
			{
				src = image.href;
				title = image.title;
				image.onclick = function()
					{
						var win = window.open('/pub/img/scripts/new_tab.html');
						win.focus();
						return false;
					}
			}
	}
// -->

// Stylization "input type='file'" -->
function ChangeInputFile(obj,name)
	{
		var result;
		var path = obj.value;
		var position = path.lastIndexOf("\\");
		if (position > 0)
			{
				result = path.slice(position + 1);
			}
		else
			{
				result = path;
			}
		document.getElementById(name).value = result;
	}
// -->


// !!! -->
function BackToForm ()
	{
		if (history.length)
			{
				history.back();
				return false;
			}
		else
			{
				return true;
			}		
	}

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

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