
function popup (theURL, winName, features) {
  window.open(theURL, winName, features);
}

function fotos () {
	popup('fotos.php', 'fotos', 'width=1000,height=450');
}

var imgBuf = new Array();
function preload (image) {
	var img = new Image();
	img.src = image;
	imgBuf[imgBuf.length] = img;
}

function setStatus (msgStr) {
	document.SCRIPT_oldStatus = status;
  window.status = msgStr;
}

function restoreStatus () {
  window.status = document.SCRIPT_oldStatus;
}

function frameSet (contentId) {
	if (window == top)
		window.location.replace("index.php?c="+contentId);
	else
		syncTitle();
}

function syncTitle () {
	top.document.title = document.title;
}

function keyDownListener (evt) {
	switch (evt.keyCode) {
		case 32 :	// DOM_VK_SPACE
			// alert(evt.target.nodeName);
			var evtTargetNode = evt.target.nodeName.toLowerCase();
			if (evtTargetNode != "input" && evtTargetNode != "textarea") {
				var contentDiv = document.getElementById("content");
				var contentHeight = document.defaultView.getComputedStyle(contentDiv, "").getPropertyValue("height");
				contentHeight = parseInt(contentHeight);
				var togo = evt.shiftKey ? window.pageYOffset : (contentHeight - window.pageYOffset - window.innerHeight);
				var border = 56; // + 60;
				
				if (togo > (window.innerHeight - border)) {
					var offset = evt.shiftKey ? border : (0 - border);
					window.setTimeout("window.scrollBy(0, "+offset+")", 100);
				}
			} /* else {
				alert("[space] pressed in ["+evt.target.nodeName+"] element.");
			} */
			break;
	}
}

function initEventListener () {
	/* if (window.addEventListener) {
		window.addEventListener("keyup", spaceListener, true);
	} */
	window.onkeydown = keyDownListener;
}

function deO () {
	if (! document.getElementsByTagName)
		return;
	var spans = document.getElementsByTagName("span");
	for (var i=0; i<spans.length; i++) {
		if (spans[i].innerHTML == " AT ") {
			spans[i].innerHTML = "@";
			// spans[i].style.color = "#CC0099";
		}
	}
}

function val (x) {
	if ((x >= 0x41) && (x <= 0x5a)) return (x - 0x41);
	if ((x >= 0x61) && (x <= 0x7a)) return (0x1a + x - 0x61);
	if ((x >= 0x30) && (x <= 0x39)) return (0x34 + x - 0x30);
	if (x == 0x2b) return 0x3e;
	return 0x3f;
}
function decode (str) {
	var clear = "";
	var i = 0;
	while (i < str.length) {
		clear += String.fromCharCode((val(str.charCodeAt(i))<<2) + (val(str.charCodeAt(i+1))>>4));
		i++;
		if (str.charAt(i+1) == "=")
			break;
		clear += String.fromCharCode( ((val(str.charCodeAt(i))<<4)&0x00ff) + (val(str.charCodeAt(i+1))>>2) );
		i++;
		if (str.charAt(i+1) == "=")
			break;
		clear += String.fromCharCode( ((val(str.charCodeAt(i))<<6)&0x00ff) + val(str.charCodeAt(i+1)) );
		i+=2;
	}
	return clear;
}
function m (adr) { document.location.href = "mailto:"+decode(adr); }
function pm (adr) {
	var clearAdr = decode(adr);
	document.write("<a href=\"mailto:"+clearAdr+"\">");
	document.write(pm.arguments.length > 1 ? pm.arguments[1] : clearAdr);
	document.write("</a>");
}

var initBuf = new Array();
function addInit (execStr) {
	initBuf[initBuf.length] = execStr;
}

var rootPath = "/";
function initPage (queryString) {
/*	if (window == top)
		window.location.href = rootPath + "?" + queryString; */
	
	syncTitle();
	initEventListener();
	
	if (document.images) {
		preload("img/skin/li_menue.gif");
		preload("img/skin/menue-re-06.gif");
		preload("img/skin/li_top.gif");
		// preload("img/skin/re_werbung-fire.gif");
	}
	for (var i=0; i<initBuf.length; i++)
		eval(initBuf[i]);
}

function orderAT () {
		var input = document.getElementById("o_cyInput");
		if (input) {
			input.value = "Österreich";
			input.disabled = true;
		}
}

function orderEU () {
		var input = document.getElementById("o_cyInput");
		if (input) {
			input.value = "";
			input.disabled = false;
			input.focus();	// doFocus("o_cyInput");
		}
}
