// from http://www.quirksmode.org/ by Peter-Paul Koch

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	if (this.obj) this.style = this.obj.style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	if (this.obj) this.style = this.obj.style;
  }
  else if (document.layers)
  {
	this.obj = getObjNN4(document,name);
	this.style = this.obj;
  }
  else
  {
  	this.obj = false;
  	this.style = false;
  }
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}

function writit(text,id)
{
	if (document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = text;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = text;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		text2 = '<P CLASS="testclass">' + text + '</P>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

// END

function ShowObj(ID, blok) {
	var x = new getObj(ID);
	if (!blok) blok = 'inline';
	if (x.style) {
		x.style.display = blok;
	}
}

function HideObj(ID) {
	var x = new getObj(ID);
	if (x.style) {
		x.style.display = 'none';
	}
}

function SwitchObj(ID1, ID2) {
	var x = new getObj(ID1);
	var y = new getObj(ID2);
	if (x.style && y.style) {
		temp = x.style.display;
		x.style.display = y.style.display;
		y.style.display = temp;
	}
}

function ShowNext(list) {
	if (list.count > list.current+1) {
		HideObj(list.ids[list.current++]);
		ShowObj(list.ids[list.current]);
		UpdateButtons(list);
	}
}

function ShowPrev(list) {
	if (list.current > 0) {
		HideObj(list.ids[list.current--]);
		ShowObj(list.ids[list.current]);
		UpdateButtons(list);
	}
}

function UpdateButtons(list) {
	if (list.current+1 < list.count)
		ShowObj(list.next_button);
	else {
		HideObj(list.next_button+'on');
		ShowObj(list.next_button+'off');
		HideObj(list.next_button);
	}

	if (list.current > 0)
		ShowObj(list.prev_button);
	else {
		HideObj(list.prev_button+'on');
		ShowObj(list.prev_button+'off');
		HideObj(list.prev_button);
	}
}

function CreateList() {
	this.prev_button = '';
	this.next_button = '';
	this.current = 0;
	this.count = 0;
	this.ids = new Array();
}

function AddToList(list, id) {
	list.ids[list.count++] = id;
}

function flashme(obj) {
	if (!swfobject.hasFlashPlayerVersion("9.0.0")) return false;

	var params = {
		"menu": "false",
		"quality": "high",
		"wmode": "transparent",
		"allowScriptAccess": "sameDomain",
		"bgcolor": "#FFFFFF"
	};

	var name = '';
	switch (obj.nodeName) {
		case 'IMG':
		case 'img':
			name = obj.src;
			var map = obj.getAttribute("usemap");
			if (map && (map = new getObj(map.replace(/^#/, '')))) {
				map.obj.parentNode.removeChild(map.obj);
			}
			break;

		case 'DIV':
		case 'div':
			// we use div only for IE to show PNG alpha images
			if (obj.style.filter) {
				name = obj.style.filter.replace(/(.*)AlphaImageLoader\(src\=\'/, '');
				name = name.replace(/\'(.*)/, '');
			}
			break;

		default:
			return;
			break;
	}
	name = name.replace(/\.(\w{3})$/, '.swf');

	if (!document._flashed) document._flashed = 0;
	document._flashed++;
	if (!obj.id) obj.setAttribute("id", "flashed"+document._flashed);

	var attributes = {
		"id": obj.id,
		"name": obj.id,
		"align": "bottom",
		"style": obj.getAttribute("style")
	};
	swfobject.embedSWF(name, obj.id, obj.width, obj.height, "9.0.0", "web_gfx/expressInstall.swf", false, params, attributes);
}

function flashall() {
	if (!swfobject.hasFlashPlayerVersion("9.0.0")) return false;

	var index = 0;
	while (1) {
		var temp = new getObj('flashme'+(index++));
		if (!temp || !temp.obj) break;
		temp = temp.obj;

		flashme(temp);
	}
}


