// JavaScript Document

function button(path, id, upBild, overBild, downBild, inactBild, doOver, doDown, statusId){
	this.path = path;
	this.obj = '';
	this.up = new Image();
	this.over = new Image();
	this.down = new Image();
	this.inact = new Image();
	this.up.src = upBild;
	this.over.src = overBild;
	if(downBild != '')
		this.down.src = downBild;
	if(inactBild != '')
		this.inact.src = inactBild;
	this.showUp = showUp
	this.showOver = showOver
	this.showDown = showDown
	this.showInact = showInact
	this.doOver = doOver
	this.doDown = doDown
	this.statusId = statusId
}

function showOverStatus(barArray, grpElem){
	document.getElementById('wmcShowStatus'+tBB[barArray][grpElem].statusId).innerHTML = locallang[0][barArray][grpElem][0];
}

function showLastStatus(barArray, grpElem){
	if(tBB[barArray]['lastStatus'] != tBB[barArray][grpElem])
		document.getElementById('wmcShowStatus'+tBB[barArray][grpElem].statusId).innerHTML = locallang[0][barArray][tBB[barArray]['lastStatus']][1];
}

function showDownStatus(barArray, grpElem){
	document.getElementById('wmcShowStatus'+tBB[barArray][grpElem].statusId).innerHTML = locallang[0][barArray][grpElem][1];
	tBB[barArray]['lastStatus'] = grpElem;
}

function showUp(){
	this.obj.src = this.up.src
}

function showOver(){
	if(this.obj.src != this.down.src)
		this.obj.src = this.over.src;
}

function showDown(){
	if(this.obj.src != this.down.src)
		this.obj.src = this.down.src;
}

function showInact(barArray,grpElem){
	tBB[barArray][grpElem].obj = eval(tBB[barArray][grpElem].path+'document.images[grpElem]');
	tBB[barArray][grpElem].obj.src = tBB[barArray][grpElem].inact.src;
}

function activateIt(barArray,grpElem){
	tBB[barArray][grpElem].obj = eval(tBB[barArray][grpElem].path+'document.images[grpElem]');
	tBB[barArray][grpElem].obj.src = tBB[barArray][grpElem].up.src;
}

function naviByFunctions(){
	navileiste('down','none');
}

function navileiste(ereignis, barArray, grpElem){
	tBB[barArray][grpElem].obj = eval(tBB[barArray][grpElem].path+'document.images[grpElem]');

	if(ereignis == 'over'){ 
		//if(tBB[barArray][grpElem].inact){
		
		//}
		//else{
			if(tBB[barArray][grpElem].obj.src == tBB[barArray][grpElem].up.src){
				//if(tBB[barArray]['lastStatus'] != '')
				if(tBB[barArray][grpElem].statusId != '')
					showOverStatus(barArray, grpElem); 
				tBB[barArray][grpElem].showOver();
			}
		//}
	}
	else if(ereignis == 'out'){
		//if(tBB[barArray][grpElem].inact){
		
		//}
		//else{
			if(tBB[barArray][grpElem].obj.src == tBB[barArray][grpElem].over.src){
				tBB[barArray][grpElem].showUp();
				
				if(tBB[barArray][grpElem].statusId != '' && tBB[barArray]['lastStatus'] != '')
				showLastStatus(barArray, grpElem);
			}
		//}
	}
	else if(ereignis == 'down'){
		if(grpElem == tBB[barArray]['lastDown']){
			if(tBB[barArray][grpElem].statusId == false){
				navileiste('down',barArray,barArray+'none');
				//break;
				//tBB[barArray][tBB[barArray]['lastDown']].showUp();
				//tBB[barArray]['lastDown']='';
				//if(grpElem == (barArray+'none'))
				//	eval(tBB[barArray][grpElem].doDown);
			}
		}
		else{
			var downAllowed = true;
			//if(tBB[barArray]['lastStatus'] != '')
			if(grpElem.indexOf('none') < 0 && tBB[barArray][grpElem].statusId != '')
				showDownStatus(barArray,grpElem);	
			
			if(isNaN(tBB[barArray][grpElem].doDown) != '')
				downAllowed = eval(tBB[barArray][grpElem].doDown);
			
			if(downAllowed){
				tBB[barArray][grpElem].showDown();
			
				if(tBB[barArray]['lastDown'] != ''){
					tBB[barArray][tBB[barArray]['lastDown']].obj = eval(tBB[barArray][tBB[barArray]['lastDown']].path+'document.images[tBB[barArray]["lastDown"]]');
					tBB[barArray][tBB[barArray]['lastDown']].showUp();
				}
				
				tBB[barArray]['lastDown']=grpElem;
				if(wmcMapFrame.setZIndex){
					wmcMapFrame.setZIndex(grpElem);
				}
			}
		}
	}
	else if(ereignis == 'justDo'){
		if(isNaN(tBB[barArray][grpElem].doDown) == false)
			openPopUpWindow(tBB[barArray][grpElem].doDown);
		else{
			eval(tBB[barArray][grpElem].doDown);
		}
	}
}

function resetByCheck(theme,checkedStatus){
	var imgTmp;
	for(var i=0; i<checkdependence.length; i++){
		if(checkdependence[i]["own"]){
			if(checkdependence[i]["own"][0] == theme){
				if(checkedStatus)
					navileiste("down",checkdependence[i]["own"][1],checkdependence[i]["own"][1]+checkdependence[i]["own"][2]);
				else{
					if(tBB[checkdependence[i]["own"][1]]['lastDown'] == checkdependence[i]["own"][1]+checkdependence[i]["own"][2])
						navileiste("down",checkdependence[i]["own"][1],checkdependence[i]["own"][1]+'none');
					else{
						for(var j=2; j<checkdependence[i]["other"].length; j++){
							if(tBB[checkdependence[i]["other"][1]]['lastDown'] == checkdependence[i]["other"][1]+checkdependence[i]["other"][j]){
								if(eval(tBB[checkdependence[i]["other"][1]][checkdependence[i]["other"][1]+'none'].path+'document.images['+checkdependence[i]["other"][1]+'none]'))
									navileiste("down",checkdependence[i]["other"][1],checkdependence[i]["other"][1]+'none');
							}
						}
					}
				}
			}
		}
		if(checkdependence[i]["other"]){
			if(checkdependence[i]["other"][0] != theme){
				if(checkedStatus && top.document.form1.elements[i].checked){ 
					if(tBB[checkdependence[i]["other"][1]]['lastDown'] != '' || tBB[checkdependence[i]["other"][1]]['lastDown'] != 'undefined'){
						for(var j=2; j<checkdependence[i]["other"].length; j++){
							if(tBB[checkdependence[i]["other"][1]]['lastDown'] == checkdependence[i]["other"][1]+checkdependence[i]["other"][j]){
								var imgTmp = tBB[checkdependence[i]["other"][1]][checkdependence[i]["other"][1]+'none'].path+'document.images["'+checkdependence[i]["other"][1]+'none"]';
								if(eval(imgTmp)){
									navileiste("down",checkdependence[i]["other"][1],checkdependence[i]["other"][1]+'none');
								}
							}
						}
					}
				}
			}
		}
	}
}


var popUpWindow = null;

function openPopUpWindow(id){
    if(popUpWindow != null) {
        if(!popUpWindow.closed) {
            popUpWindow.close();
  		}
   	}
	var url = 'index.php?id='+id+'&L='+top.language;
    popUpWindow = window.open(url,'popUpWindow','toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=600,height=450')
}
    