/* 	event.js v2.0 030222 (c)h */
function initEvent() {
	eventHolder = new Array(); //global
}
function addEvent(trig, events) {
	eventHolder[trig] = new Array();
	var i = events.length - 1;
	do {
		var type = events[i]['type'];
		var opt = events[i]['opt'];
		if (type == 'infoShow') {
			eventHolder[trig][i] = new EventInfoShow(opt);
		}
		if (type == 'imageSwap') {
			eventHolder[trig][i] = new EventImageSwap(opt);
		}
		if (type == 'playSound') {
			eventHolder[trig][i] = new EventPlaySound(opt);
		}
	} while (i-- > 0)
	//set event handlers on trigger
	var obj = getObj(trig);
	if (obj) {
		obj.onmouseover = new Function('doOverEvent(this);')
		obj.onfocus = new Function('doOverEvent(this);')
		obj.onmouseout = new Function('doOutEvent(this);')
		obj.onblur = new Function('doOutEvent(this);')
	}
}
function doOverEvent(obj) {
	var trig = obj.id;
	var i = eventHolder[trig].length - 1;
	do {
		eventHolder[trig][i].over();
	} while (i-- > 0)
}
function doOutEvent(obj) {
	var trig = obj.id;
	var i = eventHolder[trig].length - 1;
	do {
		eventHolder[trig][i].out();
	} while (i-- > 0)
}
//InfoShow
function EventInfoShow(opt) {
	this.over = new Function("doEventInfoShow('" +opt['target']+ "', '" +opt['src']+ "');")
	this.out = new Function("doEventInfoShow('" +opt['target']+ "');")
}
	function doEventInfoShow(target, src) {
		var content;
		if (src) {
			idShow(target);
			content = getContent(src);
		}
		else {
			idHide(target);
			content = "&nbsp;";
		}
		setContent(target, content);
	}
//ImageSwap
function EventImageSwap(opt) {
	this.over = new Function("doEventImageSwap('" +opt['img']+ "', '" +opt['b']+ "');");
	this.out = new Function("doEventImageSwap('" +opt['img']+ "', '" +opt['a']+ "');");
}
	function doEventImageSwap(id, url){
		var img = getObj(id);
		if (img) img.src = url;
		return true;
	}
//PlaySound
function EventPlaySound(option) {
	this.over = new Function("doPlaySound('" +option['id']+ "', '" +option['label']+ "');");
	this.out = new Function(";");
}
	function doPlaySound(id, label) {
		var swf = getSWF(id);
		if (swf) {
			swf.Rewind();
			swf.TGotoLabel("_flash0", label);
			swf.Play();
		}
	}
		function getSWF(id) {
			if (!ie) return null; //n6x does not support liveconnect!!!
			var swf;
			if (w3c) swf = document.getElementById(id);
			else if (ie) swf = window.document[id];
			//else if (ns4) swf = document.embeds[id]; 
		 	if (swf.PercentLoaded() < 100) return null
			return swf;
		}

		/* test props */
		function testprops(thing) {
			ps = [];i = 0
			for (p in thing) {ps[i] = p + " ";i++;}
			ps.sort()
			alert(ps.join("---"))
		}

