function setFocus(id){
	document.getElementById(id).focus();
}

function clearText(thefield){
	if (thefield.defaultValue==thefield.value) {
		thefield.value = "";
	}
} 

/*
* This function will control the checkbox with the "All" id. Whenever you click on the check all checkbox, it will check or uncheck all
* of the checkboxes on the form, but if you click in one by one checkbox, it will not enable the check all checkbox unless you use this function.
* This will help the user control be more friendly and error free
* Parameters:
* chk_All_ID = id of the checkbox that represents the "check all"
* formID	 = id of the form that wraps the checkboxes with the files 
*/
function uncheck_chkall(chk_All_ID,formID)
{
	var chk_to_uncheck = document.getElementById(chk_All_ID);
	var fmobj = document.forms[formID];
	var chkCounter = 0;
	var chkCheckedCounter = 0;
	
	for (var i=0;i<fmobj.elements.length;i++)
	{
		var e = fmobj.elements[i];
		if ( (e.id != chk_All_ID ) && (e.type=='checkbox') && (!e.disabled)) 
		{
			chkCounter = chkCounter + 1;
			if(e.checked)
			{
				chkCheckedCounter = chkCheckedCounter + 1;
			}
		}
	}
	
	el = document.getElementById(chk_All_ID);

	if(chk_to_uncheck.checked == true || chk_to_uncheck.checked == 'on' )
	{
		if(chkCheckedCounter == chkCounter)
		{
			chk_to_uncheck.checked = true;
			el.onclick = function onclick(event) { check(formID,'uncheck',chk_All_ID); };
		}
		else
		{
			chk_to_uncheck.checked = false;
			el.onclick = function onclick(event) { check(formID,'check',chk_All_ID); };
		}
	}
	else
	{
		if(chkCheckedCounter == chkCounter)
		{
			chk_to_uncheck.checked = true;
			el.onclick = function onclick(event) { check(formID,'uncheck',chk_All_ID); };
		}
		else
		{
			chk_to_uncheck.checked = false;
			el.onclick = function onclick(event) { check(formID,'check',chk_All_ID); };
		}
	}
}

/*
* This function will control the checkboxes on the form. It will check all checkboxes on the form or uncheck based on the onClick event
* from the checkbox with the "All" Id.
* This function will dinamicly change the onClick event of the checkbox All changing the type of the action that will be taken.
* Parameters:
* formID 	= id of the form that wraps the checkboxes with the files
* type 		= type of action (check or uncheck)
* chkAllID	= id of the checkbox that represents the "check all"
*/
function check(formID,type,chkAllID)
{
	var fmobj = document.forms[formID];
	
	for (var i=0;i<fmobj.elements.length;i++)
	{
		var e = fmobj.elements[i];
		
		if ( (e.id != chkAllID ) && (e.type=='checkbox') && (!e.disabled)) 
		{
			if(type == 'check')
			{
				e.checked = true;
				el = document.getElementById(chkAllID);
				el.onclick = function onclick(event) { check(formID,'uncheck',this.id); };
			}
			else
			{
				e.checked = false;
				el = document.getElementById(chkAllID);
				el.onclick = function onclick(event) { check(formID,'check',this.id); };
			}
		}
	}
	return true;
}