var currentImg = "default";

addEvent(window, "load", function() {	
	var objMouseovers = document.getElementsByClassName("iconlist")

	// Loop through all divs with the class of iconlist
	for (var i = 0; i < objMouseovers.length; i++) {
		var bolOnObject = false;
		
		// Attach an event to handle the mouseover of each iconlist div
		Event.observe(objMouseovers[i], 'mouseover', function(event) {
			// Pick up the id of the main iconlist div and uses that for the image name
			if (Event.element(event).tagName == "IMG")
				strId = Event.element(event).parentNode.id;
			else
				strId = Event.element(event).id;
			
			// Change the image
			$('mouseoverpic').innerHTML = "<img src=\"/pics/homepage/" + strId + ".gif\" />";
			currentImg = strId;
			bolOnObject = true;

			// Attach an event to mouseout event
			addEvent($(strId), "mouseout", function() {
				// At a timeout to change the image back to the default in 0.5 seconds
				hideTime = window.setTimeout(function() {
					if(!bolOnObject) {
						if (currentImg != "default") {
							currentImg = "default";
							var fo = new FlashObject("/pics/homepage/mobi-flash.swf?spak=sv", "domainflash", "275", "170", "7");
							fo.addParam("wmode", "transparent")
							fo.write("mouseoverpic");
						}	
					}
						
				}, 1500);
				bolOnObject = false;
			});
					
		}.bind(this), true);
	}
});

function removeEvent( obj, type, fn ) {
   if ( obj.detachEvent ) {
     obj.detachEvent( 'on'+type, obj[type+fn] );
     obj[type+fn] = null;
   } else
     obj.removeEventListener( type, fn, false );
} 