// ============================================
// Animator Object
// ============================================
function isInQueue(obj) {
	var found = false;
	for (var i=this.aniQueue.length; i--;) {
 		if (this.aniQueue[i]==obj) found = true;
 	}
 	for (var i=this.waitingQueue.length; i--;) {
 		if (this.waitingQueue[i]==obj) found = true;
 	}
 	return found;
}
 
function addToAniQueue(obj) {
	if (!this.isInQueue(obj) && obj) { 
		this.aniQueue[this.aniQueue.length] = obj;
		this.startAnimation();
	}
}

function appendToWaitingQueue(arr) {
	if (arr.length) { 
		this.waitingQueue = this.waitingQueue.concat(arr);
		this.startWaitingQueue();
	}
}
 
function animateStuff() {
 	for (var i=this.aniQueue.length; i--;) {
		var a = this.aniQueue[i];
		if (a.animate()) this.aniQueue.splice(i,1);
	}
  	if (this.aniQueue.length == 0) this.stopAnimation();
	
  	
}

function startAnimation() {
  if (!this.timer) this.timer = setInterval('animator.animateStuff()',animationInterval);
}

function startWaitingQueue() {
  if (!this.timer2) this.timer2 = setInterval('animator.next()',waitingInterval);
}

function stopAnimation() {
  if (!this.timer) return false;
  clearInterval(this.timer);
  this.timer = null;
 if (selectedThumbItem == null && thumbOrder.length>0) {
  			var arr = firstImage.split(',');
		}
}

function next() {
	this.addToAniQueue(this.waitingQueue.shift());
	if (this.waitingQueue.length == 0) {
		if (this.timer2) clearInterval(this.timer2);
		this.timer2 = null
	}
}
 
function Animator() {
	this.name ='animator';
	this.aniQueue = new Array();
	this.waitingQueue = new Array();
	this.timer1 = null;
	this.timer2 = null;
	
	this.isInQueue = isInQueue;
	this.addToAniQueue = addToAniQueue;
	this.startAnimation = startAnimation;
	this.stopAnimation = stopAnimation;
	this.animateStuff = animateStuff;
	this.appendToWaitingQueue = appendToWaitingQueue;
	this.startWaitingQueue = startWaitingQueue;
	this.next = next;
}
// ============================================

// ============================================
// animatable "interface"	
// ============================================
function Animatable(el){
	this.s_x = 0;
	this.s_y = 0;
	this.t_x = 0;
	this.t_y = 0;
	this.s_z = 0;
	this.t_z = 0;
	this.step = 0;
	this.el = el;
	this.style = this.el.style;
	
	this.setTarget = function (x,y,w,h) {
		if(x != null) this.t_x = x;
		if(y != null) this.t_y = y;
		if(w != null) this.t_w = w;
		if(h != null) this.t_h = h;
		this.step=0;
		
	}
	
	this.animate = function () {};
	this.stop = function () {};
}

// ============================================
// navigation object, implements animatable	
// ============================================
function moveBySinus() {
	var distX = parseInt(sinustable[this.step]*(this.t_x - this.s_x));
	var distY = parseInt(sinustable[this.step]*(this.t_y - this.s_y));
	this.step++;
	this.style.left = this.s_x+distX+'px';
	this.style.top = this.s_y+distY+'px';
	if (this.t_x == parseInt(this.style.left) && this.t_y == parseInt(this.style.top)) {
		this.step=0;
		this.stop();
		return true;
	}
}



function activateNavItem() {
	var pos = this.bezier(60, 0, -100,0,  sinustable[this.step]);
	
	this.style.left = pos[0]+'px';
	this.style.top = pos[1]+'px';
	
	this.step++;
	
	if (this.step == sinustable.length) {
		this.step=0;
		this.stop();
		return true;
	}
}

function deactivateNavItem() {
	var pos = this.bezier(0,parseInt((this.t_y-this.s_y)/2),  0, parseInt((this.t_y-this.s_y)/2),  sinustable[this.step]);
	
	this.style.left = pos[0]+'px';
	this.style.top = pos[1]+'px';
	
	this.step++;
	
	if (this.step == sinustable.length) {
		this.step=0;
		this.stop();
		return true;
	}
}

