/*
	Naming Schema for JavaScript:
		All words use CamelCase
		All variables start with a lowercase word unless the variable word represents an HTML element, 
			then the related variable name is uppercased and trailing word starts with a lowercase character
		NO words separated by underscore character '_'


*/

if (document.getElementById) {

   var contact_member_off = new Image();
   contact_member_off.src = "/images/nav/common/contact_member_a.gif";
   
   var contact_member_on = new Image();
   contact_member_on.src = "/images/nav/common/contact_member_i.gif";

   var img_nav_u_off = "/web/images/nav/image_controls/img_nav_u_off.png";
   
   var img_nav_r_off = "/web/images/nav/image_controls/img_nav_r_off.png";
   
   var img_nav_d_off = "/web/images/nav/image_controls/img_nav_d_off.png";
   
   var img_nav_l_off = "/web/images/nav/image_controls/img_nav_l_off.png";
   
   var img_nav_e_off = "/web/images/nav/image_controls/img_nav_e_off.png";
   var img_nav_x_off = new Image();
   
  	img_nav_x_off.src = "/images/nav/image_controls/img_nav_x_off.png";
   
   var img_nav_u_on = "/web/images/nav/image_controls/img_nav_u_on.png";
   
   var img_nav_r_on = "/web/images/nav/image_controls/img_nav_r_on.png";
   
   var img_nav_d_on = "/web/images/nav/image_controls/img_nav_d_on.png";
   
   var img_nav_l_on = "/web/images/nav/image_controls/img_nav_l_on.png";
   
   var img_nav_e_on = "/web/images/nav/image_controls/img_nav_e_on.png";
   
   //var img_nav_x_on = "/web/images/nav/image_controls/img_nav_x_on.png";
   var img_nav_x_on = new Image();
   img_nav_x_on.src = "/images/nav/image_controls/img_nav_x_on.png";
  
   var bio_nav_preface_on = new Image();
   bio_nav_preface_on.src = "/images/nav/left/preface_i.gif";
   
   var bio_nav_preface_off = new Image();
   bio_nav_preface_off.src = "/images/nav/left/preface_a.gif";
   
   var bio_nav_documents_on = new Image();
   bio_nav_documents_on.src = "/images/nav/left/documents_i.gif";
   
   var bio_nav_documents_off = new Image();
   bio_nav_documents_off.src = "/images/nav/left/documents_a.gif";
   
   var bio_nav_pages_on = new Image();
   bio_nav_pages_on.src = "/images/nav/left/pages_i.gif";
   
   var bio_nav_pages_off = new Image();
   bio_nav_pages_off.src = "/images/nav/left/pages_a.gif";
   
   var bio_nav_introduction_on = new Image();
   bio_nav_introduction_on.src = "/images/nav/left/introduction_i.gif";
   
   var bio_nav_introduction_off = new Image();
   bio_nav_introduction_off.src = "/images/nav/left/introduction_a.gif";
   
   var bio_nav_education_on = new Image();
   bio_nav_education_on.src = "/images/nav/left/education_i.gif";
   
   var bio_nav_education_off = new Image();
   bio_nav_education_off.src = "/images/nav/left/education_a.gif";
   
   var bio_nav_solo_exhibitions_on = new Image();
   bio_nav_solo_exhibitions_on.src = "/images/nav/left/solo_exhibitions_i.gif";
   
   var bio_nav_solo_exhibitions_off = new Image();
   bio_nav_solo_exhibitions_off.src = "/images/nav/left/solo_exhibitions_a.gif";
   
   var bio_nav_group_exhibitions_on = new Image();
   bio_nav_group_exhibitions_on.src = "/images/nav/left/group_exhibitions_i.gif";
   
   var bio_nav_group_exhibitions_off = new Image();
   bio_nav_group_exhibitions_off.src = "/images/nav/left/group_exhibitions_a.gif";
  
   var bio_nav_bibliography_on = new Image();
   bio_nav_bibliography_on.src = "/images/nav/left/bibliography_i.gif";
   
   var bio_nav_bibliography_off = new Image();
   bio_nav_bibliography_off.src = "/images/nav/left/bibliography_a.gif";
  
   var bio_nav_collections_on = new Image();
   bio_nav_collections_on.src = "/images/nav/left/collections_i.gif";
   
   var bio_nav_collections_off = new Image();
   bio_nav_collections_off.src = "/images/nav/left/collections_a.gif";
   
   var bio_nav_awards_on = new Image();
   bio_nav_awards_on.src = "/images/nav/left/awards_and_grants_i.gif";
   
   var bio_nav_awards_off = new Image();
   bio_nav_awards_off.src = "/images/nav/left/awards_and_grants_a.gif";
   
   var bio_nav_upcoming_events_on = new Image();
   bio_nav_upcoming_events_on.src = "/images/nav/left/upcoming_events_i.gif";
   
   var bio_nav_upcoming_events_off = new Image();
   bio_nav_upcoming_events_off.src = "/images/nav/left/upcoming_events_a.gif";
   
   var bio_nav_review_biography_on = new Image();
   bio_nav_review_biography_on.src = "/images/nav/left/review_biography_i.gif";
   
   var bio_nav_review_biography_off = new Image();
   bio_nav_review_biography_off.src = "/images/nav/left/review_biography_a.gif";
   
   var work_nav_genre_medium_on = new Image();
   work_nav_genre_medium_on.src = "/images/nav/left/genre_medium_i.gif";
   
   var work_nav_genre_medium_off = new Image();
   work_nav_genre_medium_off.src = "/images/nav/left/genre_medium_a.gif";
   
   var work_nav_information_on = new Image();
   work_nav_information_on.src = "/images/nav/left/information_i.gif";
   
   var work_nav_information_off = new Image();
   work_nav_information_off.src = "/images/nav/left/information_a.gif";
   
   var work_nav_review_work_on = new Image();
   work_nav_review_work_on.src = "/images/nav/left/review_work_i.gif";
   
   var work_nav_review_work_off = new Image();
   work_nav_review_work_off.src = "/images/nav/left/review_work_a.gif";
   
    
   var page_control_next_on = new Image();
   page_control_next_on.src = "/images/nav/common/page_control_next_i.gif";
   
   var page_control_prev_on = new Image();
   page_control_prev_on.src = "/images/nav/common/page_control_prev_i.gif";
  
   var page_control_off = new Image();
   page_control_off.src = "/images/nav/common/page_control_a.gif";
   
   
   var portfolio_control_next_on = new Image();
   portfolio_control_next_on.src = "/images/nav/common/portfolio_control_next_i.gif";
   
   var portfolio_control_prev_on = new Image();
   portfolio_control_prev_on.src = "/images/nav/common/portfolio_control_prev_i.gif";
  
   var portfolio_control_off = new Image();
   portfolio_control_off.src = "/images/nav/common/portfolio_control_a.gif";
   
   var post_critique_on = new Image();
   post_critique_on.src = "/images/nav/common/add_critique_i.gif";
   
   var post_critique_first_off = new Image();
   post_critique_first_off.src = "/images/nav/common/add_critique_a.gif";
   
   var post_critique_first_on = new Image();
   post_critique_first_on.src = "/images/nav/common/add_critique_first_i.gif";
   
   var post_critique_first_off = new Image();
   post_critique_first_off.src = "/images/nav/common/add_critique_first_a.gif";
   
   
   
   var view_browse_all_on = new Image();
   view_browse_all_on.src = "/images/nav/left/view_browse_all_i.gif";
   
   var view_browse_all_off = new Image();
   view_browse_all_off.src = "/images/nav/left/view_browse_all_a.gif";
   
   var view_portfolio_on = new Image();
   view_portfolio_on.src = "/images/nav/left/view_portfolio_i.gif";
   
   var view_portfolio_off = new Image();
   view_portfolio_off.src = "/images/nav/left/view_portfolio_a.gif";
      
   var view_biography_on = new Image();
   view_biography_on.src = "/images/nav/left/view_biography_i.gif";
   
   var view_biography_off = new Image();
   view_biography_off.src = "/images/nav/left/view_biography_a.gif";
      
   var view_contact_on = new Image();
   view_contact_on.src = "/images/nav/left/view_contact_i.gif";
   
   var view_contact_off = new Image();
   view_contact_off.src = "/images/nav/left/view_contact_a.gif";
   
   
   
   var left_nav_review_on = new Image();
   left_nav_review_on.src = "/images/nav/left/review_and_publish_i.gif";
   
   var left_nav_review_off = new Image();
   left_nav_review_off.src = "/images/nav/left/review_and_publish_a.gif";
    
   var left_nav_publish_on = new Image();
   left_nav_publish_on.src = "/images/nav/left/publish_i.gif";
     
   var left_nav_publish_off = new Image();
   left_nav_publish_off.src = "/images/nav/left/publish_a.gif";
   
   var left_nav_save_on = new Image();
   left_nav_save_on.src = "/images/nav/left/save_and_exit_i.gif";
     
   var left_nav_save_off = new Image();
   left_nav_save_off.src = "/images/nav/left/save_and_exit_a.gif";
   
   
   /* 20091029 NEW MESSAGE RELATED NOT NEEDED DUE TO SIMPLE SWAP CODE
   
   var message_artwork_add_off = new Image();
   message_artwork_add_off.src = "/images/messages/links/artwork_add_a.gif";
   
   var message_artwork_add_on = new Image();
   message_artwork_add_on.src = "/images/messages/links/artwork_add_i.gif";
   
   var message_artwork_edit_off = new Image();
   message_artwork_edit_off.src = "/images/messages/links/artwork_edit_a.gif";
   
   var message_artwork_edit_on = new Image();
   message_artwork_edit_on.src = "/images/messages/links/artwork_edit_i.gif";
   
   var message_artwork_delete_off = new Image();
   message_artwork_delete_off.src = "/images/messages/links/artwork_delete_a.gif";
   
   var message_artwork_delete_on = new Image();
   message_artwork_delete_on.src = "/images/messages/links/artwork_delete_i.gif";
   
  */
   
   
}



function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var oversrc = x[i].getAttribute("oversrc");
    if (!oversrc) continue;
      
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].oversrc_img = new Image();
    x[i].oversrc_img.src=oversrc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();setControls();}


function findPos(obj) {

	var curleft = curtop = 0;  
	
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
		//alert("curleft = " + curleft + ", curtop = " + curtop);
		return [curleft,curtop];
	}
}

var hideMenuTimerIdGenre = 0;
var hideMenuTimerIdMedium = 0;

function showMenu(obj, menuId, h, v) {
	if (menuId == "genres") { 
		clearTimeout(hideMenuTimerIdGenre); 
	} else {
		clearTimeout(hideMenuTimerIdMedium); 
	}
	
	var location = findPos(obj);
	var menu = document.getElementById(menuId);
	menu.style.left = (location[0] + h) + "px";
	menu.style.top = (location[1] + v) + "px";
}

function hideMenu(menuId) {
	if (menuId == "genres") { 
		clearTimeout(hideMenuTimerIdGenre); 
	} else {
		clearTimeout(hideMenuTimerIdMedium); 
	}
	var menu = document.getElementById(menuId);
	if (menuId == "genres") { 
		hideMenuTimerIdGenre = setTimeout(function() {menu.style.left = '-9999px'}, 500);
	} else {
		hideMenuTimerIdMedium = setTimeout(function() {menu.style.left = '-9999px'}, 500);
	}
}


function overMenuGenre() {
	clearTimeout(hideMenuTimerIdGenre);
}

function overMenuMedium() {
	clearTimeout(hideMenuTimerIdMedium);
}


sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		//alert("Hello = " + (i + 1));
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);




var active = false;
var allowSubmit = false;
var isIE = false;
var activeTimer;
var parentElem;

var upVal = "move up";
var downVal = "move down";


function swapImg(n, newState) {
	//alert('HIT swapImg()');
	n.src = newState.src;
}



function swapImgMap(n, newState) {
	//alert('HIT swapImg()');
	folioControlImg = document.getElementById(n)
	folioControlImg.src = newState.src;
}



