// -----------------------------------------------------------------------------------
//	PageTrans v 0.2 - 2007-11-08
//	by Sindre Wimberger - http://www.sindre.at
//
//  v 0.2   - replaced AddEvent with prototype dom:loaded
//            rewrite for content.life integration
//  v 0.1.3 - improved variable usage
//  v 0.1.2 - added support for loadingcontainer used when allready in HTML
//            disabled multiple clicks/pagetrans starts before finish
//  v 0.1.1 - added support for loadingcontainer insert selection
//            removed some prototype dependencies
//
//	For more information on this script, visit:
//	
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//	
//	Credit also due to those who have helped, inspired, and made their code available to the public.
//	Including:  Elisabeth Kühr and others.
// -----------------------------------------------------------------------------------
//
// PageTrans.init("x1",x2,x3,x4,"x5",'x6');
//
// Configuration
// x1 || Container ID which content should be changed. must be identical in all sader links
// x2 || 1 - Fade/Appear, 2 - BlindUp/BlindDown, 3 - SlideUp/SlideDown, 4 - Shrink/Grow [Buggy], 5 - Pulsate
// x3 || true - loadingcontent appears, false - no loading message
// x4 || ID - loadingcontainer will be inserted in element with #ID, body - loadingcontainer will be inserted at body end 
// x5 || ID of the lodingcontainer 
// x6 || HTML which will be insertet in the loadingcontainer 
// -----------------------------------------------------------------------------------
var PageTrans = {	
	clickstate: 0,
	formstate: false,
	restartNavAccordion: false,
	init: function(ContainerID,effect,loadStatus,loadLocation,loadID,LoadContent) {
		PageTrans.ContainerID = ContainerID;
		PageTrans.EffectContainerID = ContainerID;
		PageTrans.fx = effect;
		PageTrans.LStatus = loadStatus; 
		if (loadLocation == "" || loadLocation == null) {PageTrans.LLocation = "body";} else {PageTrans.LLocation = loadLocation;}
		PageTrans.LID = loadID;
		PageTrans.LContent = LoadContent; 
		PageTrans.getLinks();
	},
    getLinks: function(contentid) {
		if (PageTrans.LStatus == true) {PageTrans.LoaderInit();}
		if(contentid) {
			var anchors = $$('#'+contentid+' a[rel=pagetrans]','#'+contentid+' a[href^="/"]','#'+contentid+' a[href^="/"]','#'+contentid+' a[href^="http://novelli.at"]','#'+contentid+' a[href^="http://www.novelli.at"]','#'+contentid+' a[href^="http://novelli.echonet.at"]');
		} else {
			var anchors = $$('a[rel=pagetrans]','#c-text a[href^="/"]','#c-text a[href^="/"]','#c-text a[href^="http://novelli.at"]','#c-text a[href^="http://www.novelli.at"]','#c-text a[href^="http://novelli.echonet.at"]');
		}
		anchors.invoke('observe', 'click', 
		 function(event){
			if (PageTrans.clickstate==0) {
				PageTrans.clickstate = 1;
				PageTrans.disappearFX(this.getAttribute('href'));
				PageTrans.currenturl = this.getAttribute('href');			
				StateManager.setState(this.getAttribute('href').replace(/http:\/\/www.novelli.at/g, ""));
				StateManager.setState(this.getAttribute('href').replace(/http:\/\/novelli.at/g, ""));
//				StateManager.setState(this.getAttribute('href'));

				if(!this.hasClassName('ntoggle') && !this.hasClassName('subnav')) {
					mainnav._closeAll(event,'0.5');
				}
				if(this.descendantOf('c-content')) {
					PageTrans.restartNavAccordion = true;
				}
			}
			Event.stop(event);
		});
	}, 	
    removeClass: function() {
		$$('#c-nav a.active','#c-mnav a.active').invoke('removeClassName', 'active');
//		$$('#c-mnav a.active').invoke('removeClassName', 'active');
	}, 	
    request: function(url,params) {
//		console.info(url);
		if (PageTrans.LStatus == true) {PageTrans.LoaderAppear();}		
		if (!params) {
			params = 'ajax=1';
		} else {
			params = 'ajax=1&'+params;
		}
//		console.info(params);
//		var ajaxurl = url+'?ajax=1';
		new Ajax.Request(url, {
		 	parameters : params,
			onFailure : function(resp) {PageTrans.redirect(url,resp.statusText);},
			onException : function(resp,ex) {PageTrans.redirect(url,ex);},
			onComplete:function(req){	
				PageTrans.insert(req.responseXML);
		}});
	},
    insert: function(XML) {
		var page = PageTrans.getMarkupById(XML);
		$('novelli-at').className = page["bodyclass"];
		document.title = page["title"];
		$(PageTrans.ContainerID).innerHTML = page["content"];
		
		if(page["flashtable"] && page["flashid"] && $('FlashHeaderInstall')) {
			initFlashHeader(page["flashtable"],page["flashid"]);
		}
		if($('KochbuchAlternativeContent')) {
			initFlashKochbuch() 
		}
		PageTrans.removeClass();
		if (page["nnav"]) {
			$(page["nnav"]).down(0).addClassName('active');
		}
		if (page["snav"]) {
			$(page["nnav"]+"-"+page["snav"]).down(0).addClassName('active');
		}
		if (PageTrans.restartNavAccordion) {
			mainnav._closeOpen(0, 'start');
			PageTrans.restartNavAccordion = false;
		}		
//		if(page["module"]=='module_product') {
		if($('gutschein')) {
			this.formObserve("gutschein");  
		}
		if(page["module"]=='module_menu') {
			this.menuAccordion();  
		}
		if (PageTrans.LStatus == true) {
			PageTrans.LoaderDISAppear();			
		} else {
        	PageTrans.appearFX();
		}
	},
    disappearFX: function(url) {
		if (PageTrans.fx==1) {new Effect.Fade(PageTrans.EffectContainerID,
									 { duration:'0.5',
 									   afterFinish: function(){PageTrans.request(url)},
									   queue: { scope: 'aktive', position: 'front'}
									 });
		}
		if (PageTrans.fx==2) {new Effect.BlindUp(PageTrans.EffectContainerID,
									 { duration:'0.8',
									   afterFinish: function(){PageTrans.request(url)},
									   queue: { scope: 'aktive', position: 'front'}
									 });
		}
		if (PageTrans.fx==3) {new Effect.SlideUp(PageTrans.EffectContainerID,
									 { duration:'1.2',
									   afterFinish: function(){PageTrans.request(url)},
									   queue: { scope: 'aktive', position: 'front'}
									 });
		}
		if (PageTrans.fx==4) {new Effect.Shrink(PageTrans.EffectContainerID,
									{ duration:'1.2',
									  afterFinish: function(){PageTrans.request(url)},
									  queue: { scope: 'aktive', position: 'front'}
									});
		}
		if (PageTrans.fx==5) {PageTrans.request(url);}
		
	},
    appearFX: function() {
		if (PageTrans.fx==1) {new Effect.Appear(PageTrans.EffectContainerID,
									 { duration:'0.5',
 									   afterFinish: function(){PageTrans.functionJS();},
									   queue: { scope: 'aktive', position: 'end'}
									 });
		}
		if (PageTrans.fx==2) {new Effect.BlindDown(PageTrans.EffectContainerID,
									 { duration:'0.8',
 									   afterFinish: function(){PageTrans.functionJS();},
									   queue: { scope: 'aktive', position: 'end'}
									 });
		}
		if (PageTrans.fx==3) {new Effect.SlideDown(PageTrans.EffectContainerID,
									 { duration:'1.2',
 									   afterFinish: function(){PageTrans.functionJS();},
									   queue: { scope: 'aktive', position: 'end'}
									 });
		}
		if (PageTrans.fx==4) {new Effect.Grow(PageTrans.EffectContainerID,
									 { duration:'1.2',
 									   afterFinish: function(){PageTrans.functionJS();},
									   queue: { scope: 'aktive', position: 'end'}
									 });
		}
		if (PageTrans.fx==5) {new Effect.Pulsate(PageTrans.EffectContainerID,
									 { duration:'1.2',
 									   afterFinish: function(){PageTrans.functionJS();},
									   queue: { scope: 'aktive', position: 'end'}
									 });
		}
	},
    getMarkupById: function(markup) {
		var pagedetail = Array();
		pagedetail["title"] = markup.getElementsByTagName("title")[0].childNodes[0].nodeValue;
		if(markup.getElementsByTagName("bodyclass")[0].childNodes[0]) {
			pagedetail["bodyclass"] = markup.getElementsByTagName("bodyclass")[0].childNodes[0].nodeValue;
		}
		pagedetail["content"] = markup.getElementsByTagName("content")[0].childNodes[0].nodeValue;
		if(markup.getElementsByTagName("flashtable")[0].childNodes[0]) {
			pagedetail["flashtable"] = markup.getElementsByTagName("flashtable")[0].childNodes[0].nodeValue;
		}
		if(markup.getElementsByTagName("flashid")[0].childNodes[0]) {
			pagedetail["flashid"] = markup.getElementsByTagName("flashid")[0].childNodes[0].nodeValue;
		}
		if(markup.getElementsByTagName("nnav")[0].childNodes[0]) {
			pagedetail["nnav"] = markup.getElementsByTagName("nnav")[0].childNodes[0].nodeValue;
		} else {
			pagedetail["nnav"] = false;
		}
		if(markup.getElementsByTagName("snav")[0].childNodes[0]) {
			pagedetail["snav"] = markup.getElementsByTagName("snav")[0].childNodes[0].nodeValue;
		} else {
			pagedetail["snav"] = false;
		}
		if(markup.getElementsByTagName("module")[0].childNodes[0]) {
			pagedetail["module"] = markup.getElementsByTagName("module")[0].childNodes[0].nodeValue;
		}
		return pagedetail;
	}, 
    LoaderInit: function() {
		if (!$(PageTrans.LID)){
			if (PageTrans.LLocation=="body") {var objBody = document.getElementsByTagName("body").item(0);}
			else {var objBody = $(PageTrans.LLocation);}
			objLoading = document.createElement("div");
			objLoading.setAttribute('id',PageTrans.LID);
			objLoading.style.display = "none";
			objLoading.innerHTML = PageTrans.LContent;
			objBody.appendChild(objLoading);
		} else {
			objLoading = $(PageTrans.LID);			
			objLoading.style.display = "none";
		}		
	},	
    LoaderAppear: function() {
		objLoading.style.display = "block";
	},
    LoaderDISAppear: function() {
		objLoading.style.display = "none";
		PageTrans.appearFX();
	},
    redirect: function(url,res) {
//		alert(res);
		window.location.href = url;
	},
    formObserve: function(element) {
		var form = $(element);
		var valid = new Validation(element,{immediate : true, useTitles : true, onSubmit:false});
		form.observe('submit', 
			function(event){
				Event.stop(event);
				if(valid.validate() && !PageTrans.formstate) {
					PageTrans.formstate = true;
//					console.info(form.serialize());
					PageTrans.request(form.action, form.serialize());
					form.disable();
				}
		});
		PageTrans.forminit = false;		
	},
    menuAccordion: function() {
		$$('#menu li ul').invoke('setStyle', {display: "none"});	
		$$('#menu > li').invoke('setStyle', {opacity:'0.6'});
		$$('#menu li h3.ntoggle')[0].addClassName('active');
		/*$$('#menu li')[0].addClassName('active');*/
		$('menu').addClassName('menujs');	
		PageTrans.menu = new Effect.Accordion("menu", {duration: '0.4', eventlistener:'click',
					downBeforestart: function(e) { 
//					   e.element.up().addClassName('active');
					   e.element.up().addClassName('active').setStyle({opacity:'1.0'});
					},
					upAfterfinish: function(e) { 
//					   e.element.up().removeClassName('active');
					   e.element.up().removeClassName('active').setStyle({opacity:'0.6'});
	       			}
			});
		PageTrans.menuinit = false;		
	},
	functionJS: function(){
		this.clickstate = 0;		
		this.formstate = false;		
		this.getLinks("c-text");
		initLighthover();
		mainnav._closeOpen(0, 'start');
		initGoogleMaps();
		taf.init();
		enablePrintButton();		
//		(function(){ /*Use Object Detection to detect IE6*/ var m = document.uniqueID /*IE*/ && document.compatMode /*>=IE6*/ && !window.XMLHttpRequest /*<=IE6*/ && document.execCommand ; try{ if(!!m){ m("BackgroundImageCache", false, true) /* = IE6 only */ } }catch(oh){}; })();	  
	}
};

