// General Utilities JavaScript v1.4.7 
// --------------------------------------------------------------------------------------------
// This file contains various functions and methods called by topic pages in the WBT Framework.
// --------------------------------------------------------------------------------------------
// Functions include:
// --------------------------------------------------------------------------------------------
// OpenPopupWindow - used to open popup windows
//
// OpenPopupWindow2 - used to open popup windows - legacy
//
// ClosePopupWindow - used to close popup windows
// 					- uses onunload and onfocus events to initiate
//
// commonUtilities  - used to create readable statusbar from topic page elements
// 					- contains learning check page 'sniffer' that runs CourseBuilder specific code
// 					- contains automatic title tag creator
// 					- uses onload event to initiate
// 					- contains section 508 features for learning check pages
//
// addScriptElement - adds a script element to the document
//
// --------------------------------------------------------------------------------------------
// Popup Window Methods
// --------------------------------------------------------------------------------------------
/* The OpenPopupWindow function opens a secondary browser window to display additional information, displaying the URL file and the windowfeatures passed to the function
View with tabs set to 4
*/

popupWindow = null;	// Init popupWindow in the global namespace

function OpenPopupWindow(URL, windowFeatures)
{
	var popupWindowDate = new Date();	// Create a temporary date object
	popupWindowTime = popupWindowDate.getTime();	// Get the current date/time in milliseconds and save it in the global namespace
	popupWindow = window.open(URL,"PopupWindow",windowFeatures);	// Save the popup window reference
	popupWindow.focus();	// Focus the window
}

function OpenPopupWindow2(URL, windowName, windowFeatures)
{
	var popupWindowDate = new Date();
	popupWindowTime = popupWindowDate.getTime();
	popupWindow = window.open(URL,"PopupWindow",windowFeatures);
	popupWindow.focus(); 	
}

function ClosePopupWindow()
{
/*
Description: A function to close a popup window that is open.  Called from the learning check pages when the content window receives focus.  Also called when learning check pages unload.
*/	
	if (popupWindow != null)	// Is there a window?
	{
		var popupWindowDate = new Date();	// If there is, create a temporary date object
		if (popupWindowDate.getTime() <  popupWindowTime  + 1000)	// Get the current date/time and compare it to when the popup was called plus an offset to 
		{															// take care of any double clicks
			// If they did double click, the main window now has focus and won't close the popup the next time the learner clicks.  
			// By calling setTimeout to refocus popupWindow the learner, once again, has the opportunity to click the main window to close the popup
			window.setTimeout("popupWindow.focus()", 200);	
		}
		else
		{
			if (!popupWindow.closed)	// If there is a popup window, there wasn't a double click and the window is still open
			{
				popupWindow.close();	// Let's close it
				popupWindow = null;		// Reset the reference to null
				popupWindowTime = null;	// And reset the popupWindowTime reference to null.
			}
		}		
	}
}

// --------------------------------------------------------------------------------------------
// commonUtilities v1.1                                                             - [mg] 2006
// --------------------------------------------------------------------------------------------
// The following code prevents Pop-up Layers, Image Swaps, Clickable Lists hyperlinks from jumping 
// to the top of the page and prevents incomprehensible text from showing in the status bar.

// create Arrays to hold Anchor tag information
var omoSwap = new Array();
var omoPath = new Array();
var popupPath = new Array();
var popupOldPath = new Array();
var subtopicPath = new Array();
var swapPath = new Array();
var filenamePath = new Array();
var popuplayerPath = new Array();
var openWindowPath = new Array();
var areaPath = new Array();
var preloadArray = new Array();


// learning check flag
var isLCpage = false;

// Initialize Rollover glossary check variable
var isRG = false;

// Initialize Rollover glossary check variable
var isBehavior = false;

// Image Swap flag
var isIS = false;


// simple browser sniffer			
if (navigator.userAgent.indexOf("Gecko") != -1) {
  var moz = true;
} else if (navigator.userAgent.indexOf("MSIE") != -1) { 
  var msie = true;
}//else if  


function activateObj(obj){	// function to work around the Microsoft ActiveX Activation issue
	document.write(obj);
}


