var mapMaker = {
	offsetX: 16, // tooltip X offset
	offsetY: 16,  // tooltip Y offset
	element: false,
	DLs:     false,
	DTs:     false,
	on:      false,
	/* constructor - sets events */
	init: function(){
		var i=0;
		var ii=0;
		var currentLocation = 0;
		mapMaker.DLs = document.getElementsByTagName('dl');
		mapMaker.DTs = document.getElementsByTagName('dt');
		// only loop thru items once
		if( mapMaker.on == false ){
			//loop through each DL on page
			while (mapMaker.DLs.length > i) {
				//only affect DLs with a class of 'map'
				if (mapMaker.DLs[i].className == 'map on'){
					//change map DL class, this way map is text only without javascript enabled
					mapMaker.DLs[i].className = 'map on';
					//strip whitespace
					mapMaker.stripWhitespace(mapMaker.DLs[i]);
					mapMaker.stripWhitespace(mapMaker.DTs[i]);
					// loop thru all DT elements
					while (mapMaker.DTs.length > ii){
						//current Location
						currentLocation = mapMaker.DTs[ii].firstChild;
						// add events to links
						mapMaker.addEvt(currentLocation,'mouseover',mapMaker.showTooltip);//displays tooltip on mouse over
						mapMaker.addEvt(currentLocation,'mouseout',mapMaker.hideTooltip);//hide tooltip on mouse out
						mapMaker.addEvt(currentLocation,'focus',mapMaker.showTooltip);//display tooltip on focus, for added keyboard accessibility
						mapMaker.addEvt(currentLocation,'blur',mapMaker.hideTooltip);//hide tooltip on focus, for added keyboard accessibility
						ii++;
					};
					ii=0;
				};
				i++;
			};
			mapMaker.on = true;
		};
	},
	/* SHOW TOOLTIP */
	showTooltip: function() {
		var evt = this;
		var i = 0;
		//Find DD to display - based on currently hovered anchor move to parent DT then next sibling DD
		var objid = evt.parentNode.nextSibling;
		mapMaker.element = objid;//set for the hideTooltip
		//get width and height of background map
		var mapWidth  = objid.parentNode.offsetWidth;
		var mapHeight = objid.parentNode.offsetHeight;
		//get width and height of the DD
		var toopTipWidth = objid.offsetWidth;
		var toopTipHeight = objid.offsetHeight;
		//figure out where tooltip should be places based on point location
		var newX = evt.offsetLeft + mapMaker.offsetX;
		var newY = evt.offsetTop + mapMaker.offsetY;
		var customOffsetHeight = getCustomHeight(evt.offsetLeft, evt.offsetTop);
		
		var browserType = navigator.appName;
		if(navigator.appName=="Microsoft Internet Explorer")
		{
			customOffsetHeight = customOffsetHeight + 0;
				//check if tooltip fits map width 
		objid.style.left = newX -305+ 'px';
		}
		
		if(navigator.appName=="Netscape")
		{
			customOffsetHeight = customOffsetHeight - 5;
				//check if tooltip fits map width 
		objid.style.left = newX -335+ 'px';
		}
		
		//check if tooltip fits map width 
		//objid.style.left = newX -305+ 'px';
		//check if tooltip fits map height 
		objid.style.top = newY-toopTipHeight+ customOffsetHeight + 'px';
	},
	/* HIDE TOOLTIP */
	hideTooltip: function() {
		mapMaker.element.style.left = '-9999px';
	},
	addEvt: function(element, type, handler) {
		// assign each event handler a unique ID
		if (!handler.$$guid) handler.$$guid = mapMaker.addEvt.guid++;
		// create a hash table of event types for the element
		if (!element.events) element.events = {};
		// create a hash table of event handlers for each element/event pair
		var handlers = element.events[type];
		if (!handlers) {
			handlers = element.events[type] = {};
			// store the existing event handler (if there is one)
			if (element["on" + type]) {
				handlers[0] = element["on" + type];
			};
		};
		// store the event handler in the hash table
		handlers[handler.$$guid] = handler;
		// assign a global event handler to do all the work
		element["on" + type] = mapMaker.handleEvent;
	},
	handleEvent: function(event) {
		var returnValue = true;
		// grab the event object (IE uses a global event object)
		event = event || mapMaker.fixEvent(window.event);
		// get a reference to the hash table of event handlers
		var handlers = this.events[event.type];
		// execute each event handler
		for (var i in handlers) {
			this.$$handleEvent = handlers[i];
			if (this.$$handleEvent(event) === false) {
				returnValue = false;
			};
		};
		return returnValue;
	},
	fixEvent: function(event) {
		// add W3C standard event methods
		event.preventDefault = mapMaker.fixEvent.preventDefault;
		event.stopPropagation = mapMaker.fixEvent.stopPropagation;
		return event;
	},
	stripWhitespace: function( el ){
		for(var i = 0; i < el.childNodes.length; i++){
			var node = el.childNodes[i];
			if( node.nodeType == 3 && !/\S/.test(node.nodeValue)) {
				node.parentNode.removeChild(node);
			};
		};
	}
};
mapMaker.fixEvent.preventDefault = function() {this.returnValue = false;};
mapMaker.fixEvent.stopPropagation = function() {this.cancelBubble = true;};
mapMaker.addEvt.guid = 1;


