// Java Centering Code
window.name="main";

function aodpopup(URL){
window.open(URL,'aod','width=693,height=525,toolbar=no,personalbar=no,location=no,directories=no,statusbar=no,menubar=no,status=no,resizable=yes,left=60,screenX=60,top=100,screenY=100');
}

if(location.search.substring(1)=="focuswin"){
	window.focus();
}

// Determine User Agent
var isCSS, isW3C, isIE4, isNN4, isIE6CSS, isOpera, isKonq;
function getUserAgent() {
	if( document.images ) {
		isCSS = ( document.body && document.body.style ) ? true : false;
		isW3C = ( isCSS && document.getElementById ) ? true : false;
		isIE4 = ( isCSS && document.all ) ? true : false;
		isNN4 = ( document.layers ) ? true : false;
		isIE6CSS = ( document.compatMode && document.compatMode.indexOf("CSS1") >= 0 ) ? true : false;
        isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
        isOpera = (navigator.userAgent.indexOf("Safari") != -1) ? true : false;
        isKonq = (navigator.userAgent.indexOf("KHTML") != -1) ? true : false;
	}
} // end function getUserAgent

window.onload = getUserAgent;


function debug() {
	 return "isCSS: " + isCSS + "\n" + "isW3C: " + isW3C + "\n" + "isIE4: " + isIE4 + "\n" + "isNN4: " + isNN4 + "\n" + "isIE6CSS: " + isIE6CSS + "\n";
} //end function debug


// Convert object name string or object reference

// into a valid element object reference
function getRawObject(obj) {
    var theObj;
    if (typeof obj == "string") {
        if (isW3C) {
            theObj = document.getElementById(obj);
        } else if (isIE4) {
            theObj = document.all(obj);
        } else if (isNN4) {
            theObj = seekLayer(document, obj);
        }
    } else {
        // pass through object reference
        theObj = obj;
    }
    return theObj;
}

// Convert object name string or object reference
// into a valid style (or NN4 layer) reference
function getObject(obj) {
    var theObj = getRawObject(obj);
    if (theObj && isCSS) {
        theObj = theObj.style;
    }
    return theObj;
}

function seekLayer(doc, name) {
    var theObj;
    for (var i = 0; i < doc.layers.length; i++) {
        if (doc.layers[i].name == name) {
            theObj = doc.layers[i];
            break;
        }
        // dive into nested layers if necessary
        if (doc.layers[i].document.layers.length > 0) {
            //alert(doc.layers[i].name + " has " + doc.layers.length);
            theObj = seekLayer(doc.layers[i].document, name);
        }
    }
    return theObj;
}

function getHeight( div ) {
    if( document.all ) {
        return document.all[div].clientHeight;
    } else if( document.getElementById ) {
        return document.getElementById(div).clientHeight;
    }
}

function centerDiv( div, bodyWidth , bodyHeight ) {

	// Function to determine browser window size
	var thisDiv = getObject(div);
	var windowWidth = getClientWidth();
	var windowHeight = getClientHeight();
	
	var whiteSpaceLeft = windowWidth - bodyWidth;
	var whiteSpaceTop = windowHeight - bodyHeight;

	offsetLeft = (whiteSpaceLeft < 0) ? 0 : (whiteSpaceLeft / 2);
	offsetTop = (whiteSpaceTop < 0) ? 0 : (whiteSpaceTop / 2);

	shiftTo(div, offsetLeft, offsetTop);
} // end function centerDiv

// Position an object at a specific pixel coordinate
function shiftTo(obj, x, y) {
    var theObj = getObject(obj);
    if (theObj) {
        if (isCSS) {
            // equalize incorrect numeric value type
            var units = (typeof theObj.left == "string") ? "px" : 0 
            theObj.left = x + units;
            theObj.top = y + units;
        } else if (isNN4) {
            theObj.moveTo(x,y)
		}
    }
}


function getClientWidth() {
	
	// return the width of the browser window
	if( window.innerWidth ) {
		return window.innerWidth;
	} else if( document.body.clientWidth ) {
		return document.body.clientWidth;
	} else {
		return 0;
	}
} // end function getClientWidth

function getClientHeight() {

	// return the height of the browser window.
	if( window.innerHeight ) {
		return window.innerHeight;
	} else if( document.body.clientHeight ) {
		return document.body.clientHeight;
	} else {
		return 0;
	}
	
} // end function getClientHeight


function showScrollBar() {

    var thisLayer = getObject('contentInterior');
    currHeight = 0;
    if( isNN4 ) {
        currHeight = thisLayer.clip.height;
    } else if( isOpera ) {
        currHeight = document.all["contentInterior"].clientHeight;
    } else if( isKonq ) {
        alert(getHeight("contentInterior"));
    }

    if( currHeight > 360 && ( isNN4 || isOpera )) { // More content than window can hold without scrolling...

        var topObj = getObject('NN4SliderTop');
        var bottomObj = getObject('NN4SliderBottom');

        if( isNN4 || isOpera) {
            viewState =  ( isNN4 ) ? "show" : "visible";
            topObj.visibility = viewState;
            bottomObj.visibility = viewState;
        }
    }
}
	
function swapImage(imgName,fileName) {

    if( document.images ) {
        if( isNN4 ) {
            thisLayer = ( imgName == 'upButton' ) ? getObject('NN4SliderTop') : getObject('NN4SliderBottom');
            thisImg = thisLayer.document.images[0];
        } else {
            thisImg = ( imgName == 'upButton' ) ? document.upButton : document.downButton;
        }
        thisImg.src = eval("'/assets/images/" + fileName + "'");
    }
}

var sliderIncrement = 0;

function scrollLayer(dir) {

    var currTop, currBottom, currHeight, dir;
    
    thisLayer = getObject('contentInterior');

    // Determine current top
    currTop = (thisLayer.top == "") ? 0 : parseInt(thisLayer.top);

    // Get size of contentInterior
    
    maxBottom = (! isNN4 ) ? -(document.all['contentInterior'].clientHeight - 360) : -(thisLayer.clip.height - 360);
    maxTop = 0;
    
    // set the increment to move up or down
    var inc = (dir == "up") ? 20 : -20;
    
    // Don't do anything if either already at top or bottom
    if( ( currTop >= maxTop && dir == "up" ) || ( currTop <= maxBottom && dir == "down") ) {
        inc = 0;
    }
    
    //Shift the layer
    if( isNN4 ) {
        thisLayer.moveBy(0,inc);
    } else {
        thisLayer.top = currTop + inc;
    }
    
    timeoutVar = setTimeout("scrollLayer(\"" + dir + "\")",50);
}

function clearUp() {
    if( window.timeoutVar ) {
        clearInterval(timeoutVar);
    }
}

function popWindow( strTitle , strContents , intHeight , intWidth ) {
    thisWindow = window.open( "" , "popWindow" , "menu=no,status=no,scrollbar=no,toolbar=no,height=" + (intHeight + 20) + ",width=" + (intWidth + 20));
    thisWindow.document.write("<html>\n<head>\n<title>" + strTitle + "</title>\n</head>\n<body>\n" + strContents + "\n</body>\n</html>");
} // end function popWindow