// Copyright 2003-2006 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.top_navigate   = top_navigate;

	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;

}



function top_navigate(current_page)

{

	var top_navigate_html = "";



	for (var i = 0; i < this.navs.length; i++)

	{

		var nav_element = this.navs[i];



		var image_tag = new _img;

		image_tag.alt = nav_element.alt;

		

		image_tag.onclick = "document.location='" + nav_element.link + "';";



		if (i == current_page) {

			image_tag.src = nav_element.ro.src;

			image_tag.onmouseover = "this.style.cursor='pointer';this.style.cursor='hand';window.status='" + nav_element.alt + "';";

		}

		else {

			image_tag.src = nav_element.i.src;

			image_tag.onmouseover = "this.src='" + nav_element.ro.src + "';" + "this.style.cursor='pointer';this.style.cursor='hand';window.status='" + nav_element.alt + "';";

			image_tag.onmouseout  = "this.src='" + nav_element.i.src + "';"  + "window.status='';";

		}

		top_navigate_html += "<td>" + image_tag.toString() + "</td>";

	}

	//the top navigation is just a group of images (with roll-overs) enclosed in a table

	return("<table style='width:100%'><tr>" + top_navigate_html + "</tr></table>");

}



function smartparts()

{

	this.top_table  = top_table;

	this.bottom_table  = bottom_table;

}

smartparts.prototype = new base("#ffffff");

var nav = new smartparts();



function top_table(current_page, left_columns, right_columns, total_columns)

{

	document.write("<div style='position:absolute;top:10px;left:30px;'>" +

				   "<table width='831' border='0' style='margin:0px;padding:0px;' cellpadding='0' cellspacing='0'>" +

				   "<tr><div style='width:831px'><img style='float:left' src='/local_images/sp_logo.jpg'>" +

"<a href='http://www.syncpix.com'><img align='top' border=0 style='margin-top:8px;float:right' src='/local_images/syncpix_logo.jpg'></a>" +

"<a href='http://www.optipix.com'><img align='top' border=0 style='margin-right:20px;margin-top:12px;float:right' src='/local_images/opti_pix_logo.png'></a></div>" +

				   "<div style='clear:both;margin:0px;'></div></tr>" +

				   "<tr><td height='31' colspan='" + total_columns + "' valign='top'>" +

				   this.top_navigate(current_page) + 

				   "</td></tr>" +

				   "<tr><td height='19' colspan='" + total_columns + "' valign='top' bgcolor='#666666'>&nbsp;</td></tr>");

}

function bottom_table(total_columns)

{

	document.write("<tr><td height='20' colspan='" + total_columns + "' valign='top' bgcolor='#666666'>&nbsp;</td></tr>" +

				   "<tr>" +

				    "<td height='52' colspan='" + total_columns + "' valign='top' align='center'>" +

				  	  "<img src='/local_images/asi.jpg' width='622' height='40'>" +

				    "</td>" +

				   "</tr>" +

				   "</table></div>");

}