function swapController(n, direction, newState) {

 	/*
	alert('Hit swapController, newState.src=' + newState.src + '\n' +
		'n.firstChild.nodeName=' + n.firstChild.nodeName + '\n' +
		'n.firstChild.getAttribute("src")=' + n.firstChild.getAttribute("src"));
	*/
	
	// alert('this.firstChild.src=' + this.firstChild.src);this.firstChild.src='/culturehall/web/images/nav/image_controls/img_nav_x_on.png';alert('this.firstChild.src=' + this.firstChild.src);
	// this.firstChild.src='/culturehall/web/images/nav/image_controls/img_nav_x_off.png';
	
	var newSrc = '/web/images/nav/image_controls/img_nav_' + direction + '_' + newState + '.png';
	//alert('n.firstChild.src=' + n.firstChild.src);
	
	//n.src = newSrc;
	//n.setAttribute("src",newSrc);
	//document.n.src= newSrc;
	//n.firstChild.setAttribute("src",newSrc);
	
	//alert('HIT newSrc=' + newSrc);
	
	var controllerImg = document.createElement("img");
	controllerImg.setAttribute("border","0");
	controllerImg.setAttribute("height","30");
	controllerImg.setAttribute("width","30");
	controllerImg.setAttribute("src",newSrc);
	//var functionPayload = "swapController(this,'x','off');";
	//controllerImg.mouseout  = new Function(functionPayload);
	nParent = n.parentNode;
	nParent.replaceChild(controllerImg,n);
	
	
}

function scrollUp() {
	//alert('scrollUP JS');
	 window.scrollTo(0,0);
}

function resizePlayer(swfId, newHeight, scroll) {
	//alert('swfId = ' + swfId + ', newHeight = ' + newHeight + ', scroll = ' + scroll);
	document.getElementById(swfId).style.height = ((newHeight + 100) + "px");
	if (scroll) scrollUp();
}


function updateLeftNavMediaFileCount(count) {
	var labelText = count + " listing";
	if (count > 1) {
		labelText = count + " listings";
	} else if (count == 0) {
		labelText = "Empty"
	}
	document.getElementById("mediaPagesInfo").innerHTML = labelText;
}


function updateLeftNavCount(i, target) {
	var origText = document.getElementById(target).innerHTML;
	var count = 0;
	if (origText != "Empty") count = parseInt(origText.replace(/ [a-z]+/, ""));
	count += parseInt(i);
	var labelText = count + " listing";
	if (count > 1) {
		labelText = count + " listings";
	} else if (count == 0) {
		labelText = "Empty";
	}
	
	document.getElementById(target).innerHTML = labelText;
	
}


function updateCountryByState(state, country) {
	if (state.value > 0) {
		country.value = 205;
	} 
}


function updateStateByCountry(state, country) {
	if (country.value != 205) {
		state.value = 0;
	}
}


function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
 
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
 
    return vars;
}


///////////////////// Form Clear  /////////////////////

// 20090815 PROBABLY REMOVE - USING DIRECT METHODS
function clearAllFormElements(parentNodeId) {

	//alert('hit clearAllFormElements');
	var parentNode = document.getElementById(parentNodeId);
	
 	formInputs = parentNode.getElementsByTagName("input");

	//alert('formInputs.length=' + formInputs.length);
	
  	for (var i = 0; i < formInputs.length; i++) {
  		
		if (formInputs.item(i).type == "text") {
			formInputs.item(i).value = "";
		}
	}
	
	
	formInputs = parentNode.getElementsByTagName("textarea");

	
  	for (var i = 0; i < formInputs.length; i++) {
  		/*
  		alert('TEXTAREA: formInputs.item(i).value=' + formInputs.item(i).value);
  		
		alert('img.parentNode.parentNode.getAttribute("value")=' + formInputs.item(i).getAttribute("value") + '\n' +
			'img.parentNode.parentNode.getAttribute("type")=' + formInputs.item(i).getAttribute("type"));	
		*/
		
		//if (formInputs.item(i).getAttribute("type") == "text") {
			formInputs.item(i).value = "";
		//}
	}
	
	
	formInputs = parentNode.getElementsByTagName("select");

	//alert('formInputs.length=' + formInputs.length);
	
  	for (var i = 0; i < formInputs.length; i++) {
  		formInputs.item(i).selectedIndex = 0;
	}
	
	return false;
/*
  formInputs = parentNode.getElementsByTagName("textarea");

  for (var i = 0; i < formInputs.length; i++)

    out.push( formInputs.item(i) );

  formInputs = parentNode.getElementsByTagName("select");

  for (var i = 0; i < formInputs.length; i++)

    out.push( formInputs.item(i) );

  formInputs = parentNode.getElementsByTagName("button");

  for (var i = 0; i < formInputs.length; i++)

    out.push( formInputs.item(i) );

  return out;
*/
}






///////////////////// Image Order Controller Code /////////////////////

function controllerOverlay(targetImage) {
	var img = new Image();
	img = targetImage;
	alert('img.nodeName=' + img.nodeName);
	alert('img.parentNode.nodeName=' + img.parentNode.nodeName);
	alert('img.parentNode.parentNode.nodeName=' + img.parentNode.parentNode.nodeName);
	alert('img.parentNode.parentNode.nodeName=' + img.parentNode.parentNode.nodeName);
	alert('img.parentNode.parentNode.getAttribute("id")=' + img.parentNode.parentNode.getAttribute("id"));
}

/*
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	alert('findPos(), curtop=' + curtop + ', obj.height=' + obj.height);
	return curtop;
}
*/

function activateImageControls(img) {
	//img.parentNode.lastChild.style.top="-98px"; NON-IE
	//var currImgTop = findPos(img);
	
	if (document.all) {
		isIE = true;
	}
	
	
	if (isIE == false) {
		img.parentNode.lastChild.style.top ="-98px";
	} else {
		img.parentNode.lastChild.style.top ="0px";
	}
	
	//findPos(img);
	//findPos(img.parentNode.lastChild);
	
	//img.parentNode.lastChild.style.top="0px";  // IE
}

function deactivateImageControls(tbl) {
	parentElem = tbl.parentNode.parentNode.parentNode.parentNode.parentNode;
	activeTimer = setTimeout("moveItem(parentElem)",2);
	
}

function deactivateAllOtherControls(tbl) {
	var parentElem = tbl.parentNode.parentNode.parentNode.parentNode.parentNode;
	var allControllers = [];
	var allMediaUnits = document.getElementById("allMediaUnits");
	var allMediaUnitsChildren = allMediaUnits.childNodes;
	
	//alert('parentElem.getAttribute("class")=' + parentElem.getAttribute("class"));
	
	var testNodeAttribute = null;
	
	for (i = 0; i < allMediaUnitsChildren.length; i++) {
		if (allMediaUnitsChildren[i].nodeName == "DIV") {
			
			testNode = allMediaUnitsChildren[i].firstChild.lastChild;
			//alert('testNode.nodeName=' + testNode.nodeName);
			//alert('testNode.nodeName=' + testNode.nodeName + ', testNode.getAttribute("class")=' + testNode.getAttribute("class"));
			
			//alert('allMediaUnitsChildren[i].firstChild.nextSibling.nodeName=' + allMediaUnitsChildren[i].firstChild.nextSibling.nodeName);
			//alert('allMediaUnitsChildren[i].firstChild.nextSibling.getAttribute("class")=' + allMediaUnitsChildren[i].firstChild.nextSibling.getAttribute("class"));
			//if (testNode != parentElem) {
			
			/*
			alert('deactivateAllOtherControls() >>> \n' +
				'testNode.getAttribute("class")=' + testNode.getAttribute("class")
				);
			*/
			
			testNodeAttribute = testNode.getAttribute("class");
			if (testNodeAttribute == null) {
				testNodeAttribute = testNode.attributes['class'].nodeValue;
			}
			
			if (testNode != parentElem && testNodeAttribute == 'imageController') {
				moveItem(testNode);
			} 
			
		}
	}
}


function deactivateAllControls(tbl) {
	var parentElem = tbl.parentNode.parentNode.parentNode.parentNode.parentNode;
	var allControllers = [];
	var allMediaUnits = document.getElementById("allMediaUnits");
	var allMediaUnitsChildren = allMediaUnits.childNodes;
	
	//alert('parentElem.getAttribute("class")=' + parentElem.getAttribute("class"));
	
	var testNodeAttribute = null;
	
	for (i = 0; i < allMediaUnitsChildren.length; i++) {
		if (allMediaUnitsChildren[i].nodeName == "DIV") {
			
			testNode = allMediaUnitsChildren[i].firstChild.lastChild;
			//alert('testNode.nodeName=' + testNode.nodeName);
			//alert('testNode.nodeName=' + testNode.nodeName + ', testNode.getAttribute("class")=' + testNode.getAttribute("class"));
			
			//alert('allMediaUnitsChildren[i].firstChild.nextSibling.nodeName=' + allMediaUnitsChildren[i].firstChild.nextSibling.nodeName);
			//alert('allMediaUnitsChildren[i].firstChild.nextSibling.getAttribute("class")=' + allMediaUnitsChildren[i].firstChild.nextSibling.getAttribute("class"));
			//if (testNode != parentElem) {
			
			/*
			alert('deactivateAllOtherControls() >>> \n' +
				'testNode.getAttribute("class")=' + testNode.getAttribute("class")
				);
			*/
			
			
			testNodeAttribute = testNode.getAttribute("class");
			if (testNodeAttribute == null) {
				testNodeAttribute = testNode.attributes['class'].nodeValue;
			}
			
			
			if (testNodeAttribute == 'imageController') {
				moveItem(testNode);
			} 
			
		}
	}
}




function moveItem(itemToMove) {
	itemToMove.style.top="-6000px";
}


function keepImageControls(tbl) {
	clearTimeout(activeTimer);
	deactivateAllOtherControls(tbl);
}

function cursorOff() {
	document.body.style.cursor="default";
}

function cursorOff() {
	document.body.style.cursor="auto";
}


function addMediaInfo(n, targetTagId, content) {
	var currUnit = n.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
	var target = document.getElementById(targetTagId);
	var targetKids = target.childNodes;
	
	//alert('currUnit.nodeName=' + currUnit.nodeName + ', currUnit.getAttribute("class")=' + currUnit.getAttribute("class"));
	
	target.setAttribute("value", target.getAttribute("value") + currUnit.getAttribute("cid") + content +',');
	
}


function removeImage(tbl) {

	var isIE = false;
	
	if (document.all) {
		isIE = true;
	}
	
	var generalController = tbl.parentNode.parentNode.parentNode.parentNode.parentNode;
	var controllerParent = generalController.parentNode;
	var imageUnit = controllerParent.parentNode;
	var allUnits = imageUnit.parentNode;
	var offController = controllerParent.removeChild(controllerParent.lastChild.previousSibling);
	controllerParent.appendChild(offController);
	
	//alert('HIT: Remove Image\n');
	
	/*
	alert('HIT: Remove Image\n' +
		'controllerParent.nodeName=' + controllerParent.nodeName + ', controllerParent.getAttribute("class")=' + controllerParent.getAttribute("class") + '\n' +
		'generalController.nodeName=' + generalController.nodeName + ', generalController.getAttribute("class")=' + generalController.getAttribute("class") + '\n' +
		'offController.nodeName=' + offController.nodeName + ', offControler.getAttribute("class")=' + offController.getAttribute("class"));
	
	alert('HIT: Remove Image\n' +
		'imageUnitParent.nodeName=' + imageUnitParent.nodeName + ', imageUnitParent.getAttribute("class")=' + imageUnitParent.getAttribute("class") + '\n' +
		'allUnitsParent.nodeName=' + allUnitsParent.nodeName + ', allUnitsParent.getAttribute("id")=' + allUnitsParent.getAttribute("id"));
	
	*/
	
	generalController.style.top="-6000px";
	
	if (isIE == false) {
		offController.style.top ="-98px";
	} else {
		offController.style.top ="0px";
	}
	
	placeImageUnit(allUnits,imageUnit);
	
	setControls();
}




function returnImage(tbl) {

	var isIE = false;
	
	if (document.all) {
		isIE = true;
	}
	
	var offController = tbl.parentNode.parentNode.parentNode.parentNode.parentNode;
	var controllerParent = offController.parentNode;
	var imageUnit = controllerParent.parentNode;
	var allUnits = imageUnit.parentNode;
	
	//var offController = generalController.previousSibling;
	var offController = controllerParent.removeChild(controllerParent.lastChild);
	var generalController = controllerParent.removeChild(controllerParent.lastChild);
	
	controllerParent.appendChild(offController);
	controllerParent.appendChild(generalController);
	
	
	/*
	alert('HIT: Remove Image\n' +
		'controllerParent.nodeName=' + controllerParent.nodeName + ', controllerParent.getAttribute("class")=' + controllerParent.getAttribute("class") + '\n' +
		'generalController.nodeName=' + generalController.nodeName + ', generalController.getAttribute("class")=' + generalController.getAttribute("class") + '\n' +
		'offController.nodeName=' + offController.nodeName + ', offControler.getAttribute("class")=' + offController.getAttribute("class") + '\n' +
		'imageUnit.nodeName=' + imageUnit.nodeName + ', imageUnit.getAttribute("class")=' + imageUnit.getAttribute("class") + '\n' +
		'allUnits.nodeName=' + allUnits.nodeName + ', allUnits.getAttribute("id")=' + allUnits.getAttribute("id"));
	
	*/
	
	
	
	offController.style.top="-6000px";
	
	if (isIE == false) {
		generalController.style.top ="-98px";
	} else {
		generalController.style.top ="0px";
	}
	
	
	// Iterate through children, checking for the first instance of an inactive controller, then insert this element before this first inactive one
	
	placeImageUnit(allUnits,imageUnit);
	
	setControls();
	
}


