
function autoLoadTroubleTicket(loadChoice) {
	document.data.choice.value="trouble1";
	document.data.loadChoice.value=loadChoice;
	if(loadChoice=="itn"){document.data.loadField.value=document.data.itn.value;}
	if(loadChoice=="phone"){document.data.loadField.value=document.data.phone.value;}
	if(loadChoice=="email"){document.data.loadField.value=document.data.email.value;}
	document.data.submit();
}

function verifyUser() {
	var themessage = "";
	if ((document.data.first.value=="")&&(document.data.last.value=="")&&(document.data.itn.value=="")&&(document.data.email.value=="")) {
		themessage = "You are required to complete at least one field";
	}
	if (themessage == "") {
		document.data.submit();
	} else {
		alert(themessage);
		return false;
	}
}

function verifyGeneralInventory() {
	var themessage = "You are required to complete the following fields: ";
	if (document.data.inventory_id.value=="") {
		themessage = themessage + " - ITN";
	}
	if (document.data.itemType.value=="") {
		themessage = themessage + " -  Item Type";
	}
	if (document.data.department_id.value=="") {
		themessage = themessage + " -  Department";
	}
	if (document.data.completionDate.value=="") {
		themessage = themessage + " -  Purchase Date";
	}
	if (document.data.location_id.value=="") {
		themessage = themessage + " -  Location";
	}
	if (document.data.vendor.value=="") {
		themessage = themessage + " -  Vendor";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
		document.data.submit();
	} else {
		alert(themessage);
		return false;
	}
}

function verifySecondaryInventory() {
	var themessage = "You are required to complete the following fields: ";
	if (document.data.model.value=="") {
		themessage = themessage + " - Model";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
		document.data.submit();
	} else {
		alert(themessage);
		return false;
	}
}

function verifyAccountTicket() {
	var themessage = "You are required to complete the following fields: ";
	if (document.data.first.value=="") {
		themessage = themessage + " - First Name";
	}
	if (document.data.last.value=="") {
		themessage = themessage + " -  Last Name";
	}
	if (document.data.login_id.value=="") {
		themessage = themessage + " -  Login ID";
	}
	if (document.data.completionDate.value=="") {
		themessage = themessage + " -  Effective Date";
	}
	if (document.data.department.value=="") {
		themessage = themessage + " -  Department";
	}
	if ((document.data.accountType.value=="")&&(document.data.requestType.value!="Edit Account")&&(document.data.requestType.value!="Delete Account")){
		themessage = themessage + " -  Account Type";
	}
	if (document.data.requestType.value=="") {
		themessage = themessage + " -  Request Type";
	}
	if ((document.data.requestType.value=="Edit Account")&&(document.data.comments.value=="")) {
		themessage = themessage + " -  Description of Changes";
	}
	if ((document.data.requestType.value=="Add Account")&&(document.data.adminSideFlag.value=="1")&&(document.data.location_id.value=="")&&(document.data.status.value=="Complete")) {
		themessage = themessage + " -  Location";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
		document.data.submit();
	} else {
		alert(themessage);
		return false;
	}
}

function verifyAccount() {
	var themessage = "You are required to complete the following fields: ";
	if (document.data.first.value=="") {
		themessage = themessage + " - First Name";
	}
	if (document.data.last.value=="") {
		themessage = themessage + " -  Last Name";
	}
	if (document.data.login_id.value=="") {
		themessage = themessage + " -  Login ID";
	}
	if (document.data.department_id.value=="") {
		themessage = themessage + " -  Department";
	}
	if (document.data.location_id.value=="") {
		themessage = themessage + " -  Location";
	}
	if (document.data.accountType.value=="") {
		themessage = themessage + " -  Account Type";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
		document.data.submit();
	} else {
		alert(themessage);
		return false;
	}
}

function verifyProject() {
	var themessage = "You are required to complete the following fields: ";
	if (document.data.title.value=="") {
		themessage = themessage + " - Project Title";
	}
	if (document.data.first.value=="") {
		themessage = themessage + " - First Name";
	}
	if (document.data.last.value=="") {
		themessage = themessage + " -  Last Name";
	}
	if (document.data.phone.value=="") {
		themessage = themessage + " -  Phone";
	}
	if (document.data.email.value=="") {
		themessage = themessage + " -  Email";
	}
	if (document.data.department.value=="") {
		themessage = themessage + " -  Department";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
		document.data.submit();
	} else {
		alert(themessage);
		return false;
	}
}

function verify() {
	var themessage = "You are required to complete the following fields: ";
	if (document.data.first.value=="") {
		themessage = themessage + " - First Name";
	}
	if (document.data.last.value=="") {
		themessage = themessage + " -  Last Name";
	}
	if (document.data.itn.value=="") {
		themessage = themessage + " -  ITN";
	}
	if (document.data.phone.value=="") {
		themessage = themessage + " -  Phone";
	}
	if (document.data.email.value=="") {
		themessage = themessage + " -  Email";
	}
	if (document.data.category.value=="") {
		themessage = themessage + " -  Category";
	}
	if (document.data.department.value=="") {
		themessage = themessage + " -  Department";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
		document.data.submit();
	} else {
		alert(themessage);
		return false;
	}
}

