function getLastChildElement(element)
{
	if (element.childNodes && element.childNodes.length>0)
	{
		lastChildElement = element.childNodes[element.childNodes.length-1];
	}

	else if (element.innerHTML)
	{
		lastChildElementId = element.innerHTML.substring(element.innerHTML.lastIndexOf('id='),element.innerHTML.length)
		lastChildElementId = lastChildElementId.substring(3,lastChildElementId.indexOf('>'));
		lastChildElement = document.getElementById(lastChildElementId);
	}

	return (lastChildElement);
}

function getClassAttribute(element)
{
	if (element.getAttribute('class'))
	{
		return (element.getAttribute('class'));
	}

	else if (element.outerHTML)
	{
		tag=String(element.outerHTML);

		classAttribute = tag.substring(tag.indexOf('class='),tag.length);
 		classAttribute = classAttribute.substring(6,classAttribute.indexOf(' '));
	}

	return (classAttribute)
}

function getHrefAttribute(element)
{
	if (element.getAttribute('href'))
	{
		return (element.getAttribute('href'));
	}

	else if (element.outerHTML)
	{
		tag=String(element.outerHTML);

//alert(tag);

		hrefAttribute = tag.substring(tag.indexOf('href='),tag.length);
 		hrefAttribute = hrefAttribute.substring(6,hrefAttribute.indexOf(' '));
	}
	//alert(hrefAttribute);
	return (hrefAttribute)
}


function hoverButton(element)
{
	classAttribute = getClassAttribute(element);
	lastChildElement = getLastChildElement(element);

	fgColor="#008CD6";
	bgColor = "#FFFFFF";

	switch(classAttribute)
	{
		case "diaryDimButton":
			bgColor = "#FFFFFF";
			break;
		case "diaryBrightButton":
			bgColor = "#FFFFFF";
			break;
		case "diaryButtonHeaderCell":
			bgColor = "#F7F7E7";
			fgColor = "#990000"
			break;
		case "calDayStandard":
			bgColor = "#E6CACA";
			fgColor = "#990000"
			break;
		case "nColDiaryButton":
			bgColor = "#F7F3DE";
			fgColor = "#990000";
			break;
		case "nColToolsButton":
			bgColor = "#F7FFE7";
			fgColor = "#990000"
			break;
	}

	element.style.backgroundColor=bgColor;
	lastChildElement.style.color=fgColor;
}

function dehoverButton(element)
{
	lastChildElement = getLastChildElement(element);

	fgColor="#003873";

	switch(classAttribute)
	{
		case "diaryDimButton":
			bgColor = "#E2E1DC";
			break;
		case "diaryBrightButton":
			bgColor = "#F1F1ED";
			break;
		case "diaryButtonHeaderCell":
			bgColor = "#ECE8D4";
			fgColor = "#424139"
			break;
		case "calDayStandard":
			bgColor = "#E5E1CF";
			fgColor = "#424139"
			break;
		case "nColDiaryButton":
			bgColor = "#F2EBCE";
			fgColor = "#382E05"
			break;
		case "nColToolsButton":
			bgColor = "#EBF3D7";
			fgColor = "#3C3E00"
			break;
	}

	element.style.backgroundColor=bgColor;
	lastChildElement.style.color=fgColor;
}


function clickButton(element)
{
	//lastChildElement = getLastChildElement(element);
	//location.href=getHrefAttribute(lastChildElement);
}

// td only buttons

function hoverTdButton(element)
{
	classAttribute = getClassAttribute(element);

	fgColor="#008CD6";
	bgColor = "#FFFFFF";

	switch(classAttribute)
	{
		case "diaryDimButton":
			bgColor = "#FFFFFF";
			break;
		case "diaryBrightButton":
			bgColor = "#FFFFFF";
			break;
		case "diaryButtonHeaderCell":
			bgColor = "#F7F7E7";
			fgColor = "#990000"
			break;
		case "calDayStandard":
			bgColor = "#E6CACA";
			fgColor = "#990000"
			break;
		case "nColDiaryButton":
			bgColor = "#F7F3DE";
			fgColor = "#990000";
			break;
		case "nColToolsButton":
			bgColor = "#F7FFE7";
			fgColor = "#990000"
			break;
	}

	element.style.backgroundColor=bgColor;
	element.style.color=fgColor;
}

function dehoverTdButton(element)
{

	fgColor="#003873";

	switch(classAttribute)
	{
		case "diaryDimButton":
			bgColor = "#E2E1DC";
			break;
		case "diaryBrightButton":
			bgColor = "#F1F1ED";
			break;
		case "diaryButtonHeaderCell":
			bgColor = "#ECE8D4";
			fgColor = "#424139"
			break;
		case "calDayStandard":
			bgColor = "#E5E1CF";
			fgColor = "#424139"
			break;
		case "nColDiaryButton":
			bgColor = "#F2EBCE";
			fgColor = "#382E05"
			break;
		case "nColToolsButton":
			bgColor = "#EBF3D7";
			fgColor = "#3C3E00"
			break;
	}

	element.style.backgroundColor=bgColor;
	element.style.color=fgColor;
}