function placeImageUnit(allUnits,imageUnit) {

	var controllerToPlace = null;
	
	var allUnitsAllChildren = allUnits.childNodes;
	var j = 0;
	for (i = 0; i < allUnitsAllChildren.length; i++) {
		if (allUnitsAllChildren[i].nodeName == "DIV") {
			j++;
			if (j == 2) {
				break;
			}
		}
	}
	
	if (j > 1) {
		controllerToPlace = allUnits.removeChild(imageUnit);
	}


	 
	
	var allUnitsChildren = [];
	
	// Iterate through children, checking for the first instance of an inactive controller, then insert this element before this first inactive one
	
	
	var allUnitsChildren = [];
	
	
	
	
	for (i = 0; i < allUnitsAllChildren.length; i++) {
		if (allUnitsAllChildren[i].nodeName == "DIV") {
			allUnitsChildren.push(allUnitsAllChildren[i]);
		}
	}
	/*
	alert('HIT: placeImageUnit\n' + 
		'allUnitsAllChildren.length=' + allUnitsAllChildren.length + '\n\n' +
		'allUnitsChildren.length=' + allUnitsChildren.length + '\n\n'
		);
	*/
	
	
	var classAttribute = null;
	
	/*
	if (allUnitsChildren.length == 0) {
		
		if (allUnitsAllChildren.length > 0) {
			insertAfter(controllerToPlace, allUnits.firstChild);
		} else {
			allUnits.appendChild(controllerToPlace);
		}
	
	} else {
	
	*/
		
	if (j > 1) {
	
		//var controllerToPlace = allUnits.removeChild(imageUnit);
	
		for (i = 0; i < allUnitsChildren.length; i++) {
			
			classAttribute = allUnitsChildren[i].firstChild.lastChild.getAttribute("class");
			if (classAttribute == null) {
				classAttribute = allUnitsChildren[i].firstChild.lastChild.attributes['class'].nodeValue;
			}
			
			if (classAttribute == "imageControllerRemove") {
				allUnits.insertBefore(controllerToPlace,allUnitsChildren[i]);
				break;
			}	
			if ((i + 1) == allUnitsChildren.length) {
				
				/*
				alert('placeImageUnit() \n' +
					'allUnitsChildren.length=' + allUnitsChildren.length + ', i=' + i
				);
				*/
			
				// Need to add the element back adjacent to the last DIV object in the collection
				if (allUnits.lastChild.nodeName == "DIV") {
					allUnits.appendChild(controllerToPlace);
				} else {
					allUnits.insertBefore(controllerToPlace,allUnits.lastChild);
				}
			}
		}
	}

}




///////////////////// Image Order Controller Code /////////////////////


function promoteWorkSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "submit");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function skipPromoteWorkSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "skip");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}



function addInfo(targetTagId, content) {
	var target = document.getElementById(targetTagId);
	var targetKids = target.childNodes;
	
	target.setAttribute("value", target.getAttribute("value") + content +',');
	
}

function addMediaPagesSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("name", "_eventId_mediaPages");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function editMediaFilesSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "editMediaFilesFromReview");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function addIntroductionSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("name", "_eventId_introduction");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function editIntroductionSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "editIntroductionFromReview");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function addWorkSubmit() {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "???");
}

function addSoloExhibitionsSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("name", "_eventId_exhibitionSolo");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function editSoloExhibitionsSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "editSoloExhibitionsFromReview");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function removeSoloExhibitionsSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "removeSoloExhibitionsEdit");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


/*
function addGroupExhibitionsSubmit() {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "addGroupExhibitions");
}
*/

function addGroupExhibitionsSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("name", "_eventId_exhibitionGroup");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function editGroupExhibitionsSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "editGroupExhibitionsFromReview");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function removeGroupExhibitionsSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "removeGroupExhibitionsEdit");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


/*
function addCollectionsSubmit() {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "addCollections");
}
*/

function addCollectionsSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("name", "_eventId_collection");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function editCollectionsSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "editCollectionsFromReview");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function removeCollectionSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "removeCollectionEdit");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


/*
function addBibliographySubmit() {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "addBibliography");
}
*/

function addBibliographySubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("name", "_eventId_bibliography");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function editBibliographySubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "editBibliographyFromReview");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function removeBibliographySubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "removeBibliographyEdit");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


/*
function addEducationSubmit() {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "addEducation");
}
*/

function addEducationSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("name", "_eventId_education");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function editEducationSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "editEducationFromReview");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function removeEducationSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "removeEducationEdit");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function saveAndExitSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("name", "_eventId_saveAndExit");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

/*
function addAwardSubmit() {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "addAward");
}
*/

function addAwardSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("name", "_eventId_award");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function editAwardSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "editAwardFromReview");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function removeAwardSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "removeAwardEdit");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function reviewSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	//submitEvent.setAttribute("value", "addAndReview");
	submitEvent.setAttribute("name", "_eventId_review");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}

function editReviewSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	//submitEvent.setAttribute("value", "addAndReview");
	submitEvent.setAttribute("name", "_eventId_review");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function publishAllSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("name", "_eventId_publish");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function removeAllSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "removeAll");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}



function removeMediaOnReviewEventSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "removeMediaOnReview");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}



function addAndReviewSubmit() {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "addAndReview");
}



function addGenreMediumSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "addGenreMedium");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function addMediaFilesSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "addMediaFiles");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function addInformationSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "addInformation");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function workReviewSubmit(formToSubmit) {
	var submitEvent = document.getElementById("submitEvent");
	submitEvent.setAttribute("value", "workReview");
	var thisForm = document.getElementById(formToSubmit);
	thisForm.submit();
}


function removeNode(nodeId) {
	var node = document.getElementById(nodeId);
	var nodeParent = node.parentNode;
	nodeParent.removeChild(node);
}

function alertTest(message) {
	alert(message);
	
}


function showForm(n) {
	var base = n.parentNode.parentNode;
	var addLink;
	var form2;
	var form3;
	var base3;
	
	// list of div children
	var divkids = [];
    for(var i = 0; i < base.childNodes.length; i++) {
		if ( base.childNodes[i].nodeName == "DIV") {
			divkids.push(base.childNodes[i]);
		}
    }
	
	var baseId = base.getAttribute("id");
	if (baseId == null) {
		baseId = base.attributes['id'].nodeValue;
	}
	if (baseId == "form_base_2") {
		form2 = base.removeChild(divkids[1]);
		addLink = base.removeChild(divkids[0]);
		form2.style.position="relative";
		form2.style.top="0px";
		base.appendChild(form2);
		base3 = document.getElementById("form_base_3");
		form3 = document.getElementById("form_3");
		base3.insertBefore(addLink, form3);
	}
	
	if (baseId == "form_base_3") {
		form3 = base.removeChild(divkids[1]);
		addLink = base.removeChild(divkids[0]);
		form3.style.position="relative";
		form3.style.top="0px";
		base.appendChild(form3);
	}
	
}


function showFormId(idVar,n) {
	var base = document.getElementById(idVar);
	var addLink;
	var form2;
	var form3;
	var base3;
	
	// list of div children
	var divkids = [];
	 
	if (base != null) {    
	    for(var i = 0; i < base.childNodes.length; i++) {
			if ( base.childNodes[i].nodeName == "DIV") {
				divkids.push(base.childNodes[i]);
			}
	    }
	}
		
		var baseId = null;
		
		if (base != null) {
			baseId = base.getAttribute("id");
		}
		
		if (base != null && baseId == null && baseId != '') {
			baseId = base.attributes['id'].nodeValue;
		}
		
		if (base != null && baseId != null && baseId != '' && baseId == "form_base_2") {
			form2 = base.removeChild(divkids[0]);
			//form2 = base.removeChild(divkids[1]);
			//addLink = base.removeChild(divkids[0]);
			form2.style.position="relative";
			form2.style.top="0px";
			base.appendChild(form2);
			//base3 = document.getElementById("form_base_3");
			//form3 = document.getElementById("form_3");
			//base3.insertBefore(addLink, form3);
			var functionPayload = "showFormId('form_base_3',this);return false;";
			n.onclick  = new Function(functionPayload);
			
		}
		
		if (baseId != null && baseId == "form_base_3") {
			form3 = base.removeChild(divkids[0]);
			//addLink = base.removeChild(divkids[0]);
			form3.style.position="relative";
			form3.style.top="0px";
			base.appendChild(form3);
			var submitParent = n.parentNode;
			submitParent.removeChild(n);
		}
	//} else {
	//	alert('base == null');
	//	return;
	//}
}




function toggleShowFormId(idVar,n) {
	var base = document.getElementById(idVar);
	var addLink;
	var form2;
	var form3;
	var base3;
	
	// list of div children
	var divkids = [];
	 
	if (base != null) {    
	    for(var i = 0; i < base.childNodes.length; i++) {
			if ( base.childNodes[i].nodeName == "DIV") {
				divkids.push(base.childNodes[i]);
			}
	    }
	}
		
	var baseId = null;
	
	if (base != null) {
		baseId = base.getAttribute("id");
	}
	
	if (base != null && baseId == null && baseId != '') {
		baseId = base.attributes['id'].nodeValue;
	}
	
	if (base != null && baseId != null && baseId != '' && baseId == "form_base_2") {
		form2 = base.removeChild(divkids[0]);
		form2.style.position="relative";
		form2.style.top="0px";
		base.appendChild(form2);
	}
}


function toggleHideFormId(idVar,n) {
	// Nothing Yet...
	var base = document.getElementById(idVar);
	var addLink;
	var form2;
	var form3;
	var base3;
	
	// list of div children
	var divkids = [];
	 
	if (base != null) {    
	    for(var i = 0; i < base.childNodes.length; i++) {
			if ( base.childNodes[i].nodeName == "DIV") {
				divkids.push(base.childNodes[i]);
			}
	    }
	}
		
	var baseId = null;
	
	if (base != null) {
		baseId = base.getAttribute("id");
	}
	
	if (base != null && baseId == null && baseId != '') {
		baseId = base.attributes['id'].nodeValue;
	}
	
	if (base != null && baseId != null && baseId != '' && baseId == "form_base_2") {
		form2 = base.removeChild(divkids[0]);
		form2.style.position="absolute";
		form2.style.top="-3000px";
		base.appendChild(form2);
		
	}
}


function toggleShowOptElement(optElement) {
	optElement.style.position="relative";
	optElement.style.top="0px";

}



function toggleHideOptElement(optElement) {
	optElement.style.position="absolute";
	optElement.style.top="-3000px";
}


function toggleFormVisibility(idVar,n) {
	//alert('n.value == ' + n.value + ', n.type == ' + n.type);
	if (n.value == 'true') {
		n.value="false";
		//n.checked=false;
		//alert('SHOW');
		toggleShowFormId(idVar,n);
		
	} else {	
		//alert('HIDE');
		n.value="true";
		//n.checked=true;
		toggleHideFormId(idVar,n);
		
	}
	return true;
}



function toggleFormVisibilityByFileType(checkBoxId,optElementId,idVar,n) {
	
	var checkBox = document.getElementById(checkBoxId);
	var optElement = document.getElementById(optElementId);
	
	var reMov = /.+[.]mov$/i;
	var reM4v = /.+[.]m4v$/i;
	var re3gpp = /.+[.]3gp$/i;
	var reMp3 = /.+[.]mp3$/i;
	
	if (n.value.match(reMov) || n.value.match(reM4v) || n.value.match(re3gpp) || n.value.match(reMp3)) {
		checkBox.checked=false;
		toggleShowFormId(idVar,n);
		toggleHideOptElement(optElement);
	} else {
		checkBox.checked=true;
		toggleHideFormId(idVar,n);
		toggleShowOptElement(optElement);
	}
	
	/* REMOVED 20080922 - Original block
	if (n.value.match(reMov)) {
		checkBox.checked=false;
		toggleShowFormId(idVar,n);
		toggleHideOptElement(optElement);
	} else if (n.value.match(reMp3)) {
		checkBox.checked=false;
		toggleShowFormId(idVar,n);
		toggleHideOptElement(optElement);
	} else {
		checkBox.checked=true;
		toggleHideFormId(idVar,n);
		toggleShowOptElement(optElement);
	}
	*/
	

} 


