/**
 * SEVENSPIRE JS-UTILITIES
 * (c) 2008 by sevenspire.com
 * Author: Peter Wallner | peter@helic.net
 */


function Sevenspire()
{
	var that = this;

	this.$ = function(id)
	{
		return document.getElementById(id); 
	}
	
	this.$v = function(id)
	{
		return document.getElementById(id).value; 
	}

	this.changeBgColor = function(id, color)
	{
		this.$(id).style.backgroundColor = color;
	}
	
	this.changeBorderColor = function(id, color)
	{
		this.$(id).style.borderColor = color;
	}

	this.validateForm = function(elements)
	{
		var ret_val = true;
		var elements = elements.split(" ");

		for(i=0;i<=(elements.length-1);i++)
		{
			var e = elements[i];
			this.highlightFormElement(e);
			
			if(!this.$v(e)) ret_val = false;
		}

		return ret_val;
	}

	this.highlightFormElement = function(id, options)
	{
		if(!options) options = new Array();
	
		if(!options[0]) options[0] = "#fff";
		if(!options[1]) options[1] = "#eee";
		
		if(!this.$v(id))
		{
			this.changeBgColor(id, options[1]);
		}
		else
		{
			this.changeBgColor(id, options[0]);
		}
	}

}


//create object
var s = new Sevenspire;