function activateCatItemPerson() {
	var pos = this.bezier(190, -17, -227,-53, sinustablelong[this.step]);
	if (pos[0] >= 0) {
		document.getElementById('bgperson').style.width = pos[0]+'px';
	}
	this.style.left = pos[0]+'px';
	this.style.top = pos[1]+'px';
	
	this.step++;
	
	if (this.step == sinustablelong.length) {
		this.step=0;
		this.stop();
		return true;
	}
}

function activateCatItemAuftrag() {
	var pos = this.bezier(178, 0, -170,78, sinustablelong[this.step]);
	if (pos[0] >= 0) {
		document.getElementById('bgauftrag').style.width = pos[0]+'px';
	}
	this.style.left = pos[0]+'px';
	this.style.top = pos[1]+'px';
	
	this.step++;
	
	if (this.step == sinustablelong.length) {
		this.step=0;
		this.stop();
		return true;
	}
}

function activateCatItemFrei() {
	var pos = this.bezier(342, -17, -146,64, sinustablelong[this.step]);
	if (pos[0] >= 0) {
		document.getElementById('bgfrei').style.width = pos[0]+'px';
	}
	this.style.left = pos[0]+'px';
	this.style.top = pos[1]+'px';
	
	this.step++;
	
	if (this.step == sinustablelong.length) {
		this.step=0;
		this.stop();
		return true;
	}
}

function activateHome() {
	var pos =  parseInt(this.s_x + ((this.t_x - this.s_x)*sinustablelong[this.step]));
	
	this.style.width = pos+'px';
	this.step++;
	if (this.step == sinustablelong.length) {
		this.step=0;
		this.stop();
		return true;
	}
}

function calculateBezier(dx2,dy2,dx3,dy3,t1) {
	var pos = [];
	var x1 = this.s_x;
	var y1 = this.s_y;
	var x2 = this.s_x+dx2;
	var y2 = this.s_y+dy2;
	
	var x3 = this.t_x+dx3;
	var y3 = this.t_y+dy3;
	var x4 = this.t_x;
	var y4 = this.t_y;
	
	var cx = 3 * (x2 - x1);
	var cy = 3 * (y2 - y1);
	var bx = 3 * (x3 - x2) - cx;
	var by = 3 * (y3 - y2) - cy;
	var ax = x4 - x1 - cx - bx;
	var ay = y4 - y1 - cy - by;
	//var t1 = ;
	var t2 = t1 * t1;
	var t3 = t2 * t1;
	//debug(this.s_x);
	pos[0] = parseInt(ax * t3 + bx * t2 + cx * t1 + x1);
	pos[1] = parseInt(ay * t3 + by * t2 + cy * t1 + y1);
	return pos;
}


function stopNavObject() {
	this.s_x = parseInt(this.style.left);
	this.s_y = parseInt(this.style.top);
	
	if (navOrder.length >0 && animator.aniQueue.length <=1 ) { 
		if (gotoPage!= null) setTimeout('select(gotoPage)',100);  // if jumptarget is present, load page1
		else if (!selectedNavItem) {
			var b = document.getElementById('beschreibung');
			//b.innerHTML = '< make a pick';
			//b.style.visibility = 'visible';
			get('get_page.php?page_id='+chapter, 'beschreibung');
		}
	}
 	
 	if (this.el.id == 'm100') {
		//introduceNews()
		tri.setTarget(navLeft,30,null,null);
		animator.addToAniQueue(tri);
	}
 	
 	if (this == selectedNavItem) {
		this.views++;
		load_page(this.el.id);
	}
	if (this.views >0 && this != selectedNavItem)  this.el.className='visited';
}

function newNavObject(el, i) {
	var o = new Animatable(el);
	
	o.s_x = -100;
	o.s_y = navTop+(navFreq*i);
	o.t_x = navLeft;
	o.t_y = o.s_y;
	o.style.left = '-200px';
	o.style.top = o.s_y+'px';
	
	o.views = 0;
	
	o.bezier = calculateBezier;
	o.animate = moveBySinus;
	o.stop = stopNavObject;
	
	return o;
}