/* LOAD SCRIPT */
	/* for Mozilla */
		if (document.addEventListener) {
			document.addEventListener("DOMContentLoaded", mapMaker.init, null);
		};
		
	/* for Internet Explorer */
		/* @cc_on @ */
		/* @if (@_win32)
			document.write("<script defer src=javascript:init()><"+"/script>");
		/* @end @ */
		
	/* for other browsers */
		mapMaker.addEvt( window, 'load', mapMaker.init);
		
function getCustomHeight(left, top)
{
	if(left==528 && top==155)
	{
		//location01(North America)
		return(14);
	}
	
	if(left==236 && top==248)
	{
		//location02(Singapore)
		return(54);
	}
	
	if(left==434 && top==110)
	{
		if(navigator.appName=="Microsoft Internet Explorer")
		{
		//location06(North America)
		return(28);
		}
		if(navigator.appName=="Netscape")
		{
		//location06(North America)
		return(30);
		}
	}
	
	if(left==353 && top==348)
	{
		if(navigator.appName=="Microsoft Internet Explorer")
		{
		//location10(NewZealand)
		return(80);
		}
		if(navigator.appName=="Netscape")
		{
			return(70);
		}
	}
	
	if(left==308 && top==338)
	{
		if(navigator.appName=="Microsoft Internet Explorer")
		{
		//location11(Australia -Sydney)
		return(80);
		}
		if(navigator.appName=="Netscape")
		{
		return(65);
		}
	}
	
	if(left==319 && top==318)
	{
		//location12(Aus-Gold Coast)
		return(26);
	}
	
	if(left==311 && top==296)
	{
		if(navigator.appName=="Netscape")
		{
		//location13(Aus-Cairns)
		return(15);
		}
		if(navigator.appName=="Microsoft Internet Explorer")
		{
		return(30);
		}
	}
	
	if(left==344 && top==302)
	{
		if(navigator.appName=="Netscape")
		{
		//location14(NewCaledonia)
		return(30);
		}
		if(navigator.appName=="Microsoft Internet Explorer")
		{
			return(25);
		}
	}
	
	if(left==305 && top==243)
	{
		if(navigator.appName=="Netscape")
		{
		//location18(Palau)
		return(15);
		}
		if(navigator.appName=="Microsoft Internet Explorer")
		{
		return(25);
		}
	}
	
	if(left==261 && top==267)
	{
		if(navigator.appName=="Netscape")
		{
		//location21(Indonesia-bali)
		return(95);
		}
		if(navigator.appName=="Microsoft Internet Explorer")
		{
		return(105);
		}
	}

	
	if(left==253 && top==190)
	{
		//location24(HongKong)
		return(132);
	}
	
	if(left==253 && top==198)

	{
		if(navigator.appName=="Netscape")
		{
		//location25(Macau)
		return(70);
		}
		if(navigator.appName=="Microsoft Internet Explorer")
		{
		//location25(Macau)
		return(80);
		}
	}
	
	if(left==250 && top==207)
	{
		if(navigator.appName=="Netscape")
		{
		//location26(China-Hainan)
		return(85);
		}
		if(navigator.appName=="Microsoft Internet Explorer")
		{
		//location26(China-Hainan)
		return(80);
		}
	}
	
	if(left==274 && top==188)
	{
		//location27
		return(26);
	}
	
	if(left==284 && top==177)
	{
		//location28(Japan-okinawa)
		return(54);
	}
	
	if(left==394 && top==181)
	{
		if(navigator.appName=="Microsoft Internet Explorer")
		{
		//location34(Hawaii)
		return(110);
		}
		if(navigator.appName=="Netscape")
		{
		//location34(Hawaii)
		return(95);
		}
	}
	
	if(left==430 && top==136)
	{
		if(navigator.appName=="Microsoft Internet Explorer")
		{
			
			//location37(Hollywood)
			return(25);
		}
		if(navigator.appName=="Netscape")
		{
			//location37(Hollywood)
			return(18);
		}

	}
		
	
	if(left==246 && top==218)
	{
		//location41(Vietnam)
		return(54);
	}
	
	if(left==340 && top==232)
	{
		if(navigator.appName=="Microsoft Internet Explorer")
		{
			//location46(Saipan)
		       return(70);

		}
		if(navigator.appName=="Netscape")
		{
			//location46(Saipan)
			return(54);
		}

	}
	
	if(left==348 && top==243)
	{
		if(navigator.appName=="Microsoft Internet Explorer")
		{
			//location47(Guam)
			return(70);
		}
		if(navigator.appName=="Netscape")
		{
			//location47(Guam)
			return(54);
		}
	}
	
	if(left==335 && top==364)
	{
		//location51
		return(26);
	}
	if(left==138 && top==192)
	{
		if(navigator.appName=="Microsoft Internet Explorer")
		{
		//location52(UnitedArabEmirates)
		return(120);
		}
		if(navigator.appName=="Netscape")
		{
		//location52(UnitedArabEmirates)
			return(105);
		}
	}
	if(left==175 && top==206)
	{
             //location53(India)
             return(15);
       }
	
}