function toggleSmallThumbFormVisibility(idVar,n) {
	//alert('n.value == ' + n.value + ', n.type == ' + n.type);
	var base = document.getElementById(idVar);
	if (n.value == 'yes') {
		n.value="";
		//n.checked=false;
		base.style.position="relative";
		base.style.top="0px";
		//base.style.marginBottom="20px";
		
	} else {	
		n.value="yes";
		//n.checked=true;
		base.style.position="absolute";
		base.style.top="-3000px";
		
	}
	return true;
}




function move(n,direction) {
	
	controlOut(n);

	// direction 1=up, 0=down
	//var LI = n.parentNode;
	var LI = n.parentNode.parentNode.parentNode;
	var ul = LI.parentNode;
	var ULKids = ul.childNodes;    
	var tempDivider;
	var tempCommand;
	var nextnode;
	
	//alert ('hit move 1');
		
	// Create an array of the LI node and it's siblings
	var likids = [];
    for(var i = 0; i < ULKids.length; i++) {
        
        //alert("ULKids[i].nodeName=" + ULKids[i].nodeName);
        
		if ( ULKids[i].nodeName == "LI") {
			likids.push(ULKids[i]);
		}
    }
	

	// Calculate the total live LI nodes
	var liveKidsCount = 0;
	for ( var i = 0; i < likids.length; i++ ) {
			
		var classAttribute = likids[i].lastChild.firstChild.getAttribute("class");
   		if (classAttribute == null) { // IE does not read some attributes properly, use variation below
   			classAttribute = likids[i].lastChild.firstChild.attributes['class'].nodeValue;
   		}
   		
		//if (classAttribute == "controller_live") {
		if (classAttribute == "active") {	
			liveKidsCount += 1;
		} 
	}
	
	
	// Next sort through list and match the selected LI node
	for ( var i = 0; i < likids.length; i++ ) {
		if ( likids[i] == LI) {
			
			var classAttribute = likids[i].lastChild.firstChild.getAttribute("class");
    		if (classAttribute == null) { // IE does not read some attributes properly, use variation below
    			classAttribute = likids[i].lastChild.firstChild.attributes['class'].nodeValue;
    		}
			
			for ( var j = 0; j < likids.length; j++ ) {
				ul.removeChild(likids[j]);
			}
			 
			if (direction == 1) { 
				//alert('move 1');
				nextnode = likids[i-1];
				likids[i-1] = LI;

				// second to top, remove "up"
				if (i == 1) {
					
					tempDivider = LI.lastChild.firstChild.removeChild(n.previousSibling); // remove divider
					LI.lastChild.firstChild.removeChild(n); // remove "up"
					//tempCommand = generateNodeFromClone(nextnode, "up");
					tempCommand = generateNodeFromClone(nextnode, upVal);
					nextnode.lastChild.firstChild.insertBefore(tempDivider, nextnode.lastChild.firstChild.lastChild.previousSibling); // add removed divider to next LI
					nextnode.lastChild.firstChild.insertBefore(tempCommand, nextnode.lastChild.firstChild.lastChild.previousSibling); // add removed "up" to next LI
				}
				
				if (i + 1 == liveKidsCount) {
					nextnode.lastChild.firstChild.removeChild(nextnode.lastChild.firstChild.lastChild); // remove "down"
					//tempCommand = generateNodeFromClone(LI, "down");
					tempCommand = generateNodeFromClone(LI, downVal);
					tempDivider = nextnode.lastChild.firstChild.removeChild(nextnode.lastChild.firstChild.lastChild); // remove divider
					LI.lastChild.firstChild.appendChild(tempDivider); // add removed divider to next LI
					LI.lastChild.firstChild.appendChild(tempCommand); // add removed "down"
				}
				
			} else {
			//	alert('move -1');
				nextnode = likids[i+1];
				likids[i+1] = LI;
				
				// second to last, remove "down"
				//if (i + 2 == likids.length) {
				if (i + 2 == liveKidsCount) {
					
					tempDivider = LI.lastChild.firstChild.removeChild(n.previousSibling); // remove divider
					LI.lastChild.firstChild.removeChild(n); // remove "down"
					//tempCommand = generateNodeFromClone(nextnode, "down");
					tempCommand = generateNodeFromClone(nextnode, downVal);
					nextnode.lastChild.firstChild.appendChild(tempDivider);
					nextnode.lastChild.firstChild.appendChild(tempCommand);
				}
				
				// top element, swap "down" from element moving up
				//if (i == 0 && likids.length == 2) {
				if (i == 0 && liveKidsCount == 2) {
					nextnode.lastChild.firstChild.removeChild(nextnode.lastChild.firstChild.lastChild.previousSibling.previousSibling); // remove "up" transfer to lower elements
					//tempCommand = generateNodeFromClone(LI, "up");
					tempCommand = generateNodeFromClone(LI, upVal);
					tempDivider = nextnode.lastChild.firstChild.removeChild(nextnode.lastChild.firstChild.lastChild.previousSibling.previousSibling); // remove divider
					LI.lastChild.firstChild.appendChild(tempDivider); // add removed divider to next LI
					LI.lastChild.firstChild.appendChild(tempCommand); // add removed "down"
				}
				
				//if (i == 0 && likids.length > 2) {
				if (i == 0 && liveKidsCount > 2) {
					nextnode.lastChild.firstChild.removeChild(nextnode.lastChild.firstChild.lastChild.previousSibling.previousSibling); // remove "up" transfer to lower elements
					tempDivider = nextnode.lastChild.firstChild.removeChild(nextnode.lastChild.firstChild.lastChild.previousSibling.previousSibling); // remove divider
					//tempCommand = generateNodeFromClone(LI, "up");
					tempCommand = generateNodeFromClone(LI, upVal);
					LI.lastChild.firstChild.insertBefore(tempDivider, LI.lastChild.firstChild.lastChild.previousSibling);
					LI.lastChild.firstChild.insertBefore(tempCommand, LI.lastChild.firstChild.lastChild.previousSibling)
				}
			}
			
			likids[i] = nextnode;
			for ( var j = 0; j < likids.length; j++ ) {
				ul.appendChild(likids[j]);
			}
			
			break;
		}
	}
	
	return false;  // 'return false' for Safari onClick action
}

// 20090930 ORIGINAL SIGNATURE
//function remove(n) {
function remove(n, target) {	
	// Needs to swap out controller tags as if moving to bottom with whatever the 
	
	controlOut(n);

	var LI = n.parentNode.parentNode.parentNode;
	var ul = LI.parentNode;
	var ULKids = ul.childNodes;   
	var removedLI = ul.removeChild(LI);
	var removedElementFound = false;
	
	
	
	// Find all direct anchors of LI and alter their style
	// Create an array of the LI node's children
	var liChildren = LI.childNodes;
	
	for (var i = 0; i < liChildren.length; i++) {
		if (liChildren[i].nodeName == "A") {
			liChildren[i].style.color="#8cb3e0";
		}
	}
	
	// Create an array of the LI node and it's siblings
	var likids = [];
    for(var i = 0; i < ULKids.length; i++) {
        
        
		if ( ULKids[i].nodeName == "LI") {
			likids.push(ULKids[i]);
		}
    }
    
    // Insert newly removed item before the first already removed item
    for (var j = 0; j < likids.length; j++) {
    	var classAttribute = likids[j].lastChild.firstChild.getAttribute("class");
    	if (classAttribute == null) { // IE does not read some attributes properly, use variation below
    		classAttribute = likids[j].lastChild.firstChild.attributes['class'].nodeValue;
    	}
    	
    	var currNode = likids[j].lastChild.firstChild;
    			
    	if (classAttribute == "remove") {
    		removedElementFound = true;
    	} else {
    		removedElementFound = false;
    	}

    	if (removedElementFound == true) { // Add 
    		ul.insertBefore(removedLI,likids[j]);
    		
    		// Then look for "down" control on the previous LI sibling's previous sibling
    		if (j > 0) {
	    		var lastActiveNode = likids[j-1];
	    		var firstActiveNode = likids[0];
    		
    			// If present, remove
    			// if (lastActiveNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "down") {
    			if (lastActiveNode.lastChild.firstChild.lastChild.firstChild.nodeValue == downVal) {
    				//alert('Matched Down, now remove');
    				lastActiveNode.lastChild.firstChild.removeChild(lastActiveNode.lastChild.firstChild.lastChild);
    				lastActiveNode.lastChild.firstChild.removeChild(lastActiveNode.lastChild.firstChild.lastChild);
    			}
    			
    			// if (firstActiveNode.lastChild.firstChild.lastChild.previousSibling.previousSibling.firstChild.nodeValue == "up") {
    			if (firstActiveNode.lastChild.firstChild.lastChild.previousSibling.previousSibling.firstChild.nodeValue == upVal) {	
    				//alert('Match Up for first element, now remove');
    				firstActiveNode.lastChild.firstChild.removeChild(firstActiveNode.lastChild.firstChild.lastChild.previousSibling.previousSibling);
    				firstActiveNode.lastChild.firstChild.removeChild(firstActiveNode.lastChild.firstChild.lastChild.previousSibling.previousSibling);
    			}
    			
		 		//if (firstActiveNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "up") {
		 		if (firstActiveNode.lastChild.firstChild.lastChild.firstChild.nodeValue == upVal) {
					//alert('Match Up for first element, now remove');
					firstActiveNode.lastChild.firstChild.removeChild(firstActiveNode.lastChild.firstChild.lastChild);
					firstActiveNode.lastChild.firstChild.removeChild(firstActiveNode.lastChild.firstChild.lastChild);
				}
    		}
    		
    		break;
    	}
    	
    }
    
    // If one does not already exist, add to bottom of list
    if (removedElementFound == false) {
    	ul.appendChild(removedLI);
    	
    	var lastActiveNode = likids[likids.length - 1];
    	var firstActiveNode = likids[0];
    	
    	if (likids.length > 0) {
	    	// If present, remove
			//if (lastActiveNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "down") {
			if (lastActiveNode.lastChild.firstChild.lastChild.firstChild.nodeValue == downVal) {
				lastActiveNode.lastChild.firstChild.removeChild(lastActiveNode.lastChild.firstChild.lastChild);
				lastActiveNode.lastChild.firstChild.removeChild(lastActiveNode.lastChild.firstChild.lastChild);
			}
			
			//if (firstActiveNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "up") {
			if (firstActiveNode.lastChild.firstChild.lastChild.firstChild.nodeValue == upVal) {
				firstActiveNode.lastChild.firstChild.removeChild(firstActiveNode.lastChild.firstChild.lastChild);
				firstActiveNode.lastChild.firstChild.removeChild(firstActiveNode.lastChild.firstChild.lastChild);
			}
			
			//if (firstActiveNode.lastChild.firstChild.lastChild.previousSibling.previousSibling.firstChild.nodeValue == "up") {
			if (firstActiveNode.lastChild.firstChild.lastChild.previousSibling.previousSibling.firstChild.nodeValue == upVal) {
				firstActiveNode.lastChild.firstChild.removeChild(firstActiveNode.lastChild.firstChild.lastChild.previousSibling.previousSibling);
				firstActiveNode.lastChild.firstChild.removeChild(firstActiveNode.lastChild.firstChild.lastChild.previousSibling.previousSibling);
			}
 		}
    }
    
	n.parentNode.parentNode.parentNode.style.color="#aaaaaa";
	n.parentNode.parentNode.parentNode.style.backgroundColor="#eaeaea";
	n.parentNode.style.postion="absolute";
	n.parentNode.style.top="-4000px";
	
	n.parentNode.nextSibling.style.position="relative";
	n.parentNode.nextSibling.style.top="0px";
	var controllersParent = n.parentNode.parentNode;
	var liveControllers = controllersParent.removeChild(n.parentNode);

	controllersParent.appendChild(liveControllers);
	
	LINodes = n.parentNode.childNodes;
	var msg;
	
	// find if first element in list is in the "removed" state, if so, also grey out the related year for the group as all items are slated for deletion
	
	var firstElementClassAttribute;
	
	if (likids[0] != null) {
		firstElementClassAttribute = likids[0].lastChild.firstChild.getAttribute("class");
	   	if (firstElementClassAttribute == null) { // IE does not read some attributes properly, use variation below
	    	firstElementClassAttribute = likids[0].lastChild.firstChild.attributes['class'].nodeValue;
	    }
	} else { // This item in a one element list, short circuit the behavior

		firstElementClassAttribute  =  "remove";
	}
   	
	if (firstElementClassAttribute == "remove" && ul.parentNode.previousSibling != null) {
		if (ul.parentNode.previousSibling.nodeName == '#text') {
			// if (ul.parentNode.previousSibling.previousSibling.firstChild.nodeName != '#text') {
			if (ul.parentNode.previousSibling.previousSibling != null && ul.parentNode.previousSibling.previousSibling.firstChild.nodeName != '#text') {
				ul.parentNode.previousSibling.previousSibling.firstChild.style.color="#aaaaaa";
				ul.parentNode.previousSibling.previousSibling.firstChild.style.backgroundColor="#eaeaea";
			}
		} else if (ul.parentNode.previousSibling.firstChild.nodeName != '#text') {
			ul.parentNode.previousSibling.firstChild.style.color="#aaaaaa";
			ul.parentNode.previousSibling.firstChild.style.backgroundColor="#eaeaea";
		} else {
			ul.parentNode.previousSibling.previousSibling.firstChild.style.color="#aaaaaa";
			ul.parentNode.previousSibling.previousSibling.firstChild.style.backgroundColor="#eaeaea";
		}
	}
	
	updateLeftNavCount(-1, target);
	
}



