﻿function Fontzoom(Typ) {

		FontZoomService.GetNewFontSize(Typ, FontzoomCB);
}

function FontzoomCB(result) {

		var tag = document.getElementById(result.InhaltsClientID).getElementsByTagName('p');
		for (i = 0; i < tag.length; i++) {
				tag[i].style.fontSize = result.NeueGroesse + "px";
				tag[i].style.lineHeight = result.LineHeight + "px";
		}

		tag = document.getElementById(result.InhaltsClientID).getElementsByTagName('h1');
		for (i = 0; i < tag.length; i++) {
				tag[i].style.fontSize = result.NeueGroesseH1 + "px";
		}

		tag = document.getElementById(result.InhaltsClientID).getElementsByTagName('h2');
		for (i = 0; i < tag.length; i++) {
				tag[i].style.fontSize = result.NeueGroesseH2 + "px";
		}

		tag = document.getElementById(result.InhaltsClientID).getElementsByTagName('h3');
		for (i = 0; i < tag.length; i++) {
				tag[i].style.fontSize = result.NeueGroesseH3 + "px";
		}

		tag = document.getElementById(result.InhaltsClientID).getElementsByTagName('h4');
		for (i = 0; i < tag.length; i++) {
				tag[i].style.fontSize = result.NeueGroesseH4 + "px";
		}

		tag = document.getElementById(result.InhaltsClientID).getElementsByTagName('li');
		for (i = 0; i < tag.length; i++) {
				tag[i].style.fontSize = result.NeueGroesseLI + "px";
		}

		tag = document.getElementById(result.InhaltsClientID).getElementsByTagName('td');
		for (i = 0; i < tag.length; i++) {
				tag[i].style.fontSize = result.NeueGroesseLI + "px";
		}
}

/*Katalog*/
function ShowPano(ID) {

		var pnlWidth = 750;
		var pnlHeight = 700;
		document.getElementById("BGVorsch").style.display = "block";
		document.getElementById("pnlVorschau").style.display = "block";

		//BG vergroessern
		var SeitenGroesse = GetSeitenGroesse();
		document.getElementById("BGVorsch").style.height = SeitenGroesse[1] + "px";

		//Vorschau bei Tastendruck wieder schliesen
		InitKeypressForVorschauClose()

		//Panel fuer Vorschau Positionieren verschieben
		var pnlPos = CalculatePanelPos(pnlWidth, pnlHeight);


		document.getElementById("pnlVorschau").style.left = pnlPos[0] + "px";
		document.getElementById("pnlVorschau").style.top = pnlPos[1] + "px";

		document.getElementById("ctl01_ctlPanoOpen1_IframePano").src = "Panoramen.aspx?ID_Panorama="  + ID + "&PanoramaTyp=java";

}

//Berechnet die Position eines Panels anhand
//Breite und Hoehe und in Abhaengigkeit der Scrollposition
//Gibt ein Array mit X und Y zuruek
function CalculatePanelPos(pnlWidth, pnlHeight) {

		var vpWidth = document.documentElement.clientWidth;
		var pnlPosX = (vpWidth / 2) - (pnlWidth / 2);

		var scrollPosY = document.documentElement.scrollTop;
		var vpHeight = document.documentElement.clientHeight;
		var pnlPosY = scrollPosY + (vpHeight / 2) - (pnlHeight / 2);

		return new Array(pnlPosX, pnlPosY);
}




//Schliesst die Vorschau
function CloseVorschau() {
		document.getElementById("BGVorsch").style.display = "none";
		document.getElementById("pnlVorschau").style.display = "none";
}

//Schliesst die Vorschau bei drueken des ESC Key
function CloseVorschauByESCKey(e) {
		if (e == null) {
				keycode = event.keyCode;
				ESCKey = 27;
		} else {
				keycode = e.keyCode;
				ESCKey = e.DOM_VK_ESCAPE;
		}

		key = String.fromCharCode(keycode).toLowerCase();

		if (keycode == ESCKey) {

				//Vorschau Ausblenden
				CloseVorschau();
		}
}

//Greift den Tastendruck an
function InitKeypressForVorschauClose() {
		if (document.layers) document.captureEvents(Event.KEYDOWN);
		document.onkeydown = CloseVorschauByESCKey;
}

//Ermittelt die Seitengroesse inkl Scrollbar
function GetSeitenGroesse() {

		var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY) {
				xScroll = document.body.scrollWidth;
				yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
		} else {
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;
		if (self.innerHeight) {
				windowWidth = self.innerWidth;
				windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
		} else if (document.body) {
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
		}

		if (yScroll < windowHeight) {
				pageHeight = windowHeight;
		} else {
				pageHeight = yScroll;
		}
		if (xScroll < windowWidth) {
				pageWidth = windowWidth;
		} else {
				pageWidth = xScroll;
		}

		arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
		return arrayPageSize;
}

/*Funktion um die Suche ein und auszublenden*/
function ToogleSuche() {
  if (document.getElementById("pnlSuche").style.display == "inline") {
    document.getElementById("pnlSuche").style.display = "none";
    document.getElementById("sucheeinaus").src = "images/plus.gif";
  } else if (document.getElementById("pnlSuche").style.display == "none") {
    document.getElementById("pnlSuche").style.display = "inline";
    document.getElementById("sucheeinaus").src = "images/minus.gif";
  }
}

function ShowSuche() {
  document.getElementById("pnlSuche").style.display = "inline";
  document.getElementById("sucheeinaus").src = "images/minus.gif";
}