function initFlashHeader(table,id) {
	/*var flashvars = {};
	flashvars.streamName = "/xml/fotoshow_"+table+"_"+id+".xml";
	var params = {};
	params.menu = "false";
	params.quality = "high";
	params.scale = "exactfit";
	params.wmode = "transparent";
	params.allowfullscreen = "true";
	params.allowscriptaccess = "always";
	var attributes = {};
	attributes.id = "FlashHeader";
	attributes.styleclass = "flash";
	swfobject.embedSWF("/assets/flash/slideshow.swf", "FlashHeaderInstall", "660", "200", "8.0.0", "/assets/flash/expressInstall.swf", flashvars, params, attributes);*/
	swfobject.registerObject("FlashHeader", "8.0.0", "/assets/flash/expressInstall.swf");
}
function initFlashKochbuch() {
	var flashvars = {};
	var params = {};
	params.menu = "false";
	params.quality = "high";
	params.scale = "exactfit";
	params.wmode = "transparent";
	params.allowfullscreen = "true";
	params.allowscriptaccess = "always";
	var attributes = {};
	attributes.id = "flash1";
	attributes.name = "kochbuch";
	attributes.styleclass = "flash";
	attributes.align = "middle";
	swfobject.embedSWF("/assets/flash/kochbuch/kochbuch.swf", "KochbuchAlternativeContent", "676", "527", "8.0.0", "/assets/flash/expressInstall.swf", flashvars, params, attributes);
}


