// FUER PSF-Webseite

var naviId="navi_container";
var first=true;
var isGrown=false;
var growing=false;
var shrinking=false;
var normal=new naviContainerNormal();
var big= new naviContainerBig();
var growTimeout=false;
var growAnimation=false;
var shrinkTimeout=false;
var shrinkAnimation=false;
var anzahl_schleifen=20;
var i=0;

function naviContainerNormal() {
	this.width=750;
	this.height=40;
	this.paddingLeft=0;
	this.marginLeft=-376;
	this.marginTop=0;
	this.borderTop=0;
	this.borderBottom=0;
	this.borderLeft=1;
	this.borderRight=1;
	//this.borderRightAndLeft = 'solid #1F5289';
}

function naviContainerBig(){
	this.width=790;
	this.height=66;
	this.paddingLeft=40;
	this.marginLeft=-396;
	this.marginTop=-5;
	this.borderTop=5;
	this.borderBottom=1;
	this.borderLeft=1;
	this.borderRight=1;
}


function growNavi(){
//document.getElementById("animation_log").innerHTML+="MOUSEOVER: GROW";
//document.getElementById("animation_frame").innerHTML+=''+i+' growing='+growing+', shrinking='+shrinking+', isGrown='+isGrown+'.\n';
	if(i>=anzahl_schleifen){
		i=anzahl_schleifen;
		isGrown=true;
	}
	if(i<0) i=0;
	if(shrinking){
		shrinking=false;
		clearInterval(shrinkAnimation);
	}
	if(!growing&&i<anzahl_schleifen){
		//document.getElementById("animation_log").innerHTML+="NEW Grow-Anim\n";
		growing=true;
		//setTimeout('startGrowAnimation()',250);
		startGrowAnimation();
	}
}

function shrinkNavi(){
	//document.getElementById("animation_log").innerHTML+="MOUSEOVER: SHRINK";
	//document.getElementById("animation_frame").innerHTML+=''+i+' growing='+growing+', shrinking='+shrinking+', isGrown='+isGrown+'.\n';
	if(i>=anzahl_schleifen){
		i=anzahl_schleifen;
		isGrown=true;
	}
	if(i<0) i=0;
	if(growing){
		growing=false;
		clearInterval(growAnimation);
	}
	if(!shrinking&&i<=anzahl_schleifen){
		//document.getElementById("animation_log").innerHTML+="NEW Shrink-Anim\n";
		shrinking=true;
		//setTimeout('startShrinkAnimation()',500);
		startShrinkAnimation();
	}
}

function startGrowAnimation(){
	//document.getElementById("animation_log").innerHTML+="START Grow-Anim\n\n";
	growAnimation = setInterval('growNaviAnimation()',1);
}

function startShrinkAnimation(){
	//document.getElementById("animation_log").innerHTML+="START Shrink-Anim\n\n";
	shrinkAnimation = setInterval('shrinkNaviAnimation()',25);
}

function growNaviAnimation(){
	//document.getElementById("animation_frame").innerHTML+=''+i+' growing='+growing+', shrinking='+shrinking+', isGrown='+isGrown+'.\n';

	if(i>anzahl_schleifen){
		i=anzahl_schleifen;
		setNaviBig();
		growing=false;
		isGrown=true;
		//document.getElementById("animation_log").innerHTML+="Grow-Anim: returnin\n";
	}
	if(growing){
		style = document.getElementById(naviId).style;
		i++;
		
		style.width=normal.width+(big.width-normal.width)/anzahl_schleifen*i+"px";
		style.height=normal.height+(big.height-normal.height)/anzahl_schleifen*i+"px";
		//style.paddingLeft=normal.paddingLeft+i*2+2+'px';
		style.marginLeft=normal.marginLeft-(normal.marginLeft-big.marginLeft)/anzahl_schleifen*i+"px";
		style.marginTop=normal.marginTop-(normal.marginTop-big.marginTop)/anzahl_schleifen*i+"px";
		style.borderTop=normal.borderTop+(big.borderTop-normal.borderTop)/anzahl_schleifen*i+'px solid #1F5289';
		//style.borderBottom=normal.borderBottom+(big.borderBottom-normal.borderBottom)/anzahl_schleifen*(anzahl_schleifen-i)+'px solid #1F5289';
		//document.getElementById("animation_frame").innerHTML+=normal.borderTop+(big.borderTop-normal.borderTop)/anzahl_schleifen*i+"px\n";
		//style.borderLeft=0+'px solid #1F5289';
		//style.borderRight=0+'px solid #1F5289';
	}
	if(!growing) clearInterval(growAnimation);
}

