// handler
function mkhandler (usefile) {
		var ajax = new ajaxRequest(usefile);
		ajax.onSuccess = function(txt, xml){
			ajax.root = xml.getElementsByTagName("standort")[0];
			//ajax.showhandler(0);
			
			for (i = 0; i < 10; i++){
	        	document.getElementById('h'+i).onclick = function (){
					ajax.showhandler(this.id.substr(1));
				}
				document.getElementById('plz'+i).onclick = function (){
					ajax.showhandler(this.id.substr(3));
				}
	        }
		}
		ajax.showhandler = function (useplz) {
			rootlength  = ajax.root.childNodes.length;
			out = "";
			for (i=0; i<rootlength; i++){
				if (ajax.root.childNodes[i].nodeType == 1){
					xplz = ajax.root.childNodes[i].attributes[0].nodeValue;
					if (xplz == useplz){
						xplzlength = ajax.root.childNodes[i].childNodes.length
						for (n=0; n<xplzlength; n++){
							if (ajax.root.childNodes[i].childNodes[n].nodeType == 1){
								xlocation= ajax.root.childNodes[i].childNodes[n];
								xlocationid = xlocation.attributes[0].nodeValue;
								xname = xlocation.getElementsByTagName("name")[0].firstChild.nodeValue;
								xstr = xlocation.getElementsByTagName("str")[0].firstChild.nodeValue;
								xort = xlocation.getElementsByTagName("ort")[0].firstChild.nodeValue;
								xfon = xlocation.getElementsByTagName("fon")[0].firstChild.nodeValue;
								out += xname+"<br />"+xstr+"<br />"+xort+"<br />"+xfon+"<br /><br />";
							}
						}
					}
				}
			}
			document.getElementById('handler').innerHTML = out;
		}
		ajax.doRequest();
}
// href
function fngoto (wert){
	window.location.href = wert;
}
// subnav hover
function hovernav (aktiv){
	for (i=0; i<navAr.length; i++){
		if (i != aktiv){
			document.getElementById('sn'+i).onmouseover = function (){
				document.getElementById('img'+this.id.substr(2)).src = navAr[this.id.substr(2)][1];
			}
			document.getElementById('sn'+i).onmouseout = function (){
				document.getElementById('img'+this.id.substr(2)).src = navAr[this.id.substr(2)][0];
			}
		}
	}
}
// conten background-img
function setcontentimg (file) {
	document.getElementById("content").style.backgroundImage = "url("+file+")";
}
// duftbeschreibung hover
function sethovercolor (useid,normal,hover,todoel){
	document.getElementById(useid).style.color = normal;
	document.getElementById(useid).onmouseover = function (){
		this.style.color = hover;
	}
	document.getElementById(useid).onmouseout = function (){
		this.style.color = normal;
	}
	// todo
	if (todoel == ""){
		return;
	}
	el = $(todoel);
	el.setStyle("display","none");
	el.setOpacity(0);
	document.getElementById(useid).onclick = function (){
		//document.getElementById(todoel).style.display='';
		el.setStyle("display","");
		showelement (el);
	}
}
// fade in-out
function showelement (el) {
	el.fade('toggle');
	document.getElementById("btn_close").onclick = function (){
		showelement (el);
	}
}
// drag
function drag (element,dragelement){
	el = $(element);
	//IE drag hack
	document.ondragstart = function () {
		return false;
	};
	var myDrag = new Drag.Move(el, {
		handle: $(dragelement),
		onStart: function(el){
			el.setOpacity(.7);
		},
		onComplete: function(el){
			el.setOpacity(1);
		}
	});
}