function show_tab(tab_name)
{
	//alert(document.getElementById(tab_name).innerHTML);
	for (var i = 0; i < fee_tabs.length; i++)
	{
		//alert(document.getElementById(fee_tabs[i]).innerHTML);
		if (fee_tabs[i] != tab_name)
			document.getElementById(fee_tabs[i]).style.display = 'none';
		else
			document.getElementById(fee_tabs[i]).style.display = 'block';
	}
}

function nameFormat(str) {
	var tempArray = str.split(' ');
	return tempArray.join('_').toLowerCase();
}

function joinByUnderscore(str) {
	var tempArray = str.split(' ');
	return tempArray.join('_');
}

function real_url(relative_path, url)
{
	if (url.indexOf("http:") < 0)
		url = relative_path + url;

	return url;
}

function popup(url, width, height) {
	var win = window.open(url, 'image_display', 'toolbar=no,status=no,scrollbars=yes,resizable=no,screenx=0,screeny=0,top=0,left=0,width=' + width + ',height=' + height);
}

function PopupPic(sPicURL) { 
	msgWindow=window.open("./Tools/popup.htm?"+sPicURL, "", "resizable=1,screenx=0,screeny=0,top=20,left=2,HEIGHT=200,WIDTH=200");
}

function PopupPic_New_Version(pop_file, sPicURL, category) { 
	msgWindow=window.open(pop_file + "?" + sPicURL + "?" + category, "", "resizable=1,screenx=0,screeny=0,top=20,left=2,HEIGHT=200,WIDTH=200");
}

function PopupPic_New(popup_rela_path, sPicURL) { 
	msgWindow=window.open(popup_rela_path + "Tools/popup_new.htm?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200");
}

function popup_resize_help(url, width, height) {
	var win = window.open(url, 'image_display', 'toolbar=no,status=no,scrollbars=yes,resizable=yes,screenx=0,screeny=0,top=10,left=0,width=' + width + ',height=' + height);
	//win.location.reload();
}

function popup_help(url, width, height) {
	var win = window.open(url, 'image_display', 'toolbar=no,status=no,scrollbars=yes,resizable=no,screenx=0,screeny=0,top=10,left=0,width=' + width + ',height=' + height);
	//win.location.reload();
}

function popup_tight_image(image_src)
{
	var tmp_img = new Image();
	tmp_img.src = image_src;
	
	open_popup(image_src, tmp_img.width, tmp_img.height);
}

function goto_merchant()
{
	var merchant = document.frmmerchant.merchant.value;
	if ((merchant != "Browse by Merchant") && (merchant != "Seperator")) 
		parent.window.location.href = "./category.asp?Dealer=" + merchant + "&Category_Name=All";
}

function draw_tight_image(image_src)
{
	max_width =350;
	var tmp_img = new Image();
	tmp_img.src = image_src;
	
	if (tmp_img.width < max_width)
		max_width = tmp_img.width;
		
	document.write("<img src=" + image_src + " border=0 width=" + max_width + " alt='" + image_src + "'>");
}

function goto_page(selection)
{
	var id = selection.options[selection.selectedIndex].value;
	location.href = id ;
}

function goto_city(selection)
{
	var id = selection.options[selection.selectedIndex].value;
	var id_array = id.split('^');
	if (id.indexOf("Dummy") == -1)
		location.href = "?City=" + id_array[0] + "&State=" + id_array[1];
}

