/* Links blur */
function linksblur() {
		var i,l=document.getElementsByTagName('a')
		for(i=0;i<l.length;i++)
		{
			l[i].onfocus=function(){this.blur()}
		}
}
window.onload = linksblur

/* Forms */

	var form_messages = Array ("   ", "   ", " ", "     ", " ")

var err_col = '#FF3333';
var norm_col = '#003854';

function process_form(the_form, show_alert, info_saved)
{
	var real_fields = 0, err = 0, empty_fields = 0, fields = 0, errmess = ""
	if (document.all || document.getElementById)
	{
		for (i = 0; i < the_form.length; ++i)
		{
			var elem = the_form.elements[i]
			var _realname = (elem.getAttribute('alt'))

			if (_realname)
			{	
				real_fields++
				if (((elem.type && (elem.type=="text" || elem.type=="input" || elem.type=="textarea" || elem.type=="password" )) || elem.options) && (elem.value == '' || elem.value == elem.alt))
				{
					errmess += "\n\"" + _realname + "\""
						if(!err){elem.focus()}
						elem.style.borderColor = err_col
					err++
				}
				else
				{
						elem.style.borderColor = norm_col
				}
			}
		}
		
		if(err == 1)
		{
			alert(form_messages[1] + "\n" + errmess)
			return false
		}
		else
		{
			if(err > 1)
			{
				alert(form_messages[0] + "\n" + errmess)
				return false
			}
			if (real_fields > 0 || empty_fields != fields || (empty_fields == 0 && fields == 0))
			{
				if (show_alert)
				{
					if (info_saved)
					{
						alert(form_messages[4])
					}
					else
					{
						alert(form_messages[2])
					}
				}
				return true
			}
			else
			{
			alert(form_messages[3])
			return false
			}
		}
	}
}

/* Placehlder */
function InputPlaceholder (input, value, cssFilled, cssEmpty)
{
	var thisCopy = this
	
	this.Input = input
	this.Value = value
	this.SaveOriginal = (input.value == value)
	this.CssFilled = cssFilled
	this.CssEmpty = cssEmpty

	this.setupEvent (this.Input, 'focus', function() {return thisCopy.onFocus()})
	this.setupEvent (this.Input, 'blur',  function() {return thisCopy.onBlur()})
	this.setupEvent (this.Input, 'keydown', function() {return thisCopy.onKeyDown()})

	if (input.value == '') this.onBlur();

	return this
}

InputPlaceholder.prototype.setupEvent = function (elem, eventType, handler)
{
	if (elem.attachEvent)
	{
		elem.attachEvent ('on' + eventType, handler)
	}

	if (elem.addEventListener)
	{
		elem.addEventListener (eventType, handler, false)
	}
}

InputPlaceholder.prototype.onFocus = function()
{
	if (!this.SaveOriginal &&  this.Input.value == this.Value)
	{
		this.Input.value = ''
	}
	else
	{
			this.Input.className = ''
	}
}

InputPlaceholder.prototype.onKeyDown = function()
{
	this.Input.className = ''
}

InputPlaceholder.prototype.onBlur = function()
{
	if (this.Input.value == '' || this.Input.value == this.Value)
	{
		this.Input.value = this.Value
		this.Input.className = this.CssEmpty
	}
	else
	{
		this.Input.className = this.CssFilled
	}
}