function select(ni) {
	for (var i=navOrder.length; i--;) {
 		var a = navOrder[i];
		if (a.el.id == ni) {
			a.setTarget(hlLeft,navTop);
			a.animate = activateNavItem;
			old = selectedNavItem;
			selectedNavItem = a;
			navOrder.splice(i,1);
			animator.addToAniQueue(a);
			document.getElementById('beschreibung').style.visibility = 'hidden';
			killThumbs();
			
			if (old) {
				old.animate = deactivateNavItem;
				//old.style.color='#000';
				old.style.visibility = "visible";
				navOrder[navOrder.length] = old;
			}
		}
  	}	
  	gotoPage = null;
	repositionAll();
}

function repositionAll() {
	for (var i=navOrder.length; i--;) {
 		var a = navOrder[i];
 		if (a != old) a.animate = moveBySinus;
 		a.setTarget(navLeft, navTop+(navFreq*i));
		animator.addToAniQueue(a);
  	}	
}
// ============================================


// ============================================
// thumbnail object, implements animatable
// ============================================
function scaleBySinus() {
	var dW = parseInt(sinustable[this.step]*(this.t_w - this.s_w));
	var dH = parseInt(sinustable[this.step]*(this.t_h - this.s_h));
	var dX = parseInt(sinustable[this.step]*(this.t_x - this.s_x));
	var dY = parseInt(sinustable[this.step]*(this.t_y - this.s_y));

	this.style.width = this.s_w+dW+'px';
	this.style.height = this.s_h+dH+'px';
	
	if (this.step == 0) this.style.visibility = 'visible';
	
	this.style.left = this.s_x - Math.floor(parseInt(this.style.width)/2) + dX +'px';
	this.style.top = this.s_y - Math.floor(parseInt(this.style.height)/2)+dY+'px';
	
	this.step++;
	if(this.step>sinustable.length) this.step=sinustable.length;
	if (this.step == sinustable.length) {
		this.step=0;
		this.stop();
		return true;
	}
}

function activateThumbnail() {
	var pos = this.bezier(-100, 0, -100,0,  sinustable[this.step]);
	
    var dW = parseInt(sinustable[this.step]*(this.t_w - this.s_w));
	var dH = parseInt(sinustable[this.step]*(this.t_h - this.s_h));
	
	this.style.width = this.s_w+dW+'px';
	this.style.height = this.s_h+dH+'px';
	this.style.left = pos[0] - Math.floor(parseInt(this.style.width)/2) +'px';
	this.style.top = pos[1] - Math.floor(parseInt(this.style.height)/2)+'px';
	
	this.style.visibility = 'visible';
  	
  	this.step++;
	if (this.step == sinustable.length) {
		this.step=0;
		this.stop();
		return true;
	}
}

function deActivateThumbnail() {
	var dW = parseInt(sinustable[this.step]*(this.t_w - this.s_w));
	var dH = parseInt(sinustable[this.step]*(this.t_h - this.s_h));
	
	var pos = this.bezier(+100, 0, +250,0,  sinustable[this.step]);
	
	this.style.width = this.s_w+dW+'px';
	this.style.height = this.s_h+dH+'px';
	this.style.left = pos[0] - parseInt(parseInt(this.style.width)/2) +'px';
	this.style.top = pos[1] - parseInt(parseInt(this.style.height)/2)+'px';
	
	this.style.visibility = 'visible';
  	//showThumbs();
  	
  	this.step++;
	if (this.step == sinustable.length) {
		this.step=0;
		this.stop();
		return true;
	}
}


