/*	global.jsCreated for:	Oregon Graduate Institute (OGI)Created by:		ISITE Design, Inc. (ISITE)*/function bCheck() {	var browser;		if (document.all) { 	  browser = "IE";   							} else if (document.layers) {	 	browser = "NS4";	} else if (document.getElementById) {	  	browser = "NS6"; 	} 		return browser;}function showHide(anItem) {			browser = bCheck();		if (browser == "IE") {				if (document.all[anItem].style.display == 'none') {			document.all[anItem].style.display = 'block';		}		else {			document.all[anItem].style.display = 'none';		}	}		if (browser == "NS4") {				if (document.layers[anItem].style.display == 'none') {			document.layers[anItem].style.display = 'block';		}		else {			document.layers[anItem].style.display = 'none';		}	}		if (browser == "NS6") {		if (document.getElementById(anItem).style.display == 'none') {			document.getElementById(anItem).style.display = 'block';		}		else {			document.getElementById(anItem).style.display = 'none';		}	}		}function setFocus(anItem) {	browser = bCheck();		if (browser == "IE") {		//	anItem.focus();		//	anItem.select();		document[anItem].focus()			}		if (browser == "NS4") {		document.layers[anItem].focus();		document.layers[anItem].select();	}		if (browser == "NS6") {		document.getElementById(anItem).focus();		document.getElementById(anItem).select();	}}	// Main validation function.// Variables needed: form name// All validation functions will be called from// this function// The actual validation functions will be outside// of this function, either above or below it// If any of the variables used in these functions// are ColdFusion variables, the functions must be// within CFOUTPUT tagsfunction ExtendJS(FormName) {  // Call the function to validate a date as being  // before today's date.  // Variables to pass: form name, field name,  // type  // The type parameter will have a value of  // either 'date' or 'eurodate'  if (!DateLessThan(FormName,'DOB','date')) {    alert("Your DOB cannot be after today.");    return false;  }  // Call the RadioCheckBox function to  // ensure one of a radio button series is  // checked  // Variables to pass: form name, field name,  // number of items total, min required, max  // required  // * For radio fields, min and max will be 1  // * The number of items total will most likely  // be the RecordCount of the query used to  // generate the options.  if (!RadioCheckBox(FormName,'Sex',2,1,1))  {    alert("You must select your sex.");    return false;  }  // Call the RadioCheckBox function to  // ensure one (or more) of a checkbox series is  // checked  // Variables to pass: form name, field name,  // number of items total, min required, max  // required  // * The number of items total will most likely  // be the RecordCount of the query used to  // generate the options.  if   (!RadioCheckBox(FormName,'Hobbies',4,2,3))  {    alert("You must select 2 or 3 hobbies.");    return false;  }  // Call the SingleSelectRequired function to  // ensure an item in a select box is chosen  // Variables to pass: form name, field name  if (!SingleSelectRequired(FormName,'Version')) {    alert("You must a version of CF.");    return false;  }  // Call the MultiSelectCheck function to ensure  // one (or more) items in multi-select box are  // chosen  // Variables to pass: form name, field name  if (!MultiSelectCheck(FormName,'FavTags',2,6)) {    alert("You must at least 2 tags.");    return false;  }  // Call the TextAreaRequired function to ensure  // a textbox field is filled out  // Variables to pass: form name, field name  if (!TextAreaRequired(FormName, 'Comments')) {    alert("You must enter some comments.");  return false;  }}// Validation functions// Function to ensure a text area field is filled// out.// Variables needed: form name, field namefunction TextAreaRequired(Form,Field) {  // determine the length of the value of the  // field.  // The eval function will evaluate the statement  // inside the parenthesis.  var length = eval("document." + Form + "." + Field    + ".value.length");  // If the length of the value of the field is 0,  // return false.  if (length == 0) {    return false;  } else {    return true;  }}// Function to validate the number of items// selected in a multi-select box// Variables needed: form name, field name,// minimum items selected,// maximum items selectedfunction MultiSelectCheck(Form,Field,minReq,maxReq){  // Set the selected var to a default of 0.  var selected = 0;  // Determine how many options are in the  // multi-select box  var length = eval("document." + Form + "." + Field    + ".length");  // Loop through the items in the multi-select  //box  for (i=0; i<length; i++) {    // If an item is selected, increment the    // selected var by one    if (eval("document." + Form + "." + Field + "["      + i + "].selected")) {      selected++;    }  }  // Determine if the number of items selected is  // between the max and min values.  // Return false if not, true if so  if (selected < minReq || selected > maxReq) {    return false;  } else {    return true;  }}// Function to ensure that a value in a select box// is selected// Variables needed: form name, field namefunction SingleSelectRequired(Form,Field) {  // Determine the index of the item currently  // selected  var itemSelected = eval("document." + Form + "." +    Field + ".selectedIndex");  // If that index is 0, return false  if (itemSelected == 0) {    return false;  } else {    return true;  }}// Function to validate radio and check boxes// For radio, ensures that one radio button in a// series is selected// For checkbox, ensures that the number selected// is in the min and under the max// Variables needed: form name, field name, number// of items total, minimum items checked, maximum// items checked// For radio buttons, the min and max will always// be 1function  RadioCheckBox(Form,Field,length,minReq,maxReq){  // Set the checked var to a default value of 0  var checked = 0;  // Loop through the number of items  for (i=0; i<length; i++) {    // If an item is checked, increment the    // checked var    if (eval("document." + Form + "." + Field + "["      + i + "].checked")) {      checked++;    }  }  // If the checked var is between the min and  // max, return true, otherwise, false  if (checked < minReq || checked > maxReq) {    return false;  } else {    return true;  }}// Function to validate a date so that the date// entered must be less than today// Variables needed: form name, field name// Don't you wish JavaScript had a DateCompare// function?function DateLessThan(Form,Field,type) {  // Create a var called today with a value of  // today's date  var today = new Date();  // Get the time in milliseconds from the current  // date  var todayMS = today.getTime();  // Get the date value of the form field (this  // has already been validated as a valid date by  // CF's form validation'  var dateValue = eval("document." + Form + "." +    Field + ".value");  // Split the date to create an array  var dateSplit = dateValue.split("/");  // If the type is 'date', set the month to the  // first value in the array  // Subtract 1 from the date because JavaScript  // uses 0-11 to represent months  // Set the day of the month to the second value  // in the array  if (type == 'date') {    var month = dateSplit[0] - 1;    var day = dateSplit[1];  }  // If the type is 'eurodate', set the month to  // the second value in the array  // Subtract 1 from the date because JavaScript  // uses 0-11 to represent months  // Set the day of the month to the first value  // in the array  if (type == 'eurodate') {    var month = dateSplit[1] - 1;    var day = dateSplit[0];  }  // Set the year to the third value in the array  var year = dateSplit[2];  // Create a new date object variable to hold the  // date, passing in the month, day and year  var dateEntered = new Date(year,month,day,0,0,0);  // Get the milliseconds from this date  var dateEnteredMS = dateEntered.getTime();  // Compare the milliseconds from the current  // date with those of the date entered.  // Return false if the date entered is greater  // than today's date  if (dateEnteredMS > todayMS) {    return false;  } else {    return true;  }}