/*
Class: shellUtility

Overview: shellUtility Overview
shellUtility contains all of the essential functions necessary to operate the functional needs of the generic standardized shell.

Bugs:
	None known.
	
To do:
	- Make OO.

Change Log:
	2006.06.16	JEM	- Initial version.
	2006.10.23	BDG	- made the image link dynamic.  Init path oninclude
*/


addEvent(window, "load", externalLinks);
addEvent(window, "load", makeContentFluid);
addEvent(window, "resize", makeContentFluid);
var activeTab = null;
var imagePath = "";
var menuClosedSrc = 'styles/styleImages/plus.gif';
var menuOpenedSrc = 'styles/styleImages/minus.gif';
var menuClosedAlt = 'Expand menu';
var menuOpenedAlt = 'Collapse menu';
var menuClosedClass = 'off';
var menuOpenedClass = 'on';

function initImagePath(courseImagePath){
	imagePath = courseImagePath;
}

/* 
Function: fluidHeight
	Calculates the screen height available to an element and adjusts the height of that element to be as large as possible.

Parameters:
	scrollingEl		- reference to element to adopt scrolling.
	minHeight		- height of el at and below which fluidity stops and a locked environment is used.
	reservedHeight	- vertical space within browser not accounted for by the height of el.

Dependencies:
	<$>; <attachFluidCSS>;

Change Log:
	2005.??.??	JEM	- Initial version.
	2006.04.27	JEM	- Changed from directly applying the height to the element to using attachFluidCSS, instead, to prevent print problems.
	2006.05.09	JEM	- Added browser sniffing to work around IE's limitations by reverting back a step for IE.  :-(
	2006.06.02	JEM	- Made more reusable by moving element reference, minHeight, and reservedHeight to parameters; renamed function to fluidHeight; minor code clean-up.

Bugs:
	None known.
	
To do:
	- Find a workable way of attaching a stylesheet cross-browser so we don't have to browser sniff.
*/
function fluidHeight(scrollingEl, minHeight, reservedHeight, cssId) {
	if (domCompat) { // DOM check & not Mac/IE
		try {
			var lockedHeight = minHeight - reservedHeight; // height of scrolling div within "locked" environment.
			var y, scrollHeightNew;
			var isIE = true;
			
			// First, figure out how much height is available within the browser window.
			if (self.innerHeight) { // all except Explorer
				y = self.innerHeight;
				isIE = false;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				y = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				y = document.body.clientHeight;
			}
			
			// Second, calculate ScrollHeightNew depending upon if we need to be in the "locked height" environment.
			scrollHeightNew = (y < minHeight) ? lockedHeight + "px" : y - reservedHeight + "px";
			
			// Lastly, depending upon the browser, use one of two methods to apply the scrolling height.
			if (isIE) {
				scrollingEl.style.height = scrollHeightNew;
				return null;
			} else {
				return scrollHeightNew;
				//attachFluidCSS(scrollHeightNew, cssId, scrollingEl.id);
			}
		} catch(e) {
			return null;
			// alert (e.message) // not sure why an object error is thrown in IE on occassion, so we'll just catch and ignore it...
		}
	} // end if domCompat
}