// -----------------------------------------------------------------------------------
//	lighthover v 0.1 - 2007-12-20
//	by Sindre Wimberger, wimberger@echonet.at
// -----------------------------------------------------------------------------------

//
//	Configuration
//
var fileLoadingImage = "/assets/style/lightbox/loading.gif";		
var overlayDuration = 0.2;	// shadow fade in/out duration
var animate = true;
var loading = false;
var borderSize = 5;		//if you adjust the padding in the CSS, you will need to update this variable

// -----------------------------------------------------------------------------------

var Lighthover = Class.create();

Lighthover.prototype = {
	initialize: function() {	
		navstate = true;
		this.updateImageList();
        if(!document.getElementById("Lighthover")) {

			var objBody = document.getElementsByTagName("body").item(0);
			
			var objLighthover = document.createElement("div");
			objLighthover.setAttribute('id','Lighthover');
			objLighthover.style.display = 'none';
			objBody.appendChild(objLighthover);				
				
			var objLHImageContainer = document.createElement("div");
			objLHImageContainer.setAttribute('id','LHImageContainer');
			objLighthover.appendChild(objLHImageContainer);
				
			var objLHImage = document.createElement("img");
			objLHImage.setAttribute('id','LHImage');
			objLHImageContainer.appendChild(objLHImage);

			var objLoading = document.createElement("div");
			objLoading.setAttribute('id','loading');
			objLHImageContainer.appendChild(objLoading);
		
			var objLoadingLink = document.createElement("a");
			objLoadingLink.setAttribute('id','loadingLink');
			objLoadingLink.setAttribute('href','#');
			objLoading.appendChild(objLoadingLink);
		
			var objLoadingImage = document.createElement("img");
			objLoadingImage.setAttribute('src', fileLoadingImage);
			objLoadingLink.appendChild(objLoadingImage);
	
			var objLHDataContainer = document.createElement("div");
			objLHDataContainer.setAttribute('id','LHDataContainer');
			objLHImageContainer.appendChild(objLHDataContainer);
	
			var objLHDetails = document.createElement("div");
			objLHDetails.setAttribute('id','LHDetails');
			objLHDataContainer.appendChild(objLHDetails);		
		}
	},
	updateImageList: function() {	
		$$('#c-content a[rel=lighthover]').each(function(el) {
			el.observe('mouseover', this.start.bindAsEventListener(this));
			el.observe('mouseout', this.end.bindAsEventListener(this));
			el.onclick = function () {return false;}
			IMGpreload(el.getAttribute('href'));
		}.bind(this));
	},
	start: function(event) {	
		var imageLink = Event.findElement(event, 'A');
		this.navstate = false;
		this.imageHref = imageLink.getAttribute('href');
		this.imageTitle = imageLink.getAttribute('title');	
		if(this.imageHref.indexOf("=6.jpg") < 0) {
				if($('LHImage').src != this.imageHref) { // wenn neues Bild
					$('LHImage').setStyle({visibility:'hidden'});
					$('LHImage').src = '/assets/style/lightbox/nix.gif';
				} 
				$('Lighthover').setStyle({
					height: "60px",
					width: "60px"
				})
				$('LHDataContainer').hide();
				$('LHImageContainer').setStyle({
					height: '50px',
					width: '50px'
				})
				$('Lighthover').show();
				
				if($('LHImage').src != this.imageHref) {
					if(loading){ Element.show('loading');}
					this.changeImage();
				} else { // wenn gleiches Bild
					this.resizeImageContainer($('LHImage').width, $('LHImage').height);			
				}
		} else {
			this.navstate = true;
		}
	},
	changeImage: function() {	
		var imgPreloader = new Image();
		// once image is preloaded, resize image container
		imgPreloader.onload=function(){
			$('LHImage').src = this.imageHref;
			if (imgPreloader.width < 100) {imgPreloader.width = 100;}
			Element.hide('loading');
			$('LHImage').setStyle({visibility:'visible'});
			this.resizeImageContainer(imgPreloader.width, imgPreloader.height);			
			imgPreloader.onload=function(){};	//	clear onLoad, IE behaves irratically with animated gifs otherwise 
		}.bind(this);
		imgPreloader.src = this.imageHref;
	},
	resizeImageContainer: function( imgWidth, imgHeight) {
		var widthNew = (imgWidth  + (borderSize * 2));
		var heightNew = (imgHeight  + (borderSize * 2));
		$('Lighthover').setStyle({
			height: heightNew+"px",
			width: widthNew+"px"
		})
		if(animate) {
			new Effect.Morph('LHImageContainer',{style:'height:'+ heightNew+'px; width:'+ widthNew+'px; /*opacity:1.0;*/', duration: overlayDuration, afterFinish: function(){/*	myLighthover.showImage(); */}});
		} else {
			$('LHImageContainer').setStyle({
				height: heightNew+"px",
				width: widthNew+"px"
			})
		}
			this.showImage();
		
	},
	showImage: function(){
		this.updateDetails();
	},
	updateDetails: function() {
		if(this.imageTitle){
			$('LHDetails').update(this.imageTitle);
			$('LHDataContainer').show();
		}		
	},
	end: function(event) {
		$('Lighthover').hide();
//		$('LHImage').setStyle({visibility:'hidden'});
//		$('LHImage').remove();
		this.navstate = true;
	}
}
// -----------------------------------------------------------------------------------
function loadGoogleMaps() { 
	/* ABQIAAAA1NPrAg5my5Yyo4v80SyAKBSD8PTmm-y9dLZg1xS6EihasfGUuhTLtoyB8HeX35ddPCrX4V1azwENGg // novelli.at 
	   ABQIAAAA1NPrAg5my5Yyo4v80SyAKBS_z5jlT5VPh1d1xlbQFw9zg5jASxTaLEWKbeAIlLSmRYtE8DmhF6gKHg // novelli.echonet.at */
	var script = document.createElement("script");
	script.setAttribute("src", "http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA1NPrAg5my5Yyo4v80SyAKBSD8PTmm-y9dLZg1xS6EihasfGUuhTLtoyB8HeX35ddPCrX4V1azwENGg&c&async=2&callback=createGoogleMaps&locale=de_AT");
	script.setAttribute("type", "text/javascript");
	script.setAttribute("id", "googlemaploader");
//	document.documentElement.firstChild.appendChild(script);
	document.getElementsByTagName("body").item(0).appendChild(script);
}
function initGoogleMaps() { 
	if(!$('googlemap')) { return false; }
	if($('googlemaploader')) {
		  createGoogleMaps();
	} else {
		  loadGoogleMaps();
	}
}
    
