//<!--

// These vars indicate element sizes for dynamic positioning.  Internet Explorer does not always
// allow these values to be detected when they are not explicitly set, so they must be hard-coded.  

var tabHeight = 26;
var edgePadding = 10;

var loadingNoticeDelay = 3000; // milliseconds 
var navButtonHeight = 50;
var navButtonWidth = 60;

// These vars are for use inside the script, and should not be modified

var navControlIndex = 0;
var activeTabIndex = 0;
var firstVisibleTab;
var subtabIndex = 0;
var allTabs = new Array();
var loadComplete = false;
 
function navigationTab (label, url, isActive) {
    this.label = label;
    this.url = url;
    this.elementID = "tab" + navControlIndex++;
    this.leftElementID = this.elementID + "_left";
    this.centerElementID = this.elementID + "_label";
    this.rightElementID = this.elementID + "_right";
    this.width = 0;
    this.tabIndex = allTabs.length;
    this.isVisible = false;
    this.isActive = isActive;
    if (isActive) {
    	activeTabIndex = this.tabIndex;
    	firstVisibleTab = activeTabIndex;
    }
    this.draw = drawTab;
    allTabs.push(this);
}


function drawTab () {
    var html = "";
    var cssClass = "";
    var mouseActions = "";
	var imageSuffix = ".gif";

    if (this.isActive) {
        cssClass = "activeTab";
        mouseActions+= "onClick=\"document.location='"+ this.url +"'\" ";
    }
    else {
        cssClass = "inactiveTab";
		imageSuffix = "_inactive.gif"
        mouseActions+= "onClick=\"document.location='"+ this.url +"'\" ";
    }
	html+= "<td class='" + cssClass + "' style='width: 4px;' ";
	html+= mouseActions;
	html+= "><img src='"+ mediaPath +"/tab_left" + imageSuffix + "' width='4' height='" + tabHeight + "'></td>";
	html+= "<td class='" + cssClass + "' style='height: " + tabHeight + "px'";
	if (this.isActive) {
		html+= mouseActions;
		html+= ">\n";
		html+= "<span class='activeTabLabel'>"
	}
	else {
		html+= ">\n";
		html+= "<a href='" + this.url + "' class='tabLabel'>"
	}
	html+= this.label;
	if (this.isActive) {
		html+= "</span>";
	}	
	else {
		html+= "</a>";
	}
	html+= "</td> \n";
	html+= "<td class='" + cssClass + "' style='width: 4px;' ";
	html+= mouseActions;
	html+= "><img src='"+ mediaPath +"/tab_right" + imageSuffix + "' width='4' height='" + tabHeight + "'></td>\n";

	showString("TAB SOURCE", html);
	
	document.write(html);
}



function navigationButton (label, icon, onClick) {
    this.label = label;
    this.icon = icon;
    this.onClick = onClick;
    this.elementID = "navbutton" + navControlIndex++;
    this.draw = drawNavButton;
}


function drawNavButton () {
    var html = "";

    html+= "<div id='"+ this.elementID +"' class='navButton' ";
    html+= ">";
    html+= "<table cellpadding='0' cellspacing='0' border='0'>";
    html+= "<tbody>";
    html+= "<tr>";
    html+= "<td align='center' valign='center'>";
    html+= "<a href=\"javascript:" + this.onClick + "\" class='navButton' alt='" + this.label + "' title='" + this.label + "'>";
   	html+= "<img src='" + this.icon + "' border='0'>";
   	html+= "</a>";
   	html+= "</td>";
    html+= "</tr>";
    html+= "<tr>";
    html+= "<td align='center'><a href=\"javascript:" + this.onClick + "\" class='navButtonLabel' style='text-decoration: none;'><nobr>" + this.label + "</nobr></a></td>";
    html+= "</tr>";
    html+= "</tbody>";
    html+= "</table>";
    html+= "</div>";

    document.write(html);
}


function subtab (label, hovertext, onClick, isActive) {
	this.label = label;
	this.hovertext = hovertext;
	this.onClick = onClick;
	this.isActive = isActive;
	this.elementID = "subtab" + (subtabIndex++);
	this.draw = drawSubtab;
}


function drawSubtab (returnOnly) {

    var html = "";
    var attribs = "";
    
	if (this.isActive) {
		attribs+= "class='activeSubtab' ";
	}
	else {
		attribs+= "class='inactiveSubtab' ";
		attribs+= "onMouseOver=\"switchClass('" + this.elementID + "', 'inactiveSubtabMouseOver')\" \n";
		attribs+= "onMouseOut=\"switchClass('" + this.elementID + "', 'inactiveSubtab')\" \n";
	}

	html+= "<td align='center'>";
	html+= "<a href=\"javascript:" + this.onClick + "\" id='" + this.elementID + "' " + attribs + ">";
	html+= this.label;
	html+= "</a>";
    html+= "</td>\n";
    if (! returnOnly) document.write(html);	
    return html;
}


function createTab (label, url, isActive) {
    var temp = new navigationTab(label, url, isActive);
    temp.draw();
}


function createNavButton (label, icon, onClick) {
    var temp = new navigationButton(label, icon, onClick);
    temp.draw();
}


function createSubtab (label, onClick, isActive) {
    var temp = new subtab(label, onClick, isActive);
    temp.draw();
}



function titleBarContents (titleString, subtabArray, returnOnly) {
	var html = "";
	
	if (subtabArray && subtabArray.length > 0) titleString += ": ";
	
	html+= "<td class='channelTitleText' width='3%'><nobr>" + titleString + "</nobr></td>";
	if (subtabArray && subtabArray.length > 0) {
		html+= "<td>";
		html+= "<table cellpadding='0' cellspacing='0' border='0'><tr>";
		for (var i=0; i < subtabArray.length; i++) {
			html+= subtabArray[i].draw(true);		
			if (i != subtabArray.length - 1) html+= subtabSeparator(true);
		}
		html+= "</tr></table>";
		html+= "</td>";
	}
	else {
		html+= "<td></td>";
	}
    if (! returnOnly) document.write(html);
    return html;
}


function subtabSeparator (returnOnly) {
    var html = "";
	html+= "<td align='center' valign='center' style='width:2px'>";
	html+= "<img src='"+ mediaPath +"/subtab_separator.gif' width='1' height='18'>";
    html+= "</td>\n";
    if (! returnOnly) document.write(html);
    return html;
}


function drawTitlebar (titleString, subtabArray, minimized, showMinimizeControl, minimizeURL) {
	var html = "";
	html+= "<table class='channelTitle' border='0'>";
	html+= "<tr>";
	html+= titleBarContents(titleString, subtabArray, true);
	html+= "<td align='right'>";
	if (showMinimizeControl) {
		html+= "<a href='" + minimizeURL + "' class='alphaImageLink'>";
		if (minimized) {
			html+= "<img src='" + mediaPath +  "/control_restore_channel.png' border='0'>";
		}
		else {
			html+= "<img src='" + mediaPath +  "/control_rollup_channel.png' border='0'>";
		}
		html+= "</a>";
	}
	html+= "</td></tr></table>";
	document.write(html);
}


function resizeLayout () {
	
}


function initialLayout () {

	loadComplete = true;
	
	fixPngImages();
	resizeLayout();

	hide("loadingNotice");

	if (browser == ie) { 
		window.onresize = resizeLayout; 
	} 
	else { 
		window.addEventListener("resize", resizeLayout, false); 
	} 

	setFocus();
}


function showLoadingNotice () {
	hide("channels");
	center("loadingNotice");
	show("loadingNotice");
}


function jumpToResults () {
	//jumpToDivAnchor("searchResults");
}


// -->