/* 
Function: attachFluidCSS
	Removes the existing fluidCSS stylesheet and reattaches it using supplied CSS code.

Parameters:
	cssStr	- The CSS code to be inserted into the page.
	cssId	- Optional ID of the HTML element (e.g. style or link tag) containing CSS to be manipulated.

Dependencies:
	<$>;

Bugs:
	- Causes IE<7 to crash.  Doesn't work on IE7.  Therefore an alternate solution is used for IE (directly applying height to element and relying upon expanding boxes for print view).  Seems to be related to dynamically loading stylesheets.  Possibly related to IE's multiple-firing onWindowResize event.  Tried attaching both a link and a style tag, both via DOM node manipulation and innerHTML methods but to no avail in IE.
	
To do:
	- Generally make this much more reusable, object-oriented.
	
Change Log:
	2006.04.27	JEM	- Inital version.
	2006.05.09	JEM	- Changed to append style tag rather than a link tag so as to prevent an extra http request by the browser to the server.
	2006.06.02	JEM	- Added optional cssId parameter.
	2006.06.12	JEM	- Converted to assume CSS is supplied as a string, not an isolated height value, for generalizability.
*/
function attachFluidCSS(cssStr, cssId) {
	var styleId = cssId || "fluidCSS";
	var parentNode = $(styleId).parentNode;
	
	// First, remove the old style.
	parentNode.removeChild($(styleId));
	
	// Second, create the new style.
	var newCSS = document.createElement('style');
	newCSS.setAttribute('type','text/css');
	newCSS.setAttribute('id', styleId);
	newCSS.setAttribute('media','screen, projector'); // Projector included for Opera compatibility
	var innerCSS = document.createTextNode(cssStr);
	
	// Lastly, attach the new style.
	newCSS.appendChild(innerCSS);
	parentNode.appendChild(newCSS);
}

/* 
Function: initMenuEvents
	Unobtrusively attach functionality to all menu tabs and the close button.  If a tab has been specified as to be loaded for a given page, then <updateMenu> is called to display that tab.

Parameters:
	None.

Dependencies:
	<$>; <toggleMenu>; <restoreTabDefaults>; <closeTabs>

Returns:
	N/A.
	
Bugs:
	None known.
	
To do:
	None.

Change Log:
	2006.06.12	JEM	- Initial version.
*/


/* 
Function: restoreTabDefaults
	Loops through all of the menu tabs and images and applies the default image and events to each.

Parameters:
	parentEl	- reference to the node containing all of the menu images and their links

Dependencies:
	<toggleMenu>; <toggleTabState>

Returns:
	N/A.
	
Bugs:
	None known.
	
To do:
	None.

Change Log:
	2006.06.16	JEM	- Initial version.
*/


/* 
Function: toggleMenu
	Given a clicked tab, display or hide the menu area as appropriate.  All tab LIs should be named in the convention of "tab_"+tabType.

Parameters:
	el	- Reference to the element that was clicked

Dependencies:
	<closeTabs>; <updateMenu>

Returns:
	N/A.
	
Bugs:
	None known.
	
To do:
	- Clean-up messyness.

Change Log:
	2006.06.12	JEM	- Initial version.
*/
function toggleMenu(el) {
	var tabPrefix = "tab_";
	var tabType = el ? el.parentNode.id.substring(tabPrefix.length,el.parentNode.id.length) : null;
	var tabMenuImgs = el.parentNode.parentNode.getElementsByTagName("img");

	if (!tabType) { // close tab clicked
		closeTabs(); // so close the menu
	} else 	if (tabType != activeTab) { // selected tab not currently active
		showMenuContent(tabType); // so show the selected tab
	} else { // active tab was clicked
		closeTabs(); // so close the menu
	}
	var stateForClickedEl = (activeTab) ? "active" : "";
	
	restoreTabDefaults(el.parentNode.parentNode);
	
	if (stateForClickedEl.length>0) { // remove events for swapping to/from hover images on active tab
		el.onmouseover = function () {};
		el.onmouseout = function () {};
		el.onfocus = function () {};
		el.onblur = function () {};
	} else { // not active tab, so ensure events for swapping to/from hover images are present
		el.onmouseover = function () {toggleTabState(this.getElementsByTagName("img")[0], "hover"); return false;};
		el.onmouseout = function () {toggleTabState(this.getElementsByTagName("img")[0], ""); return false;};
	}
	toggleTabState(el.getElementsByTagName("img")[0], stateForClickedEl); // update selected image
}

