var top_menu_item_text = new Array()
var top_menu_item_link = new Array()
var sub_menu_item = new Array()

top_menu_item_text[0] = "Home"
top_menu_item_link[0] = "http://www.nationalreview.com/"

top_menu_item_text[1] = "Blog Row"
top_menu_item_text[2] = "NRO Radio"
top_menu_item_text[3] = "NRO TV"
top_menu_item_text[4] = "Subscribe"
top_menu_item_text[5] = "Search"
top_menu_item_text[6] = "NR / Digital"

top_menu_item_text[7] = "Shop!"

top_menu_item_text[8] = "Donate"
top_menu_item_link[8] = "https://store.nationalreview.com/donate/"

top_menu_item_text[9] = "Media Kit"
top_menu_item_link[9] = "http://www.nationalreview.com/mediakit/"

top_menu_item_text[10] = "Appearances"
top_menu_item_link[10] = "http://appearances.nationalreview.com/"

top_menu_item_text[11] = "Contact"
top_menu_item_link[11] = "http://www.nationalreview.com/contact/"

sub_menu_item[1] = 	new Array(
				new Array("Bench Memos", "http://bench.nationalreview.com/"),
				new Array("Campaign Spot", "http://campaignspot.nationalreview.com/"),
				new Array("The Corner", "http://corner.nationalreview.com/"),
				new Array("Kudlow", "http://kudlow.nationalreview.com/"),
				new Array("Liberal Fascism", "http://liberalfascism.nationalreview.com/"),
				new Array("Media Blog", "http://media.nationalreview.com/"),
				new Array("Phi Beta Cons", "http://phibetacons.nationalreview.com/"),
				new Array("Planet Gore", "http://planetgore.nationalreview.com/"),
				new Array("Pryce-Jones", "http://pryce-jones.nationalreview.com/"),
				new Array("Tank", "http://tank.nationalreview.com/")
			)

sub_menu_item[2] = 	new Array(
				new Array("Betsy Hart", "http://radio.nationalreview.com/betsyhart/"),
				new Array("Between the Covers", "http://radio.nationalreview.com/betweenthecovers/"),
				new Array("John Derbyshire", "http://www.nationalreview.com/derbradio/")
			)

sub_menu_item[3] = 	new Array(
				new Array("Uncommon Knowledge", "http://tv.nationalreview.com/uncommonknowledge/"),
				new Array("Off the Page", "http://tv.nationalreview.com/offthepage/")
			)

sub_menu_item[4] = 	new Array(
				new Array("Subscribe to <i>National Review</i>", "https://www.nationalreview.com/subscribe/nr.p"),
				new Array("Subscribe to <i>National Review Digital</i>", "https://www.nationalreview.com/subscribe/nrd.p"),
                                new Array("Pay Online", "https://www.kable.com/pub/ntrv/payment.asp"), 
				new Array("Renew your Subscription", "https://www.kable.com/pub/ntrv/renew.asp?theStyle=COABETA"),
				new Array("Give the Gift of NR", "https://www.nationalreview.com/subscribe/gift.p"),
				new Array("Subscription Help", "https://www.nationalreview.com/contact/")
			)

sub_menu_item[5] = 	new Array(
				new Array("National Review Online", "http://search.nationalreview.com/"),
				new Array("NRO Authors", "http://author.nationalreview.com/"),
				new Array("Syndicated Columnists", "http://syndicated.nationalreview.com/"),
				new Array("NR Magazine (pre-2003)", "http://store.nationalreview.com/archives/"),
				new Array("NR Magazine (post-2003)", "http://search.nationalreview.com/?s=NQ==")
			)

sub_menu_item[6] = 	new Array(
				new Array("NR / Digital Home", "http://nrd.nationalreview.com/"),
				new Array("NR / Digital Login", "http://nrd.nationalreview.com/login/"),
				new Array("Search", "http://search.nationalreview.com/?s=NQ==")
			)

sub_menu_item[7] = 	new Array(
				new Array("NRO Store Home", "http://store.nationalreview.com/"),
				new Array("Accessories", "http://store.nationalreview.com/?ic=Mw=="),
				new Array("Books", "http://store.nationalreview.com/?ic=Mg=="),
				new Array("Clothing", "http://store.nationalreview.com/?ic=MQ=="),
				new Array("Specials", "http://store.nationalreview.com/?ic=NQ=="),
				new Array("Stationery", "http://store.nationalreview.com/?ic=Ng=="),
				new Array("Buy Jay Nordlinger's Book!", "http://store.nationalreview.com/?i=Zjk5ZGU3NmE5MGZhZGE2NmNkZWY1NWYyN2QxMTQ2OGY=")
			)


function show_menu(menu_number)
{
	var topHTML = ""
	var subHTML = ""
	var allHTML = ""

	allHTML  = top_menu(menu_number)
	allHTML += sub_menu(menu_number)

	if (!document.getElementById('menu'))
	{
		document.write('<div id="menu" style="margin: 0px; border:0px; padding:0px;">')
		document.write('</div>')
	}

	document.getElementById('menu').innerHTML = allHTML
}

