function clearElement(element)
{
	// remove all the nodes from the DBTable node first
	if ( element.hasChildNodes() )
	{
		while ( element.childNodes.length >= 1 )
		{
			element.removeChild( element.firstChild );       
		} 
	}
}

Array.prototype.contains=function(object)
{
	for (var i = 0; i < this.length; i++) 
	{
		if(this[i].equals && this[i].equals(object))
		{
			return true;
		}
		else if(this[i] == object) 
		{
			return true;
		} 
	}
	
	return false;
}

Array.prototype.append=function(object, noDuplicate)
{
	if(!(noDuplicate && this.contains(object)))
	{
		this[this.length] = object;
	}
}



function getMonthName(month)
{
	if(month == 0)
	{
		return "January";
	}
	else if(month == 1)
	{
		return "February";
	}
	else if(month == 2)
	{
		return "March";
	}
	else if(month == 3)
	{
		return "April";
	}
	else if(month == 4)
	{
		return "May";
	}
	else if(month == 5)
	{
		return "June";
	}
	else if(month == 6)
	{
		return "July";
	}
	else if(month == 7)
	{
		return "August";
	}
	else if(month == 8)
	{
		return "September";
	}
	else if(month == 9)
	{
		return "October";
	}
	else if(month == 10)
	{
		return "November";
	}
	else if(month == 11)
	{
		return "December";
	}
	
	return "Unknown";
}

function isLeapYear(year)
{
	return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))));
}

function daysInMonth(month, year)
{
	if(month == 1)
	{
		if(isLeapYear(year))
		{
			return 29;
		}
		
		return 28;
	}
	
	if(month == 3 || month == 5 || month == 8 || month == 10)
	{
		return 30;
	}
	
	return 31;
}

Date.prototype.equals=function(obj)
{
	if(obj instanceof Date && this.getTime() == obj.getTime())
	{
		return true;
	}
	
	return false;
}
