/*
################################################################################
#	PHCDownload - Download Management System
################################################################################
# Copyright (c) 2005 by Alex G-White -- http://www.phpcredo.com
# PHCDL is free to use software. Please visit the website for futher licence
# information on distribution and use.
################################################################################
*/

/*
 * Fetch an object from the page
 **/
 
function read_obj( obj )
{
	if( document.getElementById )
	{
		return document.getElementById( obj );
	}
	else if( document.all )
	{
		return document.all[ obj ];
	}
	else if( document.layers )
	{
		return document.layers[ obj ];
	}
	else
	{
		return null;
	}
}

/*
 * Form field focus/blur notations
 **/

function init_obj_focus( element, objvalue )
{
	if( document.getElementById( element ).value == objvalue )
	{
		document.getElementById( element ).value = "";
		document.getElementById( element ).style.color = "#000000";
	}
}

function init_obj_blur( element, objvalue )
{
	if( document.getElementById( element ).value == "" )
	{
		document.getElementById( element ).value = objvalue;
		document.getElementById( element ).style.color = "#c0c0c0";
	}
}

function field_show_bg( element )
{
	if( element.value == "" )
		{ element.className = "field_back_" + element.name; }
	else
		{ element.className = ""; }
}

// Invert a set of (or all) checkboxes at once by clicking a single checkbox.
function invertCheckboxes(headerfield, checkform, mask, ignore_disabled)
{
	for (var i = 0; i < checkform.length; i++)
	{
		if (typeof(checkform[i].name) == "undefined" || (typeof(mask) != "undefined" && checkform[i].name.substr(0, mask.length) != mask && checkform[i].id.substr(0, mask.length) != mask))
			continue;
		if (!checkform[i].disabled || typeof(ignore_disabled) != "undefined")
			checkform[i].checked = headerfield.checked;
	}
}