function stopThumbObject() {
	this.s_w = parseInt(this.style.width);
	this.s_h = parseInt(this.style.height);
	this.s_x = parseInt(this.style.left) + parseInt(parseInt(this.style.width)/2);
	this.s_y = parseInt(this.style.top) + parseInt(parseInt(this.style.height)/2);
	this.animate = scaleBySinus;
	if (this.s_w <= 22)	this.el.firstChild.style.visibility = 'hidden';
	if (this == selectedThumbItem) {
		var id = parseInt(selectedThumbItem.el.id);
		if (id != parseInt(image.el.name)) get('get_image.php?page_id='+selectedNavItem.el.id+'&info_id='+id, 'bild');
	}
}

function popup(img) {
	
	for (var i=thumbOrder.length; i--;) {
		var a = thumbOrder[i];
		if (a.el == img) {
			if (a.step != 0) return;
			//a.setTarget(40,30,null);
			//animator.addToAniQueue(a);
			img.style.zIndex = 2000+'';
			img.firstChild.style.visibility = 'visible';
			showToolTip(564+parseInt(img.style.left), navTop+parseInt(image.el.height)+28, img.name);
		}
	}
}

function popdown(img) {
	for (var i=thumbOrder.length; i--;) {
		var a = thumbOrder[i];
		if (a.el == img) {
			//if (a.s_x != a.t_x) return;
			//a.setTarget(20,15,null,null);
			//animator.addToAniQueue(a);
			img.style.zIndex = 1000+'';
			img.firstChild.style.visibility = 'hidden';
			showToolTip(-300,0,'');
		}
	}
}


function load_image(id,w,h) {
	for (var i=thumbOrder.length; i--;) {
		var a = thumbOrder[i];
		if (a.el.id.substr(0,4).indexOf(id) != -1) {
			var img = a.el;
			img.firstChild.style.visibility = 'hidden';
			img.style.zIndex = 1000-parseInt(id)+'';
			old = selectedThumbItem;
			selectedThumbItem = a;
			thumbOrder.splice(i,1);
 			a.animate = activateThumbnail;
 			showToolTip(-500, 0, '');
 			//a.setOpacity(50);
 			var bild = document.getElementById('bild');
 			killImage();
 			bild.style.width =w+'px';
 			bild.style.height =h+'px';
 			bild.innerHTML =' ';
			w = parseInt(w);
			h = parseInt(h);
 			a.setTarget(Math.ceil(w/2), Math.floor(-h/2-10), w, h);
 			if (old) {
 				old.animate = deActivateThumbnail;
				thumbOrder[thumbOrder.length] = old;
 			}
			animator.addToAniQueue(a);
		}
	}
	repositionAllThumbs();
}

function repositionAllThumbs() {
	for (var i=thumbOrder.length; i--;) {
 		var a = thumbOrder[i];
 		if (a != old) a.animate = scaleBySinus;
 		a.setTarget(10+thumbFreq*i,8,  20, 15);
		animator.addToAniQueue(a);
  	}	
}

function newThumbObject(el, i) {
	var o = new Animatable(el);
	o.s_w = 40;
	o.s_h = 30;
	o.t_w = 20;
	o.t_h = 15;
	o.s_x = parseInt(o.style.left)+o.t_w/2;
	o.style.left = o.s_x+'px';
	o.t_x = o.s_x;
	o.s_y = 7;
	o.style.top = o.s_y+'px';
	o.t_y = o.s_y;
	o.views = 0;
	o.animate = scaleBySinus;
	o.stop = stopThumbObject;
	o.bezier = calculateBezier;
	
	o.setOpacity = setOpacity;
	el.onmouseover = function() {
		popup(this);
	}
	el.onmouseout = function() {
		popdown(this);
	}
	return o;
}
// ============================================


// ============================================
// image object, implements animatable	
// ============================================
function fadeLinear() {
	var opacity = this.s_x+((this.t_x - this.s_x)/15)*this.step;
	//alert(opacity);
	this.step++;
	this.setOpacity(opacity);
	if (this.t_x == opacity) {
		this.step=0;
		this.stop();
		return true;
	}
}

function setOpacity(opacity) {
	var opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	this.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	this.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	this.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	this.style.opacity = opacity/100;
}