/* 
Function: toggleTabState
	Toggles between active and off states for each tab.

Parameters:
	el		- reference to image to be changed.
	state	- string indicating what state the tab should take on.

Dependencies:
	None.

Returns:
	N/A.
	
Bugs:
	None known.
	
To do:
	- Because IE6 relies upon the PNG32 fix which swaps out the img.src for blank.gif, parsing the current src cannot work.  Once IE6 is dropped, revert back to parsing the img.src instead of this "hack" of parsing the el.parentNode.parentNode.id (ugh).

Change Log:
	2006.06.15	JEM	- Initial version.
*/
function toggleTabState(el,state) {
	var xtn = "png";
	var stateDelim = "_";
	var tabSuffix = "_tab";
	var linkPrefix = "tab_";
	var parentLink = el.parentNode.parentNode;
	var tabType = parentLink.id.substring(linkPrefix.length,parentLink.id.length);
	var newSrc = imagePath + tabType + tabSuffix;
	newSrc += (state.length > 0) ? stateDelim + state : "";
	newSrc += "." + xtn;
	el.src = newSrc;
}

/* 
Function: closeTabs
	Removes the className of the tabs element, which should mean according to the CSS that the element is display:none.

Parameters:
	None.

Dependencies:
	<$>;

Returns:
	N/A.
	
Bugs:
	None known.
	
To do:
	None.

Change Log:
	2006.06.12	JEM	- Initial version.
	2006.09.22	ALP	- Added call to showEl function, which redisplays flash elements that were hidden when the menu was opened.
*/
function closeTabs() {
	var tabParent = $("tabMenu");
	var tabsEl = $("tabs");
	tabsEl.className = "";
	activeTab = null;
	restoreTabDefaults(tabParent);
	var target = $('menuContentWrapper');
	showEl(target);
}

/* 
Function: showMenuContent
	Display the tab area and fill it with the contents related to that area.

Parameters:
	tabType	- The string indicating which tab should be activated.

Dependencies:
	<$>; <getMenuContent>

Returns:
	N/A.
	
Bugs:
	None known.
	
To do:
	None.

Change Log:
	2006.06.12	JEM	- Initial version.
	2006.09.22	ALP	- Added call to checkOlay function, which determines whether the menu is hiding any flash elements and (in FF) changes visibility to hidden for those that are covered to prevent the punch through effect.
*/
function showMenuContent(tabType) {
	var tabsEl = $("tabs");
	tabsEl.className = "tabDisplayed";
	activeTab = tabType;
	//getMenuContent(tabType);
	var target = $('menuContentWrapper');
	checkOlay(target,target.offsetTop,target.offsetLeft);
}

/* 
Function: getMenuContent
	Given a menu type, call AJAX to load the appropriate menu content into the menu area.

Parameters:
	type	- The string indicating which tab content should be retrieved and inserted into the page.

Dependencies:
	<Ajax.Updater>;

Returns:
	Outputs returned AJAX content to menuContent element.
	
Bugs:
	None known.
	
To do:
	None.

Change Log:
	2006.06.12	JEM	- Initial version.
	2006.10.17	JEM	- Added onComplete to AJAX.Updater.
*/
function getMenuContent(type) {
	var url="styles/menuOutput.cfm";
	var now = new Date();
	var rand_no = Math.random();
	var params="type="+type+"&amp;n="+ rand_no // must append date to effectively prevent IE from caching AJAXed content
	var ajax = new Ajax.Updater(
		{success: "menuContent"},
		url,
		{
			method: 'get',
			parameters: params,
			onFailure: reportMenuError,
			onComplete: menuContentDone
		}
	);
}

/* 
Function: menuContentDone
	Upon completion of an AJAX request, prep the menu.

Parameters:
	None.

Dependencies:
	<prepCourseMenu>;

Returns:
	N/A.
	
Bugs:
	None known.
	
To do:
	None.

Change Log:
	2006.09.29	JEM	- Initial version.
*/
function menuContentDone() {
	prepCourseMenu();
}

