//----------------------------------------------------------------------------------
// This function confirms an employee addition for a job assignment
//----------------------------------------------------------------------------------
function ConfirmAddEmployeeAssignment(test)
{
	// get selected employee name
	var selectBox = document.getElementById(test); //document.Form1[test]
	SelectedEmployeeName = selectBox.options[selectBox.selectedIndex].text;

	// confirm employee assignment before adding to job
	return confirm('Are you sure you want to add ' + SelectedEmployeeName + ' to this job?');
}
// End confirmAdd()
//----------------------------------------------------------------------------------



//----------------------------------------------------------------------------------
// This function confirms a delete action.
//----------------------------------------------------------------------------------
function ConfirmDelete() {
	if (confirm("Are you sure you want to continue?")) 
	{
		//alert ("The action is completed!");
		return true;
	}	
else
	{
		alert ("The action has been cancelled.");
		return false;
	}   
}
// End ConfirmDelete()
//----------------------------------------------------------------------------------



//----------------------------------------------------------------------------------
// This function confirms an archive action.
//----------------------------------------------------------------------------------

function ConfirmArchive() {
	if (confirm("Are you sure you want to archive?")) {
		alert ("The record(s) will now be archived!");
		return true;
	}	
else
	{
		alert ("The archive process has been cancelled.");
		return false;
	}   
}
// End ConfirmDelete()
//----------------------------------------------------------------------------------



//----------------------------------------------------------------------------------
// This function sets form focus to the first field on the form
//----------------------------------------------------------------------------------
function SetFocus(){
	
	//if(document.forms[0][0] != null){
	//if(document.getElementById("ddlActiveEmployees1") != null)
	//{
	//	alert("TEST");
		document.forms[0][0].focus();
	//}

}
// End SetFocus()
//----------------------------------------------------------------------------------



//----------------------------------------------------------------------------------
// Highlight Table Cells Script-- By Dynamic Drive
// For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
// This credit MUST stay intact for use
//----------------------------------------------------------------------------------

var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName=="TR"||source.tagName=="TABLE")
return
while(source.tagName!="TR"&&source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function contains_ns6(master, slave) { //check if slave is contained by master
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if
(ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TD"||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}


//-----------------------------------------------------------------
// Highlight form element
//-----------------------------------------------------------------

var highlightcolor="#FFFF99"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}
//-----------------------------------------------------------------



// ----------------------------------------------------------------
// AutoTab
//
// Creates autotab feature that aids data entry tasks by moving (tabbing)
// the cursor to the next field automatically once the specified 
// fied length is matched.
// -----------------------------------------------------------------

<!-- Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}

function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}

function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
//  End -->
// ----------------------------------------------------------------------


// -------------------------
// <!-- BEGIN
function select_deselectAll (chkVal, idVal) { 
var frm = document.forms[0];

// Loop through all elements
for (i=0; i<frm.length; i++) {

		// Look for our Header Template's Checkbox
		if (idVal.indexOf ('CheckAll') != -1) {

		// Check if main checkbox is checked, then select or deselect datagrid checkboxes 
		if(chkVal == true) {

		frm.elements[i].checked = true;
		} else {

		frm.elements[i].checked = false;
		}

		// Work here with the Item Template's multiple checkboxes
		} else if (idVal.indexOf ('DeleteThis') != -1) {

		// Check if any of the checkboxes are not checked, and then uncheck top select all checkbox
		if(frm.elements[i].checked == false) {

		frm.elements[1].checked = false; //Uncheck main select all checkbox

		}
	 }
  }
}

// END -->
//------------------------