<!--

var primary_menus_string;
var primary_menus;
var secondary_menus_string;
var secondary_menus;

primary_menus_string = "mp_4,mp_6";
primary_menus = primary_menus_string.split(",");
secondary_menus_string = "menu_4,menu_6";
secondary_menus = secondary_menus_string.split(",");

tab_link_string = "tab_1,tab_2,tab_3,tab_4";
tab_links = tab_link_string.split(",");
tabs_string = "containers,works,instantiations,raw_data";
tabs = tabs_string.split(",");

tab_link_string_2 = "";
for(i=0;i<30;i++) {
	if (i == 0) {
		tab_link_string_2 += "tab_works_"+i;
	} else {
		tab_link_string_2 += ",tab_works_"+i;
	}
}
tab_links_2 = tab_link_string_2.split(",");

tabs_string_2 = "";
for(i=0;i<30;i++) {
	if (i == 0) {
		tabs_string_2 += "tabbing_works_"+i;
	} else {
		tabs_string_2 += ",tabbing_works_"+i;
	}
}
tabs_2 = tabs_string_2.split(",");

tab_link_string_3 = "";
for(i=0;i<30;i++) {
	if (i == 0) {
		tab_link_string_3 += "tab_instantiations_"+i;
	} else {
		tab_link_string_3 += ",tab_instantiations_"+i;
	}
}
tab_links_3 = tab_link_string_3.split(",");

tabs_string_3 = "";
for(i=0;i<30;i++) {
	if (i == 0) {
		tabs_string_3 += "tabbing_instantiations_"+i;
	} else {
		tabs_string_3 += ",tabbing_instantiations_"+i;
	}
}
tabs_3 = tabs_string_3.split(",");

function setMenu() {

	for(i=0;i<secondary_menus.length;i++) {
		document.getElementById(secondary_menus[i]).style.visibility = 'hidden';
	}
	
	if (document.getElementById("tabbing")) {
		for(i=0;i<tabs.length;i++) {
			document.getElementById(tabs[i]).style.display = 'none';
		}
		document.getElementById("containers").style.display = 'block';
	}
	
	//for development
	goTab_2('tabbing_works_0','tab_works_0','works','tab_2');
	goTab_3('tabbing_instantiations_0','tab_instantiations_0','instantiations','tab_3');
	goTab('containers','tab_1');

}

function resetMenus() {
	for(i=0;i<primary_menus.length;i++) {
		document.getElementById(primary_menus[i]).style.backgroundColor = 'transparent';	
	}
	for(i=0;i<secondary_menus.length;i++) {
		document.getElementById(secondary_menus[i]).style.visibility = 'hidden';
	}
}

function resetTabs() {
	if (document.getElementById("tabbing")) {
		for(i=0;i<tabs.length;i++) {
			document.getElementById(tabs[i]).style.display = 'none';
		}
		for(i=0;i<tab_links.length;i++) {
			document.getElementById(tab_links[i]).className = 'tab';
		}
	}
}

function resetTabs_2() {
	if (document.getElementById("tabbing")) {
		for(i=0;i<tabs_2.length;i++) {
			if (document.getElementById(tabs_2[i])) {
				document.getElementById(tabs_2[i]).style.display = 'none';
			}
		}
		for(i=0;i<tab_links_2.length;i++) {
			if (document.getElementById(tab_links_2[i])) {
				document.getElementById(tab_links_2[i]).className = 'tabSecondary';
			}
		}
	}
}

function resetTabs_3() {
	if (document.getElementById("tabbing")) {
		for(i=0;i<tabs_3.length;i++) {
			if (document.getElementById(tabs_3[i])) {
				document.getElementById(tabs_3[i]).style.display = 'none';
			}
		}
		for(i=0;i<tab_links_3.length;i++) {
			if (document.getElementById(tab_links_3[i])) {
				document.getElementById(tab_links_3[i]).className = 'tabSecondary';
			}
		}
	}
}

