﻿/*Navigation Funktion*/
function navi_outall(id)
{
	if (document.getElementById('navi_subnode_'+id).style.display == 'none') {
		for(var i = 0; i < document.getElementsByTagName("div").length; i++)
		{
			ids = document.getElementsByTagName("div")[i].id;
			result = ids.search(/navi_subnode_.+/);
		    if(result != -1 && id != ids)
		    {				
				document.getElementById(ids).style.display = 'none';
		    }		    
		}
		
		for(var i = 0; i < document.getElementsByTagName("td").length; i++)
		{
		    ids = document.getElementsByTagName("td")[i].id;			
			result = ids.search(/navi_node_.+/);		   
		    if(result != -1 && id != ids)
		    {
				document.getElementById(ids).className='navi_treegrau';			
		    }
        }
	}
}

function navi_over(id)
{
    navi_outall(id);
    document.getElementById('navi_node_'+id).className='navi_treered';
    document.getElementById('navi_subnode_'+id).style.display='block';
}

function navi_rollover(name_img,url_img)
{
    document.getElementById(name_img).src=url_img;  
}
/*End Navigation Funktion*/

/*Popups*/
function popup_produkt(url)
{    
    var w = 675;
	var h = 550;
		
	var left=window.screen.width/2-(w/2);
 	var top=window.screen.height/2-(h/2);
 	if (win){
 		win.focus();
 	}
 	else {
		var win = window.open(url,'produkt','toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=1, copyhistory=0, menuBar=0, width='+w+', height='+h+', left='+left+', top='+top+'');
		win.focus();
 	}
}

function popup_news(url)
{    
    var w = 645;
	var h = 575;
		
	var left=window.screen.width/2-(w/2);
 	var top=window.screen.height/2-(h/2);
 	if (win){
 		win.focus();
 	}
 	else {
		var win = window.open(url,'news','toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=1, copyhistory=0, menuBar=0, width='+w+', height='+h+', left='+left+', top='+top+'');
		win.focus();
 	}
}

function image_zoom(w,h,url)
{
    var left=window.screen.width/2-(w/2);
 	var top=window.screen.height/2-(h/2);
    var Fensteroptionen = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0";
    var popupWindow = window.open(url, 'Imagezoom', Fensteroptionen + ',width=' + w + ',height=' + h +', left=' + left + ', top=' + top);
    var focus = popupWindow.focus();
} 
/*End Popups*/

/*Header Animation*/
/*****
Image Cross Fade Redux
steve@slayeroffice.com

Please leave this notice intact. 

Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html
*****/
var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init() {
	if(!d.getElementById || !d.createElement || !d.getElementById("header_bild"))return;	
	
	imgarray = new Array();
	imgs = d.getElementById("header_bild").getElementsByTagName("img");
		
	for(i=0;i<imgs.length;i++) {	    
	    imgarray.push(imgs[i]);	    	   
	}
	
	imgarray.sort( randOrd );
	
	for(i=1;i<imgs.length;i++) {	    
	    imgarray.push(imgs[i]);
	    imgarray[i].xOpacity = .5;
	    setInitOpacity(imgarray[i]);	   
	}	
	
	imgarray[0].xOpacity = .99;
		
	setTimeout(so_xfade,2000);
}

function so_xfade() {
	cOpacity = imgarray[current].xOpacity;
	nIndex = imgarray[current+1]?current+1:0;
	nOpacity = imgarray[nIndex].xOpacity;
	
	cOpacity-=.05; 
	nOpacity+=.05;	
	
	imgarray[current].xOpacity = cOpacity;
	imgarray[nIndex].xOpacity = nOpacity;
	
	setOpacity(imgarray[current]); 
	setOpacity(imgarray[nIndex]);
	
	if(cOpacity<=.5) {		
		current = nIndex;		
		setTimeout(so_xfade,2000);
	} else {
		setTimeout(so_xfade,100);
	}
	
	function setOpacity(obj) {
	if(obj.xOpacity>.99) {
		obj.xOpacity = .99;
		return;
	}
	obj.style.opacity = obj.xOpacity;
	obj.style.MozOpacity = obj.xOpacity;
	obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
    }	
}

function setInitOpacity(obj) {
	if(obj.xOpacity>.99) {
		obj.xOpacity = .99;
		return;
	}
	obj.style.opacity = obj.xOpacity;
	obj.style.MozOpacity = obj.xOpacity;
	obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
    }

function randOrd(){
    return (Math.round(Math.random())-0.5);
} 
/*End Header Animation*/

/*Body Init*/
function init(nav_id){
    so_init();
}
/*End Body Init*/
