//generic validation
function validateAll(){
	var msg = "";
	var args = validateAll.arguments;
	//array cell content definitions:
	//0 = page location; 1 = form name; 2-? = parameters
	//alert(eval(args[1]).name);
	for (i=2;i<args.length;i++){
		var tempArray = args[i].split(",");
		//check if form field is a plain text field
		//array cell content definitions:
		//0 = field type; 1 = field name; 1 = error message
		if (tempArray[0] == "text"){
			if (switchDom(eval(args[0]),tempArray[1]).value == ""){
				msg = msg + tempArray[2];
			}
		}
		//check if form field is a drop down menu
		//array cell content definitions:
		//0 = field type; 1 = field name; 2 = error message
		if (tempArray[0] == "drop"){
			if (switchDom(eval(args[0]),tempArray[1]).value == ""){
				msg = msg + tempArray[2];
			}
		}
		//check if form field is a numeric field
		//array cell content definitions:
		//0 = field type; 1 = field name; 2 = length of number (or 'n/a' if no length requirement; 3 = error message
		else if (tempArray[0] == "num"){
			if (switchDom(eval(args[0]),tempArray[1]).value != ""){
				if (switchDom(eval(args[0]),tempArray[1]).value.length < tempArray[2] && tempArray[2] != "n/a"){
					msg = msg + "The " + tempArray[3] + " must be " + tempArray[2] + " digits.\n"
				}
				else{
					for (j=0;j<switchDom(eval(args[0]),tempArray[1]).value.length;j++){
						if (isNaN(switchDom(eval(args[0]),tempArray[1]).value.charAt(j))){
							msg = msg + "The " + tempArray[3] + " must be a number.\n"
							break;
						}
					}
				}
			}
			else{
				msg = msg + "Please enter a  " + tempArray[3] + ".\n"
			}
		}
		//check if form field is a password field
		//array cell content definitions:
		//0 = field type; 1 = field name; 2 = length of number or 'n/a' if no length requirement;
		else if (tempArray[0] == "pass"){
			if (switchDom(eval(args[0]),tempArray[1]).value != ""){
				if (switchDom(eval(args[0]),tempArray[1]).value.length < tempArray[2] && tempArray[2] != "n/a"){
					msg = msg + "The password must be " + tempArray[2] + " characters.\n"
				}
				else{
					//
				}
			}
			else{
				msg = msg + "Please enter a password.\n"
			}
		}
		//check if form field is a password field
		//array cell content definitions:
		//0 = field type; 1 = field name; 2 = length of number (or 'n/a' if no length requirement; 3 = confirm pw field name;
		else if (tempArray[0] == "confirmpass"){
			if (switchDom(eval(args[0]),tempArray[1]).value != ""){
				if (switchDom(eval(args[0]),tempArray[1]).value.length < tempArray[2] && tempArray[2] != "n/a"){
					msg = msg + "The password must be " + tempArray[2] + " characters.\n"
				}
				else{
					//
				}
			}
			else{
				msg = msg + "Please enter a password.\n"
			}
			if (switchDom(eval(args[0]),tempArray[3]).value != ""){
				if (switchDom(eval(args[0]),tempArray[3]).value.length < tempArray[2] && tempArray[2] != "n/a"){
					msg = msg + "Your password verification must be " + tempArray[2] + " characters.\n"
				}
				else if (switchDom(eval(args[0]),tempArray[3]).value != switchDom(eval(args[0]),tempArray[1]).value){
					msg = msg + "Your password verification must match your password.\n"
				}
			}
			else{
				msg = msg + "Please verify your password.\n"
			}
		}
		//check if form field is an email address field
		//array cell content definitions:
		//0 = field type; 1 = field name; 2 = error message
		else if (tempArray[0] == "email"){
			if (switchDom(eval(args[0]),tempArray[1]).value != ""){
				if (validateEmail(switchDom(eval(args[0]),tempArray[1]).value) != true){
					msg = msg + validateEmail(switchDom(eval(args[0]),tempArray[1]).value)
				}
			}
			else{
				msg = msg + tempArray[2];
			}
		}
	}
	if (msg != ""){
		alert(msg);
	}
	else{
		//alert(args[1]);
		switchDom(eval(args[0]),args[1]).submit();
	}
}
//ADD CLIENT VALIDATION
function AddClientValidate(){
	var msg = ""
	if (document.all("CName").value == ""){
		msg = msg + "Please enter a company/station name.\n"
	}
//
	if (document.all("CAddress1").value == ""){
		msg = msg + "Please enter a company/station address.\n"
	}
///
	if (document.all("CCity").value == ""){
		msg = msg + "Please enter a city.\n"
	}
//
	if (document.all("CState").value == ""){
		msg = msg + "Please select a state.\n"
	}
//
	if (document.all("CZip").value != ""){
		if (document.all("CZip").value.length < 5){
			msg = msg + "The zip code must be 5 digits.\n"
		}
		else{
			for (i=0;i<document.all("CZip").value.length;i++){
				if (isNaN(document.all("CZip").value.charAt(i))){
					msg = msg + "The zip code must be a number.\n"
					break;
				}
			}
		}
	}
	else{
		msg = msg + "Please enter a zip code.\n"
	}
///	
	if (document.all("CPhoneArea").value != ""){
		if (document.all("CPhoneArea").value.length < 3){
			msg = msg + "The area code must be 3 digits.\n"
		}
		else{
			for (i=0;i<document.all("CPhoneArea").value.length;i++){
				if (isNaN(document.all("CPhoneArea").value.charAt(i))){
					msg = msg + "The area code must be a whole number.\n"
					break;
				}
			}
		}
	}
	else{
		msg = msg + "Please enter an area code.\n"
	}
///	
	if (document.all("CPhoneNum").value != ""){
		if (document.all("CPhoneNum").value.length < 7){
			msg = msg + "The phone number must be 7 digits.\n"
		}
		else{
			for (i=0;i<document.all("CPhoneNum").value.length;i++){
				if (isNaN(document.all("CPhoneNum").value.charAt(i))){
					msg = msg + "The phone number must be a whole number.\n"
					break;
				}
			}
		}
	}
	else{
		msg = msg + "Please enter an phone number.\n"
	}
///	
	if (document.all("CContactName").value == ""){
		msg = msg + "Please enter a company/station contact name.\n"
	}
///
	if (document.all("CContactEmail").value != ""){
		if (validateEmail(document.all("CContactEmail").value) != true){
			msg = msg + validateEmail(document.all("CContactEmail").value)
		}
	}
	else{
		msg = msg + "Please enter a company/station contact email address.\n"
	}
///
	if (document.all("CUserID").value != ""){
		if (validateEmail(document.all("CUserID").value) != true){
			msg = msg + validateEmail(document.all("CUserID").value)
		}
	}
	else{
		msg = msg + "Please enter a valid User ID (email address).\n"
	}
///
	if (document.all("CCourse").value == ""){
		msg = msg + "Please select a course for initial registration.\n"
	}
///
	if (document.all("CNumLicense").value != ""){
		for (i=0;i<document.all("CNumLicense").value.length;i++){
			if (isNaN(document.all("CNumLicense").value.charAt(i))){
				msg = msg + "The number of licenses must be a whole number.\n"
				break;
			}
		}
	}
	else{
		msg = msg + "Please enter the number of licenses purchased by this company/station.\n"
	}
///
	if (document.all("CExpires").value != ""){
		for (i=0;i<document.all("CExpires").value.length;i++){
			if (isNaN(document.all("CExpires").value.charAt(i))){
				msg = msg + "The number of days a license is valid must be a whole number.\n"
				break;
			}
		}
	}
	else{
		msg = msg + "Please enter number of days a license is valid.\n"
	}
///
	if (msg != ""){
		alert(msg);
	}
	else{
		CompanyInfo.submit();
	}
}
function modifyClientValidate(){
	var msg = ""
	if (document.all("CName").value == ""){
		msg = msg + "Please enter a company/station name.\n"
	}
//
	if (document.all("CAddress1").value == ""){
		msg = msg + "Please enter a company/station name.\n"
	}
///
	if (document.all("CCity").value == ""){
		msg = msg + "Please enter a city.\n"
	}
//
	if (document.all("CState").value == ""){
		msg = msg + "Please select a state.\n"
	}
//
	if (document.all("CZip").value != ""){
		if (document.all("CZip").value.length < 5){
			msg = msg + "The zip code must be 5 digits.\n"
		}
		else{
			for (i=0;i<document.all("CZip").value.length;i++){
				if (isNaN(document.all("CZip").value.charAt(i))){
					msg = msg + "The zip code must be a number.\n"
					break;
				}
			}
		}
	}
	else{
		msg = msg + "Please enter a zip code.\n"
	}
///	
	if (document.all("CPhoneNum").value != ""){
		if (document.all("CPhoneNum").value.length < 9){
			msg = msg + "The phone number must be 9 digits.\n"
		}
		else{
			for (i=0;i<document.all("CPhoneNum").value.length;i++){
				if (isNaN(document.all("CPhoneNum").value.charAt(i))){
					msg = msg + "The phone number must be a whole number.\n"
					break;
				}
			}
		}
	}
	else{
		msg = msg + "Please enter an phone number.\n"
	}
///	
	if (document.all("CContactName").value == ""){
		msg = msg + "Please enter a company/station contact name.\n"
	}
///
	if (document.all("CContactEmail").value != ""){
		if (validateEmail(document.all("CContactEmail").value) != true){
			msg = msg + validateEmail(document.all("CContactEmail").value)
		}
	}
	else{
		msg = msg + "Please enter a company/station contact email address.\n"
	}
///
	if (document.all("CUserID").value == ""){
		msg = msg + "Please choose a user id.\n"
	}
///
	if (msg != ""){
		alert(msg);
	}
	else{
		CompanyInfo.submit();
	}
}
//ADD STUDENT VALIDATION
function AddStudentValidate(){
	var cStudents = switchDom(this,"CStudents").value
	var duplicate = cStudents.split(",");
	var pointer;
	var validEmail = "The following email addresses are invalid:\n\n";
	var vE = true;
	var dupeEmail = "You have entered duplicate email addresses in the 'Student Email Addresses' box:\n\n";
	var dE = true;
	var msg = "";
	var cName = document.all("cAppID").value;
	var coursename = "Please select a course."
	if (cStudents != ""){
		for (var i=0;i<duplicate.length;i++){
			pointer = duplicate[i];
			if (msg != ""){
				break;
			}
			if (validateEmail(pointer) != true){
				msg = msg + "Please check your email addresses for validity\nand make sure there are no carriage returns."
				break;
			}
			for (var j=0;j<duplicate.length;j++){
				if (j != i){
					if (pointer == duplicate[j]){
						msg = msg + "Please check for duplicate email addresses.\n"
						break;
					}
				}
			}
		}
		if (cName == ""){
			msg = msg + "Please select a course.\n"
		}
		if (msg != ""){
			alert(msg);
		}
		else{
			AddStudent.submit();
		}
	}
	else if (cStudents == ""){
		msg = msg + "Please enter email addresses to be sent for registration."
		if (cName == ""){
			msg = msg + "\nPlease select a course."
		}
		alert(msg);
	}
}
//STUDENT REGISTRATION VALIDATION
function regStudentValidate(){
var msg = "";
	if (document.all("cFName").value == ""){
		msg = msg + "Please enter a first name.\n"
	}
//
	if (document.all("cLName").value == ""){
		msg = msg + "Please enter a last name.\n"
	}
///
	if (document.all("cEmail").value != ""){
		if (validateEmail(document.all("cEmail").value) != true){
			msg = msg + validateEmail(document.all("cEmail").value)
		}
	}
	else{
		msg = msg + "Please enter an email address.\n"
	}
//
	if (document.all("cPassword").value != ""){
		if (document.all("cPassword").value.length != 8){
			msg = msg + "Your password must be 8 characters long.\n"
		}
	}
	else{
		msg = msg + "Please enter a password.\n"
	}
	if (document.all("cPassword2").value != ""){
		if (document.all("cPassword2").value.length != 8){
			msg = msg + "Your password verification must be 8 characters long.\n"
		}
		else if (document.all("cPassword2").value != document.all("cPassword").value){
			msg = msg + "Your password verification must match your password.\n"
		}
	}
	else{
		msg = msg + "Please verify your password.\n"
	}
//
	if (document.all("cQuestions").value == ""){
		msg = msg + "Please select a security question.\n"
	}
//
	if (document.all("cAnswer").value == ""){
		msg = msg + "Please enter a security answer.\n"
	}
	if (msg != ""){
		alert(msg);
	}
	else{
		Reg_Student.submit();
	}
}
//STUDENT LOGON VALIDATION	
function LogonStudentValidate(){
var msg = "";
	if (document.all("cStudentID").value != ""){
		if (validateEmail(document.all("cStudentID").value) != true){
			msg = msg + "Please enter a valid user ID.\n"
		}
	}
	else{
		msg = msg + "Please enter a user ID.\n"
	}
	if (document.all("cPassword").value != ""){
		if (document.all("cPassword").value.length != 8){
			msg = msg + "Your password must be 8 characters long.\n"
		}
	}
	else{
		msg = msg + "Please enter a password.\n"
	}
	if (msg != ""){
		alert(msg);
	}
	else{
		Logon_Student.submit();
	}
}
//Quantum ADMIN LOGON VALIDATION
function csiLogonValidate(){
var msg = "";
	if (document.all("User Name").value != ""){
		if (validateEmail(document.all("User Name").value) != true){
			msg = msg + validateEmail(document.all("User Name").value)
		}
	}
	else{
		msg = msg + "Please enter an email address.\n"
	}
	if (document.all("Password").value != ""){
		if (document.all("Password").value.length != 8){
			msg = msg + "Your password must be 8 characters long.\n"
		}
	}
	else{
		msg = msg + "Please enter a password.\n"
	}
	if (msg != ""){
		alert(msg);
	}
	else{
		Login.action = "c_admin_login_submit.asp";
		Login.submit();
	}
}
//MANAGER CHANGE PASSWORD FUNCTION
function mgrChangePass(){
var msg = "";
var changPass = confirm("Are you sure you want to reset your password?");
if (changPass){
	if (document.all("User Name").value != ""){
		if (validateEmail(document.all("User Name").value) != true){
			msg = msg + validateEmail(document.all("User Name").value)
		}
	}
	else{
		msg = msg + "Please enter your User ID.\n"
	}
	if (msg != ""){
		alert(msg);
	}
	else{
		Login.action = "change_password_submit.asp";
		Login.submit();
	}
}
}
//MASTER ADMIN VALIDATE
function masterLogonValidate(){
var msg = "";
	if (document.all("User Name").value != ""){

	}
	else{
		msg = msg + "Please enter a user name.\n"
	}
	if (document.all("Password").value != ""){
		if (document.all("Password").value.length != 8){
			msg = msg + "Your password must be 8 characters long.\n"
		}
	}
	else{
		msg = msg + "Please enter a password.\n"
	}
	if (msg != ""){
		alert(msg);
	}
	else{
		Login.submit();
	}
}
//ADD SECURITY QUESTION VALIDATION
function AddQValidate(){
var msg = "";
//
	if (document.all("cQuestions").value == ""){
		msg = msg + "Please select a security question.\n"
	}
//
	if (document.all("cAnswer").value == ""){
		msg = msg + "Please enter a security answer.\n"
	}
	if (msg != ""){
		alert(msg);
	}
	else{
		Add_Question.submit();
	}
}
//CHANGE PASSWORD VALIDATION
function changePassValidate(){
var msg = "";
	if (document.all("Student_ID").value != ""){
		if (validateEmail(document.all("Student_ID").value) != true){
			msg = msg + "Please enter a valid email address.\n"
		}
	}
	else{
		msg = msg + "Please enter an email address.\n"
	}
	if (msg != ""){
		alert(msg);
	}
	else{
		Change_Pass.submit();
	}
}
function changePass2Validate(){
var msg = "";
	if (document.all("cAnswer").value == ""){
		msg = msg + "Please answer the security question.\n"
	}
	if (msg != ""){
		alert(msg);
	}
	else{
		Change_Pass2.submit();
	}
}
function validateChangePass(){
var msg = "";
	if (document.all("User Name").value != ""){
		if (validateEmail(document.all("User Name").value) != true){
			msg = msg + "Please enter a valid User Name.\n"
		}
	}
	else{
		msg = msg + "Please enter a User Name.\n"
	}
	if (document.all("Old Password").value != ""){
		if (document.all("Old Password").value.length != 8){
			msg = msg + "Your password must be 8 characters long.\n"
		}
	}
	else{
		msg = msg + "Please enter a password.\n"
	}
	if (document.all("New Password").value != ""){
		if (document.all("New Password").value.length != 8){
			msg = msg + "Your new password must be 8 characters long.\n"
		}
	}
	else{
		msg = msg + "Please enter a new password.\n"
	}
	if (document.all("Confirm New Password").value != ""){
		if (document.all("Confirm New Password").value.length != 8){
			msg = msg + "Your new password confirmation must be 8 characters long.\n"
		}
	}
	else{
		msg = msg + "Please confirm your new password.\n"
	}
	if (document.all["New Password"].value != "" & document.all["Old Password"].value != "" & (document.all["New Password"].value == document.all["Old Password"].value)){
		msg = msg + "Your old password and new password cannot be the same.\n";
	}
	if (document.all["New Password"].value != "" & document.all["Confirm New Password"].value != "" & (document.all["New Password"].value != document.all["Confirm New Password"].value)){
		msg = msg + "Your new password and new password confirmation do not match.\n";
	}
if (msg != ""){
	alert(msg);
}
else{
	Login.submit();
}
}
//VALIDATE CHANGE Quantum PASSWORD
function valChangeCSIPass(){
var msg = "";
	if (document.all("User Name").value == ""){
		msg = msg + "Please enter a User Name.\n"
	}
	if (document.all("Old Password").value != ""){
		if (document.all("Old Password").value.length != 8){
			msg = msg + "Your password must be 8 characters long.\n"
		}
	}
	else{
		msg = msg + "Please enter a password.\n"
	}
	if (document.all("New Password").value != ""){
		if (document.all("New Password").value.length != 8){
			msg = msg + "Your new password must be 8 characters long.\n"
		}
	}
	else{
		msg = msg + "Please enter a new password.\n"
	}
	if (document.all("Confirm New Password").value != ""){
		if (document.all("Confirm New Password").value.length != 8){
			msg = msg + "Your new password confirmation must be 8 characters long.\n"
		}
	}
	else{
		msg = msg + "Please confirm your new password.\n"
	}
	if (document.all["New Password"].value != "" & document.all["Old Password"].value != "" & (document.all["New Password"].value == document.all["Old Password"].value)){
		msg = msg + "Your old password and new password cannot be the same.\n";
	}
	if (document.all["New Password"].value != "" & document.all["Confirm New Password"].value != "" & (document.all["New Password"].value != document.all["Confirm New Password"].value)){
		msg = msg + "Your new password and new password confirmation do not match.\n";
	}
if (msg != ""){
	alert(msg);
}
else{
	Login.submit();
}
}
//EMAIL VALIDATION
function validateEmail(email) {
            // Script prepared by Answer Studios / ToUnite.com
            // Version 1.1 (Feb. 1, 2001)
            // Logic:
            // 8 steps: Preset elements, 6 error checks, write error (if appicable)
            // --- Presets
            var count = 0;
            var error = "";
            // #1 Check if email address field is blank
                        if (email == "") {
                                    error = "";
                        }
            // #1 Check for invalid characters
            // Create an arroay of invalid characters
            if (error == "") {
            var invChars = new Array(" ", "#", "$", "%", "!", "^", "~", "'", "*", "(", ")", ",", "<", ">", "/", "\\","\r","\t");
            // Loop through Array and see if there are any matches, if yes then throw and error.
            for (var i = 0; i < invChars.length; i++) {
                        if (email.indexOf(invChars[i]) >= 0) {
                                    error = error + "Email address: Invalid character found.\n";
                        }
            }
            }
            // #2 If passed previous error step  >>> Check the @ symbol (1 instance of the symbol)
            if (error == "") {
                        // Loop by character through the email string for the @ symbol, count the number of instances
                        for (var i = 0; i < email.length; i++) {
                                    if (email.charAt(i) == "@") {
                                                count = count+1;
                                    }
                        }
                        // If there is not 1 instance (0 or more than 1) then throw an error.
                        if (count != 1) {
                                    error = error + "Email address: Missing the @ symbol.\n";
                        }
            }
            // Split the email string by the @ sign, forming the name portion and the domain portion.
            if (error == "") {
                        var splitEmail = email.split("@");
                        var emailName = splitEmail[0];
                        var emailDom = splitEmail[1];
                        // #3 Verify minimum characters in name portion (minimum of 1), if not throw an error.
                        if (emailName.length<1) {
                                    error = error + "Email address: Problem with the email name.\n";
                        }
                        // #4 Verify there is a . (dot) in the domain portion
                        if (emailDom.indexOf(".")<0) {
                                    error = error + "Email address: Missing the dot for the domain name.\n";
                        } else {
                                    // #5 Verify a minimum of 2 characters before the dot, if not throw an error.
                                    // First split the domain portion by the . (dot)
                                    var splitDom = emailDom.split(".");
                                    if (splitDom[0].length<2) {
                                                error = error + "Email address: Problem with the domain name or domain name missing.\n";
                                    }
                                    // #6 Verify a minimum of 2 characters after the dot, if not throw an error.
                                    if (splitDom[1].length<2) {
                                                error = error + "Email address: Invalid domain name extension (.com).\n";
                                    }
                        }
            }
            // Associate the error number into the message array for displaying results on the screen.
            if (error != ""){
              emailerror = error
            }
            else{
              emailerror = true
            }
            return emailerror
}
//LAUNCH COURSE FUNCTION
function startcourse(url,userID,appID,quizID){
		if (screen.width <= 800){
			strAtrLeft = "left=0"
			strAtrTop = "top=0"
			}
		else{
			strAtrLeft = "left=50"
			strAtrTop = "top=50"
		}
		strAttributes = "titlebar=yes, menubar=yes, toolbar=yes, location=yes, status=yes, resizable=yes, scrollbars=yes, " + strAtrLeft + ", " + strAtrTop + ", width=780, height=545"
		window.open(url + "?userID=" + userID + "&appID=" + appID + "&quizID=" + quizID,appID,strAttributes)
		//window.open(url + "?userID=" + userID + "&appID=" + appID + "&quizID=" + quizID,appID)
		
}
function launchWin(url){
		if (screen.width <= 800){
			strAtrLeft = "left=0"
			strAtrTop = "top=0"
			}
		else{
			strAtrLeft = "left=50"
			strAtrTop = "top=50"
		}
		strAttributes = "titlebar=yes, menubar=yes, toolbar=yes, scrollbars=yes, location=yes, status=yes, resizable=yes, " + strAtrLeft + ", " + strAtrTop + ", width=780, height=545"
		window.open(url,"ChalkTalk",strAttributes);
}

