function swapDiv( divId  )
{
	turnoff('home');
	turnoff('about_us');
	turnoff('why_shred');
	turnoff('shredding_services');
	turnoff('faq');
	turnoff('news');
	turnoff('contact_us');
	turnon( divId );
}

function turnoff( targetId ){
	target = document.getElementById(targetId);
	if ((!target.style.display) || (target.style.display == "block")) 
	{
		target.style.display = "none"; 
	}	
}

function turnon(targetId){
	target = document.getElementById(targetId).style;
	target.display = "block";
}

function remove_class_selected()
{
	this.mainNav = document.getElementById('nav_bar');

	this.nav_links = this.mainNav.getElementsByTagName('a');

	len = this.nav_links.length;

	for(var ii=0; ii < len; ii++ )
	{
		switch(this.nav_links[ii].className)
		{
			case 'selected':
				//this.nav_links[ii].removeAttribute('class');
				this.nav_links[ii].className = '';
				break;
		}
	}
}

function create_links()
{
	this.mainNav = document.getElementById('nav_bar');

	this.nav_links = this.mainNav.getElementsByTagName('a');

	len = this.nav_links.length;

	var class_links = this.nav_links;

	for(var i=0; i < len; i++ )
	{
		switch(this.nav_links[i].firstChild.nodeValue)
		{
			
			case 'Home':
				this.nav_links[i].onmouseover = function()
				{
					remove_class_selected();
					class_links[6].className='selected';
					swapDiv('home');
				}
				if( this.nav_links[i].className == 'selected'){ swapDiv('home'); }
				
				
				break;
			
			case 'About Us':
				this.nav_links[i].onmouseover = function()
				{
					remove_class_selected();
					class_links[6].className='selected';
					swapDiv('about_us');
				}
				if( this.nav_links[i].className == 'selected'){ swapDiv('about_us'); }
				
				
				break;

			case 'Why Shred':
				this.nav_links[i].onmouseover = function()
				{
					remove_class_selected();
					//class_links[1].setAttribute('class','selected');
					class_links[5].className='selected';
					swapDiv('why_shred');
				}
				if( this.nav_links[i].className == 'selected'){ swapDiv('why_shred'); }
				break;

			case 'Shredding Services':
				this.nav_links[i].onmouseover = function()
				{
					remove_class_selected();
					class_links[4].className='selected';
					swapDiv('shredding_services');
				}
				if( this.nav_links[i].className == 'selected'){ swapDiv('shredding_services'); }
				break;
				
				
						case 'FAQ':
				this.nav_links[i].onmouseover = function()
				{
					remove_class_selected();
					class_links[6].className='selected';
					swapDiv('faq');
				}
				if( this.nav_links[i].className == 'selected'){ swapDiv('faq'); }
				
				
				break;
				
							case 'News':
				this.nav_links[i].onmouseover = function()
				{
					remove_class_selected();
					class_links[6].className='selected';
					swapDiv('news');
				}
				if( this.nav_links[i].className == 'selected'){ swapDiv('news'); }
				
				
				break;
				
							case 'Contact Us':
				this.nav_links[i].onmouseover = function()
				{
					remove_class_selected();
					class_links[6].className='selected';
					swapDiv('contact_us');
				}
				if( this.nav_links[i].className == 'selected'){ swapDiv('contact_us'); }
				
				
				break;
		}

	}
}

window.onload=create_links;