
var flashheight = 261;
var flashheightnew = flashheight
var contenttop = 341;
var contenttopnew = contenttop;
var navitop = 283;
var navitopnew = navitop;
var sidebartop = 322;
var sidebartopnew = sidebartop;

var textblockwidth = 448;
var textblockwidthnew = textblockwidth;
var searchtableft = 0;
var searchtableftnew = searchtableft;
var searchtaboutleft = 260;
var searchtaboutleftnew = searchtaboutleft;

var userCookie = null;


function init() {
	
	userCookie = new cookieObject("bukuserdata9", 365, null, "headerbar", "searchbar", "searchbar_tab")
	
	if (userCookie && userCookie.found) {
		//headerbar_init(userCookie.get("headerbar"));
		searchbar_init(userCookie.get("searchbar"));
		searchbar_switch(userCookie.get("searchbar_tab"));
	} else {
		//userCookie.put("headerbar", "in");
		userCookie.put("searchbar", "out");
		userCookie.put("searchbar_tab", "searchtab_bilder");
		searchbar_init("out");
		searchbar_switch("searchtab_dateien");
	}
	
	var FO = { movie:"media/headerflash.swf", flashvars:"startheight="+ flashheightnew, wmode:"transparent", width:"742", height:flashheightnew, majorversion:"8", build:"0", id:"flashheader", name:"flashheader", swliveconnect:"true" };
	UFO.create(FO, "header");

	vdate = new Date()
	userCookie.put("date", vdate.toGMTString())
	userCookie.write();

}



function flashheader_DoFSCommand(command, args) {
	
	if (!document.getElementById('content'))  return false;
	
	if (command=='stageSize') {
		
		if (args=='minimize') {
			if (userCookie)  userCookie.put("headerbar", "in");
			flashheightnew = 261;
			contenttopnew = 341;
			navitopnew = 282;
			sidebartopnew = 322;
			document.getElementById('logolinks').style.visibility = 'visible';
			document.getElementById('logolangswitch').style.visibility = 'visible';
		}
		
		if (args=='maximize') {
			if (userCookie)  userCookie.put("headerbar", "out");
			flashheightnew = 261+292;
			contenttopnew = 341+292;
			navitopnew = 282+292;
			sidebartopnew = 322+292;
			document.getElementById('logolinks').style.visibility = 'hidden';
			document.getElementById('logolangswitch').style.visibility = 'hidden';
		}
		
		if (userCookie)  userCookie.write();
		
		isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
		var flashObj = isInternetExplorer ? document.all.flashheader : document.flashheader;
		if (flashObj) {
			flashObj.setAttribute('height',flashheightnew);
			document.getElementById('content').style.top = contenttopnew+'px';
			document.getElementById('navi').style.top = navitopnew+'px';
			document.getElementById('sidebar').style.top = sidebartopnew+'px';	
		}
		
	}
	
}


function headerbar_init(sMode) {
	//alert ('headerbar_init');
	
	
	if (!document.getElementById('content'))  return false;

	if (sMode=='in') {
		flashheightnew = 261;
		contenttopnew = 341;
		navitopnew = 283;
		sidebartopnew = 322;
		document.getElementById('logolinks').style.visibility = 'visible';
		document.getElementById('logolangswitch').style.visibility = 'visible';
	}
	
	if (sMode=='out') {
		flashheightnew = 261+292;
		contenttopnew = 341+292;
		navitopnew = 283+292;
		sidebartopnew = 322+292;
		document.getElementById('logolinks').style.visibility = 'hidden';
		document.getElementById('logolangswitch').style.visibility = 'hidden';
	}
	
	flashheight = flashheightnew;
	contenttop = contenttopnew;
	navitop = navitopnew;
	sidebartop = sidebartopnew;

	document.getElementById('content').style.top = contenttopnew+'px';
	document.getElementById('navi').style.top = navitopnew+'px';
	document.getElementById('sidebar').style.top = sidebartopnew+'px';	
	
	/*
	isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	var flashObj = isInternetExplorer ? document.all.flashheader : document.flashheader;
	if (flashObj) {
		flashObj.setAttribute('height',flashheight);
		document.getElementById('content').style.top = contenttop+'px';
		document.getElementById('navi').style.top = navitop+'px';
		document.getElementById('sidebar').style.top = sidebartop+'px';
	}
	*/

}


function searchbar_slide(sMode) {
	
	
	
	if (!document.getElementById('searchtabcontainer'))  return false;
	
	if (userCookie) {
		userCookie.put("searchbar", sMode);
		userCookie.write();
	}
	
	
	if (sMode=='in') {
		textblockwidthnew = 448;
		searchtableftnew = 0;
		searchtaboutleftnew = 260;
		if (document.getElementById('searchtabcontainer'))  document.getElementById('searchtabcontainer').style.zIndex = 50;
		if (document.getElementById('searchtaboutcontainer'))  document.getElementById('searchtaboutcontainer').style.zIndex = 10;
		if (document.getElementById('sideimages'))  document.getElementById('sideimages').style.zIndex = 10;
	}
	
	if (sMode=='out') {
		textblockwidthnew = 448+240;
		searchtableftnew = 260;
		searchtaboutleftnew = 0;
	}
	
	
	
}