/* 
Function: reportMenuError
	Upon failure of an AJAX request, output the error to the screen for debugging.

Parameters:
	request	- Reference to the AJAX request that failed.

Dependencies:
	<$>;

Returns:
	N/A.
	
Bugs:
	None known.
	
To do:
	* Make more user-friendly.

Change Log:
	2006.06.12	JEM	- Initial version.
*/
function reportMenuError(request) {
	$('menuContent').innerHTML = "Error: " + request.responseText;
}


/* 
Function: prepCourseMenu
	Unobtrusively adds appropriate linked images or spans to make menu collapsible/expandable.

Parameters:
	None.

Dependencies:
	<$>;

Returns:
	N/A.
	
Bugs:
	None known.
	
To do:
	Remove span once IE7 is no longer supported.

Change Log:
	2006.09.29	JEM	- Initial version.
*/
function prepCourseMenu() {
	var elOpen;
	var root = $('menuContent');
	var lis = root.getElementsByTagName('LI');
	for (var i=0,j=lis.length; i<j; i++) {
		
		if (lis[i].getElementsByTagName('UL').length != 0) {
			
			if(lis[i].className == "current" || lis[i].className == "current done"){
				lis[i].innerHTML = '<a href="#" class="bullet" onclick="toggleChildren(this); return false;"><img src="'+menuClosedSrc+'" alt="'+menuClosedAlt+'" /></a>' + lis[i].innerHTML;				
			} else {
				lis[i].innerHTML = '<a href="#" class="bullet" onclick="toggleChildren(this); return false;"><img src="'+menuOpenedSrc+'" alt="'+menuOpenedAlt+'" /></a>' + lis[i].innerHTML;	
			}
		
		} else {
			lis[i].innerHTML = '<span class="bullet">&nbsp;</span>' + lis[i].innerHTML;
		}
	}
	var uls = root.getElementsByTagName('UL')[0].getElementsByTagName('UL');
	//alert(uls.length);
	for (var k=0, m=uls.length; k<m; k++) {
		elOpen = (uls[k].parentNode.firstChild.firstChild.src.indexOf(menuOpenedSrc) > 0) ? true : false;
		//console.log(elOpen);
		uls[k].parentNode.firstChild.firstChild.src = (elOpen) ? menuClosedSrc : menuOpenedSrc;
		uls[k].parentNode.firstChild.firstChild.alt = (elOpen) ? menuClosedAlt : menuOpenedAlt;
		//uls[k].parentNode.getElementsByTagName('UL')[0].className = (elOpen) ? menuClosedClass : menuOpenedClass;
		//uls[k].className = (elOpen) ? menuClosedClass : menuOpenedClass;
	}
	
	if (activeTab == "Help") {
		prepSecondaryMenus();
	} else {
		
		// expand relevant menu
	}
	/*var wl = window.location.toString();
		alert(wl.substring(wl.indexOf('/u')+2, wl.indexOf('/u')+4));*/
	//check modules and units
	//checkUnit();
}


