// Version 1.14; 20010504
// Bernd Goebel
// beg@kognito.de, info@kognito.de
// insprirated by Thomas Brattli from "www.bratta.com"

//root folder
var myRoot = 'www.mpib-berlin.mpg.de';
var myScript = '../css/index.html';

//Map Path
var myIndexpath = "http://www.mpib-berlin.mpg.de/";
var myMainpath = "http://www.mpib-berlin.mpg.de/";
////////////////////////////// Browser ////////////////////////////////
function checkBrowser(){
	this.ver=navigator.appVersion;
	this.name=navigator.appName;
	this.dom=document.getElementById?1:0;
	this.ie5=(this.ver.indexOf("MSIE")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ie=this.ie4||this.ie5;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	//-->Change for outside Script
	this.ns4=(this.name== "Netscape" && parseInt(navigator.appVersion)==4)?1:0;
	if (this.ns4){
	this.ns4old=(navigator.appVersion.substring (2,3)=="0")?1:0;
	}
	//<--
	this.mac=(navigator.appVersion.indexOf("Mac") > -1);
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);
	return this;
}

bw = new checkBrowser()

if (bw.ns4){
	origWidth = innerWidth;
	origHeight = innerHeight;
	onresize = netscapeResizeFix;
}

if(!bw.bw) alert("sorry you need a 4.x+ browser to see this page") //location.href='sorry.html'

////////////////////////////// Bratta Libary ////////////////////////////////


function lib_doc_size(){ //Page positions - needed!
	this.x=0;this.x2=(bw.ns4 || bw.ns5)?innerWidth:document.body.offsetWidth;
	this.y=0;this.y2=(bw.ns4 || bw.ns5)?innerHeight:document.body.offsetHeight;
	//if(!this.x2||!this.y2) return message('Document has no width or height') 
	this.x50=this.x2/2;     this.y50=this.y2/2;
	this.x10=(this.x2*10)/100;this.y10=(this.y2*10)/100
	return this;
}

//Default lib functions
function lib_obj(obj,nest){
	if (bw.ns4old) return 'oldBrowser';
	function lib_moveIt(x,y){ //Move to a spesified position
	        this.x=x;this.y=y
	        this.css.left=x;this.css.top=y
	}
	function lib_moveBy(x,y){ //Move by a spesified number of pixels
	        this.moveIt(this.x+x,this.y+y)
	}
	function lib_showIt(){ //Show a layer
	        this.css.visibility="visible";
	}
	function lib_hideIt(){ //Hide a layer
	        this.css.visibility="hidden"
	}
	function lib_bg(color){ //Changing backgroundcolor
	        if(bw.dom || bw.ie4) this.css.backgroundColor=color
	        else if(bw.ns4) this.css.bgColor=color  
	}
	function lib_writeIt(text,startHTML,endHTML){  //Writing new content to a layer
	        if(bw.ns4){
	                if(!startHTML){startHTML=""; endHTML=""}
	                this.ref.open("text/html"); this.ref.write(startHTML+text+endHTML); this.ref.close()
	        }else this.evnt.innerHTML=text //NOTE: This only works on Explorer4+5 and Gecko M16+
	}
	function lib_clipTo(t,r,b,l,setwidth){ //Clip to a spesified setting
		this.ct=t; this.cr=r; this.cb=b; this.cl=l
		if(bw.ns4){
			this.css.clip.top=t;this.css.clip.right=r
			this.css.clip.bottom=b;this.css.clip.left=l
		}else{
			if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0
			this.css.clip="rect("+t+","+r+","+b+","+l+")";
			if(setwidth){this.css.width=r; this.css.height=b}
		}
	}
	function lib_clipBy(t,r,b,l,setwidth){ //Clip by a spesified number of pixels
		this.clipTo(this.ct+t,this.cr+r,this.cb+b,this.cl+l,setwidth)
	}
	if(!bw.bw) return message('Old browser')
	this.evnt=bw.dom && document.getElementById(obj)||bw.ie4 && document.all[obj]|| (nest?bw.ns4 && document[nest].document[obj]:bw.ns4 && document.layers[obj]);
	if(!this.evnt) return lib_message('The layer does not exist ('+obj+') - Exiting script\n\nIf your using Netscape please check the nesting of your tags!')
	this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt;      
	this.ref=bw.dom||bw.ie4?document:this.css.document;
	this.x=this.css.left||this.css.pixelLeft||this.evnt.offsetLeft||0
	this.y=this.css.top||this.css.pixelTop||this.evnt.offsetTop||0
	//-->change for NS6 PC<--
	this.w=this.evnt.offsetWidth||this.css.pixelWidth||this.ref.width||0
	this.h=this.ref.height||this.evnt.offsetHeight||this.css.pixelHeight||0
	this.moveIt=lib_moveIt; this.moveBy=lib_moveBy; 
	this.showIt=lib_showIt; this.hideIt=lib_hideIt;
	this.writeIt=lib_writeIt; this.bg=lib_bg;
	//Clip values
	this.c=0
	if((bw.dom || bw.ie4) && this.css.clip) {
		this.c=this.css.clip; this.c=this.c.slice(5,this.c.length-1); 
		this.c=this.c.split(' '); 
		for(var i=0;i<4;i++){this.c[i]=parseInt(this.c[i])}
	}
	this.ct=this.css.clip.top||this.c[0]||0; 
	this.cr=this.css.clip.right||this.c[1]||this.w||0
	this.cb=this.css.clip.bottom||this.c[2]||this.h||0; 
	this.cl=this.css.clip.left||this.c[3]||0
	this.clipTo=lib_clipTo;	this.clipBy=lib_clipBy;
	this.obj = obj + "Object"; 	eval(this.obj + "=this")
	return this
}


