/***** ScriptReaction Mutli Media Development - All Code Copyright ScriptReaction - www.scriptreaction.com *****/

var portNav = {
	controls: {
		inactiveAlpha: 50
	},
	launch: function (x){
		
		var portNavHolder = document.getElementById('bdy_opt');
		var portNavIcons = portNavHolder.getElementsByTagName('img');
		
		portNav.iconNames = new Array();
		
		for(var iconCount=0; iconCount<portNavIcons.length; iconCount++){
			var whichIcon = portNavIcons[iconCount];
			
			whichIcon.id = 'portNavIcon_' + whichIcon.name;
			portNav.iconNames.push(whichIcon.name);
			
			whichIcon.onclick = function (){
				portNav.iconClick(this.id);
				this.blur();
			}
			
			whichIcon.onmouseover = function (){
				portNav.iconOver(this.id);	
			}
			
			whichIcon.onmouseout = function (){
				portNav.iconOut(this.id);	
			}
			
			with(whichIcon.style){
				cursor = 'pointer';	
			}
			
			global.setAlpha(whichIcon, portNav.controls.inactiveAlpha);
			
		}
		
		portNav.total = portNav.iconNames.length;
		
		var starter = (x==0) ? Math.floor(Math.random()*portNav.total) : portNav.total - x; //x=0=random
		starter = (starter < 0) ? portNav.total - 1 : starter;
		portNav.starter = portNav.iconNames[starter];
		global.addEvent(window, 'load', portNav.start);
	},
	start: function (){
		if(portNav.isOn == 0){ //no option selected yet
			portNav.iconClick('portNavIcon_' + portNav.starter);
		}
	},
	isOn: 0,
	iconClick: function (x){
		if(x != portNav.isOn){
			portNav.isOn = x;
			portNav.resetIcons();
			var array_id = x.split('_'); //x[0]='liNav', x[1]=li id;
			var theIcon = document.getElementById('portNavIcon_' + array_id[1]);
			global.setAlpha(theIcon, 100);
			with(theIcon){
				with(style){
					backgroundImage = 'url(' + global.base + 'assets/gfx/bdy_bar6.gif)';
					//backgroundColor = '#cc0000';
					cursor 			= 'default';
				}
				blur();
			}
			var thePage = document.getElementById('item_' + array_id[1]);
			with(thePage.style){
				display	= 'block';
			}
		}
	},
	resetIcons: function (){
		for(var i=0; i<portNav.total; i++){
			var theIcon = document.getElementById('portNavIcon_' + portNav.iconNames[i]);
			global.setAlpha(theIcon, portNav.controls.inactiveAlpha);
			with(theIcon.style){
				backgroundImage = '';
				cursor			= 'pointer';
			}
			var thePage = document.getElementById('item_' + portNav.iconNames[i]);
			with(thePage.style){
				display	= 'none';
			}
		}
	},
	iconOver: function (x){
		if(x != portNav.isOn){
			var array_id = x.split('_'); //x[0]='liNav', x[1]=li id;
			var theIcon = document.getElementById('portNavIcon_' + array_id[1]);
			global.setAlpha(theIcon, 100);
		}
	},
	iconOut: function (x){
		if(x != portNav.isOn){
			var array_id = x.split('_'); //x[0]='liNav', x[1]=li id;
			var theIcon = document.getElementById('portNavIcon_' + array_id[1]);
			global.setAlpha(theIcon, portNav.controls.inactiveAlpha);
			with(theIcon.style){
				backgroundColor = '';
				cursor			= 'pointer';
			}
		}	
	}
}