function keep(n, target) {
	
	controlOut(n);
	
	var LI = n.parentNode.parentNode.parentNode;
	var ul = LI.parentNode;
	var ULKids = ul.childNodes;    
	var tempDivider;
	var tempCommand;
	var nextnode;
	
	// Find all direct anchors of LI and alter their style
	// Create an array of the LI node's children
	var liChildren = LI.childNodes;
	
	for (var i = 0; i < liChildren.length; i++) {
		if (liChildren[i].nodeName == "A") {
			liChildren[i].style.color="#0156af";
			
		}
	}
		
	// Create an array of the LI node and it's siblings
	var likids = [];
    for(var i = 0; i < ULKids.length; i++) {
        
        //alert("ULKids[i].nodeName=" + ULKids[i].nodeName);
        
		if ( ULKids[i].nodeName == "LI") {
			likids.push(ULKids[i]);
		}
    }

	n.parentNode.parentNode.parentNode.style.color="#292929";
	n.parentNode.parentNode.parentNode.style.backgroundColor="#ffffff";
	n.parentNode.style.postion="absolute";
	n.parentNode.style.top="-4000px";
	
	n.parentNode.nextSibling.style.position="relative";
	n.parentNode.nextSibling.style.top="0px";
	
	//Also change the style of related year for group back to active as it may have been set to "remove"
	
	if (ul.parentNode.previousSibling != null && ul.parentNode.previousSibling.nodeName == '#text') {
		//if (ul.parentNode.previousSibling.previousSibling.firstChild.nodeName != '#text') {
		if (ul.parentNode.previousSibling.previousSibling != null && ul.parentNode.previousSibling.previousSibling.firstChild.nodeName != '#text') {
			ul.parentNode.previousSibling.previousSibling.firstChild.style.color="#292929";
			ul.parentNode.previousSibling.previousSibling.firstChild.style.backgroundColor="#ffffff";
		}
	} else if (ul.parentNode.previousSibling != null && ul.parentNode.previousSibling.firstChild.nodeName != '#text') {
		ul.parentNode.previousSibling.firstChild.style.color="#292929";
		ul.parentNode.previousSibling.firstChild.style.backgroundColor="#ffffff";
	} else {
		if (ul.parentNode.previousSibling != null) {
			ul.parentNode.previousSibling.previousSibling.firstChild.style.color="#292929";
			ul.parentNode.previousSibling.previousSibling.firstChild.style.borderColor="#ffffff";
		}
	}
	
	var controllersParent = n.parentNode.parentNode;
	var removeControllers = controllersParent.removeChild(n.parentNode);
	
	controllersParent.appendChild(removeControllers);
	
	var childZero = controllersParent.childNodes[0];
	
	// Calculate the total live LI nodes
	var liveKidsCount = 0;
	for ( var i = 0; i < likids.length; i++ ) {
			
		var classAttribute = likids[i].lastChild.firstChild.getAttribute("class");
   		if (classAttribute == null) { // IE does not read some attributes properly, use variation below
   			classAttribute = likids[i].lastChild.firstChild.attributes['class'].nodeValue;
   		}
		
		if (classAttribute == "active") {
			liveKidsCount += 1;
			//alert('INSIDE: controller live: liveKidsCount=' + liveKidsCount);
		} 
	}
	
	// Add new Kept item at end of "live" list
	
	var removedNode = ul.removeChild(LI);
	
	var testKids = likids[liveKidsCount - 1];
	testKids = likids[liveKidsCount];
	
	if (liveKidsCount > 1) {
		insertAfter(removedNode, likids[liveKidsCount - 2]);
	
	} else if (likids.length == 1) { // Single item, and all in "removed" state
		ul.appendChild(removedNode);
		
	} else if (liveKidsCount == 1) { // All Items currently removed, add to top of list
		ul.insertBefore(removedNode, ul.childNodes[0]);
	}
	
	var precedingNode = likids[liveKidsCount - 2];
	if (precedingNode == null) {
		precedingNode = likids[liveKidsCount - 1];
	}
	
	var nodesParent = precedingNode.parentNode;
	
	//var cgrp = likids[i].lastChild.firstChild.getAttribute("class");
	if (classAttribute == null) { // IE does not read some attributes properly, use variation below
		classAttribute = likids[i].lastChild.firstChild.attributes['class'].nodeValue;
	}
	
	// Will need to be smart about item position and whether to display 
	
	// If item is first and only item, do not display "up" or "down" controllers
	if (nodesParent.firstChild == removedNode) {
		//if (removedNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "down") {
		if (removedNode.lastChild.firstChild.lastChild.firstChild.nodeValue == downVal) {
			removedNode.lastChild.firstChild.removeChild(removedNode.lastChild.firstChild.lastChild);
			removedNode.lastChild.firstChild.removeChild(removedNode.lastChild.firstChild.lastChild);
		}
		
		//if (removedNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "up") {
		if (removedNode.lastChild.firstChild.lastChild.firstChild.nodeValue == downVal) {
			removedNode.lastChild.firstChild.removeChild(removedNode.lastChild.firstChild.lastChild);
			removedNode.lastChild.firstChild.removeChild(removedNode.lastChild.firstChild.lastChild);
		}
	}
	
	// If item is second from the top and part of a two item list, make sure top item has "down" controller and second item has up
	if (liveKidsCount == 2) {
		
		var downNode;
		var downDivider;
		var upNode;
		var upDivider;
		
		downNode = removedNode.lastChild.firstChild.lastChild.cloneNode(true);
		//downNode.firstChild.nodeValue = "down";
		downNode.firstChild.nodeValue = downVal;
		var cid = precedingNode.lastChild.firstChild.getAttribute("cid");
		var cgrp = precedingNode.lastChild.firstChild.getAttribute("cgrp");
		var functionPayload = "move(this,0);addInfo('" + cgrp + "','" + cid + "_1');return false;";
		downNode.onclick  = new Function(functionPayload);
		downDivider = removedNode.lastChild.firstChild.firstChild.nextSibling.cloneNode(true);
		
		// Attach "down" controller to top element
		precedingNode.lastChild.firstChild.appendChild(downDivider);
		precedingNode.lastChild.firstChild.appendChild(downNode);
		
		// If ends in "down" remove this controller
		//if (removedNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "down") {
		if (removedNode.lastChild.firstChild.lastChild.firstChild.nodeValue == downVal) {
			removedNode.lastChild.firstChild.removeChild(removedNode.lastChild.firstChild.lastChild);  // remove "down"
			removedNode.lastChild.firstChild.removeChild(removedNode.lastChild.firstChild.lastChild);  // remove related divider
		}
		
		// If ends in "remove" add "up" controller
		if (removedNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "remove") {
			//upNode = generateNodeFromClone(removedNode, "up");
			upNode = generateNodeFromClone(removedNode, upVal);
			upDivider = removedNode.lastChild.firstChild.firstChild.nextSibling.cloneNode(true);
			
			// Attach "up" controller to last element
			removedNode.lastChild.firstChild.appendChild(upDivider);
			removedNode.lastChild.firstChild.appendChild(upNode);
		}
		
	}
	
	// if element is in a group greater than 3 and is in last position, make sure it has an "up" controller and no "down" controller
	if (liveKidsCount > 2) {
		
		//if (removedNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "down") {
		if (removedNode.lastChild.firstChild.lastChild.firstChild.nodeValue == downVal) {
			removedNode.lastChild.firstChild.removeChild(removedNode.lastChild.firstChild.lastChild); // remove "down"
			removedNode.lastChild.firstChild.removeChild(removedNode.lastChild.firstChild.lastChild); // remove related divider
		}
		
		if (removedNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "remove") {
			//upNode = generateNodeFromClone(removedNode, "up");
			upNode = generateNodeFromClone(removedNode, upVal);
			upDivider = removedNode.lastChild.firstChild.firstChild.nextSibling.cloneNode(true);
			
			// Attach "up" controller to last element
			removedNode.lastChild.firstChild.appendChild(upDivider);
			removedNode.lastChild.firstChild.appendChild(upNode);
		}
		
		// Also make sure that preceding node has both "up" and "down" controllers in that order, if not add
		
		if (precedingNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "remove") { 
			//upNode = generateNodeFromClone(precedingNode, "up");
			upNode = generateNodeFromClone(precedingNode, upVal);
			upDivider = precedingNode.lastChild.firstChild.firstChild.nextSibling.cloneNode(true);
			
			// Attach "up" controller to last element
			precedingNode.lastChild.firstChild.appendChild(upDivider);
			precedingNode.lastChild.firstChild.appendChild(upNode);
		}
		
		
		//if (precedingNode.lastChild.firstChild.lastChild.firstChild.nodeValue == "up") { 
		if (precedingNode.lastChild.firstChild.lastChild.firstChild.nodeValue == upVal) { 
			//downNode = generateNodeFromClone(precedingNode, "down");
			downNode = generateNodeFromClone(precedingNode, downVal);
			downDivider = precedingNode.lastChild.firstChild.firstChild.nextSibling.cloneNode(true);
			
			// Attach "down" controller to last element
			precedingNode.lastChild.firstChild.appendChild(downDivider);
			precedingNode.lastChild.firstChild.appendChild(downNode);
		}
		  
	}
	
	updateLeftNavCount(1, target);
}
	
	
	
function generateNodeFromClone(hostNode, direction) {
	// valid direction values are "up" and "down"
	var controllerCloneNode = hostNode.lastChild.firstChild.lastChild.cloneNode(true);
	controllerCloneNode.firstChild.nodeValue = direction;
	var cid = hostNode.lastChild.firstChild.getAttribute("cid");
	var cgrp = hostNode.lastChild.firstChild.getAttribute("cgrp");
	var moveValue = 1; // Default value for "up"
	var addInfoValue = -1;  // Default value for "up"s
	//if (direction == 'down') {
	if (direction == downVal) {	
		moveValue = 0;
		addInfoValue = 1;
	} 
	
	var functionPayload = "move(this," + moveValue + ");addInfo('" + cgrp + "','" + cid + "_" + addInfoValue + "');return false;";
	controllerCloneNode.onclick  = new Function(functionPayload);
	return controllerCloneNode;
}	


