/********************************************************************
			MAIN
********************************************************************/
	/*Please don't use Internet Explorer...it stinks.*/
	startList = function() 
	{
		if( document.all && document.getElementById ) 
		{
			navRoot = document.getElementById("nav");
			for( i=0; i<navRoot.childNodes.length; i++ )
			{
				node = navRoot.childNodes[i];
				
				if( node.nodeName=="LI" ) 
				{
					node.onmouseover=function() 
					{
						this.className+=" over";
					}
					node.onmouseout=function() 
					{
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}
	
	window.onload=startList;
	
/********************************************************************
			DOM
********************************************************************/
function getElementsByClass( classname, tagname, parent ) 
{
	if(!parent) parent = document.getElementsByTagName("body");
	if(!tagname) tagname = "*";
	
	var elements = [];
	
	var tags = parent.getElementsByTagName(tagname);
	var regEx = new RegExp('\\b' + classname + '\\b');
	for (i = 0; i < tags.length; i++) 
	{
		if(regEx.test(tags[i].className)) 
			elements.push(tags[i]);
	}
	return elements;

}

function getElementsByTag( tagname, parent )
{
	if(!parent) parent = document.getElementsByTagName("body");
	if(!tagname) tagname = "*";
	
	var elements = parent.getElementsByTagName(tagname);
	
	return elements;
}

function hasClass( element, classname )
{
	var regEx = new RegExp('\\b' + classname + '\\b');
		
	return regEx.test(element.className);
}


/********************************************************************
			VALIDATION
********************************************************************/
function validateLength( elementId, maxlength  )
{
	var element = document.getElementById( elementId );
	return element.value.length <= maxlength;
}

/********************************************************************
			JAVASCRIPT EXTENSIONS
********************************************************************/
Date.prototype.getMonthWithZeros = function()
{
	var monthStr = "";
	var month = this.getMonth() + 1;
	
	if( month < 10 )
		monthStr = "0"; 
	
	monthStr += "" + month;
	
	return monthStr;
}
Date.prototype.getDateWithZeros = function()
{
	var dateStr = "";
	
	if( this.getDate() < 10 )
		dateStr = "0"; 
	
	dateStr += "" + this.getDate();
	
	return dateStr;
}
Date.prototype.getHoursWithZeros = function()
{
	var dateStr = "";
	
	if( this.getHours() < 10 )
		dateStr = "0"; 
	
	dateStr += "" + this.getHours();
	
	return dateStr;
}
Date.prototype.getMinutesWithZeros = function()
{
	var dateStr = "";
	
	if( this.getMinutes() < 10 )
		dateStr = "0"; 
	
	dateStr += "" + this.getMinutes();
	
	return dateStr;
}
Date.prototype.getDBFormat = function() 
{
	var returnStr = "";
	returnStr = "" + 
		this.getFullYear() + "-" +
		this.getMonthWithZeros() + "-" +
		this.getDateWithZeros() + " " +
		this.getHoursWithZeros() + ":" +
		this.getMinutesWithZeros();
		
	return returnStr;
};
Date.prototype.setDBFormat = function(dateString)
{
	var dt = dateString.split(" ");
	if( dt.length > 0 || dateString.length > 0 )
	{
		var d = dt[0].split("-");
		if( d.length > 2 )
		{
			this.setDate( d[2] );
			this.setMonth( d[1] - 1 );
			this.setYear( d[0] );
		}
	}
	if( dt.length > 1 )
	{
		var t = dt[1].split(":");
		if( t.length > 0 )
		{
			this.setHours( t[0] );
			this.setMinutes( t[1] );
		}
	}
}