function browser_version()
{
	var version = "ie";
	var browserName = navigator.appName; 
	var browserVer = parseInt(navigator.appVersion);
	
	switch (browserName)
	{
		case "Netscape":
			if (navigator.userAgent.indexOf("Firefox") != -1)
			{
				var versionindex = navigator.userAgent.indexOf("Firefox") + 8;
				if (parseInt(navigator.userAgent.charAt(versionindex)) >= 1)
					version = "firefox_v1_up";
				else
					version = "firefox";
			}
			else
				version = "netscape";
			break
		default:
			if (browserVer <= 3)
				version = "ie_early";
			else
				version = "ie";
	}

	return version;
}
function build_navigation_menu(menu_name)
{
	var str = '';

	var index = 0
	for ( index = 0; index < navigation_items.length; index++)
	{
		if (menu_name == navigation_items[index][0])
			break;
	}
	
	for ( var i = 0; i < navigation_items.length; i++)
	{
		if (navigation_items[i][2] != "submenu")
		{
			if ( menu_name == navigation_items[i][0])
			{
				str += '<a class="h_nav_menu" href="' + navigation_items[i][1] + '">' + navigation_items[i][0] + '</a><br><br>';
			}
			else
				str += '<a class="nav_menu" href="' + navigation_items[i][1] + '">' + navigation_items[i][0] + '</a><br><br>';
		}
		else if  ((menu_name == navigation_items[i][4]) || (menu_name == navigation_items[i][0]) || (navigation_items[index][4] == navigation_items[i][4]))
		{
			if ( menu_name == navigation_items[i][0])
			{
				str += '<a class="h_nav_submenu" href="' + navigation_items[i][1] + '">' + navigation_items[i][0] + '</a><br><br>';
			}
			else
				str += '<a class="nav_submenu" href="' + navigation_items[i][1] + '">' + navigation_items[i][0] + '</a><br><br>';
		}
	}
	
	return str;
}

function display_image_in_box(image_src, box_width, box_height)
{
	var tmp_img = new Image();
	tmp_img.src = image_src;
	
	var width;
	var height;
	
	if ((tmp_img.width / tmp_img.height) > (box_width / box_height))
	{
		height = box_width * (tmp_img.height / tmp_img.width);
		width = box_width;
	}
	else
	{
		width = box_height * (tmp_img.width / tmp_img.height);
		height = box_height;
	}
	
	return '<img border="1" src="' + image_src + '" width="' + width + '" height ="' + height + '">';
}

function gen_showroom_page()
{
	var str = '';
	
	str += '<html>';
	str += '	<head>';
	str += '		<title>Showroom</title>';
	str += '		<link href="Config/style.css" rel="stylesheet">';
	str += '		<script language="javascript" src="Scripts/showroom_items.js"></script>';
	str += '		<script language="javascript" src="Scripts/utils.js"></script>';
	str += '	</head>';
	str += '	<body bgcolor="#FFFFFF">';

	str += '<center><a href="' + showroom_items[current_showroom_index][1] + '" target="_blank">';
	str += '<img src="Images/Showroom/' + showroom_items[current_showroom_index][2] + '" border="1" height="210"></a>';
	str += '<br><br><font face="verdana, arial, helvetica, sans-serif" size="1" color="#335eb3">' + showroom_items[current_showroom_index][0] + '</font></a></center>';

	str += '	</body>';
	str += '</html>';

	return str;
}

function display_curr_showroom_page()
{
	parent.frames['showroom'].document.open();
	parent.frames['showroom'].document.write(gen_showroom_page());
	parent.frames['showroom'].document.close();
}

function goto_prev()
{
	if (current_showroom_index > 0)
	{
		//current_showroom_index--;
		current_showroom_index = (current_showroom_index - 1 ) % showroom_items.length;
	}
	else
		current_showroom_index = (current_showroom_index - 1 ) % showroom_items.length + showroom_items.length;
		
	frames['showroom'].document.open();
	frames['showroom'].document.write(gen_showroom_page());
	frames['showroom'].document.close();
}

function goto_next()
{
	//current_showroom_index++;
	current_showroom_index = (current_showroom_index + 1 ) % showroom_items.length;

	frames['showroom'].document.open();
	frames['showroom'].document.write(gen_showroom_page());
	frames['showroom'].document.close();
}

function build_showroom_navigation_buttons()
{
	var str = '';
	
	str += '<center>';
	str += '<br>';

	//if (current_showroom_index > 0)
	{
		str += '<a href="javascript:goto_prev();"><img src="Images/Logos/prev.jpg" border="0"></a>';
		// show left arrow
	}
	
	str += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	
	//if (current_showroom_index < (showroom_items.length - 1))
	{
		str += '<a href="javascript:goto_next();"><img src="Images/Logos/next.jpg" border="0"></a>';
		// show right arrow
	}
	
	str += '</center>';

	document.write(str);
}

