var currentColor = "";
var onColor = "yellow";
var offColor = "dimgray";
var selColor = "cyan";
var message = "";

function toggleClick(divOff, divOn, tdOff, tdOn)
{
	//Toggle code display
	document.getElementById(divOff).style.display = "none";
	div = document.getElementById(divOn);
	div.style.display = "block";

	//Toggle td backgroundColor
	document.getElementById(tdOff).style.backgroundColor = offColor;
	document.getElementById(tdOn).style.backgroundColor = onColor;
	currentColor = onColor;
	
    //Place the innerText into a textarea and copy the text from 
    //the textarea to the clipboard
	holdtext.innerText = div.innerText
	var textRange = holdtext.createTextRange();
    textRange.execCommand("RemoveFormat");
	textRange.execCommand("Copy");

	//Format message to the user that the code was copied to the clipboard
	var language = "C#";
	if(div.id.search(/VB/)>1) //-1 if VB is not found
	{
		language = "VB";
	}
	message = language + " code copied to clipboard!";

	//Toggle code copied message in the status bar for a few seconds
	window.status = message
	window.setTimeout("window.status = ' '",     1500); 
	window.setTimeout("window.status = message", 1800); 
	window.setTimeout("window.status = ' '",     3500); 
	window.setTimeout("window.status = message", 3800); 
	window.setTimeout("window.status = ' '",     5500); 
}
function mouseOver(td)
{
	//If this is not the selected cell, save aside the backcolor
	//and change it temporarially to cyan and change the cursor
	if(td.style.backgroundColor == offColor)
	{
		currentColor = td.style.backgroundColor;
		td.style.backgroundColor = selColor;
		td.style.cursor = "hand";
	}
}
function mouseOut(td)
{
	//If the cell was temporarially changed to cyan
	//change it back to the current color
	if(td.style.backgroundColor == selColor)
	{
		td.style.backgroundColor = currentColor;
	}

	//Always change the cursor back to normal
	td.style.cursor = "normal";
}
