function openVideoWindow(url)
{
	window.open(url, "JosefstadtVideo", "locationbar=no,addressbar=no,resizable=no,scrollbars=auto,status=no,top=50,left=50,width=470,height=320");
}

function openSlideshow(url)
{
	window.open(url, "JosefstadtSlideshow", "locationbar=no,addressbar=no,resizable=no,scrollbars=auto,status=yes,width=800,height=600");
}

/* Menu */
/** 
 * DIV ONMOUSEOUT
 */
// for mozilla
function containsDOM (container, containee) 
{
 var isParent = false;
 do 
 {
  if ((isParent = container == containee))
  {
   break;
  }
  containee = containee.parentNode;
 }
 while (containee != null);
 return isParent;
}
// called by onmouseout
function checkMouseLeave (element, evt) 
{
 if (element.contains && evt.toElement) 
 {
  return !element.contains(evt.toElement);
 }
 else if (evt.relatedTarget) 
 {
  return !containsDOM(element, evt.relatedTarget);
 }
}
// end DIV onmouseout


var activeColor = "#C10045";
var defaultColor = "#999999";

// sets a menÃ¼ active
function setMenuActive(o) {
	if(o.parentNode.nodeName=="TD") { // sub menu
		o.parentNode.style.width=o.offsetWidth+"px";
		o.style.padding = "0px";
	} else { // main menu
		o.parentNode.parentNode.style.width=o.parentNode.offsetWidth+"px";
		o.parentNode.style.padding = "0px";
		o.parentNode.style.textAlign = "center";
	}

	if((o.id == activeMainMenu) || (o.id == activeSubMenu)) {
		o.style.color = activeColor;
	}

	o.style.fontWeight = "bold";
}

// sets a menÃ¼ inactive
function setMenuInactive(o) {
	if((o.id != activeMainMenu) && (o.id != activeSubMenu)) {
		o.style.fontWeight = "normal";
		o.style.color = defaultColor;

		if(o.parentNode.nodeName=="TD") { // sub menu
			o.style.paddingLeft = "5px";
			o.style.paddingRight = "5px";
		} else { // main menu
			o.parentNode.style.paddingLeft = "5px";
			o.parentNode.style.paddingRight = "5px";
			o.parentNode.style.textAlign = "left";
		}
	}
}

// gets an object by id
function getObject(id) {
	return document.getElementById(id);
}

// the main menÃ¼ of the current page (setted by initMenu())
var activeMainMenu = null;
// the submenÃ¼ of the current page (setted by initMenu())
var activeSubMenu = null;

// the currently active main menÃ¼ (setted by mouse event)
var actMain = null;
// the currently active submenÃ¼ div (setted by mouse event)
var actSub=null;
// the currently active submenÃ¼ (setted by mouse event)
var actSubMenu = null;

// deactivate the current subMenu
function deactivateSubmenu() {
	if(actSubMenu!=null)
	{
		setMenuInactive(actSubMenu);
	}
}

var inactiveCursor = true;
var showtime;
function timer() {	
	/*if(actSubMenu!=null && actSubMenu.id!=activeSubMenu) {
		inactiveCursor = false;
	}
	if(inactiveCursor)*/ {
		mainMenuOut(getObject(actSub),actMain.id);// alert("menu reset");
	}
}

function checkActivity() {
	var mainId = actMain.id;
	inactiveCursor = true;
	//if(mainId!=activeMainMenu) {
		clearInterval(showtime);
		showtime = setInterval('timer()',1000);
	//}
}

var movedMenus = new Object();

function moveMenuIfNecessary(subID, rightmost) {
	if(movedMenus[subID] != true) {
		movedMenus[subID] = true;
		matchRightEdge(getObject(subID), rightmost);
	}
}

function postLoadInitMenu() {
	moveMenuIfNecessary(activeMainMenu+"_sub", rightmostMenu);
}

function new_mainMenuOver(o,subID,rightmost) {
	if(actMain!=null && actMain!=o)
	{
		setMenuInactive(actMain);
	}
	actMain = o;
	setMenuActive(o);
	if(actSub!=null){
		getObject(actSub).style.display="none";
	}

	sub = getObject(subID);
	sub.style.display="block";
	
	moveMenuIfNecessary(subID, rightmost);
	
	actSub = subID;
	clearInterval(showtime);
}

function new_mainMenuOut(o) {
	checkActivity();
}

function new_subMenuOver() {
	clearInterval(showtime);
}