/*Function: isSectionDone */
/*function checkUnit(){
	var myRoot = document.getElementById('AllUnits');
	var units = myRoot.childNodes;
	var totalUnits = units.length;
	for (var u = 0; u < totalUnits; u++) {
		var isUnitChecked = 0
		if (units[u].nodeType == document.ELEMENT_NODE) {
			isUnitChecked = isUnitChecked + checkModule(units[u]);
		}
		if (totalUnits == isUnitChecked) {
			units[u].className = "done";
		}
	}   
}

function checkModule(myUnit){
	var modules = myUnit.childNodes;
	var totalModules = modules.length;
	for (var m = 0; m < totalModules; m++) {
		var isModuleChecked = 0;
		if (modules[m].nodeType == document.ELEMENT_NODE && modules[m].tagName=='UL') {
			alert(modules[m].tagName);
			isModuleChecked = isModuleChecked + checkPage(modules[m]);
		}
		if (totalModules == isModuleChecked) {
			modules[m].className = "done";
		}
	}
	return isModuleChecked;
}

function checkPage(myPage){
	var pages = myPage.childNodes;
	var totalPages = myPage.length;
	for (var p = 0; p < totalPages; p++) {
		
		var isPageChecked = 0
		if (pages[p].nodeType == document.ELEMENT_NODE) {
			if (pages[p].className == "done"){
				isPageChecked++;	
			}
		}
	}
	return isPageChecked;
}*/
/* 
Function: prepSecondaryMenus
	Applies behavior appropriate for menus other than main course menu.

Parameters:
	None.

Dependencies:
	<$>.

Returns:
	N/A.
	
Bugs:
	None known.
	
To do:
	None known.

Change Log:
	2006.10.09	JEM	- Initial version.
*/
function prepSecondaryMenus() {
	var root = $('menuContent');
	root.getElementsByTagName('UL')[0].className = "noBoxes";
	var as = root.getElementsByTagName('A');
	for (var i=0,j=as.length; i<j; i++) {
		if (as[i].onclick == null) {
			as[i].onclick = function() {window.open(this.href,'help','width=500,height=400,toolbar=no,resizable=yes,menubar=no,location=no,scrollbars=no'); return false;};
		}
	}
}

function toggleChildren(el) {
	var elOpen = (el.firstChild.src.indexOf(menuOpenedSrc) > 0) ? true : false;
	el.firstChild.src = (elOpen) ? menuClosedSrc : menuOpenedSrc;
	el.firstChild.alt = (elOpen) ? menuClosedAlt : menuOpenedAlt;
	el.parentNode.getElementsByTagName('UL')[0].className = (elOpen) ? menuClosedClass : menuOpenedClass;
}


