 /* ====================================================*
 *           Tabinator (Marketplace version)            *
 *                  LANG Interactive                    *
 *======================================================*
 *    THIS NOTICE MUST NOT BE REMOVED OR MODIFIED       *
 *------------------------------------------------------*
 * This script may not be modified, implemented, or     *
 * distributed for profit. Not for profit use is        *
 * allowed and encouraged.                              *
 *                                                      *
 * Note that this script was initially developed for    *
 * use on the LANG family of web sites. Many changes    *
 * will need to be made for it to function correctly    *
 * on other systems.                                    *
 *                                                      *
 * Please let us know if you use the script on your     *
 * by sending a message to webtech@langnews.com .       *
 *                                                      *
 *------------------------------------------------------*
 *                 MARKETPLACE VERSION                  *
 *------------------------------------------------------*
 * This version adds the characters "MP_" to the        *
 * beginning of each Javascript variable, function,     *
 * and most HTML objects. This will prevent most        *
 * conflicts that might arise if another version of the *
 * Tabinator code is used on the same web page          *
 *                                                      *
 *------------------------------------------------------*
 * Copyright 2005 Los Angeles Newspaper Group           *
 *===================================================== */

var MP_tabs = MP_tab_names.split(',')
var temp_tab_colors = MP_tab_colors.split(',')
var MP_tabQty = MP_tabs.length
var MP_tab_numbers=new Array(MP_tabQty)
var MP_selected_tab_colors=new Array(MP_tabQty)
for (i=0;i<MP_tabs.length;i++) {
	MP_tab_numbers[MP_tabs[i]]=i
	MP_selected_tab_colors[MP_tabs[i]]=temp_tab_colors[i]
}


function MP_generateTabs(){
	for (i=0; i<MP_tabQty; i++) {
		var tabCode="<tr height=\"" + MP_tab_height + "\">\r" +
			"<a href=\"#\" onClick=\"MP_selectTab('" + MP_tabs[i] +"'); return false;\"><td id=\"MP_nav_" + MP_tabs[i] +"\" class=\"nav_tabs\"><a href=\"#\" class=\"nav_tabs\" onClick=\"MP_selectTab('" + MP_tabs[i] +"'); return false;\">" + MP_tabs[i] +"</a></td></a>\r" +
			"</tr>\r";
		document.write (tabCode)
	}
/**
		var tabCode="<tr height=\"" + MP_tab_height + "\">\r" +
			"<a href=\"#\" onClick=\"MP_selectTab('" + MP_tabs[i] +"'); return false;\"><td id=\"MP_nav_" + MP_tabs[i] +"\" class=\"nav_tabs\"><IMG SRC=\"http://extras.mnginteractive.com/live/std/clear.gif\" ALIGN=\"right\" height=\"" + MP_tab_height + "\">\r<a href=\"#\" class=\"nav_tabs\" onClick=\"MP_selectTab('" + MP_tabs[i] +"'); return false;\">" + MP_tabs[i] +"</a></td></a>\r" +

**/


	if (window.tab_content_height) {
		var remainingHeight=tab_content_height - MP_tab_height * MP_tabQty
		if (remainingHeight > 0) {
			var tabCode="<tr height=\"" + remainingHeight + "\">\r" +
				"<td id=\"MP_nav_dummy\" class=\"nav_lastTab\">&nbsp;</td>\r" +
				"</tr>\r";
			document.write (tabCode)
		}
	}
}

function MP_startTab(tabNumber) {
	if (window.tab_content_height) {
		document.write ("<div id=\"" + MP_tabs[tabNumber-1] + "\" style=\"padding: 4px 0px 0px 4px; color: #cc9900; background-color: #cc9900; font-family: Verdana; font-size: 10px; line-height: 100%; text-decoration: none; overflow: hidden; width: 100%; border-width:1px 1px 1px 0px ; border-style:solid solid solid none; display: none; height: " + tab_content_height + "px; \">");
	} else {
		document.write ("<div id=\"" + MP_tabs[tabNumber-1] + "\" style=\"padding: 4px 0px 0px 4px; color: #cc9900; background-color: #cc9900; font-family: Verdana; font-size: 10px; line-height: 100%; text-decoration: none; overflow: hidden; width: 100%; border-width:1px 1px 1px 0px ; border-style:solid solid solid none; display: none; height: " + MP_tab_height*MP_tabQty + "px; \">");
	}
}

// Choose a random tab to set "on" initially
var randomTab = MP_tabs[Math.ceil(MP_tabQty*Math.random())-1];

function MP_turnOnTab(tabName) {
	// first, display the selected content, and change the content area's color
	document.getElementById(tabName).style.display = 'block';
	document.getElementById(tabName).style.background = "#" + MP_selected_tab_colors[tabName]
	// then, updated the style of the selected tab
	selectedTabStyle=document.getElementById('MP_nav_' + tabName).style;
	selectedTabStyle.background = "#" + MP_selected_tab_colors[tabName]; // color of the selected tab
	selectedTabStyle.fontWeight = 'normal';
	selectedTabStyle.borderStyle = 'solid none solid solid';
	selectedTabStyle.borderWidth = '1px 0px 1px 1px';
	selectedTabStyle.fontSize = '16px';
	if (MP_tab_numbers[tabName] > 0) {
		selectedTabStyle.borderStyle = 'none none solid solid';
		selectedTabStyle.borderWidth = '0px 0px 1px 1px';
	}
}

function MP_turnOffTab(tabName) {
	// first, hide the selected content
	document.getElementById(tabName).style.display = 'none';
	// then, update the style of the UNselected tab
	selectedTabStyle=document.getElementById('MP_nav_' + tabName).style;
	selectedTabStyle.background = "#" + MP_tab_off_color;
	selectedTabStyle.fontWeight = 'normal';
	selectedTabStyle.borderStyle = 'solid solid solid solid';
	selectedTabStyle.borderWidth = '1px 1px 1px 1px';
	selectedTabStyle.fontSize = '12px';
	if (MP_tab_numbers[tabName] > 0) {
		selectedTabStyle.borderStyle = 'none solid solid solid';
		selectedTabStyle.borderWidth = '0px 1px 1px 1px';
	}
}

function MP_initializeTabs () {
//	MP_selectTab (randomTab);
	MP_selectTab (MP_tabs[0]); // this sets "Classifieds" as the default "on" tab
}

function MP_selectTab (tabname) {
	for (i=0; i<MP_tabQty; i++) {
		MP_turnOffTab(MP_tabs[i]);
	}
	MP_turnOnTab(tabname);
}