function new_subMenuOut() {
	checkActivity();
}

// sets the main menÃ¼ to active
function mainMenuOver(o,subID) {
	if(actMain!=null && actMain!=o)
	{
		setMenuInactive(actMain);
	}
	actMain = o;
	setMenuActive(o);
	if(actSub!=null){
		getObject(actSub).style.display="none";
	}
	getObject(subID).style.display="block";
	actSub = subID;
	//checkActivity();
	clearInterval(showtime);
}

// sets the main menÃ¼ to inactive
function mainMenuOut(o,mainID) {
	setMenuInactive(getObject(mainID));
	o.style.display="none";
	if(activeMainMenu!=null) {
		mainMenuOver(getObject(activeMainMenu),activeMainMenu+"_sub");
	} /*else {
		checkActivity();
	}*/
	subMenuOut();
	//clearInterval(showtime);
}

// sets the submenÃ¼ to active
function subMenuOver(o) {
	if(actSubMenu!=null && actSubMenu!=o)
	{
		setMenuInactive(actSubMenu);
	}
	actSubMenu = o;
	setMenuActive(o);
}

// sets the submenÃ¼ to inactive
function subMenuOut() {
	if(activeSubMenu!=null) {
		subMenuOver(getObject(activeSubMenu));
	} else{
		setMenuInactive(actSubMenu);
	}
	
}

// initializing the menÃ¼: setting the default selected menÃ¼s
function initMenu(mainmenu,submenu) {	
	activeMainMenu = mainmenu;
	activeSubMenu = submenu;
	if(mainmenu!=null) {
		mainMenuOver(getObject(mainmenu),mainmenu+"_sub")
	}
	if(submenu!=null) {
		setMenuActive(getObject(submenu));
	}
}


/* parse the entered query String */
function parseSearchQuery(theForm, message) {
	var queryValue = theForm.elements["query2"].value;
	var testValue = queryValue.replace(/ /g, "");
	if (testValue.length < 3) {
		alert(message);
		return (false);
	}
	theForm.elements["query"].value = queryValue;
	return (true);
}

/* open the print version popup window */
function openPrintVersion() {
	var params = "print=true";
	if (document.location.search != "") {
		params = document.location.search + "&" + params;		
	} else {
		params = "?" + params;
	}
	window.open(document.location.pathname + params, "print", "width=670,height=750,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes");
}

/* open the imprint popup window */
function openImprint(imprintUri, pageUri, theLocale, site) {
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(imprintUri + pageUri, "imprint", "width=670,height=550,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}

/* open the recommend page form popup window */
function openRecommendForm(recommendUri, pageUri, theLocale, site) {	
	if (window.location.search != "") {
		pageUri += window.location.search;		
	}
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(recommendUri + pageUri, "recommend", "width=670,height=700,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}

/* open the recommend page form popup window */
function openLetterForm(letterUri, pageUri, theLocale, site) {	
	if (window.location.search != "") {
		pageUri += window.location.search;		
	}
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(letterUri + pageUri, "contact", "width=670,height=700,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}

/** Calculates the top edge coordinate of an HTML element */
function findTopY(obj) {
	var curtop = 0;

	if(obj) {
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				curtop += obj.offsetTop;
				obj = obj.offsetParent;
			}
		}
		else if (obj.y) {
			curtop += obj.y;
		}
	}

	return curtop;
}

/** Calculates the left edge coordinate of an HTML element */
function findLeftX(obj) {
	var curleft = 0;

	if(obj) {
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				curleft += obj.offsetLeft;
				obj = obj.offsetParent;
			}
		} else if (obj.x) {
			curleft += obj.x;
		}
	}

	return curleft;
}

/** Calculates the right edge coordinate of an HTML element */
function findRightX(obj) {
	var offset = 0;

	if(obj) {
		offset = obj.offsetWidth;
	}

	return findLeftX(obj) + offset;
}

/** Makes sure the specified element's right edge never has a
 *  higher X coordinate than the target's right edge. Assumes that
 *  the element has a style.left property. */
function matchRightEdge(element, target) {
	myRight = findRightX(element);
	maxRight = findRightX(target);

	if(myRight > maxRight) {
		element.style.left = 0;
		diff = findRightX(element) - maxRight;
		element.style.left = -diff;
	}
}

function showWarenkorb() {
	getObject("warenkorb").style.visibility="visible";
}

function hideWarenkorb() {
	getObject("warenkorb").style.visibility="hidden";
}