function generateMediaControlFromClone(hostNode, direction) {
	var controllerCloneNode = hostNode.cloneNode(true);
	controller;
}
	
	
function moveImg(n,direction) {
	
	var currUnit = n.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;

	var allMediaUnits = document.getElementById("allMediaUnits");
	
	var allMediaUnitsChildrenRaw = allMediaUnits.childNodes;
	var allMediaUnitsChildren = [];
	
	for (i = 0; i < allMediaUnitsChildrenRaw.length; i++) {
		if (allMediaUnitsChildrenRaw[i].nodeName == "DIV") {
			allMediaUnitsChildren.push(allMediaUnitsChildrenRaw[i]);
		}
	}
	
	var nextNode;
	var swapNode;
	var previousNode;
	var followingNode;
	
	//Next sort through list and match the selected DIV node
	for (i = 0; i < allMediaUnitsChildren.length; i++) {
	
		if (allMediaUnitsChildren[i] == currUnit) {
			//alert('Hit Match');
			
			if (direction == "right") {
				nextNode = allMediaUnitsChildren[i + 1];
				allMediaUnits.removeChild(currUnit);
				insertAfter(currUnit,nextNode);
				setControls();
				
			} else if (direction == "left") {
				nextNode = allMediaUnitsChildren[i - 1];
				allMediaUnits.removeChild(currUnit);
				allMediaUnits.insertBefore(currUnit,nextNode);
				setControls();
				
			} else if (direction == "up") {
				nextNode = allMediaUnitsChildren[i - 3];
				swapNode = allMediaUnitsChildren[i - 4];
				previousNode = allMediaUnitsChildren[i - 1];
				allMediaUnits.removeChild(swapNode);
				allMediaUnits.removeChild(currUnit);
				allMediaUnits.insertBefore(currUnit,nextNode);
				insertAfter(swapNode,previousNode);
				setControls();
			
			} else if (direction == "down") {
				nextNode = allMediaUnitsChildren[i + 3];
				swapNode = allMediaUnitsChildren[i + 4];
				followingNode = allMediaUnitsChildren[i + 1];
				allMediaUnits.removeChild(swapNode);
				allMediaUnits.removeChild(currUnit);
				allMediaUnits.insertBefore(swapNode,followingNode);
				insertAfter(currUnit,nextNode);
				setControls();
					
			}
		}
	}
	
	return false;	
	
}

	
function grabController(mediaUnit, controller) {

	var table = mediaUnit.firstChild.lastChild.firstChild;

	var tr_1;
	if (table.firstChild.nodeName == "TBODY") {  // IE variation in Table
		tr_1 = table.firstChild.firstChild;
	} else {
		tr_1 = table.firstChild.nextSibling.firstChild;
	}
	var tr_2 = tr_1.nextSibling;
	var tr_3 = tr_2.nextSibling;
	
	
	// Correct TRs for FF/OSX
	if (tr_2.nodeName != "TR") {
		tr_2 = tr_1.nextSibling.nextSibling;
		tr_3 = tr_2.nextSibling.nextSibling;
	}
	
	var isFF = false;
	var td_right_test = tr_2.lastChild;
	if (td_right_test.nodeName != "TD") {
		isFF = true;
	}

	if (controller == 'left') {
		//alert('LEFT: grabController=' + controller);
		var td_left = tr_2.firstChild;
		if (isFF) {
			td_left = tr_2.firstChild.nextSibling;
		}
		return td_left.removeChild(td_left.firstChild);
	
	} else if (controller == 'right') {
		//alert('RIGHT: grabController=' + controller);
		var td_right = tr_2.lastChild;
		if (isFF) {
			td_right = tr_2.lastChild.previousSibling;	
		}
		return td_right.removeChild(td_right.firstChild);
		
	} else if (controller == 'up') {
		//alert('UP: grabController=' + controller);
		var td_up = tr_1.firstChild.nextSibling;
		//alert('[1] grabController()/UP:td_up.nodeName=' + td_up.nodeName);
		if (isFF) {
			td_up = tr_1.firstChild.nextSibling.nextSibling.nextSibling;	
			//alert('[2] grabController()/UP:td_up.nodeName=' + td_up.nodeName);
		}
		return td_up.removeChild(td_up.firstChild);
		
	} else if (controller == 'down') {
		//alert('DOWN: grabController=' + controller);
		var td_down = tr_3.firstChild.nextSibling;
		if (isFF) {
			td_down = tr_3.firstChild.nextSibling.nextSibling.nextSibling;	
		}
		return td_down.removeChild(td_down.firstChild);
	}
}


function placeController(mediaUnit, controllerNode, position) {

	var table = mediaUnit.firstChild.lastChild.firstChild;
	var cid = mediaUnit.getAttribute("cid");

	var tr_1;
	if (table.firstChild.nodeName == "TBODY") {  // IE variation in Table
		tr_1 = table.firstChild.firstChild;
	} else {
		tr_1 = table.firstChild.nextSibling.firstChild;
	}
	var tr_2 = tr_1.nextSibling;
	var tr_3 = tr_2.nextSibling;
	
	
	// Correct TRs for FF/OSX
	if (tr_2.nodeName != "TR") {
		tr_2 = tr_1.nextSibling.nextSibling;
		tr_3 = tr_2.nextSibling.nextSibling;
	}
	
	var isFF = false;
	var td_right_test = tr_2.lastChild;
	if (td_right_test.nodeName != "TD") {
		isFF = true;
	}

	if (position == 'left') {
		//alert('LEFT: grabController=' + controller);
		var td_left = tr_2.firstChild;
		if (isFF) {
			td_left = tr_2.firstChild.nextSibling;
		}
		return td_left.appendChild(controllerNode);
		
		
	
	} else if (position == 'right') {
		//alert('RIGHT: grabController=' + controller);
		var td_right = tr_2.lastChild;
		if (isFF) {
			td_right = tr_2.lastChild.previousSibling;	
		}
		return td_right.appendChild(controllerNode);
		
		
		
	} else if (position == 'up') {
		//alert('UP: grabController=' + controller);
		var td_up = tr_1.firstChild.nextSibling;
		//alert('[1] grabController()/UP:td_up.nodeName=' + td_up.nodeName);
		if (isFF) {
			td_up = tr_1.firstChild.nextSibling.nextSibling.nextSibling;	
			//alert('[2] grabController()/UP:td_up.nodeName=' + td_up.nodeName);
		}
		return td_up.appendChild(controllerNode);
		
		
		
	} else if (position == 'down') {
		//alert('DOWN: grabController=' + controller);
		var td_down = tr_3.firstChild.nextSibling;
		if (isFF) {
			td_down = tr_3.firstChild.nextSibling.nextSibling.nextSibling;	
		}
		return td_down.appendChild(controllerNode);
	}
	

}


	
	// 20091029 REMOVE BEFORE LAUNCH - ALL EDITING DONE IN FLEX - NOT USING THIS CODE
	
	function setControls() {
	
	////////// BEGIN IMAGE BASED CONTROLLERS FOR SMALL THUMBNAILS ////////// 
	
	var allMediaUnits = document.getElementById("allMediaUnits");
	var imageUnitChildren = [];
	if (allMediaUnits != null) {
		
		var allMediaUnitsChildren = allMediaUnits.childNodes;
		
		var activeController = null;
		
		for (i = 0; i < allMediaUnitsChildren.length; i++) {
			
			
			if (allMediaUnitsChildren[i].nodeName == "DIV") {
				// If 'imageController' then add to collection, otherwise ignore
			
				activeController = allMediaUnitsChildren[i].firstChild.lastChild.getAttribute("class");
				
				if (activeController == null && allMediaUnitsChildren[i] != null && allMediaUnitsChildren[i].firstChild != null && allMediaUnitsChildren[i].firstChild.lastChild != null) {
					activeController = allMediaUnitsChildren[i].firstChild.lastChild.attributes['class'].nodeValue;
				}
			
				if (activeController == "imageController") {
				
					imageUnitChildren.push(allMediaUnitsChildren[i]);
				
				}
			}
			
			
		}
		
		
		for (j = 0; j < imageUnitChildren.length; j++) {
			
			var currUnit = imageUnitChildren[j];
			
			
			var k = j + 1;
			var modVal = k % 4;
			
			
			var table = currUnit.firstChild.lastChild.firstChild;
			
			var tr_1;
			if (table.firstChild.nodeName == "TBODY") {  // IE variation in Table
				tr_1 = table.firstChild.firstChild;
			} else {
				tr_1 = table.firstChild.nextSibling.firstChild;
			}
			var tr_2 = tr_1.nextSibling;
			var tr_3 = tr_2.nextSibling;
			
			
			// Correct TRs for FF/OSX
			if (tr_2.nodeName != "TR") {
				tr_2 = tr_1.nextSibling.nextSibling;
				tr_3 = tr_2.nextSibling.nextSibling;
			}
			
			
			var td_top = tr_1.firstChild.nextSibling;
			var td_right = tr_2.lastChild;
			var td_bottom = tr_3.firstChild.nextSibling;
			var td_left = tr_2.firstChild;
			
			// Correct 'td_xxx's for FF/OSX
			if (td_right.nodeName != "TD") {
				td_top = tr_1.firstChild.nextSibling.nextSibling.nextSibling;
				td_right = tr_2.lastChild.previousSibling;
				td_bottom = tr_3.firstChild.nextSibling.nextSibling.nextSibling;
				td_left = tr_2.firstChild.nextSibling;
				
			}
			
			
			// Reset all controllers to 'blank'
			var blankTopController = blankController("up");
			td_top.removeChild(td_top.firstChild);
			td_top.appendChild(blankTopController);
			
			var blankRightController = blankController("right");
			td_right.removeChild(td_right.firstChild);
			td_right.appendChild(blankRightController);
			
			var blankBottomController = blankController("down");
			td_bottom.removeChild(td_bottom.firstChild);
			td_bottom.appendChild(blankBottomController);
			
			var blankLeftController = blankController("left");
			td_left.removeChild(td_left.firstChild);
			td_left.appendChild(blankLeftController);
			
			
			
			// Up Controller (12 o'clock)	
			if (k / 4 > 1) {
				var topController = createController("up");
				td_top.removeChild(td_top.firstChild);
				td_top.appendChild(topController);
			}	
				
			// Right Controller (3 o'clock)	
			if (modVal > 0 
				&& k != imageUnitChildren.length) {
					var rightController = createController("right");
					td_right.removeChild(td_right.firstChild);
					td_right.appendChild(rightController);
			}
			
			// Down Controller (6 o'clock)
			if (imageUnitChildren.length >= (k + 4)) {
					var bottomController = createController("down");
					td_bottom.removeChild(td_bottom.firstChild);
					td_bottom.appendChild(bottomController);
			}
			
			// Left Controller (9 o'clock)
			if (modVal > 1 
				|| modVal == 0) {
					var leftController = createController("left");
					td_left.removeChild(td_left.firstChild);
					td_left.appendChild(leftController);
			}
				
		}
		
	}
	
	
	
	
	function createController(direction) {
		// direction values ['right','left','up','down']	
		var controller = document.createElement("a");
		var controllerDir = "";
		controller.setAttribute("href","#");
		var controllerImg = document.createElement("img");
		controllerImg.setAttribute("border","0");
		if (direction == "right") {
			controllerImg.setAttribute("src","/web/images/nav/image_controls/img_nav_r_off.png");
			controllerImg.setAttribute("height","50");
			controllerImg.setAttribute("width","30");
			var functionMoveImg = "addMediaInfo(this, 'mediaFileOrder','_R');moveImg(this,'right');return false;";
			controller.onclick = new Function(functionMoveImg);
			
			///culturehall/web/images/nav/image_controls/img_nav_r_off.png
			controllerDir = "r";
		}
		
		if (direction == "left") {
			controllerImg.setAttribute("src","/web/images/nav/image_controls/img_nav_l_off.png");
			controllerImg.setAttribute("height","50");
			controllerImg.setAttribute("width","30");
			var functionMoveImg = "addMediaInfo(this, 'mediaFileOrder','_L');moveImg(this,'left');return false;";
			controller.onclick = new Function(functionMoveImg);
			controllerDir = "l";
		}
		
		if (direction == "up") {
			controllerImg.setAttribute("src","/web/images/nav/image_controls/img_nav_u_off.png");
			controllerImg.setAttribute("height","30");
			controllerImg.setAttribute("width","50");
			var functionMoveImg = "addMediaInfo(this, 'mediaFileOrder','_U');moveImg(this,'up');return false;";
			controller.onclick = new Function(functionMoveImg);
			controllerDir = "u";
		}
		
		if (direction == "down") {
			controllerImg.setAttribute("src","/web/images/nav/image_controls/img_nav_d_off.png");
			controllerImg.setAttribute("height","30");
			controllerImg.setAttribute("width","50");
			var functionMoveImg = "addMediaInfo(this, 'mediaFileOrder','_D');moveImg(this,'down');return false;";
			controller.onclick = new Function(functionMoveImg);
			controllerDir = "d";
		}
		
		controller.appendChild(controllerImg);
		//var functionKeepImageControls = "keepImageControls(this);this.firstChild.src='/culturehall/web/images/nav/image_controls/img_nav_" + controllerDir + "_off.png);";
		var functionKeepImageControls = "keepImageControls(this);";
		//var functionDeactivateImageControls = "deactivateImageControls(this);swapController(this,img_nav_" + controllerDir + "_off);";
		var functionDeactivateImageControls = "deactivateImageControls(this);";
		controller.onmouseover = new Function(functionKeepImageControls);
		controller.onmouseout = new Function(functionDeactivateImageControls);
		
		//onmouseover="this.src='/culturehall/web/images/nav/image_controls/img_nav_e_on.png;'" onmouseout="this.src='/culturehall/web/images/nav/image_controls/img_nav_e_off.png;'" 
		var functionSwapOn = "this.src='/web/images/nav/image_controls/img_nav_" + controllerDir + "_on.png;'"
		controllerImg.onmouseover = new Function(functionSwapOn);
		var functionSwapOff = "this.src='/web/images/nav/image_controls/img_nav_" + controllerDir + "_off.png;'"
		controllerImg.onmouseout = new Function(functionSwapOff);
		
		return controller;
		
		/* Code for adding function
		var functionPayload = "move(this," + moveValue + ");addInfo('" + cgrp + "','" + cid + "_" + addInfoValue + "');return false;";
		controllerCloneNode.onclick  = new Function(functionPayload);
		*/
		
		/* Sample of working controller HTML
		<a href="#" onmouseover="keepImageControls(this);" onmouseout="deactivateImageControls(this);"><img src="/web/images/nav/image_controls/top_bottom.png" height="30" width="50" border="0"/></a>
		*/
		
	}
	
	
	
	function blankController(direction) {
		
		var controllerImg = document.createElement("img");
		controllerImg.setAttribute("border","0");
		controllerImg.setAttribute("src","/web/images/nav/image_controls/spacer.png");
		var functionKeepImageControls = "keepImageControls(this);";
		controllerImg.onmouseover = new Function(functionKeepImageControls);
		var functionDeactivateImageControls = "deactivateImageControls(this);";
		controllerImg.onmouseout = new Function(functionDeactivateImageControls);
		
		
		if (direction == "right") {
			controllerImg.setAttribute("height","50");
			controllerImg.setAttribute("width","30");
		}
		
		if (direction == "left") {
			controllerImg.setAttribute("height","50");
			controllerImg.setAttribute("width","30");
		}
		
		if (direction == "up") {
			controllerImg.setAttribute("height","30");
			controllerImg.setAttribute("width","50");
		}
		
		if (direction == "down") {
			controllerImg.setAttribute("height","30");
			controllerImg.setAttribute("width","50");
		}
		
		return controllerImg;
		
		
	}

	
	
	
	////////// END IMAGE BASED CONTROLLERS FOR SMALL THUMBNAILS //////////
	
	
	////////// BEGIN LIST CONTROLLERS FOR YEAR BASED LISTS //////////
	
	var alluls = document.getElementsByTagName("ul");
	var biouls = [];
	//var ulclass;
	//var bioULKids = [];
	//var bioUlKid;
	
	
	for ( var i = 0; i < alluls.length; i++) {
		
		if (alluls[i].getAttribute("hook") == 'solo_exhibition') {
			biouls.push(alluls[i]);
			controlsEdits(biouls);
		}
		
		if (alluls[i].getAttribute("hook") == 'group_exhibition') {
			biouls.push(alluls[i]);
			controlsEdits(biouls);
		}
		
		if (alluls[i].getAttribute("hook") == 'collection') {
			biouls.push(alluls[i]);
			controlsEdits(biouls);
		}
		
		if (alluls[i].getAttribute("hook") == 'bibliography') {
			biouls.push(alluls[i]);
			controlsEdits(biouls);
		}
		
		if (alluls[i].getAttribute("hook") == 'education') {
			biouls.push(alluls[i]);
			controlsEdits(biouls);
		}
		
		if (alluls[i].getAttribute("hook") == 'award') {
			biouls.push(alluls[i]);
			controlsEdits(biouls);
		}
		
		if (alluls[i].getAttribute("hook") == 'upcoming_event') {
			biouls.push(alluls[i]);
			controlsEdits(biouls);
		}
	}
	
}