/*
Function: checkOlay
	Determines the position of an overlay and then runs the hideEl function to hide Flash elements that are partially covered by the overlay. 

Parameters:
	target_arg	- The ID of the overlay
	top	-	The top position of the overlay
	left	-	The left position of the overlay

Dependencies:
	<hideEl>; <$>

Returns:
	NA

Change Log:
	2006.09.18	ALP	- Initial version

Bugs:
	None known

To do:
	None
*/
function checkOlay(target_arg,top,left,pos) {
	var target = $(target_arg);
	var rightPos = target.offsetWidth + left;
	var bottomPos = target.offsetHeight + top;
	hideEl(target_arg,top,bottomPos,left,rightPos);
}
/*
Function: hideEl
	Hides flash elements that are below overlay divs.

Parameters:
	target	- The ID of the overlay
	top	-	The top position of the overlay
	bottom	-	The bottom position of the overlay
	left	-	The left position of the overlay
	right	-	The right position of the overlay

Dependencies:
	None

Returns:
	NA

Change Log:
	2006.09.18	ALP	- Initial version2006.11.20	ALP - Modified to account for a user scrolling on the page before opening the menu 
	2006.10.16	ALP	-	Modified to include the hiding of select tags in IE
	2006.10.16	ALP	-	Modified to hide all elements with their left x-coordinate covered by an overlay, regardless of y-coordinate.
	2006.11.14	ALP - Changed back to check both x- and y-coordinates before hiding an element
	2007.01.02	ALP	- Top position of audio players nested within multiple divs was not being calculated correctly. Fixed logic flaw.
	2007.01.09	ALP	-	Changed to hide the parent of flash elements when they are covered.

Bugs:
	None known

To do:
	None
*/
var hiddenArray = new Array();
var browserType; // variable to indicate which browser it is
var vidEls = new Array();
var videoClass = 'videoPlayer';
function hideEl(target, top, bottom, left, right) {
	var exceptionClassIE = "preventPunchThrough";
	var exceptionClassFF = "allowPunchThrough";
	var hide = false;
	var hidden = new Array();
	var els = new Array();
	var i, j, k;
	var m = 0;
	if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
		var el = "EMBED";
		browserType = 'nav';
	} else { //IE
		var el="OBJECT";
		browserType = 'ie';
	}	
	els = document.getElementsByTagName(el);
	var count = els.length; // var to count the number of els being hidden
	var selects = document.getElementsByTagName('SELECT');
	els = arrayConcat(els,selects);
	for (i=0; i<els.length; i++) {
		// If statement to prevent hiding in IE unless object's parent has a class of exceptionClassIE, and to prevent hiding in FF only if the embed's parent has a class of exceptionClassFF.
		if ((el == "OBJECT" && (els[i].parentNode.className.indexOf(exceptionClassIE) != -1)) || (el == "EMBED" && (els[i].parentNode.className.indexOf(exceptionClassFF) == -1) && els[i].tagName != "SELECT") || (el == "OBJECT" && els[i].tagName == "SELECT")) {
		/*Due to IE not calculating offsetTop/Left like FF, we need to find the parent node to get the top/left positions of the flash el. This code requires flash els to be wrapped in 2 parent nodes. */
			if (els[i].tagName == "OBJECT" || els[i].tagName == "EMBED") {	
				var currEl;
				var elTop = 0;
				var elLeft = 0;
				var isAudio;
				for (currEl = els[i].parentNode; currEl.id != contentEl; currEl = currEl.offsetParent) {					
					// On the first time through
					if (currEl == els[i].parentNode) {
						// If the el is an audio player, calculates correct position based on text button
						if (currEl.nextSibling) {
							var nextSib = currEl.nextSibling;
							for (nextSib; nextSib.nextSibling; nextSib = nextSib.nextSibling) {
								if (nextSib.nodeType == 1 && nextSib.tagName == 'A') {
									elLeft += nextSib.offsetLeft;
									elTop += currEl.offsetTop;
									isAudio = true;					
								}
							}
							if (!isAudio) {
								elLeft += currEl.offsetLeft;
							}
						} else {
							elTop += currEl.offsetTop;
							elLeft += currEl.offsetLeft;
						}
						//alert(isAudio);
					// for every subsequent offsetParent
					} else {
						elTop += currEl.offsetTop;
						elLeft += currEl.offsetLeft;
					}
				}
				var elBott = els[i].offsetHeight + elTop;
				var elRight = els[i].offsetWidth + elLeft;
			//alert('elLeft' + ' ' + elLeft + 'left ' + left + 'elRight ' + elRight + 'right ' + right);
			//alert('top ' + top + ' elTop ' + elTop + ' bottom ' + bottom + ' elBott ' + elBott);
			// if the el is a select box
			} else {
				var elTop = els[i].offsetTop;
				var elBott = els[i].offsetHeight + elTop;
				var elLeft = els[i].offsetLeft;
				var elRight = els[i].offsetWidth + elLeft;
			}
			// to adjust if user has scrolled content window before opening menu
			if ($(contentEl).scrollTop != 0) {
				elTop = elTop - $(contentEl).scrollTop;
			}
			if ( ((left <= elLeft && right >= elRight) // the overlay completely covers the el (x)
					|| (left >= elLeft && left <= elRight) // the overlay partially covers the el(x)
					|| (right <= elRight && right >= elLeft)) // the overlay partially covers the el(x)
				&& ((top <= elTop && bottom >= elBott)
					|| (top >= elTop && top <= elBott)
					|| (bottom <= elBott && bottom >= elTop)) ) { 
				if ((left <= elLeft && right >= elRight) // the overlay completely covers the el (x)
					|| (left >= elLeft && left <= elRight) // the overlay partially covers the el(x)
					|| (right <= elRight && right >= elLeft)) {
			}
				//alert('top ' + top + ' elTop ' + elTop + ' bottom ' + bottom + ' elBott ' + elBott);
				hide = true;			
			} else {
				hide = false;
			}
			//alert(hide);
			if (hide) {
				// If it is a select box
				if (els[i].tagName == "SELECT") {
					els[i].style.visibility = "hidden";
				// If it is anything else
				} else {
					//If it is video in Firefox/Netscape/Moz
					if (browserType == 'nav' && els[i].className == videoClass) {
						createPlaceholder(els[i].parentNode.parentNode,m);
					// If it is any other video player
					} else if (els[i].className == videoClass) {
						createPlaceholder(els[i].parentNode,m);
					// If it is not a video player or select box
					} else {
						els[i].parentNode.style.visibility = "hidden";
						
					}
				}
				hidden.push(els[i]);
				m++; // to avoid skipping any in the vidEls array
			}
		}
	}
	if (hidden.length != 0) {
		hiddenArray[target] = hidden;
	}
}
/*
Function: showEl
	Function that is called when an overlay div is closed to make any flash elements that were hidden visible again.

Parameters:
	target	- ID of the overlay

Dependencies:
	<hideEl>;

Returns:
	NA

Change Log:
	2006.09.18	ALP	- Initial version
	2006.10.16	ALP	-	Modified to re-show hidden select tags.
	2007.01.02	ALP	- Fixed logic flaw with re-showing els that are not video or select boxes.
	2007.01.09	ALP	-	Changed to show the parent of flash elements when they have been covered.

Bugs:
	None known

To do:
	None
*/
function showEl(target) {
	var i, j;
	if (!hiddenArray[target]) {
		//do nothing
	} else {
		var temp = hiddenArray[target];
		for (i=0, j=temp.length; i<j; i++) {
			// If it is a select box
			if (temp[i].tagName == "SELECT") {
				temp[i].style.visibility = "visible";
			// If it is a video player
			} else if (temp[i].className == videoClass) {
				removePlaceholder(i);
				var info = vidEls[i].split('|');
				var currId = info[0];
				var oldClass = info[1];
				if (oldClass.indexOf('on ') != -1) {
					oldClass = oldClass.substring(2);
				}
				$(currId).style.visibility = 'visible';
				$(currId).style.display = 'block';
				$(currId).className = 'on ' + oldClass;
			// If it is not a video player or select box
			} else {
				temp[i].parentNode.style.visibility = "visible";
			}
		}
	}
}	
/*
Function: createPlaceholder
	Function to create a placeholder when video is covered by the menu.

Parameters:
	target	- ID of the video player's parent el
	i - the position of the video in the hidden array

Dependencies:
	<$>; <wrapOrStuff>; <changeClassById>; 

Returns:
	NA

Change Log:
	2006.11.14	ALP	- Initial version

Bugs:
	None known

To do:
	None
*/
function createPlaceholder(target,i) {
	var currId = 'flashTemp'+i;
	var color = '#CCCCCC';
	if (!$(currId)) {
		var tempDiv = new wrapOrStuff(target,'wrap',1,'div','id='+currId).init(); 
	}
	var myWidth = $(target).firstChild.width;
	var myHeight = $(target).firstChild.height;
	var oldClass = target.className;
	target.style.display = 'none';
	target.style.visibility = 'hidden';
	changeClassById(target.id,'offLeft');
	vidEls[i] = target.id + '|' + oldClass;
	$(currId).style.width = myWidth+'px';

	$(currId).style.height = myHeight+'px';
	$(currId).style.backgroundColor = color;
	$(currId).className = oldClass;
}
/*
Function: removePlaceholder
	Function to make the placeholder transparent.

Parameters:
	i - the position of the video in the hidden array

Dependencies:
	<$>;

Returns:
	NA

Change Log:
	2006.11.14	ALP	- Initial version

Bugs:
	None known

To do:
	None
*/
function removePlaceholder(i) {
	var currId = 'flashTemp'+i;
	$(currId).style.backgroundColor = 'transparent';
}