function shrinkNaviAnimation(){
	//document.getElementById("animation_frame").innerHTML+=''+i+' growing='+growing+', shrinking='+shrinking+', isGrown='+isGrown+'.\n';
	
	if(i<0){
		i=0;
		setNaviNormal();
		shrinking=false;
		isGrown=false;
		//document.getElementById("animation_log").innerHTML+="Shrink-Anim: returning\n";
	}
	if(shrinking){
		//document.getElementById("animation_log").innerHTML+="Shrink-Anim: NOW SHRINKING\n";
		style = document.getElementById(naviId).style;
		i--;
		
		style.width=big.width-(big.width-normal.width)/anzahl_schleifen*(anzahl_schleifen-i)+2+"px";
		style.height=big.height-(big.height-normal.height)/anzahl_schleifen*(anzahl_schleifen-i)+1+"px";
		//style.paddingLeft=normal.paddingLeft+i*2+2+'px';
		style.marginLeft=big.marginLeft+(normal.marginLeft-big.marginLeft)/anzahl_schleifen*(anzahl_schleifen-i)+"px";
		style.marginTop=big.marginTop+(normal.marginTop-big.marginTop)/anzahl_schleifen*(anzahl_schleifen-i)+"px";
		style.borderTop=big.borderTop-(big.borderTop-normal.borderTop)/anzahl_schleifen*(anzahl_schleifen-i)+'px solid #1F5289';
		//style.borderBottom=big.borderBottom-(big.borderBottom-normal.borderBottom)/anzahl_schleifen*(anzahl_schleifen-i)+'px solid #1F5289';
		//document.getElementById("animation_frame").innerHTML+=normal.borderTop+(big.borderTop-normal.borderTop)/anzahl_schleifen*i+"px\n";
		//style.borderLeft=1+'px solid #1F5289';
		//style.borderRight=1+'px solid #1F5289';
	}
	
	if(!shrinking) clearInterval(shrinkAnimation);
}

function setNaviNormal(){
	style = document.getElementById(naviId).style;
	
	style.width=normal.width+"px";
	style.height=normal.height+"px";
	//style.paddingLeft=normal.paddingLeft+i*2+2+'px';
	style.marginLeft=normal.marginLeft+'px';
	style.marginTop=normal.marginTop+'px';
	style.borderTop=normal.borderTop+'px';
	style.borderBottom=big.borderBottom+'px solid #1F5289';
	style.borderLeft=normal.borderLeft+'px solid #1F5289';
	style.borderRight=normal.borderRight+'px solid #1F5289';
	
	i=0;
	isGrown=false;
	shrinking=false;
}

function setNaviBig(){
	style = document.getElementById(naviId).style;
	
	style.width=big.width+"px";
	style.height=big.height+"px";
	//style.paddingLeft=big.paddingLeft-(i-20)*(-2)+'px';
	style.marginLeft=big.marginLeft+'px';
	style.marginTop=big.marginTop+'px';
	style.borderTop=big.borderTop+'px solid #1F5289';
	style.borderBottom=big.borderBottom+'px solid #1F5289';
	style.borderLeft=big.borderLeft+'px solid #1F5289';
	style.borderRight=big.borderRight+'px solid #1F5289';
	
	i=anzahl_schleifen;
	isGrown=true;
	growing=false;
}