function verify2() {
	document.data.choice.value="trouble2";
	var themessage = "You are required to complete the following fields: ";
	if (document.data.first.value=="") {
		themessage = themessage + " - First Name";
	}
	if (document.data.last.value=="") {
		themessage = themessage + " -  Last Name";
	}
	if (document.data.itn.value=="") {
		themessage = themessage + " -  ITN";
	}
	if (document.data.phone.value=="") {
		themessage = themessage + " -  Phone";
	}
	if (document.data.email.value=="") {
		themessage = themessage + " -  Email";
	}
	if (document.data.category.value=="") {
		themessage = themessage + " -  Category";
	}
	if (document.data.department.value=="") {
		themessage = themessage + " -  Department";
	}
	//alert if fields are empty and cancel form submit
	if (themessage == "You are required to complete the following fields: ") {
		document.data.submit();
	} else {
		alert(themessage);
		return false;
	}
}

function verifyARTSsurvey(thisform) {
	myOption1 = -1;
	myOption2 = -1;
	myOption3 = -1;
	myOption4 = -1;
	myOption5 = -1;
	myOption6 = -1;
	myOption7 = -1;
	myOption8 = -1;
	myOption9 = -1;
	myOption10 = -1;
	for (i=thisform.result1.length-1; i > -1; i--) {
		if (thisform.result1[i].checked) {
			myOption1 = i;
		}
		if (thisform.result2[i].checked) {
			myOption2 = i;
		}
		if (thisform.result3[i].checked) {
			myOption3 = i;
		}
		if (thisform.result4[i].checked) {
			myOption4 = i;
		}
		if (thisform.result5[i].checked) {
			myOption5 = i;
		}
		if (thisform.result6[i].checked) {
			myOption6 = i;
		}
		if (thisform.result7[i].checked) {
			myOption7 = i;
		}
		if (thisform.result8[i].checked) {
			myOption8 = i;
		}
		if (thisform.result9[i].checked) {
			myOption9 = i;
		}
		if (thisform.result10[i].checked) {
			myOption10 = i;
		}
	}

	if (thisform.session.value=="") {
		alert("Please select your session");
		return false;
	}

	if (thisform.level.value=="") {
		alert("Please select your level of training");
		return false;
	}

	if ((myOption1 == -1)||(myOption2 == -1)||(myOption3 == -1)||(myOption4 == -1)||(myOption5 == -1)||(myOption6 == -1)||(myOption7 == -1)||(myOption8 == -1)||(myOption9 == -1)||(myOption10 == -1)) {
		alert("Please rate all choices.  Comments are optional");
		return false;
	}
	// place any other field validations that you require here
	thisform.submit(); // this line submits the form after validation
}

function y2k(number){
	return (number < 1000) ? number + 1900 : number;
}

var today = new Date();
var day   = today.getDate();
var month = today.getMonth();
var year  = y2k(today.getYear());

function padout(number){
	return (number < 10) ? '0' + number : number;
}

function restart() {
    document.data.completionDate.value = '' + padout(month - 0 + 1) + '/' + padout(day) +  '/' + year;
    mywindow.close();
}

function newWindow() {
    mywindow=open('cal.php','myname','resizable=no,width=350,height=270');
    mywindow.location.href = 'cal.php';
    if (mywindow.opener == null) mywindow.opener = self;
}

function restart2() {
    document.data.endDate.value = '' + padout(month - 0 + 1) + '/' + padout(day) +  '/' + year;
    mywindow.close();
}

function newWindow2() {
    mywindow=open('cal2.php','myname','resizable=no,width=350,height=270');
    mywindow.location.href = 'cal2.php';
    if (mywindow.opener == null) mywindow.opener = self;
}

function restart3() {
    document.data.completeDateStart.value = '' + padout(month - 0 + 1) + '/' + padout(day) +  '/' + year;
    mywindow.close();
}

function newWindow3() {
    mywindow=open('cal3.php','myname','resizable=no,width=350,height=270');
    mywindow.location.href = 'cal3.php';
    if (mywindow.opener == null) mywindow.opener = self;
}

function restart4() {
    document.data.completeDateEnd.value = '' + padout(month - 0 + 1) + '/' + padout(day) +  '/' + year;
    mywindow.close();
}

function newWindow4() {
    mywindow=open('cal4.php','myname','resizable=no,width=350,height=270');
    mywindow.location.href = 'cal4.php';
    if (mywindow.opener == null) mywindow.opener = self;
}

function toggleRows() {
    for (var loop=0; loop<arguments.length; loop++) {
        var id = arguments[loop];

        if( document.getElementById(id).style.display == 'none' ) {
            document.getElementById(id).style.display = '';
        } else {
            document.getElementById(id).style.display = 'none';
        }
    }
}

/*--------Bill's JavaScript--------*/
sfHover = function() {
	var sfEls = document.getElementById("ats_nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		};
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		};
	}
};
if (window.attachEvent) window.attachEvent("onload", sfHover);