function setDirections(fromAddress) {
  gdir.load("from: " + fromAddress + " to: Bräunerstrasse 11a, 1010 Wien",
			{ "locale": "de_AT" });
}

function GDirectionshandleErrors(){
   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	 alert("Die angegebene Adresse konnte nicht gefunden werden. Entweder sie ist relativ neu, oder fehlerhaft.\nFehler Code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	 alert("Der Anfahrtsplan konnte nicht erstellt werden.\n Fehler Code: " + gdir.getStatus().code);
   
   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	 alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Fehler Code: " + gdir.getStatus().code);

//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	 
   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	 alert("Der Schlüssel passt nicht zur angegeben Domain.\n Error code: " + gdir.getStatus().code);

   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	 alert("Der Anfahrtsplan konnte nicht erstellt werden.\n Fehler Code: " + gdir.getStatus().code);
	
   else alert("Fehler. Bitte überprüfen Sie Ihre Angaben.");
   
}

function onGDirectionsLoad(){ 
  // Use this function to access information about the latest load()
  // results.

  // e.g.
  // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
  // and yada yada yada...
}

function createGoogleMaps() { 
	if (!GBrowserIsCompatible()) { return false; }
//	window.onunload=GMap2.Unload; 
	if(!$('planbar')) {
		new Insertion.Top('textpad', '<div id="planbar"><p>Geben Sie Ihren momentanen Standort ein und erstellen Sie Ihren persönlichen Anfahrtsplan zum Novelli Restaurant.</p><form class="bg" onsubmit="setDirections(this.standpunkt.value); return false"><input id="standpunkt" name="standpunkt" /><button type="submit">Anfahrtsplan erstellen</button></form><div id="fahrtbeschreibung"></div></div>');
	}
	showmap(48.20712925493621, 16.368298530578613);
//    setDirections("Schottenfeldgasse 24, 1070 Wien", "Bräunerstrasse 11a, 1010 Wien");
	function showmap(x,y) {
		mapelement = $('googlemap');
/*		mapelement.setStyle({
			height: "371px",
			width: "660px"
		});*/
		map = new GMap2(mapelement);
		gdir = new GDirections(map, document.getElementById("fahrtbeschreibung"));
		GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", GDirectionshandleErrors);
		map.addControl(new GLargeMapControl());
		map.addControl(new GOverviewMapControl());
		map.addControl(new GScaleControl());
		map.setCenter(new GLatLng(x,y), 15);
		map.addOverlay(createMarker(new GLatLng(x,y)));
	}
	
	function createMarker(point) {
		var icon = new GIcon();
		icon.image = "/assets/content/icon-googlemaps.png";
		icon.printImage = "/assets/content/icon-googlemaps-print.gif";
		icon.mozPrintImage = "/assets/content/icon-googlemaps-print.gif";
	//	icon.shadow = "/grafik/content/icon-googlemaps-shadow.png";
		icon.iconSize = new GSize(71, 73);
	//	icon.shadowSize = new GSize(36, 36);
		icon.iconAnchor = new GPoint(35, 36);
		icon.infoWindowAnchor = new GPoint(35, 53);		
		var marker = new GMarker(point, icon);
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml('<div style="height:100px;"><strong>Novelli Restaurant<br />HCF Gastronomie GmbH</strong><br />A-1010 Wien . Bräunerstrasse 11a<br />Tel.: +43/1/513 42 00<br />Fax: +43/1/513 42 00-1<br />E-Mail: <a href="mailto:novelli@haslauer.at">novelli@haslauer.at</a></div>');
		});
		return marker;
	}  
}
// -----------------------------------------------------------------------------------
/*  
Project:  tell a friend lightbox
Autor:    Sindre Wimberger / wimberger@echonet.at
Created:  23.07.2007
Modified: 
 */