function newImageObject(el) {
	var o = new Animatable(el);
	o.s_x = 0;
	o.t_x = 100;
	
	o.setOpacity = setOpacity;
	o.animate = fadeLinear;
	o.stop = function() {
		this.s_x = 100;
		if (this.t_y != 0) get('get_image.php?page_id='+selectedNavItem.el.id+'&info_id='+this.t_y, 'bild');
		if (!thumbOrder.length) get('get_thumbs.php?page_id='+selectedNavItem.el.id, 'thumbs');
	};
	o.setOpacity(o.s_x);
	
	return o;
}


// ============================================
// text object, implements animatable	
// ============================================
function textAppear() {
	var distX = parseInt(sinustable[this.step]*(this.t_x - this.s_x));
	var distY = parseInt(sinustable[this.step]*(this.t_y - this.s_y));
	
	this.style.left = this.s_x+distX+'px';
	this.style.top = this.s_y+distY+'px';
	
	
	var str = '';
	var l = 30;
	if (this.step-l > 0) str += this.text.substr(0,this.step-l);
	for (var i=l; i>0; i--) {
		if (this.step-i >= 0) str += '<font style="font-size: '+(14+l-i)+'px; letter-spacing: -'+(i/(5*l))+'em;">'+ this.text.substr(this.step-i,1) + '</font>';
	}
	this.el.innerHTML = str;
	
	if (this.step == l) introduceCategories();
	this.step++;
	
	if (this.step == this.text.length+1+l) {
		this.step=0;
		this.stop();
		return true;
	}
}

function moveIn() {
	var pos = this.bezier(0,400,  0,-30,  sinustable[this.step]);
	this.style.left = pos[0]+'px';
	this.style.top =  pos[1]+'px';
	
	this.step++;
	
	if (this.step == sinustable.length) {
		this.step=0;
		this.stop();
		return true;
	}
}

function moveToPlace() {
	var pos = this.bezier(300,100,  -100,-40,  sinustablelong[this.step]);
	
	this.style.left = pos[0]+'px';
	this.style.top = pos[1]+'px';
	
	this.step++;
		//debug(this.step + ' ' +  sinustablelong.length);
	
	if (this.step == sinustablelong.length) {
		this.step=0;
		this.stop();
		if(!introduced) introduceCategories();
		if (this.t_x == navLeft)	{
			introduceNews();
			this.onclick = function() {};
		}
		return true;
	}
}

function newTextObject(el) {
	var o = new Animatable(el);
	
	// get window size
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}

	
	o.s_x = parseInt(x/2)-80;
	o.s_y = -15;
	o.t_x = parseInt(x/2)-80;
	o.t_y = parseInt(y*0.3);
	o.text = el.innerHTML;
	
	o.animate = moveIn;
	o.bezier = calculateBezier;
	o.stop = function() {
		this.s_x = this.t_x;
		this.s_y = this.t_y;
		//if (this.t_x == 25) introduceNews();
		
		//introduceCategories();
	};
	
	return o;
}




// ============================================
// general functions
// ============================================
function showToolTip(x,y,html) {
	tt = document.getElementById('tooltip');
	tt.innerHTML = html;
	tt.style.left= x+'px';
	tt.style.top = y+'px';
}

function killThumbs() {
	kill('thumbs');
	thumbOrder = [];
}
function showThumbs() {
	var i = document.getElementById('thumbs');
	i.style.visibility ='visible';
}

function showNavigation() {
	var i = document.getElementById('navigation');
	i.style.visibility ='visible';
}


function killImage() {
	kill('bild');
	//image = null;
}

function showImage() {
	var i = document.getElementById('bild');
	//alert(i.innerHTML+ ' ' + i.innerHTML.indexOf('IMG src'));
	if (i.innerHTML.indexOf('bilder') != -1) {
		i.style.visibility ='visible';
	}
}

function hideHomepage() {
	var i = document.getElementById('home');
	i.style.visibility ='hidden';
}

function kill(el) {
	var i = document.getElementById(el);
	i.style.visibility ='hidden';
	i.innerHTML=" ";
}

