//<script>
var current_tab = 'td_tab_left';

function show_tab (td_tab)
{
	if (current_tab != td_tab)
	{
		var tab_to_show = document.getElementById(td_tab);
		tab_to_show.style.background='url(images/tab_on_bg.gif)';
	}
}

function hide_tab (td_tab)
{
	if (current_tab != td_tab)
	{
		var tab_to_hide = document.getElementById(td_tab);
		tab_to_hide.style.background='url(images/tab_off_bg.gif)';
	}
}

function set_tab (td_tab)
{
	var div_for_content = document.getElementById('div_' + td_tab);
	document.getElementById('td_search_panel').innerHTML = div_for_content.innerHTML;

	// Set correct tab background
	document.getElementById('td_tab_left').style.background = 'url(images/tab_off_bg.gif)';
	document.getElementById('td_tab_right').style.background = 'url(images/tab_off_bg.gif)';

	document.getElementById(td_tab).style.background = 'url(images/tab_on_bg.gif)';

	current_tab = td_tab;
}

var menu_items = new Array();
var menu_links = new Array();

menu_items["Past Issues"] = new Array("Order Back Issues", 
									"Search Back Issues");

menu_links["Past Issues"] = new Array("order_past.asp", 
									"past_issues.asp");

menu_items["Current Issue"] = new Array("Come Stay With Me", 
									"Come Spa With Me",
									"Come Buy Me",
									"Come Dine With Me",
									"City Breaks");
									
menu_links["Current Issue"] = new Array("index.asp", 
									"index.asp",
									"index.asp",
									"index.asp",
									"index.asp");


menu_items["Advertise"] = new Array("Our clients", 
									"Media Kit",
									"Advertising Representatives");
menu_links["Advertise"] = new Array("advert_list.asp", 
									"pdf/" + strMedia_Kit,
									"contact_us.asp");

menu_items["About"] = new Array("l+t Media", 
									"About Us");
menu_links["About"] = new Array("media.asp", 
									"about_us.asp");


function menu_sub_on(menu_to_show)
{

	var td_to_show = document.getElementById('td_menu_sub_items');
	
//	var strMenu_sub = '<table cellspacing="0" cellpadding="0"><tr>'; OLD VERSION, NOW ALL RIGHT ALIGNED ANYWAY

//	if (menu_to_show == 'Advertise')
//	{
	strMenu_sub = '<table cellspacing="0" cellpadding="0" style="text-align: right; width: 100%"><tr><td><a>&nbsp;</a></td>';
//	}

	for (i = 0; i < menu_items[menu_to_show].length; i++)
	{
		if (menu_to_show == 'Advertise')
		{
			if (menu_items[menu_to_show][i] == 'Media Kit')
			{
				strMenu_sub += '<td id="td_menu_sub_text' + i + '" class="td_menu_sub_text_shorter" style="width: 65px;"><a href="' + menu_links[menu_to_show][i] + '" target="_blank">' + menu_items[menu_to_show][i] + '</a></td>';
			}
			else if (menu_items[menu_to_show][i] == 'Advertising Representatives')
			{
				strMenu_sub += '<td id="td_menu_sub_text' + i + '" class="td_menu_sub_text_shorter" style="width: 190px;"><a href="' + menu_links[menu_to_show][i] + '" target="_blank">' + menu_items[menu_to_show][i] + '</a></td>';
			}
			else
			{
				strMenu_sub += '<td id="td_menu_sub_text' + i + '" class="td_menu_sub_text_shorter"><a href="' + menu_links[menu_to_show][i] + '">' + menu_items[menu_to_show][i] + '</a></td>';
			}
		}
		else if (menu_to_show == 'About')
		{
			strMenu_sub += '<td id="td_menu_sub_text' + i + '" class="td_menu_sub_text_shorter_about"><a href="' + menu_links[menu_to_show][i] + '">' + menu_items[menu_to_show][i] + '</a></td>';
		}
	}
	
	strMenu_sub += '</tr></table>';
	
	td_to_show.innerHTML = strMenu_sub

	increase = 1;
	opacity = 0;
	
	if (document.all && document.getElementById)
	{
		//document.getElementById('td_menu_sub_items').filters.alpha.opacity = opacity * 100;
	}
	else
	{
		document.getElementById('td_menu_sub_items').style.MozOpacity = opacity;
	}
	
	setInterval("fade()", 20)

	
}
function menu_sub_off(strPage)
{
	var td_to_show = document.getElementById('td_menu_sub_items');
	
	if (strPage == 'advert_list')
	{
		menu_sub_on('Advertise')
	}
	else if (strPage == 'about_us' || strPage == 'media')
	{
		menu_sub_on('About')
	}
	else
	{
		td_to_show.innerHTML = '<p>&nbsp;</p>';
	}
	
	if (document.all && document.getElementById)
	{
		//document.getElementById('td_menu_sub_items').filters.alpha.opacity = 0;
	}
	else
	{
		document.getElementById('td_menu_sub_items').style.MozOpacity = 0;
	}
}

var opacity=0; //opacity of image
var increase=1; //increase opacity indicator

function fade()
{

	if (opacity <= 1 && increase)
		opacity += 0.05;
	else
	{
		increase=0;
	}

	if (document.all && document.getElementById)
	{
		//document.getElementById('td_menu_sub_items').filters.alpha.opacity = opacity * 100;
	}
	else
	{
		document.getElementById('td_menu_sub_items').style.MozOpacity = opacity;
	}
	
}

function go_to_issue ()
{
	var intIssue_Number = document.getElementById("sel_Issues").value;
	
	document.location = "past_issue_contents.asp?id=" + intIssue_Number
	
}


function FormatNumber(num, decimalNum, bolLeadingZero, bolParens, bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
{ 
        if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	return tmpNumStr;		// Return our formatted string!
}