var taf = {
	stat : false,
	init: function(){		
		taf.starter = $('recommend');
		if (taf.starter) {
			taf.url = taf.starter.href;
			if (!$('tafoverlay')) {
				var objBody = document.getElementsByTagName("body").item(0);	
					var objOverlay = document.createElement("div");
					objOverlay.setAttribute('id','tafoverlay');
					objOverlay.style.display = 'none';
					Element.setOpacity(objOverlay, 0.8);
					objOverlay.onclick = function() { taf.end(); }
					objBody.appendChild(objOverlay);
					var objTaf = document.createElement("div");
					objTaf.setAttribute('id','taf');
					objTaf.style.display = 'none';
	//				objTaf.onclick = function(e) {	// close Lightbox is user clicks shadow overlay
	//					if (!e) var e = window.event;
	//					var clickObj = Event.element(e).id;
	//					if ( clickObj == 'lightbox') {
	//						taf.end();
	//					}
	//				};
					objBody.appendChild(objTaf);
			}
			Event.observe(taf.starter, 'click', taf.start);
			$('mailto').show();
		}
	},
	start: function(event){
        Event.stop(event);
		taf.hideSelectBoxes();
		taf.hideFlash();
		var arrayPageSize = taf.getPageSize();
//		Element.setHeight('tafoverlay', arrayPageSize[1]);
		$('tafoverlay').setStyle({height: arrayPageSize[1]+'px'});
		new Effect.Appear('tafoverlay', { duration: 1, from: 0.0, to: 0.8 });
		var arrayPageScroll = taf.getPageScroll();
		var boxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
//		Element.setTop('taf', boxTop);
		$('taf').setStyle({top: boxTop+'px'});
		new Ajax.Request(taf.url, {
			method: 'get',
			onException: function(r,e) {
			  taf.message(e);
			},
			onComplete: function(resp) {
					$('taf').update(resp.responseText);
						Element.show('taf');
						Event.observe('recommend', 'submit', taf.send);
						Event.observe('sendbutton', 'click', taf.send);
						Event.observe('closebutton', 'click', taf.end);					
			},
			onFailure: function() {
			  taf.message("Übertragung fehlgeschlagen. Bitte versuchen Sie es noch einmal.");
			}
		});
	},
	send: function(event){
        Event.stop(event);
		if(taf.stat) return;
		taf.stat = true;	
        f = $('recommend');
//		var params = Form.serialize(f);
		var params = "fromname="+Form.Element.getValue('fromname')+ "&fromemail="+Form.Element.getValue('fromemail')+"&toname="+Form.Element.getValue('toname')+"&toemail="+Form.Element.getValue('toemail')+"&text="+Form.Element.getValue('text')+"&sent=1";
		Element.hide('taf');
		new Ajax.Request(taf.url, {
			method: 'post',
			parameters: params,
			onComplete: function(resp) {
					$('taf').update(resp.responseText);
						Element.show('taf');
						if($('recommend')) {Event.observe('recommend', 'submit', taf.send);}
						if($('sendbutton')) {Event.observe('sendbutton', 'click', taf.send);}
						Event.observe('closebutton', 'click', taf.end);					
						taf.stat = false;	
			},
			onFailure: function() {
			  taf.message("Übertragung fehlgeschlagen. Bitte versuchen Sie es noch einmal.");
 			  taf.stat = false;	
			}
		});
	},
	end: function(event){
        Event.stop(event);
		Element.hide('taf');
		new Effect.Fade('tafoverlay', { duration: 0.5});
		taf.showSelectBoxes();
		taf.showFlash();
		$('taf').update('');
		taf.stat = false;	
	},
	// Error Klasse
	message: function(msg){
		alert(msg);
	},	
	showSelectBoxes: function(){
		var selects = document.getElementsByTagName("select");
		for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "visible";
		}
	},
	hideSelectBoxes: function(){
		var selects = document.getElementsByTagName("select");
		for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "hidden";
		}
	},
	showFlash: function(){
		var flashObjects = document.getElementsByTagName("object");
		for (i = 0; i < flashObjects.length; i++) {
			flashObjects[i].style.visibility = "visible";
		}
	
		var flashEmbeds = document.getElementsByTagName("embed");
		for (i = 0; i < flashEmbeds.length; i++) {
			flashEmbeds[i].style.visibility = "visible";
		}
	},
	hideFlash: function(){
		var flashObjects = document.getElementsByTagName("object");
		for (i = 0; i < flashObjects.length; i++) {
			flashObjects[i].style.visibility = "hidden";
		}
	
		var flashEmbeds = document.getElementsByTagName("embed");
		for (i = 0; i < flashEmbeds.length; i++) {
			flashEmbeds[i].style.visibility = "hidden";
		}
	},
	//
	// getPageSize()
	// Returns array with page width, height and window width, height
	// Core code from - quirksmode.com
	// Edit for Firefox by pHaez
	//
	getPageSize: function (){
		
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			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 { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		return arrayPageSize;
	},
	//
	// getPageScroll()
	// Returns array with x,y page scroll values.
	// Core code from - quirksmode.com
	//
	getPageScroll: function(){
	
		var xScroll, yScroll;
	
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
			xScroll = self.pageXOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
			xScroll = document.documentElement.scrollLeft;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
			xScroll = document.body.scrollLeft;	
		}
	
		arrayPageScroll = new Array(xScroll,yScroll) 
		return arrayPageScroll;
	}
}
// -----------------------------------------------------------------------------------
function enablePrintButton() {
	if ($('print')) {
		$('print').show();
		$('print').observe('click', function(e) {
			if($("menu")) {
				PageTrans.menu._openAll();
			}
			window.print();
			Event.stop(e);
		});
	}
}
// -----------------------------------------------------------------------------------
function IMGpreload(imglink) {	
		var imagePreloader = new Image();
		imagePreloader.setAttribute('src',imglink);
}
// -----------------------------------------------------------------------------------
function initLighthover() { myLighthover = new Lighthover();}
// -----------------------------------------------------------------------------------
// "Import" the StateManager so we don't have to keep typing
// "EXANIMO.managers.StateManager".
var StateManager = EXANIMO.managers.StateManager;
StateManager.onstaterevisit = function(e) {
	PageTrans.disappearFX(e.id);
	PageTrans.currenturl = e.id;
}        
// -----------------------------------------------------------------------------------
document.observe("dom:loaded", function() {										
	// Menu Accordion Effect
	if($("menu")) {
		PageTrans.menuAccordion();
	}
		
	// Ajax Übergänge
	PageTrans.init("c-content",1,false,"","pagetransloading",'<p class="center"><img src="/media/kube/assets/content/ajax-loader.gif" alt="Laden" /><br /><br />Seite wird geladen...</p>');	
	
	// Hauptnavigation Accordion Effect
	mainnav = new Effect.Accordion("c-nav", {duration: '0.5', eventlistener:'click'}); 
	
	// subnav auf display:block setzen
	$$('#c-nav li').invoke('addClassName', 'active'); 		
	
	// Formularüberprüfung und Ajax absenden
	if($("gutschein")) {PageTrans.formObserve("gutschein");} //

	// Lighthover Effext
 	initLighthover();
	
	// Google Maps 
  	initGoogleMaps();
	
	// Seite weiterempfehlen erstellen und einblenden
	taf.init();

	// Seite Drucken einblenden
	enablePrintButton();
	
	StateManager.defaultStateID = document.URL;
   	StateManager.initialize();
});