function launchChalk(url){
		if (screen.width <= 800){
			strAtrLeft = "left=0"
			strAtrTop = "top=0"
			}
		else{
			strAtrLeft = "left=50"
			strAtrTop = "top=50"
		}
		strAttributes = "titlebar=yes, menubar=yes, toolbar=yes, scrollbars=yes, location=yes, status=yes, resizable=yes, " + strAtrLeft + ", " + strAtrTop + ", width=780, height=545"
		window.open(url,"ChalkTalk",strAttributes);
}

function resetReg(url,w,h,winName){
var agree = confirm("Are you sure you want to reset/resend the registration?");
if (agree){
		if (screen.width <= 800){
			strAtrLeft = "left=0"
			strAtrTop = "top=0"
			}
		else{
			strAtrLeft = "left=50"
			strAtrTop = "top=50"
		}
		strAttributes = "titlebar=yes, menubar=no, toolbar=no, scrollbars=no, location=no, status=no, resizable=no, " + strAtrLeft + ", " + strAtrTop + ", width=" + w + ", height=" + h
		window.open(url,winName,strAttributes);
}
}
function paperTest(url,w,h,winName){
	if (screen.width <= 800){
		strAtrLeft = "left=0"
		strAtrTop = "top=0"
		}
	else{
		strAtrLeft = "left=50"
		strAtrTop = "top=50"
	}
	strAttributes = "titlebar=yes, menubar=yes, toolbar=no, scrollbars=yes, location=no, status=no, resizable=yes, " + strAtrLeft + ", " + strAtrTop + ", width=" + w + ", height=" + h
	window.open(url,winName,strAttributes);
}
function hideObject(){
	document.all("AllRecordsBut").style.display = "none"
}
function submitReport(url){
	SelectReport.action = url;
	SelectReport.submit();
}
function chooseCourseLic(url){
	var msg = ""
	if (document.all("cAddLicense").value != ""){
		for (i=0;i<document.all("cAddLicense").value.length;i++){
			if (isNaN(document.all("cAddLicense").value.charAt(i))){
				msg = msg + "The number of licenses must be a whole number.\n"
				break;
			}
		}
	}
	else{
		msg = msg + "Please enter the number of licenses you wish to add.\n"
	}
	if (msg != ""){
		alert(msg);
	}
	else{
		ClientLic.action = url;
		ClientLic.submit();
	}
}
function selectAllStudents(){
	for (i=0;i<document.all("StudentSelect").options.length;i++){
		document.all("StudentSelect").options[i].selected = true;
	}
	document.all("StudentsComplete").checked = false;
	document.all("StudentsInComplete").checked = false;
	document.all("LicensesExpired").checked = false;
}
function selectComplete(whichchecked){
	if (whichchecked == "StudentsComplete"){
		document.all("StudentsInComplete").checked = false;
		document.all("LicensesExpired").checked = false;
	}
	if (whichchecked == "StudentsInComplete"){
		document.all("StudentsComplete").checked = false;
		document.all("LicensesExpired").checked = false;
	}
	if (whichchecked == "LicensesExpired"){
		document.all("StudentsComplete").checked = false;
		document.all("StudentsInComplete").checked = false;
	}
	for (i=0;i<document.all("StudentSelect").options.length;i++){
		document.all("StudentSelect").options[i].selected = false;
	}
	document.all("AllStudents").checked = false;
}
function multiSelectStudents(){
	document.all("AllStudents").checked = false;
	document.all("StudentsComplete").checked = false;
	document.all("StudentsInComplete").checked = false;
	document.all("LicensesExpired").checked = false;
}
function validateUserSelect(url,formName){
	if (document.all("StudentSelect").value != ""){
		submitAny(url,formName);
	}
	else{
		alert("Please select a student.");
	}
}
//generic submit function
function submitAny(url,formName){
	eval(formName).action = url;
	eval(formName).submit();
}
function modifyQuiz(url,formName,mode){
	if (mode == "delete"){
		var confDel = confirm("Delete Question?");
		if (confDel){
			submitAny(url + "?mode=" + mode,formName)
		}
	}
	else if (mode == "updateQuiz"){
		var confUpdate = confirm("Update Quiz Data?");
		if (confUpdate){
			var msg = "";
			if (eval(formName)["quizName"].value == ""){
				msg = msg + "Please enter a quiz title.\n";
			}
			var radioObject = eval(formName)["chalkTalk"];
			var radioChecked = false;
			for (i=0;i<radioObject.length;i++){
				if (radioObject[i].checked == true){
					radioChecked = true;
					break;
				}
			}
			if (radioChecked == false){
				msg = msg + "Please select whether the quiz has a 'Chalk Talk'.\n";
			}
			if (eval(formName)["quizPath"].value == ""){
				msg = msg + "Please enter a quiz path.\n";
			}
			if (msg == ""){
				submitAny(url + "?mode=" + mode,formName)
			}
			else{
				alert(msg);
			}
		}
	}
	else{
		var confUpdate = confirm("Update Question Data?");
		if (confUpdate){
			var msg = "";
			if (eval(formName)["question"].value == ""){
				msg = msg + "Please enter a question.\n";
			}
			var i = 0;
			var emptyDist = false;
			while (eval(formName)["distractor"+i]){
				if(eval(formName)["distractor"+i].value == ""){
					emptyDist = true;
					msg = msg + "Please enter all distractors.\n";
					break;
				}
				i = i + 1;
			}
			if (eval(formName)["correct"]){
				var radioObject = eval(formName)["correct"];
				var radioChecked = false;
				for (i=0;i<radioObject.length;i++){
					if (radioObject[i].checked == true){
						radioChecked = true;
						break;
					}
				}
				if (radioChecked == false){
					msg = msg + "Please select a correct answer.\n";
				}
			}
			else{
				var boxChecked = false;
				i = 0;
				while (eval(formName)["correct"+i]){
					if(eval(formName)["correct"+i].checked == true){
						boxChecked = true;
						break;
					}
					i = i + 1;
				}
				if (!boxChecked){
					msg = msg + "Please select at least one correct answer.\n";
				}
			}
			if (msg == ""){
				submitAny(url,formName);
			}
			else{
				alert(msg);
			}
			//submitAny(url + "?mode=" + mode,formName)
		}
	}
}
//add quiz
function addQuiz(url,formName){
	var msg = "";
	if (document.all("quizTitle").value == ""){
		msg = msg + "Please enter an Exam Title.\n";
	}
	if (document.all("volNum").value != ""){
		for (i=0;i<document.all("volNum").value.length;i++){
			if (isNaN(document.all("volNum").value.charAt(i))){
				msg = msg + "The volume number must be a whole number.\n"
				break;
			}
		}
	}
	else{
		msg = msg + "Please enter the Quantum Exam Number.\n";
	}
	var radioObject = document.all("chalkTalk");
	var radioChecked = false;
	for (i=0;i<radioObject.length;i++){
		if (radioObject[i].checked == true){
			radioChecked = true;
			break;
		}
	}
	if (radioChecked == false){
			msg = msg + "Please select whether the quiz has a 'Chalk Talk'.\n";
	}
	if (document.all("quizPath").value == ""){
		msg = msg + "Please enter the path to the quiz launch page.\n";
	}
	if (msg == ""){
		submitAny(url,formName);
	}
	else{
		alert(msg);
	}
}
//add question
function addQuestion(url,formName){
	var agree = confirm("Add Question?");
	if (agree) {
		var msg = "";
		if (document.all("addQ").value == ""){
			msg = msg + "Please enter an question.\n";
		}
		if (document.all("numDistractors").value != ""){
			for (i=0;i<document.all("numDistractors").value.length;i++){
				if (isNaN(document.all("numDistractors").value.charAt(i))){
					msg = msg + "The number of distractors must be a whole number.\n"
					break;
				}
			}
		}
		else{
			msg = msg + "Please enter the number of distractors.\n";
		}
		var radioObject = document.all("addType");
		var radioChecked = false;
		for (i=0;i<radioObject.length;i++){
			if (radioObject[i].checked == true){
				radioChecked = true;
				break;
			}
		}
		if (radioChecked == false){
			msg = msg + "Please choose a question type.\n";
		}
		if (msg == ""){
			submitAny(url,formName);
		}
		else{
			alert(msg);
		}
	}
}
//show hide questions on modify page
function showQuestion(tblObj){
	if (eval("q"+tblObj).style.display == "none"){
		eval("q"+tblObj).style.display = "inline";
		document.all("expandImg"+tblObj).src = "../images/minus.gif";
	}
	else{
		eval("q"+tblObj).style.display = "none";
		document.all("expandImg"+tblObj).src = "../images/plus.gif";
	}
}
//change user data submit function
function changeUserData(url,formName,change){
	if (change == "PW"){
		var agree=confirm("Reset User Password?");
	}
	else{
		var agree=confirm("Change User Status?");
	}
	if (agree){
		submitAny(url + "?change=" + change,formName);
	}
	else{
		
	}
}
function validateSelectReport(url){
if (document.all("StudentsComplete").checked != true && document.all("StudentsInComplete").checked != true && document.all("StudentSelect").value == "" && document.all("AllStudents").checked != true && document.all("LicensesExpired").checked != true){
	alert("Please select a report to run.");
}
else{
	submitReport(url);
}
}
//MASTER ADMIN DELETE REGISTRATIONS
function delRegKey(ID,formName){
	var agree=confirm("Delete Registration?");
	if (agree){
		eval(formName).action = "delReg_submit.asp?recID=" + ID;
		eval(formName).submit();
	}
}
//LOGOUT FUNCTION
function logOut(url){
var agree=confirm("Logoff?");
	if (agree){
		window.location.href = "../includes/logout.asp?url=" + url
	}
	else{
		
	}
}
//select all emails for email client page
function selectAllEmails(){
	var ckdCount = 0;
	if (switchDom(this,"AllEmails").checked == true){
		this.ckdArray = new Array();
		for (i=0;i<switchDom(this,"ChooseClient").options.length;i++){
			if (switchDom(this,"ChooseClient").options[i].value != "" && switchDom(this,"ChooseClient").options[i].selected != true){
				switchDom(this,"ChooseClient").options[i].selected = true;
				this.ckdArray[ckdCount] = i;
				ckdCount = ckdCount + 1;
			}
		}
	}
	else{
		for (j=0;j<this.ckdArray.length;j++){
			switchDom(this,"ChooseClient").options[this.ckdArray[j]].selected = false;
		}
	}
}
//add emails to the to field for email client page
function AddEmailsTo(){
	var emailArray = "";
	var emailCount = 1;
	for (i=0;i<switchDom(this,"ChooseClient").options.length;i++){
		if (switchDom(this,"ChooseClient").options[i].selected == true){
			if (emailCount == 1){
				emailArray = emailArray + switchDom(this,"ChooseClient").options[i].value;
			}
			else{
				emailArray = emailArray + ";" + switchDom(this,"ChooseClient").options[i].value;
			}
		emailCount = emailCount + 1;
		}
	}
	switchDom(this,"EmailTo").value = emailArray;
}
//add email addresses to email using mailto:
function newMail(emails,msgBody,msgSub){
	var duplicate = emails.split(";");
	var pointer;
	var validEmail = "The following email addresses are invalid:\n\n";
	var vE = true;
	var dupeEmail = "You have entered duplicate email addresses in the 'To:' box:\n\n";
	var dE = true;
	var msg = "";
	if (emails != ""){
		for (var i=0;i<duplicate.length;i++){
			pointer = duplicate[i];
			if (msg != ""){
				break;
			}
			if (validateEmail(pointer) != true){
				msg = msg + "Please check your email addresses for validity\nand make sure there are no carriage returns."
				break;
			}
			for (var j=0;j<duplicate.length;j++){
				if (j != i){
					if (pointer == duplicate[j]){
						msg = msg + "Please check for duplicate email addresses.\n"
						break;
					}
				}
			}
		}
	}
	else if (emails == ""){
		msg = msg + "Please enter email addresses.\n"
	}
	if (msgBody == ""){
		msg = msg + "Please enter the message.\n"
	}
	if (msgSub == ""){
		msg = msg + "Please enter the subject.\n"
	}
	if (msg != ""){
		alert(msg);
	}
	else{
		//alert(emails);
		var agree=confirm("Send Email?");
		if (agree){
			EmailClient.submit();
			//window.open("mailto:" + emails);
		}
		else{
		
		}
	}
}
//function to switch the dom object between NS and IE
function switchDom(loc,objName){
	if (navigator.userAgent.toUpperCase().indexOf("NETSCAPE") != -1){
		return eval(loc).document.getElementById(objName);
	}
	else if (navigator.userAgent.toUpperCase().indexOf("MSIE") != -1){
		return eval(loc).document.all(objName);
	}
	else{
		return eval(loc).document.all(objName);
	}
}