// Copyright 2003-2005 Streambay LLC
// All Rights Reserved

//constants
var DOT = " &#8226; ";

function _nav(link, i, ro, alt)
{
	var i_im = new Image;
	var ro_im = new Image;
	i_im.src  = i;
	ro_im.src = ro;

	this.link = link;
	this.i 	  = i_im;
	this.ro   = ro_im;
	this.alt  = alt;
}

function base(color)
{
	this.color = color;

	this.navs  = new Array;

	//privileged methods
	this.add = function(link, a, b, c) { this.navs.push(new _nav(link, a, b, c));};
	this.a_span = function(text, go)
	{
		return("<span class=\"a_span\" " +
			   "onclick=\"document.location='" + go + "'\" " +
			   "onmouseover=\"this.style.color='" + this.color + "';this.style.cursor='pointer';\" " +
			   "onmouseout=\"this.style.color=''\">" + text + "</span>");
	};
	this.drop_shadow = function(text)
	{
		return("<div class=\"container\">" + text + "<span class=\"text\">" + text + "</span></div>");
	};
	this.sb_text = function()
	{
		return("<span style=\"font-family:verdana;font-size:10px;font-weight:normal\">"  + 
			   this.a_span("Software by Streambay LLC", "http://www.streambay.com") +
			   "</span>");
	};
	this.onp_text = function()
	{
		return("<span style=\"font-family:verdana;font-size:10px;font-weight:normal\">&copy; 2004 "  + 
			   this.a_span("O'Neill Publishing Inc.", "http://www.onp.biz") +
			   "</span>");
	};
	this.base_trailer = function()
	{
		var a_spans = '';
		for (var i = 0; i < this.base_trailer.arguments.length; i += 2)
		{
			if (a_spans) { a_spans += DOT; }
			a_spans += this.a_span(this.base_trailer.arguments[i], this.base_trailer.arguments[i+1]);
		}
//		document.write("<div class=\"text_nav\">" + this.drop_shadow(a_spans) + this.onp_text() + "<br />" + this.sb_text() + "</div>");
		document.write("<div class=\"text_nav\">" + this.drop_shadow(a_spans) + this.onp_text() + "</div>");
	};
	this.left_navigate  = left_navigate;
	this.show_nav_image = show_nav_image;
}

function _img()
{
	this.toString = function()
	{
		if (this.isHidden) {
			this.style += "visibility:hidden;";
		}
		return "<img src=\"" 			+ this.src 			+ "\" " +
					"alt=\"" 			+ this.alt 			+ "\" " +
					"style=\"" 			+ this.style 		+ "\" " +
					"onclick=\"" 		+ this.onclick 		+ "\" " +
					"onmouseover=\"" 	+ this.onmouseover 	+ "\" " +
					"onmouseout=\"" 	+ this.onmouseout 	+ "\" " +
				(this.height?
					 "height=\"" 	+ this.height 	+ "\" " +
					 "width=\"" 	+ this.width	+ "\" " : "")   +
				">";
	};
}

function show_nav_image(nav_element, isCurrentPage, isHidden, navigate_this_button)
{
	var image_tag = new _img;

	image_tag.src = isCurrentPage? nav_element.ro.src : nav_element.i.src;
	image_tag.alt = nav_element.alt;
	image_tag.isHidden = isHidden;
	if (! isCurrentPage) {
		if (navigate_with_js) {
			image_tag.onclick = nav_element.link;
		}
		else {
			image_tag.onclick = "document.location='" + nav_element.link + "';";
		}
		if (!navigate_this_button) {
			image_tag.onmouseover = "this.src='" + nav_element.ro.src + "';this.style.cursor='pointer';this.style.cursor='hand';window.status='" + nav_element.alt + "';";
		}
		else {
			image_tag.onmouseover = "this.src='" + nav_element.ro.src + "';" + span_visibility + "='visible';" + bar_visibility + "='visible';this.style.cursor='pointer';this.style.cursor='hand';window.status='" + nav_element.alt + "';";
		}
		image_tag.onmouseout = "this.src='" + nav_element.i.src + "';" + span_visibility + "='hidden';" + bar_visibility + "='hidden';window.status='';";
	}
	return image_tag.toString();
}

var navigate_with_js = false; //set externally
function left_navigate(current_page)
{
	var ls_html = "";
	var navigate_this_button;
	var show_home_on_home_page = false;
	
	if (current_page == 0 && left_navigate.arguments.length > 0 && left_navigate.arguments[0] == 0)
	{
		show_home_on_home_page = true;
	}

	for (var i = 0; i < this.navs.length; i++)
	{
		//useful variables
		var nav_element = this.navs[i];
		var isHomeAndHidden = (i == 0 && current_page == 0 && !show_home_on_home_page);
		var isCurrentPage 	= (i == current_page);

		navigate_this_button = true;
		for(j =1; j < left_navigate.arguments.length; j++) {
			if (left_navigate.arguments[j] == i) {
				navigate_this_button = false;
			}
		}

		var bar_id = "bar_" + i;
		var span_id = "span_" + i;
		bar_visibility = "document.getElementById('" + bar_id + "').style.visibility";
		span_visibility = "document.getElementById('" + span_id + "').style.visibility";

		var text_and_bar;
		// text over the bar and bar
		if (isCurrentPage && current_page != 0 && navigate_this_button) {
			text_and_bar = "<span id=\"" + span_id 	+ "\" class=\"text_over_bars\">" + 
						   nav_element.alt + "</span>" 	+
						   "<img id=\"" + bar_id 	+ "\" src=\"/images/st_bar.gif\">";
		}
		else {
			text_and_bar = "<span id=\"" + span_id 	+ "\" class=\"text_over_bars\"   style=\"visibility:hidden\">" + 
						   nav_element.alt + "</span>" 	+
						   "<img id=\"" + bar_id 	+ "\" src=\"/images/st_bar.gif\" style=\"visibility:hidden;\">";
		}
		// end - text over the bar and bar
		
		// bottom bar
		var bottom_bar = new _img;
		bottom_bar.src 	 = "/images/st_button_bottom.gif";
		bottom_bar.style = "margin-left:111px;";
		bottom_bar.height = 27;
		bottom_bar.width = 2;
		bottom_bar.isHidden = (i == 0 && current_page == 0 && !show_home_on_home_page);
		// end bottom bar |
		ls_html += "<div style=\"position:relative;\">" + 
					this.show_nav_image(nav_element, isCurrentPage, isHomeAndHidden, navigate_this_button) + 
					text_and_bar + 
					"</div>" + 
					bottom_bar.toString() + "<br />";
	}
	document.getElementById("left_side_id").innerHTML = ls_html + document.getElementById("left_side_id").innerHTML;
}