function showmenusecondary(menu_id, link_id) {
	// Show the horizontal, secondary menu
	//alert("this ran " + link_id);
	//document.getElementById(link_id).style.visibility = 'visible';
	resetMenus();
	
	if (link_id != "") {
		document.getElementById(menu_id).style.backgroundColor = '#ff8800';
		document.getElementById(link_id).style.visibility = 'visible';
	}
	

}
function show_drop_down_menu(menu_id, link_id)
{
    if (document.getElementById(menu_id)) {
        var left = getOffsetLeft(link_id) + 'px';
        var top = getOffsetTop(link_id) + document.getElementById(link_id).offsetHeight + 'px';
        document.getElementById(menu_id).style.left = left;
        document.getElementById(menu_id).style.top = top;
        document.getElementById(link_id).style.backgroundColor = '#ff8800';
        document.getElementById(menu_id).style.visibility = 'visible';
    }
}

function hide_drop_down_menu(menu_id, link_id)
{
    if (document.getElementById(menu_id)) {
        document.getElementById(menu_id).style.visibility = 'hidden';
        document.getElementById(link_id).style.backgroundColor = '';
    }
}

function getOffsetTop(element)
{
    el = document.getElementById(element);
    xPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getOffsetLeft(element)
{
    el = document.getElementById(element);
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}


function goTab(link_id,tab_id) {
	resetTabs();
	
	if (link_id != "") {
		document.getElementById(link_id).style.display = 'block';
	}
	if (tab_id != "") {
		document.getElementById(tab_id).className = 'tab activeTab';
	}
}

function goTab_2(link_id,tab_id,parent_link_id,parent_tab_id) {
	resetTabs();
	resetTabs_2();
	
	if (parent_link_id != "") {
		document.getElementById(parent_link_id).style.display = 'block';
	}
	if (parent_tab_id != "") {
		document.getElementById(parent_tab_id).className = 'tab activeTab';
	}
	if (link_id != "") {
		document.getElementById(link_id).style.display = 'block';
	}
	if (tab_id != "") {
		document.getElementById(tab_id).className = 'tabSecondary activeTabSecondary';
	}
}

function goTab_3(link_id,tab_id,parent_link_id,parent_tab_id) {
	resetTabs();
	resetTabs_3();
	
	if (parent_link_id != "") {
		document.getElementById(parent_link_id).style.display = 'block';
	}
	if (parent_tab_id != "") {
		document.getElementById(parent_tab_id).className = 'tab activeTab';
	}
	if (link_id != "") {
		document.getElementById(link_id).style.display = 'block';
	}
	if (tab_id != "") {
		document.getElementById(tab_id).className = 'tabSecondary activeTabSecondary';
	}
}

function propagateField(currentIDs) {
	// function to copy data throughout form
	
	// standard form: instantiations_agent_date_type_field_3_1
	// word before first integer could be: field, options, other

	ids = currentIDs.split("**");
	//alert(ids.length + " is the length of ids");
	for(i=0;i<(ids.length);i++) {

		curr_id = ids[i];
		parts = curr_id.split("_");

		field = "";
		for(b=0;b<(parts.length - 3);b++) {
			field += parts[b]+"_";
		}
		field_type_place = (parts.length - 3);
		field_type = parts[ field_type_place ];
	
		field += field_type + "_";
	
		field_end = parts[ (parts.length-1) ];
		
		//alert(curr_id);
		//alert(field_type);

		if (field_type == "field") {
			replace = document.getElementById( curr_id ).value;
			b=0;
			replaceID = field + b + "_" + field_end;
			while (document.getElementById(replaceID)) {
				document.getElementById(replaceID).value = replace;
				b++;
				replaceID = field + b + "_" + field_end;
			}
		} else if (field_type == "options" || field_type == "other" ) {
			replace = document.getElementById( curr_id ).selectedIndex;
			b=0;
			replaceID = field + b + "_" + field_end;
			//alert(replace + " is the selectedIndex");
			while (document.getElementById(replaceID)) {
				//alert(replaceID + " is the replace id");
				document.getElementById( replaceID ).selectedIndex = replace;
				b++;
				replaceID = field + b + "_" + field_end;
			}
		
		}
	}
	
}


	function openPlayWindow(vars) {
		newwindow=window.open("http://www.lib.colum.edu/about/diy/listen/play_track.php?"+vars,'audio','height=400,width=580,left=200,top=150,screenX=200,screenY=150,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no');
		if (window.focus) {newwindow.focus()}
		//return true;
	}

//-->