var timeoutPeriod = 200;
var request;
var imageUrl;

var showExhibitDropDown = false;
var checkingExhibitDropDown = false;
var currentExhibitNum = "00"

function pageLoaded(arr,level)
{
    writeGoogle();
    if(getElement("exhibit-work-img")) {        
        setVisibleInline('image-numbers-1', true);
        //setVisibleInline('image-numbers-2', true);
        getElement('image-number-a-1').className = 'image-number-selected';
    }
    
    var adjust = getElement("adjust-height");
    if (adjust) {
        if(getElement("check-height").offsetTop < 550) {
            if (adjust.value.length > 0) {
                var adjustIds = adjust.value.split("|");
                for (i=0; i < adjustIds.length; i++) {
                    getElement(adjustIds[i]).className += " min-height";
                }
            }
        }
    }
}

function rollExhibitSubmenu(state) {
    showExhibitDropDown = state;
    checkExhibitDropDown();
}

function checkExhibitDropDown() {
    if (!checkingExhibitDropDown) {
        checkingExhibitDropDown = true
        setTimeout("setExhibitDropDown();",timeoutPeriod);
    }
}

function setExhibitDropDown() {
    setVisible("submenu-exhibits-content", showExhibitDropDown);
    checkingExhibitDropDown = false;
}

function getElement(name) {
    return document.getElementById(name);
}

function setVisible(name, state) {
    getElement(name).style.display = state ? "block" : "none";
}

function setVisibleInline(name, state) {
    getElement(name).style.display = state ? "inline" : "none";
}

function clearImage(name) {
    getElement(name).alt = "";
    getElement(name).src = "images/px.gif";
}

function highlight(name, state, onColor, offColor) {
    getElement(name).style.color = state ? onColor : offColor;
}

function externalLinks() { 
    if (!document.getElementsByTagName) return; 
    var anchors = document.getElementsByTagName("a"); 
    for (var i=0; i<anchors.length; i++) { 
        var anchor = anchors[i]; 
        if (anchor.getAttribute("href") &&
            anchor.getAttribute("rel") == "external") {
                anchor.target = "_blank";
        }
    } 
}

function writeGoogle() {

    if (location.href.indexOf("localhost") != -1) {
        return;
    }
    //begin Google Analytics code
    var GAAccount = 'UA-3488650-1';
	//insert the first script tag
	var InsertGC1 = document.body.lastChild;
	var GoogCode1 = document.createElement('script');
	GoogCode1.src = 'http://www.google-analytics.com/urchin.js'
	GoogCode1.type = 'text/javascript';
	InsertGC1.parentNode.insertBefore(GoogCode1, InsertGC1.nextSibling); //same as insertAfter
	//insert the second script tag
	var InsertGC2 = document.body.lastChild;
	var GoogCode2 = document.createElement('script');
	GoogCode2.type = 'text/javascript';
	
	var text = '_uacct = "'+GAAccount+'"; urchinTracker();';
	if (null == GoogCode2.canHaveChildren || GoogCode2.canHaveChildren) {
    		GoogCode2.appendChild(document.createTextNode(text));
  	} else {
    		GoogCode2.text = text;
  	} 
	InsertGC2.parentNode.insertBefore(GoogCode2, InsertGC2.nextSibling);
    //end Google Analytics code
}