function top_menu(menu_number)
{
	var topHTML = ""
	var style_class = ""
	if (sub_menu_item[menu_number])
	{
		topHTML  = '<table cellpadding=0 cellspacing=0 width=100%><tr><td class="off_fill">'
	} else {
		topHTML  = '<table cellpadding=0 cellspacing=0 width=100%><tr><td class="off_fill_border">'
	}
	topHTML += '<table cellpadding=0 cellspacing=0><tr>'
	for(i=0;i<top_menu_item_text.length;i++)
	{
		if (i == menu_number)
		{
			style_class = "on"
		} else {
			style_class = "off"
		}
		topHTML += '<td class="'+style_class+'">'
		topHTML += '&nbsp;&nbsp;&nbsp;&nbsp;'
		if (top_menu_item_link[i])
		{
			topHTML += '<a href="'+top_menu_item_link[i]+'" class="link_'+style_class+'">'+top_menu_item_text[i]+'</a>'
		} else {
			topHTML += '<a href="javascript:void(0)" onClick="javascript: show_menu('+i+');" class="link_'+style_class+'">'+top_menu_item_text[i]+'</a>'
		}
		topHTML += '&nbsp;&nbsp;&nbsp;&nbsp;'
		topHTML += '</td>'
		topHTML += '<td class="off_divider" width=1> </td>'
	}
	topHTML += '</table>'
	topHTML += '</td></tr></table>'
	return topHTML
}

function sub_menu(menu_number)
{
	var subHTML = ""
	var subber = ""
	if (sub_menu_item[menu_number])
	{
		subHTML  = '<table cellpadding=0 cellspacing=0 width=100%><tr><td class="on_sub">'
		subHTML += '<table cellpadding=0 cellspacing=0><tr>'
		for(i=0;i<sub_menu_item[menu_number].length;i++)
		{
			subHTML += '<td class="on_sub'+subber+'">'
			subHTML += '&nbsp;&nbsp;&nbsp;&nbsp;'
			subHTML += '<a href="'+sub_menu_item[menu_number][i][1]+'" class="link_sub">'+sub_menu_item[menu_number][i][0]+'</a>'
			subHTML += '&nbsp;&nbsp;&nbsp;&nbsp;'
			subHTML += '</td>'
			subHTML += '<td class="sub_divider" width=1> </td>'
		}
	


// SIGN_IN = 1 MEANS YOU ARE LOGGED IN

               if (menu_number == 6 ){
                             if (sign_in == 1) {
                                 subHTML += '<td class="on_sub'+subber+'"><span style="font-family: Arial; font-weight:bold;  font-size: 8pt; color: #99FF99;">You are now logged in</span></td>'
                                 }


else {
 

 subHTML += '<td class="on_sub'+subber+'"><span style="font-family: Arial; font-weight:bold;  font-size: 8pt; color: #FF0000;">You are not logged in</span></td>'


subHTML += '<td class="on_sub'+subber+'" valign="middle">&nbsp;&nbsp;&nbsp;&nbsp;Username: <input class="input_text" type=text name="UserName" size=20 maxlength=15>&nbsp;&nbsp;&nbsp;&nbsp;</td>'
subHTML += '<td class="on_sub'+subber+'" valign="middle">&nbsp;&nbsp;&nbsp;&nbsp;Password: <input class="input_text" type=password name="PW" size=20 maxlength=10>&nbsp;&nbsp;&nbsp;&nbsp;</td>'
subHTML += '<td class="on_sub'+subber+'" valign="middle">&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit value="Login">&nbsp;&nbsp;&nbsp;&nbsp;</td>'

subHTML += '<input type="hidden" name="MagCode" value="ONNR">'
subHTML += '<input type="hidden" name="RecordID" value="DMO">'
subHTML += '<input type="hidden" name="URL" value="request_q">'
subHTML += '<input type="hidden" name="mvForwardingLink" value="http://nrd.nationalreview.com/setcookie.p">'
subHTML += '<input type="hidden" name="memVal" value="1">'
subHTML += '<input type="hidden" name="multiMagCodeAccess" value="1">'
subHTML += '<input type="hidden" name="addtlMagCodes" value="ONNR,NTRV">'
subHTML += '<input type="hidden" name="AddIssUrl" value="1">'
subHTML += '<input type="hidden" name="fromLink" value="/pub/onnr/memvalidation.asp">'
subHTML += '<input type="hidden" name="passBackUniqueID" value="1">'
subHTML += '<input type="hidden" name="passBackMagCode" value="1">'
subHTML += '</form>'

 
}
}










        	subHTML += '</table>'
		subHTML += '</td></tr></table>'
	}
	return subHTML
}

function replaceAll( str, from, to )
{
	var idx = str.indexOf( from );

	while ( idx > -1 )
	{
        	str = str.replace( from, to )
	        idx = str.indexOf( from )
	}

	return str
}

