hs.graphicsDir = '/js/highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.dimmingOpacity = 0.85;
hs.showCredits	= false;
hs.addSlideshow({
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
	opacity: .75,
	position: 'bottom center',
		hideOnMouseOut: true
	}
});
function AW_Button(target, linktype) {
	linktype = (typeof linktype == 'undefined') ? 'internal' : linktype;
	if (target.toLowerCase() == "back") {
		history.back();	
	} else {
		if (linktype == "internal") { 
			window.location.href = target;
		}
		else { 
			nw = window.open(target,"externalLink");
			nw.focus();
		}		
	}
}
function AW_TabController(nr) {
	var tab1	= dojo.byId("tab1");
	var tab2	= dojo.byId("tab2");
	var header	= dojo.byId("tab_header");
	var content	= dojo.byId("tab_content");
	if (nr == 1) {
		dojo.style(tab1,"borderBottom","0px solid black");
		dojo.style(tab1,"backgroundColor","#ffffff");
		dojo.style(tab2,"borderBottom","1px solid black");
		dojo.style(tab2,"backgroundColor","#cccccc");
		dojo.style(tab1,"cursor","default");
		dojo.style(tab2,"cursor","pointer");
		dojo.style(content,"background","url('/Images/Content/bg_laboratories_lmu.jpg')");
		header.innerHTML = "Impressions of the LMU laboratory and office Building";
	}
	if (nr == 2) {
		dojo.style(tab2,"borderBottom","0px solid black");
		dojo.style(tab2,"backgroundColor","#ffffff");
		dojo.style(tab1,"borderBottom","1px solid black");
		dojo.style(tab1,"backgroundColor","#cccccc");
		dojo.style(tab2,"cursor","default");
		dojo.style(tab1,"cursor","pointer");
		dojo.style(content,"background","url('/Images/Content/bg_laboratories_mpq.jpg')");
		header.innerHTML = "Impressions of the MPQ Building";	
	}
	return true;
}
function getNrFromAscii(asciicode){
	rescode   = asciicode;
	if (asciicode > 96) {
	       rescode = rescode - 11;
	} else {
		if (asciicode > 94) {
			rescode = rescode - 10;
		} else { 
			if (asciicode > 63) {
				rescode = rescode - 6;
			} else {
				if (asciicode > 60) {
					rescode = rescode - 4;
				} else {
					if (asciicode > 47) {
						rescode = rescode - 1;
					}
				}
			}
		}
	}
	return rescode - 42;
}
function getAsciiFromNr(nr) {
  	asciicode = nr + 42;
  	rescode   = asciicode;
   	if (asciicode > 85) {
        rescode = rescode + 11;
	} else {
	 	if (asciicode > 84) {
        	rescode = rescode + 10;
		} else {
		 	if (asciicode > 57) {
        		rescode = rescode + 6;
			} else {
				if (asciicode > 56) {
        			rescode = rescode + 4;
				} else {
					if (asciicode > 46) {
        				rescode = rescode + 1;
					}
				}
			}
		}
	}
    return rescode;
}
function malie(str) {
	secr 	= "LaboratoryForAttosecondPhysics";
	ilema	= "";
	for (i = 0; i<str.length; i++) {
		secri = i;
		if (i >= secr.length) {
			secri = i % secr.length;
		}
		c 	= str.charCodeAt(i);
		s	= secr.charCodeAt(secri);
		cnr	= getNrFromAscii(c);
		snr	= getNrFromAscii(s);
		resnr	= ((cnr - snr + 68) % 69 ) + 1;
		res		= getAsciiFromNr(resnr);
		ilema	= ilema + (String.fromCharCode(res));
	}
	location.href = "mailto:"+ilema;
}
var activeArea		= {left:0,top:44,right:700,bottom:304};
var menueAnimation; var tooltipAnimation;
dojo.declare("MenueObject",null,{
	constructor: function(url, tooltip, menue, firstMenueContainer) {
		this.url 			= url;
		this.tooltip		= new Tooltip(tooltip);
		this.menue			= dojo.byId(menue);
		this.menueLoaded	= false;
		this.menueStructure	= [];
		this.menueContainer	= firstMenueContainer;
		this.loadMenue();
		dojo.connect(this.menue,"onmouseout",this,this.menueOnMouseOut);
	},
	menueOnMouseOut: function(event) {
		if (event.pageX >= activeArea.right 	|| event.pageX <= activeArea.left || 
			event.pageY >= activeArea.bottom 	|| event.pageY <= activeArea.top) {
				this.menueContainer.closeMenues();
			}
	},
	setMenueContainer: function(mc) {
		this.menueContainer = mc;
	},
	setUrl: function(url) {
		this.url = url;
	},
	getMenueStructure: function() {
		if (this.menueLoaded) {
			return this.menueStructure;
		}
	},
	loadMenue: function() {
		if (this.url && this.menueContainer) {
			dojo.xhrGet( {
				url: 			this.url,
				handleAs: 		"json",
				timeout: 		3000,
				menue: 			this,
				mimetype: 		"text/json-comment-filtered",
				load: function(response,ioArgs) {
					this.menue.menueStructure 	= response;
					this.menue.menueLoaded		= true;
					this.menue.menueContainer.initializeContainer(response,this.menue.tooltip,true);
				},
				error: function(response,ioArgs) {
				}
			} )
		} else {
		}
	}
})
dojo.declare("Node",null,{
	constructor: function(nodeName) {
		this.node			= dojo.byId(nodeName);
		dojo.connect(this.node,"onmouseover",this,this.onMouseOver);
		dojo.connect(this.node,"onmouseout",this,this.onMouseOut);
		dojo.connect(this.node,"onclick",this,this.onClick);
	},
	setVisibility: function(visible) {
		if (this.isVisible() != visible) {
			if (visible) {
				dojo.style(this.node,"visibility","visible");
			} else {
				dojo.style(this.node,"visibility","hidden");
			}
		}
	},
	isVisible: function() {
		var visible	= dojo.style(this.node,"visibility");
		if (visible=="visible") 	return true;
		if (visible=="hidden")		return false;
	},
	isTransparent: function() {
		var visible	= dojo.style(this.node,"opacity");
		return (visible=="0");
	},
	setOpacity: function(op) {
		dojo.style(this.node,"opacity",op);
	},
	getOpacity: function() {
		return 	dojo.style(this.node,"opacity");
	},
	hideNode: function() {
		this.setVisibility(false);
		this.setOpacity(0);
	},
	fadeNode: function(time, endOp) {
		this.setVisibility(true);
		if (time>0) {
			var animArgs = {
				node: this.node,
				duration: time,
				delay:50,
				properties: {opacity: {end: endOp}}
			};
			menueAnimation = dojo.animateProperty(animArgs);
			menueAnimation.play();
		} else {
			this.setOpacity(endOp);
		}
	},
	onMousOver: function(event) {},
	onMousOut: function(event) {},
	onClick: function(event) {}
})
	dojo.declare("Tooltip",Node,{
	constuctor: function(){
		this.node.innerHTML = "";
	},
	setText: function(text){
		this.node.innerHTML = text;
	},
	show: function(evnt) {
		this.hideNode();
		if (evnt.pageX) {
			dojo.style(this.node,"top", (evnt.pageY+10)+"px");
			dojo.style(this.node,"left", (evnt.pageX+20)+"px");
			if (this.node.innerHTML != "") {
				this.setVisibility(true);
				if (tooltipAnimation) {tooltipAnimation.stop()}
				tooltipAnimation = dojo.animateProperty({
					node: this.node,
					duration: 100,
					delay: 1500,
					properties: {opacity: {end: 0.95}}
				})
				tooltipAnimation.play();
			}
		}
	},
	onMouseOver: function(event) {
		this.hideNode();
		if (tooltipAnimation) {tooltipAnimation.stop()}
	}
})
dojo.declare("MenueContainer",Node,{
	constructor: function(nodeName,itemName,picNodeName,maxNrOfEntries) {
		this.maxNrOfEntries	= maxNrOfEntries;
		this.menueItems		= this.connectMenueItems(itemName);
		this.overlay		= picNodeName ? new Node(picNodeName) : null;
		this.tooltip		= null;
		this.nextMC			= null;
		this.prevMC			= null;
		this.isActive		= false;
		this.menueStructure	= [];
		this.activeItemId	= null;
	},
	setNextMenueContainer: function(mc) {
		this.nextMC	= mc;
	},
	setPrevMenueContainer: function(mc) {
		this.prevMC	= mc;
	},
	setMenueStructure: function(ms) {
		this.menueStructure = ms;
	},
	setActivity: function(active) {
		this.isActive = active;
	},
	connectMenueItems: function(iname) {
		var field = [];
		for (var i=0;i<this.maxNrOfEntries;i++) {
			field[i] = new MenueItem(iname+"_"+(i+1),i,this);
		}
		return field;
	},
	initializeContainer: function(ms,tooltip,visible) {
		this.setMenueStructure(ms);
		if (this.nextMC) {
			this.nextMC.initializeContainer(null,tooltip,false);
		}
		this.setMenueItems();
		this.tooltip = tooltip;
		if (visible) {
			this.fadeNode(0,1)
			this.setActivity(true);
		} else {
			this.hideNode();
			if (this.overlay) {this.overlay.hideNode()}
			this.setActivity(false);
		}
	},
	closeMenues: function() {
		for (var i=0;i<this.menueItems.length;i++){
			this.menueItems[i].makeInactive();
		}
		this.tooltip.hideNode();
		if(this.nextMC) {
			this.nextMC.deactivateContainer();
		}
	},
	activateContainer: function(ms) {
		this.setMenueStructure(ms);
		if (this.menueStructure.nrofentries == "0") {
			this.deactivateContainer();
		} else {
			this.setMenueItems();
			if (this.overlay && !this.isActive) {this.overlay.fadeNode(300,1)}
			if (!this.isActive) {this.fadeNode(300,0.9);}
			if (this.nextMC) {
				this.nextMC.deactivateContainer();
			}
			this.setActivity(true);	
		}
	},
	deactivateContainer: function() {	
		if (this.isActive) {
			this.clearItems();
			if (this.overlay) {this.overlay.fadeNode(300,0)}
			this.fadeNode(300,0);		
			if (this.nextMC) {
				this.nextMC.deactivateContainer();
			}
			this.setActivity(false);
		}
	},
	clearItems: function() {
		for (var i=0; i<this.menueItems.length;i++) {
			this.menueItems[i].clearContent();
			this.menueItems[i].setVisibility(false);
		}
	},
	setMenueItems: function() {
		if (this.menueStructure) {
			var mn	= this.menueStructure;
			if (this.activeItemId != null) {
				this.menueItems[this.activeItemId].makeInactive();
				this.activeItemId = null;
			}
			for (var i=0; i<this.menueItems.length;i++) {
				if (i<mn.nrofentries) {
					this.menueItems[i].setData(mn.entries[i].link,mn.entries[i].tooltip,mn.entries[i].shortname);
					this.menueItems[i].setVisibility(true);
				} else {
					this.menueItems[i].clearContent();
					this.menueItems[i].setVisibility(false);
				}
			}
		} else { this.clearItems() }
	},
	itemEvent: function(eventName,nr,event) {
		switch(eventName){
			case "onmouseover":
				if (this.nextMC && this.menueStructure) {
					if (this.menueStructure.nrofentries>nr) {
						this.nextMC.activateContainer(this.menueStructure.entries[nr]);
					}
				}
				if (this.activeItemId != null) {this.menueItems[this.activeItemId].makeInactive()}
				this.menueItems[nr].makeActive();
				this.activeItemId	= nr;
				if (this.prevMC && (this.prevMC.activeItemId != null)) {
					this.prevMC.menueItems[this.prevMC.activeItemId].makeVisited();
				}
				this.menueItems[nr].showTooltip(this.tooltip,event);
				break;
			case "onmouseout":
				break;
		}
	}
})
dojo.declare("MenueItem",Node,{
	constructor: function(nodeName,nr,menue) {
		this.menue			= menue;
		this.id				= nr;
		this.link			= "";
		this.content		= "";
		this.tooltip		= "";
		this.isActiveItem	= false;
		this.isVisitedItem	= false;
	},
	getId: function() {
		return this.id;
	},
	clearContent: function() {
		this.node.innerHTML	= "";
	},
	setData: function(link,tooltip,text) {
		this.link		= link;
		this.tooltip	= tooltip;
		this.content	= text;
		this.setText();
	},
	setText: function() {
		this.node.innerHTML = this.content;
	},
	showTooltip: function(ttnode,event) {
		ttnode.setText(this.tooltip);
		ttnode.show(event);
	},
	makeActive: function() {
		if (this.isActiveItem) {
			return;
		} else {
			dojo.addClass(this.node,"itemHighlighted");
			if  (this.isVisitedItem) {
				dojo.removeClass(this.node,"item");
			} else {
				dojo.removeClass(this.node,"itemVisited");
			}
			this.isActiveItem	= true;
			this.isVisitedItem	= false;
		}
	},
	makeInactive: function() {
		if (this.isActiveItem){
			dojo.addClass(this.node,"item");
			dojo.removeClass(this.node,"itemHighlighted");
			this.isActiveItem	= false;
		}
		if (this.isVisitedItem){
			dojo.addClass(this.node,"item");
			dojo.removeClass(this.node,"itemVisited");
			this.isVisitedItem	= false;
		}
	},
	makeVisited: function() {
		if (!this.isActiveItem) return;
		dojo.addClass(this.node,"itemVisited");
		dojo.removeClass(this.node,"itemHighlighted");			
		this.isActiveItem	= false;
		this.isVisitedItem	= true;
	},
	onMouseOver: function(event) { this.menue.itemEvent("onmouseover",this.id,event); return 0;},
	onMouseOut: function(event) { this.menue.itemEvent("onmouseout",this.id,event); return 0;},
	onClick: function(event) { window.location = this.link}
})
function setSideline(sname, fname) {
	if (dojo.isIE == 6) {
		var node	= dojo.byId(sname);
		var footer	= dojo.byId(fname);
		var s	= dojo.coords(node);
		var f 	= dojo.coords(footer);
		dojo.style(node,"height",(f.t-s.t)+"px");
	}
}
function setupMenue() {
		var menueName			= "M_menue";
		var	itemName			= "M_item";
		var menueFrameName		= "menue";
		var menueURL			= "/js/myscripts/menueStructure.js";
		var imageNames			=[null,"Overlay_1","Overlay_2"];	
		var tooltipName			="M_tooltip";
		var contentName			="content";
		var maxMenueDepth		= 3;
		var maxItemsPerLevel 	=[6,12,12];
		var imagePath			=".";
		var menueContainer		= [];
	for (var i=0;i<maxMenueDepth;i++) {
		menueContainer[i] = new MenueContainer(menueName+"_"+(i+1),itemName+"_"+(i+1),imageNames[i],maxItemsPerLevel[i]);
	}
	for (var i=0;i<maxMenueDepth;i++) {
		if ((i+1)<maxMenueDepth) { menueContainer[i].setNextMenueContainer(menueContainer[i+1])}
		if (i>0) { menueContainer[i].setPrevMenueContainer(menueContainer[i-1])}
	}
	var mainMenue 	= new MenueObject(menueURL,tooltipName,menueFrameName,menueContainer[0]);
	setSideline("frame_seitenlinie","footerbox");
}
dojo.addOnLoad(setupMenue);
