// JavaScript Document

function nav_container(cur_dir)
{
	this.base = 'http://www.plaync.com/us/';
	this.cur_dir = cur_dir;
	this.elements = new Array();
	this.add = function(btn_name, alt, href)
		{
			this.elements.push(new nav_main(btn_name, alt, href));
		}
	this.output = function()
		{
			var output = '';
			var is_cur_dir = false;
			var this_link = '';
			var this_sub_link = '';
			
			for(var i=0; i < this.elements.length; i++)
			{
				is_cur_dir = (this.cur_dir == this.elements[i].href.replace(/\//g, '') || this.exception(i)) ? true : false;
				
				this_link = (this.elements[i].href.indexOf('http') == 0) ? this.elements[i].href : this.base + this.elements[i].href;
				if(is_cur_dir)
				{
					output += '<a href="' + this_link + '">' +
							  '<img src="' + this.elements[i].img_on.src + '" border="0" />' +
							  '</a>';
							  
					for(var j=0; j < this.elements[i].children.length; j++)
					{
						this_sub_link = (this.elements[i].children[j].href.indexOf('http') == 0) ? this.elements[i].children[j].href : this.base + this.elements[i].children[j].href;
						output += '<div class="' + ((document.location.href.indexOf(this.elements[i].children[j].href) >= 0) ? 'navSubActive' : 'navSub') + '"><a href="' + this_sub_link + '">' + this.elements[i].children[j].title.toUpperCase() + '</a></div>';
					}
				} else {
					output += '<a href="' + this_link + '">' +
							  '<img src="' + ((is_cur_dir) ? this.elements[i].img_on.src : this.elements[i].img_off.src) + '" border="0" alt="' + this.elements[i].alt + '" onmouseover="this.src=\'' + this.elements[i].img_on.src + '\';" onmouseout="this.src=\'' + this.elements[i].img_off.src + '\';" />' + 
							  '</a><br />';
				}
			}
			return output;
		}
	this.e = function(title, href)
		{
			this.elements[this.elements.length - 1].add(title, href);
		}
	
	this.exception = function(element)
		{
			var my_element = this.elements[element];
			

			// Help Main
			if(my_element.href == 'help/')
			{
				if(document.location.href.indexOf('plaync--upgrade.custhelp.com') != -1) { return true; }
				if(document.location.href.indexOf('support.plaync.com') != -1) { return true; }
				if(document.location.href.indexOf('help.plaync.com') != -1) { return true; }
			}

			if(my_element.href.indexOf('http://') != -1)
			{
				if(document.location.href.indexOf(my_element.href) != -1)
				{
					return true;
				}
			}
			
			return false;
		}
}
function nav_main(btn_name, alt, href)
{
	this.alt = alt;
	this.btn_name = btn_name;
	this.href = href;
	this.children = new Array();
	this.add = function(title, href)
		{
			this.children.push(new nav_sub(title, href));
		}
	this.img_on = new Image();
		this.img_on.src = 'http://www.plaync.com/us/images/' + this.btn_name.replace(/\./, '_on.');
	this.img_off = new Image();
		this.img_off.src = 'http://www.plaync.com/us/images/' + this.btn_name.replace(/\./, '_off.');
}
function nav_sub(title, href)
{
	this.title = title;
	this.href = href;
}

function output_nav()
{
	var cur_dir = (document.location.href).split('/');
		cur_dir = (cur_dir.length > 3) ? cur_dir[4] : 'top';
	
	var nc = new nav_container(cur_dir);
	nc.add('b_home.gif', 'Home', '');
	nc.add('b_news.gif', 'News', 'news/');
		nc.e('E3 News', 'news/e3.html');
		nc.e('E3 Gallery', 'news/e3_gallery/');
		nc.e('E3 Movies', 'news/e3_movies/');		
		nc.e('News Archive', 'news/news_archive.html');
		nc.e('Press Release Archive', 'news/press.html');
	nc.add('b_devc.gif', 'Dev Corner', 'devcorner/');
	nc.add('b_games.gif', 'Games', 'games/');
		nc.e('Aion', 'games/aion/');
		nc.e('City of Heroes', 'games/coh/');
		nc.e('City of Villains', 'games/cov/');
		nc.e('Dungeon Runners', 'games/dr/');
		nc.e('Exteel', 'games/exteel/');
		nc.e('Guild Wars', 'games/gwp/');
		nc.e('Guild Wars Factions', 'games/gwf/');
		nc.e('Guild Wars Nightfall', 'games/gwn/');
		nc.e('Guild Wars Eye of the North', 'games/gwen/');
		nc.e('Lineage', 'games/lineage/');
		nc.e('Lineage II', 'games/l2/');
		nc.e('Tabula Rasa', 'games/tr/');
		
	nc.add('b_store.gif', 'Store', 'https://secure.plaync.com/cgi-bin/Store.pl');
	nc.add('b_account.gif', 'Account', 'account/');
	nc.add('b_about.gif', 'About NCSoft', 'about/');
	
	nc.add('b_jobs.gif', 'Careers Page', 'jobs/');
		nc.e('Austin', 'jobs/jobs_austin.html');
		nc.e('Orange County', 'jobs/jobs_oc.html');
		nc.e('Santa Monica', 'jobs/jobs_sm.html');
		nc.e('Europe', 'http://eu.plaync.com/eu/jobs/');
	nc.add('b_help.gif', 'Help', 'help/');
		nc.e('Copyright', 'help/legal_copyright.html');
		//nc.e('Support Center', 'http://www.plaync.com/us/support/');
		nc.e('Legal', 'help/legal.html');
		nc.e('Privacy Policy', 'help/privacy.html');
		nc.e('Security FAQ', 'http://support.plaync.com/cgi-bin/plaync.cfg/php/enduser/std_adp.php?p_faqid=993');
		nc.e('Seizure Warning', 'help/seizure_warning.html');
		nc.e('User Agreements', 'help/agreements.html');
		
	
	document.write('<div id="nav">' + nc.output() + '</div>');
}
output_nav();