function searchbar_move(sMode) {
	
	
	if (!document.getElementById('searchtabcontainer'))  return false;
	
	if (sMode=='in') {
		textblockwidthnew = 448;
		searchtableftnew = 0;
		searchtaboutleftnew = 260;
		if (document.getElementById('searchtabcontainer'))  document.getElementById('searchtabcontainer').style.zIndex = 50;
		if (document.getElementById('searchtaboutcontainer'))  document.getElementById('searchtaboutcontainer').style.zIndex = 10;
		if (document.getElementById('sideimages'))  document.getElementById('sideimages').style.zIndex = 10;
	}
	
	if (sMode=='out') {
		textblockwidthnew = 448+240;
		searchtableftnew = 260;
		searchtaboutleftnew = 0;
	}
	
	
	
}


function searchbar_init(sMode) {
	
	searchbar_slide ('searchbar_init');
	
	if (!document.getElementById('searchtab'))  return false;
	
	searchbar_slide(sMode);
	textblockwidth = textblockwidthnew;
	searchtableft = searchtableftnew;
	searchtaboutleft = searchtaboutleftnew;
	document.getElementById('searchtab').style.left = searchtableft+'px';
	document.getElementById('searchtabout').style.left = searchtaboutleft+'px';
	
}


function searchbar_switch(sID) {
	
	if (!document.getElementById('searchtab_dateien'))  return false;
	
	if (userCookie) {
		userCookie.put("searchbar_tab", sID);
		userCookie.write();
	}
	
	// hide all
	if (document.getElementById('searchtab_dateien')) {
		document.getElementById('searchtab_dateien').style.visibility = 'hidden';
		document.getElementById('searchtab_dateien_tab').className = 'searchtab_naviitem';
	}
	if (document.getElementById('searchtab_bilder')) {
		document.getElementById('searchtab_bilder').style.visibility = 'hidden';
		document.getElementById('searchtab_bilder_tab').className = 'searchtab_naviitem';
	}
	if (document.getElementById('searchtab_versenden')) {
		document.getElementById('searchtab_versenden').style.visibility = 'hidden';
	}
	
	// show ID
	if (document.getElementById(sID)) {
		document.getElementById(sID).style.visibility = 'visible';
		if (document.getElementById(sID+'_tab'))  document.getElementById(sID+'_tab').className = 'searchtab_naviitem_selected';
	}
	
}


function updatePositions() {
	
	if (!document.getElementById('searchtabcontainer'))  return false;
	
	var cut = 0.1;
	/*
	var flashheightdif = (flashheightnew-flashheight)/3;
	if (flashheightdif<-cut || flashheightdif>cut)  flashheight += flashheightdif;
	else flashheight = flashheightnew;
	var contenttopdif = (contenttopnew-contenttop)/3;
	if (contenttopdif<-cut || contenttopdif>cut)  contenttop += contenttopdif;
	else contenttop = contenttopnew;
	var navitopdif = (navitopnew-navitop)/3;
	if (navitopdif<-cut || navitopdif>cut)  navitop += navitopdif;
	else navitop = navitopnew;
	var sidebartopdif = (sidebartopnew-sidebartop)/3;
	if (sidebartopdif<-cut || sidebartopdif>cut)  sidebartop += sidebartopdif;
	else sidebartop = sidebartopnew;
	*/

	var textblockwidthdif = (textblockwidthnew-textblockwidth)/3;
	if (textblockwidthdif<-cut || textblockwidthdif>cut)  textblockwidth += textblockwidthdif;
	else textblockwidth = textblockwidthnew;
	var searchtableftdif = (searchtableftnew-searchtableft)/3;
	if (searchtableftdif<-cut || searchtableftdif>cut)  searchtableft += searchtableftdif;
	else searchtableft = searchtableftnew;
	var searchtaboutleftdif = (searchtaboutleftnew-searchtaboutleft)/8;
	if (searchtaboutleftdif<-cut || searchtaboutleftdif>cut)  searchtaboutleft += searchtaboutleftdif;
	else searchtaboutleft = searchtaboutleftnew;

/*
	isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	var flashObj = isInternetExplorer ? document.all.flashheader : document.flashheader;
	if (flashheightdif!=0)  flashObj.setAttribute('height',flashheight);
	if (contenttopdif!=0)  document.getElementById('content').style.top = contenttop+'px';
	if (navitopdif!=0)  document.getElementById('navi').style.top = navitop+'px';
	if (sidebartopdif!=0)  document.getElementById('sidebar').style.top = sidebartop+'px';
*/  
	//if (textblockwidthdif!=0)  document.getElementById('textblock').style.width = textblockwidth+'px';
	if (searchtableftdif!=0)  document.getElementById('searchtab').style.left = searchtableft+'px';
	if (searchtaboutleftdif!=0)  document.getElementById('searchtabout').style.left = searchtaboutleft+'px';

	if (searchtableft==260) {
		if (document.getElementById('searchtabcontainer'))  document.getElementById('searchtabcontainer').style.zIndex = 10;
		if (document.getElementById('searchtaboutcontainer'))  document.getElementById('searchtaboutcontainer').style.zIndex = 50;
		if (document.getElementById('sideimages'))  document.getElementById('sideimages').style.zIndex = 60;
	}
	
}

setInterval('updatePositions()',20);


function getStyle(el, cssproperty, csspropertyNS) {
	
	if (el.currentStyle)  return el.currentStyle[cssproperty];
	else if (window.getComputedStyle) {
		var elstyle=window.getComputedStyle(el, "");
		return elstyle.getPropertyValue(csspropertyNS);
	}
	
}



function debug(sText) {
	
	document.getElementById('debug').innerHTML = sText;
	
}