////////////////////////////// Stylesheets ////////////////////////////////
if (bw.bw) installStyleSheets();installMyMapPath();

function ScriptPath(){
	var myLoc = location.href;
	myPath = myLoc.substring(0,myLoc.lastIndexOf(myRoot))+myRoot;
	return myPath;
	}

function installStyleSheets(){
	var stylepath = ScriptPath()+myScript;
	var olderStyle='<style type="text/css">';
	olderStyle+='.head {font-family: Verdana, Geneva, sans-serif;font-size : 20px;line-height: 24px; color: #000000;}';
	olderStyle+='.subhead {	font-family: Verdana, Geneva, sans-serif;font-size : 12px;line-height: 15px; font-weight: bold;color: #000000;}';
	olderStyle+='.plain {font-family: Verdana, Geneva, sans-serif;font-size : 12px;line-height: 15px; color: #000000;}';
	olderStyle+='.plainBlue {font-family: Verdana, Geneva, sans-serif;font-size : 12px;line-height: 15px; color: #006699;}';
	olderStyle+='.plainDate {font-family: Verdana, Geneva, sans-serif;font-size : 12px;line-height: 15px; color: #000000;}';
	olderStyle+='.standDatum {font-family: Verdana, Geneva, sans-serif;font-size : 10px;line-height: 12px; color: #000000;}';
	
	olderStyle+='A {text-decoration: none;font-family : Verdana, Geneva, sans-serif;color: #006699;}';
	olderStyle+='.normalLink {font-size : 12px;line-height: 15px;}';
	olderStyle+='.smallLink {font-size : 10px;line-height: 12px;}';
	olderStyle+='.navigationsLink {	font-size : 12px;line-height: 16px;}';
	olderStyle+='.boldLink {font-size : 12px;line-height: 15px;font-weight: bold;}';
	
	olderStyle+='#Header{position:absolute;top:0;left:0; z-index:1;}';
	olderStyle+='#Basic{position:absolute;top:120;left:0; z-index:1;}';
	olderStyle+='</style>';

	if (bw.mac) document.write('<link href="' + stylepath + 'mac.css" rel="StyleSheet" type="text/css">');
	else if(bw.ie) document.write('<link href="' + stylepath + 'ie.css" rel="StyleSheet" type="text/css">');
	else if (bw.ns5)document.write('<link href="' + stylepath + 'ns6.css" rel="StyleSheet" type="text/css">');
	else if (bw.ns4old)document.write(olderStyle);	
	else document.write('<link href="' + stylepath + 'ns.css" rel="StyleSheet" type="text/css">');	
}