function commonUtilities() {  //function that is called from an onLoad event

// ------------------------------------
//Create a title tag for all images for Netscape and Mozilla - mg 2005
	if (moz) {
		var m = document.getElementsByTagName('img')
		for (var jj = 0; jj < m.length; jj++) {
			n = m[jj];
			if ((n.alt != null) || (n.alt != "")) { //if ALT text exists
				if ((n.title == null) || (n.title == "")) { //if there is no TITLE text
					n.title = n.alt; //set title text to that of alt text
				}//IF	
			}//IF
		}//FOR
	}//IF (MOZ)
	
// ------------------------------------

		var z = window.document.links;
		for (var j = 0; j < z.length; j++) {
			var w = z[j];
			w.id = j; // create id's
			
			// stop anchor from jumping
			if (w.href.substring(w.href.length - 1) == "#") { // find all hashes
				w.href = "javascript:;"; 
			} 
			
			// Conditions for Unique Anchors and HyperLinks
			// #top anchor
			if (w.href.toLowerCase().substring(w.href.length - 4) == "#top") { 
				if (msie) { 
					w.attachEvent('onmouseover',function topStatus(e){window.status='To the top of the page'; return true;});
					//w.setAttribute('onmouseover',function topStatus(){window.status='To the top of the page'; return true;});
					w.attachEvent('onmouseout',function topStatus2(){window.status=''; return true;});
					//w.setAttribute('onmouseout',function topStatus2(){window.status=''; return true;}); 
				} else if (moz) {  
					w.setAttribute("onMouseOver", "window.status='To the top of the page'; return true;");
					w.setAttribute("onMouseOut", "window.status='';return true;");
				}
			}// else if
			
			// Splash Page Only
			else if ((window.location.toString().toLowerCase().indexOf("default.htm") > -1) && (w.innerHTML.toLowerCase().indexOf("help") == -1) && (w.href.toLowerCase().indexOf("macromedia") == -1) && (w.href.toLowerCase().indexOf("windows") == -1) && (w.href.toLowerCase().indexOf("adobe") == -1) && (w.innerHTML.toLowerCase().indexOf("legal") == -1) && (w.href.toLowerCase().indexOf("tp://") == -1)) { //case-insensitive search for splash page

				var openWindowArray = w.innerHTML.toString().split("alt=\""); // get split of string
				var openWindowedArray = openWindowArray[1].toString().split("\""); //get split of string
				openWindowPath[j] = openWindowedArray[0]; //send to openWindowPath array
				if (msie) {
					w.attachEvent('onmouseover', function anonymous4000(e){window.status=openWindowPath[e.srcElement.parentElement.id]; return true;});
					//w.setAttribute('onmouseover',function anonymous4000(){window.status=openWindowPath[this.id]; return true;});
					w.attachEvent('onmouseout',function anonymous5000(e){window.status=''; return true;});
					//w.setAttribute('onmouseout',function anonymous5000(){window.status=''; return true;}); 
				} else if (moz) { 
					w.setAttribute('onmouseover',"window.status=openWindowPath[this.id]; return true");
					w.setAttribute('onmouseout',"window.status=''; return true");  
				} //else

			}// else if			
		
			//Subtopic anchor and image maps
			else if ((w.href.indexOf("#") > -1) && (w.href.substring(w.href.length - 1) != "#") && (w.href.toLowerCase().indexOf("tp://") == -1)) { //exclude any internet links as well
			
				subtopicPath[j] = w.innerHTML;
				if (msie) { 
					w.attachEvent('onmouseover',function topStatus(e){window.status=subtopicPath[e.srcElement.id]; return true;});
					//w.setAttribute('onmouseover',function topStatus(){window.status=subtopicPath[this.id]; return true;});
					w.attachEvent('onmouseout',function topStatus2(){window.status=''; return true;});
					//w.setAttribute('onmouseout',function topStatus2(){window.status=''; return true;});
				} else if (moz) { 
					w.setAttribute("onmouseover", "window.status=subtopicPath[this.id]; return true;");
					w.setAttribute("onmouseout", "window.status=''; return true");
				}
					
			}//else if
			// =========================================================			
			// Image Swap anchor using onClick event
			// =========================================================
			else if(w.getAttribute("onclick") != undefined) {
				var omo = w.getAttribute("onclick").toString(); // get onClick content
			if(omo.indexOf("MM_swapImage") != -1) {
			    	// find the MM_swapImage behavior and strip out image path
				  var str = omo.split("MM_swapImage('")[1].split(",")[2].split("'")[1].toString();
				  // add str to preloadArray
				  preloadArray.push("'"+str+"'");
				  isIS = true;

				  swapPath[j] = w.innerHTML;
					if (w.innerHTML.toLowerCase().indexOf("img") == -1) { // not an image
					if (msie) { 
						w.attachEvent('onmouseover',function anonymousA(e){window.status=swapPath[e.srcElement.id]; return true;});
						//w.setAttribute('onmouseover',function anonymousA(){window.status=swapPath[this.id]; return true;});
						w.attachEvent('onmouseout',function anonymousB(){window.status=''; return true;});
						//w.setAttribute('onmouseout',function anonymousB(){window.status=''; return true;}); 				
					} else if (moz) {
						w.setAttribute('onmouseover',"window.status=swapPath[this.id]; return true"); 
						w.setAttribute("onmouseout", "window.status=''; return true");										
					} //else if
				} else { // is an image
					if (msie) { 
						w.attachEvent('onmouseover',function anonymousC(e){window.status=''; return true;});
						//w.setAttribute('onmouseover',function anonymousC(){window.status=''; return true;});
						w.attachEvent('onmouseout',function anonymousD(){window.status=''; return true;});
						//w.setAttribute('onmouseout',function anonymousD(){window.status=''; return true;}); 
											
					} else if (moz) {
						w.setAttribute('onmouseover',"window.status=''; return true"); 
						w.setAttribute("onmouseout", "window.status=''; return true");										
					} //else if
				} // if innerHTML		
				  				  
				  
				}
			}
			
			// PopupWindow anchor
			else if (w.href.toLowerCase().indexOf("openpopupwindow") > -1) { //case-insensitive search
			
				var popupArray = w.href.toString().split("'"); // get split of string
				popupPath[j] = popupArray[1]; //send to popupPath array					
				if (msie) { 
					w.attachEvent('onmouseover',function anonymous4(e){window.status=popupPath[e.srcElement.id]; return true;});
					//w.setAttribute('onmouseover',function anonymous4(){window.status=popupPath[this.id]; return true;});
					w.attachEvent('onmouseout',function anonymous5(){window.status=''; return true;});
					//w.setAttribute('onmouseout',function anonymous5(){window.status=''; return true;}); 
				} else if (moz) { 
					w.setAttribute('onmouseover',"window.status=popupPath[this.id]; return true");
					w.setAttribute('onmouseout',"window.status=''; return true");  
				} //else
			}// else if
			
			// Deprecated PopupWindow anchor
			else if (w.href.toLowerCase().indexOf("window.open") > -1) { //case-insensitive search for window.open
			
				var popupOldArray = w.href.toString().split("'"); // get split of string
				var popupOlderArray = popupOldArray[1].toString().split("/"); // split at forward slash
				popupOldPath[j] = popupOlderArray[popupOlderArray.length - 1]; //send to popupPath array					
				if (msie) {
					w.attachEvent('onmouseover',function anonymous40(e){window.status=popupOldPath[e.srcElement.id]; return true;});
					//w.setAttribute('onmouseover',function anonymous40(){window.status=popupOldPath[this.id]; return true;});
					w.attachEvent('onmouseout',function anonymous50(){window.status=''; return true;});
					//w.setAttribute('onmouseout',function anonymous50(){window.status=''; return true;}); 
				} else if (moz) { 
					w.setAttribute('onmouseover',"window.status=popupOldPath[this.id]; return true");
					w.setAttribute('onmouseout',"window.status=''; return true");  
				} //else
			}// else if
						
			// Files PDF, EXE etc
			else if (w.href.toLowerCase().indexOf("file:/") > -1) { //case-insensitive search for window.open
				var filenameArray = w.href.toString().split("/"); // get split of string
				filenamePath[j] = filenameArray[filenameArray.length - 1]; //send to popupPath array					
				if (msie) { 
					w.attachEvent('onmouseover',function anonymous400(e){window.status=filenamePath[e.srcElement.id]; return true;});
					//w.setAttribute('onmouseover',function anonymous400(){window.status=filenamePath[this.id]; return true;});
					w.attachEvent('onmouseout',function anonymous500(){window.status=''; return true;});
					//w.setAttribute('onmouseout',function anonymous500(){window.status=''; return true;}); 
				} else if (moz) { 
					w.setAttribute('onmouseover',"window.status=filenamePath[this.id]; return true");
					w.setAttribute('onmouseout',"window.status=''; return true");  
				} //else
			}// else if
			
			//PopupLayer, Clickable List and Image swap
			else if (w.onclick != null) {
				// Initialize Behavior check variable
				isBehavior = true;
				popuplayerPath[j] = w.innerHTML;
				if (w.innerHTML.toLowerCase().indexOf("img") == -1) { // not an image
					if (msie) { 
						w.attachEvent('onmouseover',function anonymous6(e){window.status=popuplayerPath[e.srcElement.id]; return true;});
						//w.setAttribute('onmouseover',function anonymous6(){window.status=popuplayerPath[this.id]; return true;});
						w.attachEvent('onmouseout',function anonymous7(){window.status=''; return true;});
						//w.setAttribute('onmouseout',function anonymous7(){window.status=''; return true;}); 					
					} else if (moz) {
						w.setAttribute('onmouseover',"window.status=popuplayerPath[this.id]; return true"); 
						w.setAttribute("onmouseout", "window.status=''; return true");										
					} //else if
				} else { // is an image
					if (msie) { 
						w.attachEvent('onmouseover',function anonymous8(){window.status=''; return true;});
						//w.setAttribute('onmouseover',function anonymous8(){window.status=''; return true;});
						w.attachEvent('onmouseout',function anonymous9(){window.status=''; return true;});
						//w.setAttribute('onmouseout',function anonymous9(){window.status=''; return true;}); 
											
					} else if (moz) {
						w.setAttribute('onmouseover',"window.status=''; return true"); 
						w.setAttribute("onmouseout", "window.status=''; return true");										
					} //else if
				}													
			} //else if
		}//for mg
		
		//Image Maps
		if ( window.document.getElementsByTagName("area") != undefined ) {
			var y = window.document.getElementsByTagName("area");
			var imglist = document.getElementsByTagName("img"); // get all image objects on page
			
			// ------------------------------------
			// In Mozilla/Netscape set the title text the same as the title text if image map has any
			if (moz) {					
						for (var jjj = 0; jjj < y.length; jjj++) {
						t = y[jjj];
							if ((t.alt != null) || (t.alt != "")) { //if ALT text exists
								if ((t.title == null) || (t.title == "")) { //if there is no TITLE text
									t.title = t.alt; //set title text to that of alt text									
								}//IF	
							}//IF
						}//FOR
			}
			// ------------------------------------
			
			for (var i = 0; i < y.length; i++) {
				var v = y[i];
				v.id = i; // create id's for area				
				areaPath[i] = v.alt; // use image map's alt text for window.status				
			    var imgmap = v.parentNode.getAttribute("name"); // get name of image map
			    
				var mouver = v.getAttribute("onmouseover"); // get onmouseover event code
				if (mouver != null) { 
				
				if (msie) {
					// IE does not show statusbar with Image map					
				  if (mouver.toString().indexOf("rollover") != -1) { // Search for "rollver"
				        // remove alt & title text
				        // search all the image objects 
						// and find image to which the current map belongs to
				        // and clear the alt & title text.
				        for(var j = 0; j < imglist.length ; j++) { 					      
							if(imglist[j].getAttribute("usemap").substring(1) == imgmap) { 
					        	imglist[j].setAttribute("alt","");
             				    imglist[j].setAttribute("title","");
    	                	}
						} // for
				  } 
					
				} else if (moz) {					
				    if(mouver.indexOf("rollover") != -1) {  // Search for "rollver" glossary deprecated
				          // remove alt & title text
				          // search all the image objects and find image to which the current map belongs to
				          // and clear the alt & title text.
				    	for(var j = 0; j < imglist.length ; j++) {
					    
					 		if(imglist[j].getAttribute("usemap").substring(1) == imgmap) {
					 			imglist[j].setAttribute("alt","");
             					imglist[j].setAttribute("title","");
                        	} // if
						} // for
					} 
				} // else if (moz)
				} // if mouver
				
				// onClick
				var mouClick = v.getAttribute("onclick"); // get onmouseover event code
				if (mouClick != null) { 
					if (msie) {
						// IE needs timeout function 'setStatus' to show statusbar with Image maps
						v.attachEvent("onmouseover",function anonymousAreaF(e){setStatus(areaPath[e.srcElement.id]); return true});
						//v.setAttribute("onmouseover",function anonymousAreaF(){setStatus(areaPath[this.id]); return true});						
						v.attachEvent('onmouseout',function anonymousAreaG(){window.status=''; return true;});
						//v.setAttribute('onmouseout',function anonymousAreaG(){window.status=''; return true;});
					} else if (moz) {
						v.setAttribute("onmouseover","window.status=areaPath[this.id]; return true"); 
						v.setAttribute("onmouseout", "window.status=''; return true");
					}
				
				
				} // if mouClick
				
			} //for
		} //if

	// ------------------------------------
	// Learning Check Function calls 
	// ------------------------------------
	var scripty = window.document.getElementsByTagName('script'); 
 	//for loop to scan each script tag
 	for ( var iii = 0 ; iii < scripty.length ; ++iii ) {
  		//obtain the values of the src attribute of the script tag
  		var scriptySrc = scripty[iii].src.toString();  	
 		//locate the script tag that links to the behCourseBuilder.js
 		if ( scriptySrc.indexOf('behCourseBuilder.js') != -1 )  {
 	 		// call the coursebuilder initiate function
			MM_initInteractions();
			// flag topic page as LC page;
			isLCpage = true;
  		} //if
		//locate the script tag that links to the colorDetector.js
 		if ( scriptySrc.indexOf('colorDetector.js') != -1 )  {
 	 		// call the coloring function
			setColorings();		 		
  		} //if	
	} //for mg

	// -----------------------------------------------------------------------------------
	// Append Section 508 Accessibility feature to Radio Button and Text Input - [mg] 2006
	// -----------------------------------------------------------------------------------
	if (isLCpage) {		
		// get forms on page - array
		var aforms = document.getElementsByTagName("form");
		// for loop to obtain form tags
		for (var ttt = 0; ttt<aforms.length; ttt++) {			
			// validate that form is a choice form			
			// sort forms for name with Choices only			
			if (aforms[ttt].name.toLowerCase().indexOf('choices') != -1) {
				// get input tags from form elements
				var ainputs = aforms[ttt].elements;
				// check for existence of RADIO button
				if ((ainputs[0].name) && (ainputs[0].name.toLowerCase().indexOf('radioinp') != -1)) {
					// get labels inside form
					var alabel = aforms[ttt].getElementsByTagName("label");
					// run FOR loop to append input name to label for tag
					for (var sss=0; sss<ainputs.length; sss++) {
						// append an id to the INPUT tag
						ainputs[sss].id = ainputs[sss].name + sss;
						//append input name to LABEL FOR tag
						alabel[sss].htmlFor = ainputs[sss].id;
					} //for					
				} //if - check for entry text inputs and append label and id		
			} else if (aforms[ttt].name.toLowerCase().indexOf('elem') != -1) {
				// check for input entry
				// get input tags from form elements
				var ainputs = aforms[ttt].elements;
				// get labels inside form
				var alabel = aforms[ttt].getElementsByTagName("label");
				// for loop to locate input element from form tag
				for (var sss=0; sss<ainputs.length; sss++) {
					// condition to locate text type input tag
					if ((ainputs[sss].name) && (ainputs[sss].name.toLowerCase().indexOf('eleminp') != -1)) {
						// append an id to the INPUT tag
						ainputs[sss].id = ainputs[sss].name + sss;
						//append input name to LABEL FOR tag
						alabel.htmlFor = ainputs[sss].id;
					} //if
				} //for
			} //if	
		} //for
	} //if 

// ------------------------------------------------------------------------
// Glossary RollOver anchor	
// ------------------------------------------------------------------------
// Get all the links on the page
var atags = document.getElementsByTagName("a");

// For each link with the style 'glossary' apply the href="javascript: void(0);" and
// the onclick, onmouseover and mouseout behaviors.
for(var i=0;i<atags.length;i++) {
 
 // if glossary class present
 if(atags[i].className == "glossary") {
 // if href attribute not present add it and make it an empty link.
 if(atags[i].href == "") {

   // Apply href attribute
   atags[i].setAttribute("href","javascript: void(0);");
   
   // Rollover glosssary items were found on the page
   isRG = true;
   
   // If Mozilla browser
   if(moz) {
     // Apply onclick attribute
     atags[i].setAttribute("onclick","MainGlossary('" + atags[i].id + "');");
     // Apply onmouseover attribute
     atags[i].setAttribute("onmouseover","rollover('glossaryLayer',showglossary('" + atags[i].id + "')); return true;");
     // Apply onmouseout attribute
     atags[i].setAttribute("onmouseout","rollout('glossaryLayer')");
   } // end if
   // else if MS Internet Explorer
   else if(msie) {
     // Apply onclick attribute
     atags[i].attachEvent("onclick",function anonymous(e) { MainGlossary(e.srcElement.id);});
	 //atags[i].setAttribute("onclick",function anonymous() { MainGlossary(this.id);});
     // Apply onmouseover attribute
     atags[i].attachEvent("onmouseover",function anonymous(e) { rollover('glossaryLayer',showglossary(e.srcElement.id )); return true;});
	 //atags[i].setAttribute("onmouseover",function anonymous() { rollover('glossaryLayer',showglossary(this.id )); return true;});
     // Apply onmouseout attribute
     atags[i].attachEvent("onmouseout",function anonymous() { rollout('glossaryLayer');});
	 //atags[i].setAttribute("onmouseout",function anonymous() { rollout('glossaryLayer');});
   } // else if
 } // end if
 } // end if
} // end for loop

// If Rollover glosssary items were found on the page
if(isRG == true) {
  // Get the body element
  var dBody = document.body;
  // Create a new div element
  var newChild = document.createElement("div");
  // Set the id of the new div element
  newChild.setAttribute("id","glossaryLayer");
  // Set the class of the new div element
  newChild.setAttribute("class","glossary");
  
  // Append new div element to the body
  dBody.appendChild(newChild);
  
  // Add rolloverglossary.js script to the document
  var link = true;
  var language = "JavaScript";
  var type = "text/javascript";
  var src = spath[0] + "rolloverglossary/scripts/rolloverglossary.js";
  
  addScriptElement(link,language,type,src);

  // Add rolloverbehavior.js script to the document
  link = true;
  language = "JavaScript";
  type = "text/javascript";
  src = spath[0] + "rolloverglossary/scripts/rolloverbehavior.js";

  addScriptElement(link,language,type,src);

  // Add glossaryitems.js script to the document
  link = true;
  language = "JavaScript";
  type = "text/javascript";
  src = spath[0] + "rolloverglossary/glossaryitems.js";

  addScriptElement(link,language,type,src);
  
} // end if


// ===============================================
// Preload the preloadArray values     - [mg] 2006
// ===============================================
if (isIS) {
	// join preload array to string
	preloadString = preloadArray.join(",");
	// preload Images
	var preloader = "MM_preloadImages("+preloadString+")";
	eval(preloader);
}


}// end STATUSBAR function (MAIN)

