/** active head **/
var ahead = {
	activeMap : null,
	activeLink : null,
	closer : null,
	caller : null,
	mapOver : function(code) {
		ahead.onEnterMap();
		
		var xx = document.getElementById( "divSearchHead" );
		var il = document.getElementById( "link_" + code );
		var el = document.getElementById( "img_" + code );
		if( !il || !el || !xx ) return;
		
		ahead.mapOut(null);

		il.style.color = "#c1d238";
		var xy = getPageCoords( xx );
		el.style.display = "block";
		el.style.position = "absolute";
		el.style.left = (xy.x + 553) + "px";
		el.style.top = (xy.y + 18) + "px";
				
		self.activeLink = il;
		self.activeMap = el;
	},
	mapOut : function(code) {
		if( self.activeMap )
			self.activeMap.style.display = "none";
		if( self.activeLink )
			self.activeLink.style.color = "";
			
		self.activeMap = null;
		self.activeLink = null;
	},
	onEnterMap : function() {
		if( self.closer != null ) {
			window.clearTimeout( closer );
			self.closer = null;
		}
	},
	onExitMap : function() {
		closer = window.setTimeout( "ahead.hideMap()", 500 );
	},
	showMap : function(se) {
		ahead.onEnterMap();
		menu.finalCleanup();
		self.caller = se;
		var mh = document.getElementById( "divHeadMap" );
		var sh = document.getElementById( "divSearchHead" );
		if( !mh || !sh ) return;
		var xy = getPageCoords( sh );
		mh.style.display = "block";
		mh.style.left = xy.x + "px";
		mh.style.top = xy.y + "px";
		self.caller.style.background = "url(/layout/m_over.gif) repeat-x";
		self.caller.style.color = "#d3d3c9";
	},
	hideMap : function() {
		var mh = document.getElementById( "divHeadMap" );
		if( !mh ) return;
		mh.style.display = "none";
		self.closer = null;
		
		if( self.caller != null ) {
			self.caller.style.background = "";
			self.caller.style.color = "";
		}

		if( self.closer != null ) {
			window.clearTimeout( self.closer );
			self.closer = null;
		}
	},
	searchServices : function(fr) {
		var selection = "";
		var inputs = fr.getElementsByTagName( "INPUT" );
		
		for( var j = 0; j < inputs.length; j ++ ) {
			if( inputs[j].checked !== undefined ) {
				if( inputs[j].checked ) {
					if( selection != "" )
						selection += ":";

					selection += inputs[j].getAttribute( "value" );
				}
			}
		}
		
		if( selection != "" ) {
			var url = servicesTarget + "(*:" + selection + ")";
			document.location.href = url;
		}
		
		return false;
	},
	onEnterServices : function() {
		if( self.closer != null ) {
			window.clearTimeout( closer );
			self.closer = null;
		}
	},
	onExitServices : function() {
		closer = window.setTimeout( "ahead.hideServices()", 500 );
	},
	hideServices : function() {
		var mh = document.getElementById( "divHeadServices" );
		if( !mh ) return;
		mh.style.display = "none";
		self.closer = null;
		
		if( self.closer != null ) {
			window.clearTimeout( self.closer );
			self.closer = null;
		}
	},
	showServices : function() {
		ahead.onEnterServices();
		var mh = document.getElementById( "divHeadServices" );
		var sh = document.getElementById( "divSearchHead" );
		if( !mh || !sh ) return;
		var xy = getPageCoords( sh );
		mh.style.display = "block";
		mh.style.left = xy.x + "px";
		mh.style.top = xy.y + "px";
	}	
};