function hasLoaded(c) {
	el = document.getElementById(c);
	switch(c) {	 
		case "beschreibung":
			el.style.visibility ='visible';
			selectedNavItem.el.style.visibility = 'hidden';
			break;
		case "thumbs":
			initThumbs();
			break;
		case "bild":
			showImage();
			break;
		
		case "navigation":
			initNavigation();
			break;
	}
}

function jump(id) {
	gotoPage = id;
	load_chapter(id);
	waitingInterval = 100;
	if(!introduced) introduceCategories();
}
function load_chapter(id) {
	chapter = id;
	killThumbs();
	killImage();
	hideHomepage()
	kill('beschreibung');
	kill('navigation');
	get('get_subnav.php?page_id='+id, 'navigation');
	animationInterval = 10;
	highliteChapter(id);
}
function highliteChapter(id) {
	if(id<98 || id>101) return;
	for (i=98; i<101;i++) {
		e = document.getElementById('m'+i);
		(i==id)?c='activeCat':c=' ';
		e.className=c;
	}
}
function load_page(id) {
	killThumbs();
	killImage();
	get('get_page.php?page_id='+id, 'beschreibung');
	get('get_image.php?page_id='+id, 'bild');
}

function debug(message) {
		debugView.innerHTML = message;
}

// ============================================
// globals
// ============================================
var navItems = [];
var navObj = [];
var navOrder = [];
var thumbOrder = [];
var animator;
var image;
var debugView;
var selectedNavItem = null;
var clickedNavItem = null;
var selectedThumbItem = null;
var firstImage = null;
var chapter = null;
var image = null;
var old = null;
var tri = null;
var introduced = false;

var gotoPage = null;

var steps = 30;
var sinustable = [];
var sinustablelong = [];
var waitingInterval = 800;
var animationInterval = 10;

var navTop = 225;
var navLeft = 30;
var navFreq = 16;
var hlLeft = 241;
var thumbFreq = 30;

function initSinusTable(numOfSteps) {
	var st = [];
	for (var i=0;i<numOfSteps; i++) {
		st[i] = Math.sin(((i+1)*0.5*Math.PI)/numOfSteps)
	}
	return st;
}


function initThumbs() {
  selectedThumbItem = null;
  thumbOrder = [];
  var thumbs = document.getElementById('thumbs').getElementsByTagName('a');
  var totalItems = thumbs.length;
   for (var i=totalItems; i--;) {
   	if (i==0) {
   		firstImage = thumbs[i].id;
   	}
	thumbOrder[i] = newThumbObject(thumbs[i],i-1);
  }
  var arr = firstImage.split(',');
  
  var first = thumbOrder.shift();
  selectedThumbItem = first;
  first.setTarget(Math.ceil(arr[1]/2), Math.ceil(-arr[2]/2-11), arr[1], arr[2]);
  first.style.visibility = 'hidden';
  first.step = 28;
  animator.addToAniQueue(first);
  
  waitingInterval = 200;
  
  showThumbs();
  animator.appendToWaitingQueue(thumbOrder);

}

function initNavigation() {
	selectedNavItem = null;
	navOrder = [];
	navItems = document.getElementById('navigation').getElementsByTagName('a');
	totalItems = navItems.length;
	for (var i=totalItems; i--;) {
		navObj[i] = newNavObject(navItems[i],i);
		navOrder[i] = navObj[i];
  	}
  	waitingInterval = 100;
	animator.appendToWaitingQueue(navOrder);
	showNavigation();
	
}

function init() {
  sinustable = initSinusTable(steps);
  sinustablelong = initSinusTable(70);
  
  debugView = document.getElementById('debug');
  
  animator = new Animator();
	
	var arr = [];
	el = document.getElementById('tri');
	tri = newTextObject(el);
	animator.addToAniQueue(tri);
	
	if (document.location.hash) {
		jump(document.location.hash.substr(1));
	}
	
}

