var activeMenue = null;
var timer_ = null;
var count = 4;
var browserOK = true;
var pics = new Array();
var objCount = 0;
var last_img;

function cchange(who, whom) {
if (who) {
	triggerMenu(whom,who);
	clearTimer();
	return true;
	}
}
function bchange(who) {
if (who) {pHide(who);}
}

function init() {
		var rnd = parseInt(Math.random()*3)+1;
		document.unternehmen.src='/pictures/thumb/Unternehmen'+rnd+'.jpg';
		rnd = parseInt(Math.random()*3)+1;
		document.bereiche.src='/pictures/thumb/Bereiche'+rnd+'.jpg';
		rnd = parseInt(Math.random()*3)+1;
		document.fertigung.src='/pictures/thumb/Fertigung'+rnd+'.jpg';
		rnd = parseInt(Math.random()*3)+1;
		document.referenzen.src='/pictures/thumb/Referenzen'+rnd+'.jpg';
		rnd = parseInt(Math.random()*3)+1;
		document.kontakt.src='/pictures/thumb/Kontakt'+rnd+'.jpg';
		}
		
function change(who) {
		document.pic1.src='/pictures/small/'+who+count+'.jpg';
		count ++; 
		document.pic2.src='/pictures/small/'+who+count+'.jpg';
		count ++; 
		document.pic3.src='/pictures/small/'+who+count+'.jpg';
		count ++;
		if (count == 13) {count = 1;}
		setTimeout("change('"+who+"')", 5000);
		}
				
function parseObject(id) {
	if ( document.getElementById) {return document.getElementById(id);}
	else if ( document.all ){return document.all[id];}
	else if ( document.layers ){return document.layers[id];}
	return null;
	}

function showIT(objParent, obj) {
	if ( obj.style ) {
		//alert(obj.style.left+' '+ obj.style.top+' '+parseInt(docjslib_getRealLeft(objParent)));
		obj.style.visibility = 'visible';
		}
	}

function hideIT(obj) {
	if ( obj.style ) {
		obj.style.visibility = 'hidden';
		set_box('bul1','10px');
		set_box('bul2','10px');
		set_box('bul3','10px');
		set_box('bul4','10px');
		set_box('bul5','10px');
		}
	}

function pHide(str) {
	o  = parseObject(str);
	timer_=setTimeout("hideIT(o)",1000);
	}

function clearTimer(){clearTimeout(timer_);}

function triggerMenu(mparent,menu){
	objPMenu  = parseObject(menu);
	//alert(objPMenu.id);
	objParent = parseObject(mparent);
	//alert(activeMenue);
	if ( activeMenue != objPMenu && activeMenue != null) {hideIT(activeMenue);}
	//window.clearTimeout(currentTimer);
	activeMenue = objPMenu;
	if ( ! isVisible(objPMenu) ) {showIT(objParent,objPMenu);}
	return true;
	}

function isVisible(obj)	{
	if ( obj.style ) { obj = obj.style; }
	return (obj.visibility == 'visible');
	}


function preload(name, first, second) {
	pics[objCount] = new Array(5);
	pics[objCount][0] = new Image();
	pics[objCount][0].src = first;
	pics[objCount][1] = new Image();
	pics[objCount][1].src = second;
	pics[objCount][2] = name;
	objCount++;
	}

function on(name, id, height) {
 	if (id) {set_box(id,height);}
	for (i = 0; i < objCount; i++) {
		if (document.images[pics[i][2]] != null){
		if (name == pics[i][2]) {
			if (pics[i][1].complete)
			document.images[pics[i][2]].src = pics[i][1].src;
			}
		}
	}
        }

function off() {
	for (i = 0; i < objCount; i++) {
		if (document.images[pics[i][2]] != null)
			if (pics[i][0].complete)
			if (document.images[pics[i][2]].src == pics[i][1].src) {
			document.images[pics[i][2]].src = pics[i][0].src;
			}
		}	
}	

function popup(who, width, height) {
	width=parseInt(width)+25;
        height=parseInt(height)+25;
        window.open("/pictures/normal/"+who+".jpg", who, "width="+width+",height="+height+",resizable=yes,status=yes,scrollbars=yes,screenx=100,screeny=50");
	}
        
function set_box (id, height){
	var obj = parseObject(id);
        var top = 10;
        top = parseInt(top)-parseInt(height)
        obj.style.height = height;	
        obj.style.top = top+"px";
        }
