window.onload = init;

function init()
{
	elements = document.getElementsByTagName("input");

	for (i=0; i<elements.length; i++)
	{
		elm = elements[i];
		if (elm.type == "text")
		{
			elm.onfocus = vElementFocus;
			elm.onblur = vElementBlur;
		}
	}
}

function vElementFocus()
{
	this.style.backgroundColor = "#F1F4F9";
}

function vElementBlur()
{
	this.style.backgroundColor = "";
}

var bRubrikNavActive = false;

function vToggleChannelNav()
{
	l1 = document.getElementById("list_subnav");
	l2 = document.getElementById("list_rubriken");
	a1 = document.getElementById("rubrik_link");

	if (!l1 || !l2) return false;

	if (!bRubrikNavActive)
	{
		l1.style.display = "none";
		l2.style.display = "block";
		a1.className = "open";
		bRubrikNavActive = true;
	}
	else
	{
		l1.style.display = "block";
		l2.style.display = "none";
		a1.className = "";
		bRubrikNavActive = false;
	}

	return false;
}

function vHideChannelNav()
{
	l1 = document.getElementById("list_subnav");
	l2 = document.getElementById("list_rubriken");
	a1 = document.getElementById("rubrik_link");

	if (!l1 || !l2) return;

	if (bRubrikNavActive)
	{
		l1.style.display = "block";
		l2.style.display = "none";
		a1.className = "";
		bRubrikNavActive = false;
	}
}


function vSwitchTab(tab)
{
	if (tab.className == "active") return;

	container = tab.parentNode;

	if (!container) return;

	// get the Tab Layer to activate
	actLayer = oSeekTagById(container, "div", tab.id + "layer");

	// get all Tabs and Layers
	t1 = oSeekTagById(container, "h1", "tab1");
	t2 = oSeekTagById(container, "h1", "tab2");
	t3 = oSeekTagById(container, "h1", "tab3");

	l1 = oSeekTagById(container, "div", "tab1layer");
	l2 = oSeekTagById(container, "div", "tab2layer");
	l3 = oSeekTagById(container, "div", "tab3layer");

	// Reset all Tabs
	t1.className = "";
	t2.className = "";
	t3.className = "";

	// Set the active tab
	tab.className = "active";

	// Reset all Layers
	l1.style.display = "none";
	l2.style.display = "none";
	l3.style.display = "none";

	// Show the active Layer
	actLayer.style.display = "block";
}


function oSeekTagById(parentElement, tagName, id)
{
	if (!parentElement) return;
	if (tagName == "") return;
	if (id == "") return;
	if (!document.getElementsByTagName) return;


	candidates = parentElement.getElementsByTagName(tagName);
	for (i=0; i<candidates.length; i++)
	{
		if (candidates[i].id == id)
		{
			return candidates[i];
			break;
		}
	}

	return;
}

function setBgColor(obj,bgcolor)
{
	obj.style.backgroundColor = bgcolor;
}

function openWindow (address) {
	tamApps=window.open(address, "tamApps", "width=900,height=600,scrollbars=yes");
	tamApps.focus();
}
function openPopUp1 (address) {
	tamApps=window.open(address, "tamApps", "width=958,height=710,noresize");
	tamApps.focus();
}
function openPopUp2 (address) {
	tamApps=window.open(address, "tamApps", "width=958,height=710,scrollbars=yes");
	tamApps.focus();
}
function openBookingWindow (address) {
	tamApps=window.open(address, "tamApps", "width=958,height=710,scrollbars=yes,resizable=yes");
	tamApps.focus();
}
function openBoxBookingWindow (address) {
	tamApps=window.open(address, "tamApps", "width=700,height=350,scrollbars=no,resizable=yes");
	tamApps.focus();
}



function openZoom(img, caption, source, isimperia, ivwpath)
{
	if (isimperia && img.indexOf("/") == -1)
	{
		p = location.href;
		img = p.substring(0, p.lastIndexOf("/")+1) + img;
	}

	address = "/img/popup_zoom.php?img="+img+"&isimperia="+isimperia+"&ivwpath="+ivwpath+"&caption="+caption+"&source="+source;
	zoomWin = window.open(address, "zoomWin", "width=600,height=600,scrollbars=no");
	zoomWin.focus();
}