function startPage() {
	if (!introduced) {
		el = document.getElementById('zusatz');
		el.style.visibility = 'hidden';
		tri.setTarget(-325, 80,null, null);
		tri.animate = moveToPlace;
		animator.addToAniQueue(tri);
		tri.el.blur();
		document.body.focus();
	} else {
		document.location.href ='./';
	}
	//introduceNews();
}

window.onload = init;



function introduceCategories() {
	animationInterval = 10;
  	waitingInterval = 500;
	var arr = [];

	el = document.getElementById('m98');
	var p = newNavObject(el, 0)
	p.s_x = -114;
	p.s_y = 200;
	p.setTarget(516,62);
	p.animate = activateCatItemPerson;
	//arr[0] = p;
	animator.addToAniQueue(p);
	
	el = document.getElementById('m99');
	var p = newNavObject(el, 0)
	p.s_x = -92;
	p.s_y = 40;
	p.setTarget(595,89);
	p.animate = activateCatItemAuftrag;
	arr[0] = p;
	
	el = document.getElementById('m100');
	var p = newNavObject(el, 0)
	p.s_x = -98;
	p.s_y = 94;
	p.setTarget(677,143);
	p.animate = activateCatItemFrei;
	arr[1] = p;
	
	animator.appendToWaitingQueue(arr);
	introduced = true;
}

function introduceNews() {
	/*var newsObjects = [];
	newsItems = document.getElementById('quicklinks').getElementsByTagName('a');
	totalItems = newsItems.length;
	for (var i=totalItems; i--;) {
		newsObjects[i] = newNavObject(newsItems[i],i);	
  	}*/
  	var arr = [];
  	el = document.getElementById('home');
	var p = newNavObject(el, 0)
	p.style.left = '30px';
	p.s_x = 1;
	p.setTarget(780,0);
	p.animate = activateHome;
	arr[0] = p;
  	waitingInterval = 100;
	animationInterval = 20;
	animator.appendToWaitingQueue(arr);
}


// heres da photofade


<!--
//document.write("<style type='text/css'>#thephoto {visibility:hidden;}</style>");

function initImage() {
	var imageEl = document.getElementById('thephoto');
	
	image = newImageObject(imageEl);
	animator.addToAniQueue(image);
	imageEl.style.visibility = 'visible';
	imageEl.onmouseover = function () {
		document.getElementById('bu').style.visibility='visible';
	}
	imageEl.onmouseout = function () {
		document.getElementById('bu').style.visibility='hidden';
	}
	if (selectedThumbItem) selectedThumbItem.style.visibility = 'hidden';
  	var bild = document.getElementById('bild');
  	bild.style.width = imageEl.width+'px';
  	bild.style.height = imageEl.height+'px';
}
		
		

// here comes da AJAX stuff //


		/* tiny
		function showError(e){
		  alert(e);
		}
		
		function get(url, consumer, progressBar){
		  var message = NanoEngine.createMessage(url, consumer, showError);
		  if(progressBar){
			var progress = new EmbeddedProgressBar(document, progressBar);
			message.progressBar = progress;  
		  }
		  NanoEngine.sendMessage(message); 
		} 
		
		*/
		
		
		function showError(e){
		  alert(e);
		}
		
		function get(url, consumer, progressBar){
		  var message = Clean.createSimpleMessage(url, consumer, showError);
		  // createFullMessage(url, xslt, consumer, doRefresh, onError, onChange, onComplete)
		  //var message = createFullMessage(url, null, consumer, null, null, null, 'activate');
		  if(progressBar){
			var progress = new EmbeddedProgressBar(document, progressBar);
			message.progressBar = progress;  
		  }
		  Clean.doGet(message); 
		} 
		
		function post(url, consumer, form){
		  var message = Clean.createSimpleMessage(url, consumer, showError);	
		  Clean.postFormByName(message, form, false);
		} 
				
		function transform(url, xslt, consumer, progressBar){
		  var message = Clean.createMessage(url, xslt, consumer, true, null);
		  if(progressBar){
			var progress = new EmbeddedProgressBar(document, progressBar);
			message.progressBar = progress;  
		  }  
		  Clean.doGet(message);  
		} 
		
	
		