// ------------------------------------------------------------------------
// setStatus Function										    - [mg] 2006
// ------------------------------------------------------------------------
// Status bar Timeout for IE used mainly in image swaps
function setStatus(text) {
	setTimeout("window.status = \'" + text + "\';", 0);
	return true;
}
// ------------------------------------------------------------------------


// ------------------------------------------------------------------------
// addScriptElement Function
// ------------------------------------------------------------------------
// Adds a script link to the document
function addScriptElement(link,language,type,src) {
  // If a link to a script
  if(link == true) {
    // Create script element
    var elem = document.createElement("script");
    // Set language
    elem.setAttribute("language",language);
    // Set type
    elem.setAttribute("type",type);
    // Set source
    elem.setAttribute("src",src);
    // Get elements by tag name
    var dhead = document.getElementsByTagName("head");
    // Get the head element
    var ditem = dhead.item(0);
	  //add the script to head element
    ditem.appendChild(elem);
  }
}

// Add behaviors.js script to the document
var utilitiesPathFound = false; // flag for utilities path
var spath = new Array(); // create new array
var elem = document.getElementsByTagName("script"); // get all the script tags
for(var el=0; el<elem.length; el++) { // for each script tag
		if(elem[el].getAttribute("src") != "") { // find the src attribute
				str = elem[el].getAttribute("src"); // get the path to the external JavaScript file
				if(str.indexOf("scripts/utilities.js") != -1) { // Search path for utilities.js
				  spath = elem[el].getAttribute("src").split("scripts/utilities.js"); // split string into array
				  utilitiesPathFound = true;
				  break; // stop the loop
				} // end if
		} // end if
} // end for

// if utilities path is found, then add the behavior.js script path to page
if (utilitiesPathFound) {
	var link = true;
	var language = "JavaScript";
	var type = "text/javascript";
	var src = spath[0] + "scripts/behaviors.js";	
	//add element
	addScriptElement(link,language,type,src);
}


// --------------------------------------------------------------------------------------------
// Code to handle right-clicks, 06-22-2009 - SMC
// --------------------------------------------------------------------------------------------
document.oncontextmenu = function(){alert('This function has been disabled.');return false;}


// --------------------------------------------------------------------------------------------
// Event handlers
// --------------------------------------------------------------------------------------------
// the above functions are attached to the specific events
window.onload = commonUtilities;
window.onfocus = ClosePopupWindow;
window.onunload = ClosePopupWindow;