function controlsEdits(biouls) {
	
	var bioULKids = [];
	var bioUlKid;
	
	for ( var i = 0; i < biouls.length; i++) {
		bioULKids = biouls[i].childNodes;
		
		for ( var j = 0; j < bioULKids.length; j++) {
		
			// Sniff for IE
			testBioUlKid = bioULKids[bioULKids.length - 1];
			if (testBioUlKid != null && testBioUlKid.nodeName == "LI") {
				if (testBioUlKid.lastChild.lastChild != null &&
						//testBioUlKid.lastChild.lastChild.previousSibling.lastChild.childNodes[0].nodeValue == "down") {
						testBioUlKid.lastChild.lastChild.previousSibling.lastChild.childNodes[0].nodeValue == downVal) {
					isIE = true;
				}
			}
			
			bioUlKid = bioULKids[j];
			//if (bioUlKid.lastChild.lastChild != null && bioUlKid.nodeName == "LI") {
			if (bioUlKid.nodeName == "LI") {
			
				// Removes first "up" link and the divider before
				var bioUlKidObj = bioUlKid.lastChild.lastChild.previousSibling.lastChild;
				// IE 6 & 7
				//if (isIE == true && bioUlKidObj.previousSibling.previousSibling.childNodes[0].nodeValue == "up" && j == 0) {
				if (isIE == true && bioUlKidObj.previousSibling.previousSibling.childNodes[0].nodeValue == upVal && j == 0) {	
					bioUlKid.lastChild.lastChild.previousSibling.removeChild(bioUlKidObj.previousSibling.previousSibling); // removes divider
					bioUlKid.lastChild.lastChild.previousSibling.removeChild(bioUlKidObj.previousSibling.previousSibling); // removes anchor
				}
				
					
				// FF & Safari
				//if (isIE == false && bioUlKidObj.previousSibling.previousSibling.childNodes[0].nodeValue == "up" && j == 1) {
				if (isIE == false && bioUlKidObj.previousSibling.previousSibling.childNodes[0].nodeValue == upVal && j == 1) {
					bioUlKid.lastChild.lastChild.previousSibling.removeChild(bioUlKidObj.previousSibling.previousSibling); // removes divider
					bioUlKid.lastChild.lastChild.previousSibling.removeChild(bioUlKidObj.previousSibling.previousSibling); // removes anchor
				}
			
			
				// Removes last "down" link and the divider before
				
				// IE 6 & 7
				//if (isIE == true && bioULKids.length == j + 1 && bioUlKidObj.childNodes[0].nodeValue == "down") {
				if (isIE == true && bioULKids.length == j + 1 && bioUlKidObj.childNodes[0].nodeValue == downVal) {
						bioUlKid.lastChild.lastChild.previousSibling.removeChild(bioUlKidObj.previousSibling); // removes anchor
						bioUlKid.lastChild.lastChild.previousSibling.removeChild(bioUlKidObj); // removes divider
				
				
				// FF
				//} else if (isIE == false && bioULKids.length == j + 2 && bioUlKidObj.childNodes[0].nodeValue == "down") {
				} else if (isIE == false && bioULKids.length == j + 2 && bioUlKidObj.childNodes[0].nodeValue == downVal) {
						bioUlKid.lastChild.lastChild.previousSibling.removeChild(bioUlKidObj.previousSibling); // removes anchor
						bioUlKid.lastChild.lastChild.previousSibling.removeChild(bioUlKidObj); // removes divider
				
				
				// Safari
				//} else if (isIE == false && bioULKids.length == j + 3 && bioUlKidObj.childNodes[0].nodeValue == "down") {
				} else if (isIE == false && bioULKids.length == j + 3 && bioUlKidObj.childNodes[0].nodeValue == downVal) {
						bioUlKid.lastChild.lastChild.previousSibling.removeChild(bioUlKidObj.previousSibling); // removes anchor
						bioUlKid.lastChild.lastChild.previousSibling.removeChild(bioUlKidObj); // removes divider
				}
				
			}
		}
	}
	
	biouls = [];

}


//"/web/accessories/helpfileinfo.htm"

function openGenWin(imgurl,imgwidth,imgheight,extraheight,titleText,url) {
	
	openNonImgWin(imgurl,imgwidth,imgheight,extraheight,titleText);

}


function openNonImgWin(url,w,h,eh,tt,ct) {
	//windowName = url;
	windowName = 'help';
	imgURL = url;
	imgH = h;
	imgW = w;
	imgWinW = (w + 60);
	imgWinH = (h + eh + 190);
	if (imgWinH > 700) imgWinH = 700;
	topWin = (screen.availHeight - imgWinH) / 2;
	leftWin = (screen.availWidth - imgWinW) / 2;
	titleText = tt;
	contentText = ct;
	//contentText = localEncode(ct);
	
	props = "resizable=no,toolbar=no,scrollbars,menubar=no,status=no,directories=no,width=" + imgWinW + ",height=" + imgWinH + ",top=" + topWin + ",screenY=" + topWin + ",left=" + leftWin + ",screenX=" + leftWin;
	
	var myEngWin = window.open(url,windowName,props);
	myEngWin.focus();
}







function openImgWin(imgurl,imgwidth,imgheight,extraheight,titleText,contenttext) {
	
	openWin(imgurl,imgwidth,imgheight,extraheight,titleText,contenttext);

}


function openWin(url,w,h,eh,tt,ct) {
	//windowName = url;
	windowName = 'enlarge';
	imgURL = url;
	imgH = h;
	imgW = w;
	imgWinW = (w + 60);
	imgWinH = (h + eh + 190);
	if (imgWinH > 700) imgWinH = 700;
	topWin = (screen.availHeight - imgWinH) / 2;
	leftWin = (screen.availWidth - imgWinW) / 2;
	titleText = tt;
	contentText = ct;
	//contentText = localEncode(ct);
	
	props = "resizable=no,toolbar=no,scrollbars,menubar=no,status=no,directories=no,width=" + imgWinW + ",height=" + imgWinH + ",top=" + topWin + ",screenY=" + topWin + ",left=" + leftWin + ",screenX=" + leftWin;
	
	var myEngWin = window.open("/web/accessories/enlarge.htm",windowName,props);
	myEngWin.focus();
}


function enlargeStatus() {
	window.status='Click for Larger View';
	return true;

}


function statusOff() {
	window.status='';
	return true;
}

/* Original, working version
function submitEnterButton(e) {
 	var submitbtn = document.getElementById('defaultsubmit');
    if(e.keyCode==13){
      submitbtn.click();
      return false;
    }    
    return true;
}
*/


function activate() {
	active = true;
}

function deactivate() {
	allowSubmit = true;
}


// by default this code is not active for pages,
// include a call to activate() method above in each page to launch code
function loadingView() {
		
		if (active == true) {
			var mac=-1; 
			var anchor=''; 
			if (navigator.userAgent) {mac=navigator.userAgent.search(/Mac/);}
			if (mac!=-1) {
				self.scrollTo(0, 0);
				if (window.console) {
					window.console.log("IF Value of mac=" + mac);
				}
				anchor='top';
				window.location="#top";
			} else {
				if (window.console) {
					window.console.log("ELSE Value of mac=" + mac);
				}
				anchor='#top';
			} 
			window.location.hash = anchor;
			var loadingElement = document.getElementById("loading_view");
		   	var bodyElement = document.getElementById("body");
		   	if (bodyElement != null) {
		  	 	var bodyContainer = bodyElement.parentNode;
		  	 	bodyContainer.insertBefore(loadingElement,bodyElement);
		  	}
		   	
		   	var footerElement = document.getElementById("footer");
		   	if (footerElement != null) {
		   		var container = footerElement.parentNode;
		   		container.removeChild(footerElement);
		   	}
		   	
		   	
			
			bodyElement.style.postion="absolute";
		   	bodyElement.style.top="-5000px";
		   	loadingElement.style.position="relative";
		   	loadingElement.style.top="0px";
		 }
}



function submitEnterButton(e) {
 	var submitbtn = document.getElementById('defaultsubmit');
    if (allowSubmit == false) {
	    if(e.keyCode==13){
	   	  
			/*
			window.location.hash = 'top';
			
			var loadingElement = document.getElementById("loading_view");
		   	var bodyElement = document.getElementById("body");
		   	var footerElement = document.getElementById("footer");
		   	var container = footerElement.parentNode;
		   	var bodyContainer = bodyElement.parentNode;
		   	bodyContainer.insertBefore(loadingElement,bodyElement);
		   	container.removeChild(footerElement);
			
			bodyElement.style.postion="absolute";
		   	bodyElement.style.top="-5000px";
		   	loadingElement.style.position="relative";
		   	loadingElement.style.top="0px";
	   	  	*/
	   	  	if (active == true) {
	   	  		loadingView();
	   	  	}
	   	  	if (submitbtn != null) {
		  		submitbtn.click();
		  	}
		  	return false;
	    }    
    }
    return true;
}


function editSubmitAppendUrl(orderElementId, n) {
	var orderElement = document.getElementById(orderElementId);
	n.href += ("&order=" + orderElement.value);
}



//20090814 MAY NOT NEED FUNCTION - TRIGGERING DIRECTLY FROM URL

