/*	
	autor: this be tofus - maxomedia ag
*/

/* ---------------------------------------------------------------------------------------------------- */
/* =swikamin */
/* ---------------------------------------------------------------------------------------------------- */

/* constructor */
function framework () {};
var swikamin = new framework();


/* -------------------------------------------------- */
/* =map */

var mapCurrentAddress = null;

function initMap () {
	var areas = document.getElementById("map-partner").getElementsByTagName("area");
	for (var i=0; i < areas.length; i++) {
		areas[i].onclick = function () { return false };
		areas[i].onmouseover = showMapAddress;
	}
}

function showMapAddress () {
	if (mapCurrentAddress != null) mapCurrentAddress.style.display = "none";
	mapCurrentAddress = document.getElementById("address-" + this.id);
	if (mapCurrentAddress != null) mapCurrentAddress.style.display = "block";
}


/* -------------------------------------------------- */
/* =shop */

/* constructor */
function shop () {};
framework.prototype.shop = new shop();

/* =init() */
shop.prototype.init = function () {
	this.container = mxm.dom.getElement("shop-artikel");
	this.attach();
}

/* =attach() */
shop.prototype.attach = function () {
	this.btn_add = document.createElement("a"); this.btn_add.href = "#"; this.btn_add.innerHTML = "<img src=\"/_gfx/icon_add.gif\" alt=\"\" />";
	this.btn_add.onclick = this.row_add.bind(this);
	var rows = this.container.getElementsByTagName("p");
	rows[rows.length-1].appendChild(this.btn_add);
}

/* = row_add */
shop.prototype.row_add = function () {
	var rows = this.container.getElementsByTagName("p");
	var new_row = this.btn_add.parentNode.cloneNode(true)
	var inputs = new_row.getElementsByTagName("input");
	inputs[0].name = "fld_artikel_anzahl_" + (rows.length + 1); inputs[0].value = ""; mxm.dom.addElementClass(inputs[0],"anzahl");
	inputs[1].name = "fld_artikel_beschreibung_" + (rows.length + 1); inputs[1].value = ""; mxm.dom.addElementClass(inputs[1],"beschreibung");
	new_row.getElementsByTagName("a")[0].parentNode.removeChild(new_row.getElementsByTagName("a")[0]);
	this.btn_add.parentNode.removeChild(this.btn_add);	
	this.container.appendChild(new_row);
	this.attach();
	return false;
}
