// JavaScript Document

locations={
	tactical:{
		x:-130,
		y:0
	},
	civil:{
		x:425,
		y:0
	},
	maritime:{
		x:418,
		y:320
	},
	adventure:{
		x:145,
		y:450
	},
	commercial:{
		x:-125,
		y:320
	}
}
window.addEvent("domready", function(){
 
	$$(".popmenu").each(function(element){
		element.fader=new Fx.Styles(element, {duration:500, transition:Fx.Transitions.Sine.easeInOut});
		element.fader.addEvent("onComplete", function(){
			if(this.element.fadingOut==1){
				$("homedial").setStyle("background-position", "0px 0px");
			}
			this.element.fadingOut=0;
		});
		element.onmouseover=function(){
			clearTimeout(window.timer);
		}
		element.onmouseout=function(){
			this.fadingOut=1;
			window.timer=setTimeout("closer(menu)", 200);
		}
	});
	$$(".dialrollover").each(function(element){
		element.onmouseover=function(){
			menu=$(this.alt);
			if(window.theOpenMenu && window.theOpenMenu.id!=menu.id){
				window.theOpenMenu.fader.stop();
				window.theOpenMenu.fader.start({opacity:0});
			}
			switch(this.alt){
				case "tactical":
					coords=locations.tactical;
					$("homedial").setStyle("background-position", "-444px 0px");
					break;
				case "commercial":
					coords=locations.commercial;
					$("homedial").setStyle("background-position", "-2227px 0px");
					break;
				case "civil":	
					coords=locations.civil;
					$("homedial").setStyle("background-position", "-888px 0px");
					break;
				case "adventure":
					coords=locations.adventure;
					$("homedial").setStyle("background-position", "-1782px 0px");
					break;
				case "maritime":
					coords=locations.maritime;
					$("homedial").setStyle("background-position", "-1338px 0px");
					break;
			}
			menu.fader.stop();
			dial=$("homedial");
			menu.fader.start({
				opacity:[0, 1],
				top:[dial.getPosition().y+coords.y+20, dial.getPosition().y+coords.y],
				left:[dial.getPosition().x+coords.x, dial.getPosition().x+coords.x],
				height:[0, 140]
			});
			window.theOpenMenu=menu;
		};
		element.onmouseout=function(){
			switch(this.alt){
				case "tactical":
					coords=locations.tactical;
					break;
				case "commercial":
					coords=locations.commercial;
					break;
				case "civil":	
					coords=locations.civil;
					break;
				case "adventure":
					coords=locations.adventure;
					break;
				case "maritime":
					coords=locations.maritime;
					break;
			}
			menu=$(this.alt);
			window.timer=setTimeout("closer(menu)", 500);
		};
	});
});

function closer(menu){
	menu.fader.start({
		opacity:0
	});
}