// Check or uncheck all checkboxes on the page
function checkUncheckAll(theElement,checkit)
{
	if (typeof(checkit) == 'undefined')
	{
		var checkit = theElement.checked;
		var theForm = theElement.form, z = 0;
	}
	else
	{
		var theForm = theElement, z = 0;
	}

	if (checkit == 'checked')
	{
		checkit = true;
	}
	while (theForm[z])
	{
		if(theForm[z].type == 'checkbox')
		{
			theForm[z].checked = checkit;
		}
		z++;
	}
}

// Function highlights the selected row when appropriate checkbox is checked
function chkoxHlRow(rowid,defaultclass)
{
	var row = document.getElementById('row_'+rowid);
	
	if (document.getElementById('checkbox_'+rowid).checked == true)
	{
		row.className = 'highlightall' + (defaultclass != '' ? '-'+defaultclass:'');
	}
	else
	{
		row.className = defaultclass;
	}
}


// Highlights all rows in a table
function hlAllRows(table)
{
	table 	= document.getElementById(table);
	for (var c = 0; c < table.rows.length; c++)
	{
		rowid 		= table.rows[c].id;
		rowid = rowid.replace(/row_/g,'');
		defaultclass 	= table.rows[c].className;
		defaultclass	= defaultclass.replace(/highlightall(-)?/g,'');
		
		if (rowid != '')
		{
			chkoxHlRow(rowid,defaultclass);
		}
	}	
}


function highlight(action,id)
{
	// Function to highlight selected row & column in an "L" format
	var ids = new Array();
	ids = id.split('-');
	
	
	if (action == 's')
		changeClass = 'color1';
	else
	{
		changeClass = '';
		// Remove style from the active cell
		document.getElementById(id).className = '';
	}	
	// Highlight column
	for (i = ids[1]; i > 0; i--)
	{
		this_id = ids[0] + '-' + i + '-' + ids[2];
		document.getElementById(this_id).className=changeClass;
	}
	// Highlight row
	for (i = ids[2]; i > 0; i--)
	{
		this_id = ids[0] + '-' + ids[1] + '-' + i;
		document.getElementById(this_id).className=changeClass;
	}
	if (action == 's')
	{
		// Apply style to the active cell
		document.getElementById(id).className = 'active-cell';
	}
}

function isset(variable)
{
    var undefined;
    return ( variable == undefined ? false : true );
}