function editSubmit(formToSubmit, newAction, n) {
	
	// Populate hidden id and year with edit link info for submission and trigger BiographyManager.parseSoloExhibitionOrder()
	var cid = n.parentNode.getAttribute("cid");
	var cgrp = n.parentNode.getAttribute("cgrp");
	var thisForm = document.getElementById(formToSubmit);
	var idYearArray = cid.split("_");
	var id = idYearArray[1];
	var year = idYearArray[0];
	var submitEvent = document.getElementById("submitEvent");
	var hiddenId = document.getElementById("hiddenId");
	var hiddenYear = document.getElementById("hiddenYear");
	
	//alert('editSubmit values - cid=' + cid + ', cgrp=' + cgrp);
	
	submitEvent.setAttribute("name", newAction);
	hiddenId.setAttribute("value", id);
	hiddenYear.setAttribute("value", year);
	
	//alert('hiddenId.getAttribute("value")=' + hiddenId.getAttribute("value") + 'hiddenYear.getAttribute("value")=' + hiddenYear.getAttribute("value"));
	
	thisForm.submit();
	
	return false;
	
}



function editSubmitMediaFile(formToSubmit, newAction, id) {
	// Variation of editSubmit()
	// Populate hidden id and year with edit link info for submission and trigger BiographyManager.parseSoloExhibitionOrder()
	var thisForm = document.getElementById(formToSubmit);
	var submitEvent = document.getElementById("submitEvent");
	var hiddenId = document.getElementById("hiddenId");
	submitEvent.setAttribute("value", newAction);
	hiddenId.setAttribute("value", id);
	
	thisForm.submit();
	
	return false;
	
}





function insertAfter(newElement, targetElement) {
	var parent = targetElement.parentNode;
	if (parent.lastChild == targetElement) {
		parent.appendChild(newElement);
	} else {
		parent.insertBefore(newElement, targetElement.nextSibling);
	}
}

var currLinkColor;

function linkOver(n) {
	//alert(n.style.color);
	currLinkColor = n.style.color;
	n.style.color = "#ff0000";
}

function linkOut(n) {
	n.style.color = currLinkColor;
}

function controlOver(n) {
	n.style.color="#ff0000";
	n.style.textDecoration="underline";
}

function controlOut(n) {
	n.style.color="#0156af";
	//n.style.textDecoration="none";
	n.style.textDecoration="underline";
}


function createLeftNavFeatureArray() {
	
	var fai = new Array(4);
	for (i=0; i < 4; i++) fai[i]=new Array(3);	
	
	fai[0][0] = "/images/common/feature/featured_work_archive_c.gif";
	fai[0][1] = "153"; //h
	fai[0][2] = "200"; //w
		
	fai[1][0] = "/images/common/feature/featured_work_archive_m.gif";
	fai[1][1] = "153";
	fai[1][2] = "200";
		
	fai[2][0] = "/images/common/feature/featured_work_archive_y.gif";
	fai[2][1] = "153";
	fai[2][2] = "200";
		
	fai[3][0] = "/images/common/feature/featured_work_archive_k.gif";
	fai[3][1] = "153";
	fai[3][2] = "200";
	
	return fai;
			
}	


function selectLeftNavFeature() {
	var fai = createLeftNavFeatureArray();
	var r = Math.floor(Math.random()*fai.length);
	var img = fai[r];
	return img;
	
}	



/*
//Create new YUI instance, and populate it with the required modules
YUI().use('event', 'node', 'dom', 'anim', function(Y) {
	
	var node = Y.one(window);
	
	var anim = new Y.Anim({
        node: node,
        to: {
            scroll: function(node) {
				return [0, node.get('scrollTop') + node.get('offsetHeight')]
            }
        },
        easing: Y.Easing.easeOut
    });
	

	function mouseOverHandler(e) {
		
		var target = e.target;
		var windowHeight = target.get('winHeight');
		var documentHeight = target.get('docHeight');
		var scrollY = target.get('docScrollY');
		var mousePositionY = e.pageY;
		var scrollZone = 10;
		
		
		if ((mousePositionY - scrollY) <= scrollZone) {
			anim.set('to', { scroll: [0, node.get('scrollTop') - windowHeight] });
	        anim.run();
		}
		
		if ((mousePositionY - scrollY) >= (windowHeight - scrollZone)) {
			anim.set('to', { scroll: [0, windowHeight + node.get('scrollTop')] });
	        anim.run();
			
		}
	}

	Y.one(document.body).on("mousemove", mouseOverHandler);
 
});
*/


/* Begin Apple Code for QuickTime Viewer

File: AC_QuickTime.js

Abstract: This file contains functions to generate OBJECT and EMBED tags for QuickTime content.

Version: <1.1>

Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
Computer, Inc. ("Apple") in consideration of your agreement to the
following terms, and your use, installation, modification or
redistribution of this Apple software constitutes acceptance of these
terms.  If you do not agree with these terms, please do not use,
install, modify or redistribute this Apple software.

In consideration of your agreement to abide by the following terms, and
subject to these terms, Apple grants you a personal, non-exclusive
license, under Apple's copyrights in this original Apple software (the
"Apple Software"), to use, reproduce, modify and redistribute the Apple
Software, with or without modifications, in source and/or binary forms;
provided that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the following
text and disclaimers in all such redistributions of the Apple Software. 
Neither the name, trademarks, service marks or logos of Apple Computer,
Inc. may be used to endorse or promote products derived from the Apple
Software without specific prior written permission from Apple.  Except
as expressly stated in this notice, no other rights or licenses, express
or implied, are granted by Apple herein, including but not limited to
any patent rights that may be infringed by your derivative works or by
other works in which the Apple Software may be incorporated.

The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.

IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Copyright © 2006 Apple Computer, Inc., All Rights Reserved

*/ 

/*
 * This file contains functions to generate OBJECT and EMBED tags for QuickTime content. 
 */

/************** LOCALIZABLE GLOBAL VARIABLES ****************/

var gArgCountErr =	'The "%%" function requires an even number of arguments.'
				+	'\nArguments should be in the form "atttributeName", "attributeValue", ...';

/******************** END LOCALIZABLE **********************/

var gTagAttrs				= null;
var gQTGeneratorVersion		= 1.0;

function AC_QuickTimeVersion()	{ return gQTGeneratorVersion; }

function _QTComplain(callingFcnName, errMsg)
{
    errMsg = errMsg.replace("%%", callingFcnName);
	alert(errMsg);
}

function _QTAddAttribute(prefix, slotName, tagName)
{
	var		value;

	value = gTagAttrs[prefix + slotName];
	if ( null == value )
		value = gTagAttrs[slotName];

	if ( null != value )
	{
		if ( 0 == slotName.indexOf(prefix) && (null == tagName) )
			tagName = slotName.substring(prefix.length); 
		if ( null == tagName ) 
			tagName = slotName;
		return '' + tagName + '="' + value + '"';
	}
	else
		return "";
}

function _QTAddObjectAttr(slotName, tagName)
{
	// don't bother if it is only for the embed tag
	if ( 0 == slotName.indexOf("emb#") )
		return "";

	if ( 0 == slotName.indexOf("obj#") && (null == tagName) )
		tagName = slotName.substring(4); 

	return _QTAddAttribute("obj#", slotName, tagName);
}

function _QTAddEmbedAttr(slotName, tagName)
{
	// don't bother if it is only for the object tag
	if ( 0 == slotName.indexOf("obj#") )
		return "";

	if ( 0 == slotName.indexOf("emb#") && (null == tagName) )
		tagName = slotName.substring(4); 

	return _QTAddAttribute("emb#", slotName, tagName);
}


function _QTAddObjectParam(slotName, generateXHTML)
{
	var		paramValue;
	var		paramStr = "";
	var		endTagChar = (generateXHTML) ? ' />' : '>';

	if ( -1 == slotName.indexOf("emb#") )
	{
		// look for the OBJECT-only param first. if there is none, look for a generic one
		paramValue = gTagAttrs["obj#" + slotName];
		if ( null == paramValue )
			paramValue = gTagAttrs[slotName];

		if ( 0 == slotName.indexOf("obj#") )
			slotName = slotName.substring(4); 
	
		if ( null != paramValue )
			paramStr = '<param name="' + slotName + '" value="' + paramValue + '"' + endTagChar;
	}

	return paramStr;
}

function _QTDeleteTagAttrs()
{
	for ( var ndx = 0; ndx < arguments.length; ndx++ )
	{
		var attrName = arguments[ndx];
		delete gTagAttrs[attrName];
		delete gTagAttrs["emb#" + attrName];
		delete gTagAttrs["obj#" + attrName];
	}
}

		

// generate an embed and object tag, return as a string
function _QTGenerate(callingFcnName, generateXHTML, args)
{
	// is the number of optional arguments even?
	if ( args.length < 4 || (0 != (args.length % 2)) )
	{
		_QTComplain(callingFcnName, gArgCountErr);
		return "";
	}
	
	// allocate an array, fill in the required attributes with fixed place params and defaults
	gTagAttrs = new Object();
	gTagAttrs["src"] = args[0];
	gTagAttrs["width"] = args[1];
	gTagAttrs["height"] = args[2];
	gTagAttrs["classid"] = "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
		//Impportant note: It is recommended that you use this exact classid in order to ensure a seamless experience for all viewers
	gTagAttrs["pluginspage"] = "http://www.apple.com/quicktime/download/";

	// set up codebase attribute with specified or default version before parsing args so
	//  anything passed in will override
	var activexVers = args[3]
	if ( (null == activexVers) || ("" == activexVers) )
		activexVers = "6,0,2,0";
	gTagAttrs["codebase"] = "http://www.apple.com/qtactivex/qtplugin.cab#version=" + activexVers;

	var	attrName,
		attrValue;

	// add all of the optional attributes to the array
	for ( var ndx = 4; ndx < args.length; ndx += 2)
	{
		attrName = args[ndx].toLowerCase();
		attrValue = args[ndx + 1];

		// "name" and "id" should have the same value, the former goes in the embed and the later goes in
		//  the object. use one array slot 
		if ( "name" == attrName || "id" == attrName )
			gTagAttrs["name"] = attrValue;

		else 
			gTagAttrs[attrName] = attrValue;
	}

	// init both tags with the required and "special" attributes
	var objTag =  '<object '
					+ _QTAddObjectAttr("classid")
					+ _QTAddObjectAttr("width")
					+ _QTAddObjectAttr("height")
					+ _QTAddObjectAttr("codebase")
					+ _QTAddObjectAttr("name", "id")
					+ _QTAddObjectAttr("tabindex")
					+ _QTAddObjectAttr("hspace")
					+ _QTAddObjectAttr("vspace")
					+ _QTAddObjectAttr("border")
					+ _QTAddObjectAttr("align")
					+ _QTAddObjectAttr("class")
					+ _QTAddObjectAttr("title")
					+ _QTAddObjectAttr("accesskey")
					+ _QTAddObjectAttr("noexternaldata")
					+ '>'
					+ _QTAddObjectParam("src", generateXHTML);
	var embedTag = '<embed '
					+ _QTAddEmbedAttr("src")
					+ _QTAddEmbedAttr("width")
					+ _QTAddEmbedAttr("height")
					+ _QTAddEmbedAttr("pluginspage")
					+ _QTAddEmbedAttr("name")
					+ _QTAddEmbedAttr("align")
					+ _QTAddEmbedAttr("tabindex");

	// delete the attributes/params we have already added
	_QTDeleteTagAttrs("src","width","height","pluginspage","classid","codebase","name","tabindex",
					"hspace","vspace","border","align","noexternaldata","class","title","accesskey");

	// and finally, add all of the remaining attributes to the embed and object
	for ( var attrName in gTagAttrs )
	{
		attrValue = gTagAttrs[attrName];
		if ( null != attrValue )
		{
			embedTag += _QTAddEmbedAttr(attrName);
			objTag += _QTAddObjectParam(attrName, generateXHTML);
		}
	} 

	// end both tags, we're done
	return objTag + embedTag + '></em' + 'bed></ob' + 'ject' + '>';
}

// return the object/embed as a string
function QT_GenerateOBJECTText()
{
	return _QTGenerate("QT_GenerateOBJECTText", false, arguments);
}

function QT_GenerateOBJECTText_XHTML()
{
	return _QTGenerate("QT_GenerateOBJECTText_XHTML", true, arguments);
}

function QT_WriteOBJECT()
{
	document.writeln(_QTGenerate("QT_WriteOBJECT", false, arguments));
}

function QT_WriteOBJECT_XHTML()
{
	document.writeln(_QTGenerate("QT_WriteOBJECT_XHTML", true, arguments));
}

/* End Apple code for QuickTime viewer */