////////////////////////////// NetscapeStylesheets Bug ////////////////////////////////
// store window size for Netscape resize fix

if(!window.saveInnerWidth){
     window.onresize = netscapeResizeFix;
     window.saveInnerWidth = window.innerWidth;
     window.saveInnerHeight = window.innerHeight;
    }
    


function netscapeResizeFix(){
	if(bw.ns4){
		if (saveInnerWidth != window.innerWidth || saveInnerHeight != window.innerHeight)
		{
			location.reload();//window.history.go(0); //
			saveInnerWidth = window.innerWidth;
			saveInnerHeight = window.innerHeight;
			
		}
	}

}

////////////////////////////// PreparePrint IE5 ////////////////////////////////
if(bw.ie5){
    onbeforeprint = ie5_beforeprint;
    onafterprint = ie5_afterprint;
    }

////////////////////////////// Max-Planck only ////////////////////////////////

function MapPath(){
	var myLoc = location.href;
	myPath = myLoc.substring((myLoc.lastIndexOf(myRoot)),myLoc.length);
	return myPath;
	}

function startMaxPlanck(){
	//objBasic.showIt();
	if(!bw.mac){
	//	if (bw.ns4 && (!bw.ns4old))objBasic.moveBy(168,0);
	}
	else{
		if(bw.ie){
	document.body.style.overflow='scroll';
		}
	}
	//objBasic.showIt();
}

function installMyMapPath(){
	myIndexpath = "";
	myMainpath = "";
	myUpper="http://www.mpib-berlin.mpg.de/"
	myTmpLoc = MapPath();
	myDelimiter = myTmpLoc.split("http://www.mpib-berlin.mpg.de/");
	myUpper="http://www.mpib-berlin.mpg.de/"	
	for(i = 0; i < (myDelimiter.length-2); i++)
    	{
    	 myIndexpath = myIndexpath+myUpper;
     	}
     		for(i = 0; i < (myDelimiter.length-3); i++)
    	{
    	 myMainpath = myMainpath+myUpper;
     	}
		
	}

function changeLanguage(){
	myTmpLoc = location.href;
	//myTmpPath = myTmpLoc.substring(0,myTmpLoc.lastIndexOf(myRoot)+ myRoot.length+3);//+myRoot;
	myLanguage = myTmpLoc.substring((myTmpLoc.lastIndexOf(myRoot)+ myRoot.length+1) , (myTmpLoc.lastIndexOf(myRoot)+ myRoot.length+3));//
	if(myLanguage=='de'){
		myPrefix = myTmpLoc.substring(0,myTmpLoc.lastIndexOf(myRoot)+ myRoot.length+1);
		mySuffix = myTmpLoc.substring(myTmpLoc.lastIndexOf(myRoot)+ myRoot.length+4,myTmpLoc.length);
		myNewURL = myPrefix+'en/'+mySuffix;
		location.href = myNewURL;
		}
	
	if(myLanguage=='en'){
		myPrefix = myTmpLoc.substring(0,myTmpLoc.lastIndexOf(myRoot)+ myRoot.length+1);
		mySuffix = myTmpLoc.substring(myTmpLoc.lastIndexOf(myRoot)+ myRoot.length+4,myTmpLoc.length);
		myNewURL = myPrefix+'de/'+mySuffix;
		location.href = myNewURL;		
		}
	}

function ie5_beforeprint(){
	objBasic.css.left=-168;
	}

function ie5_afterprint(){
	objBasic.css.left=0;
}
	

////////////////////////////// Debugging ////////////////////////////////
function lib_showStatus (msg) {
	window.status=msg;
}

function lib_message(msg){ //Error feedback function
	alert(msg);
	return false;
}


