var grey2 = "#9B9892";
var grey4 = "#898581";
var white = "#FFFFFF";
var win = false;
var pageID;
var wins = new Array();
wins['vita'] = new Array(250,350,450,600,'yes');
wins['artikel'] = new Array(250,350,450,600,'yes');
wins['serie'] = new Array(150,150,860,520,'no');

function setPage(page){
	pageID = page;
	eval('act_'+page)();
	if(pageID == 2){
		changeImgSource(document.getElementById('C'), 'o');
	}
}
function closeChilds(){
	if(win !== false){
		if(!win.closed){
			win.close();
		}
		win = false;
	}
}

function activate(bild, idx){
	if(pageID != idx){
		changeImgSource(bild, 'a');
		eval('act_'+idx)();
		/*for(var i = 0; i < pages.length; i++){
			if(idx != pages[i]){
				eval('dea_'+idx)();
			}
		}*/
	}
}

function deactivate(bild, idx){
	if(pageID != idx){
		if(bild.id == "C" && pageID == 2){
			changeImgSource(bild, 'o');
		}else{
			changeImgSource(bild, 'i');
		}
		eval('dea_'+idx)();
	}
}

function act_1(){}
function act_5(){}

function act_2(){
	document.body.style.backgroundColor=grey2;
	if(document.getElementById("BT") && pageID == 3){
		changeImgSource(document.getElementById("BT"),'i');
	}
	if(document.getElementById("C") && pageID != 4){
		changeImgSource(document.getElementById("C"),'o');
	}
	if(document.getElementById("I") && pageID == 5){
		changeImgSource(document.getElementById("I"),'o');
	}
	document.getElementById("A").style.visibility="visible";
}

function act_3(){
	document.getElementById("gestell").style.visibility="visible";
	if(pageID == 2){
		changeImgSource(document.getElementById("BT"),'i');
	}else if(pageID == 4){
		document.getElementById("kontakt").style.zIndex="2";
		document.getElementById("kontakt").style.backgroundColor=grey4;
	}
}

function act_4(){
	document.getElementById("personBackground").style.backgroundColor=grey4;
	document.getElementById("vita").style.visibility="visible";
}
function dea_1(){}
function dea_5(){}

function dea_2(){
	document.body.style.backgroundColor=white;
	if(document.getElementById("BT") && pageID == 3){
		changeImgSource(document.getElementById("BT"),'c');
	}
	if(document.getElementById("C") && pageID != 4){
		changeImgSource(document.getElementById("C"),'i');
	}
	if(document.getElementById("I") && pageID == 5){
		changeImgSource(document.getElementById("I"),'c');
	}
	document.getElementById("A").style.visibility="hidden";
}

function dea_3(){
	document.getElementById("gestell").style.visibility="hidden";
	if(pageID == 4){
		document.getElementById("kontakt").style.zIndex="1";
		document.getElementById("kontakt").style.backgroundColor='';
	}
}

function dea_4(){
	document.getElementById("personBackground").style.backgroundColor='';
	document.getElementById("vita").style.visibility="hidden";
}

function changeImgSource(img, suffix){
	if(img.src){
		img.src = getPrefix(img.src) + '_' + suffix + '.' + getExtension(img.src);
	}
}

function getPrefix(obj){
	return obj.substring(0,obj.lastIndexOf('_'));
}

function getExtension(obj){
	return obj.substring(obj.lastIndexOf('.') + 1);
}
function clearEle(ele,std){
	if(ele.value == std){
		ele.value = "";
	}
}

function openW(n, i){
	closeChilds();
	var hf = n + (i ? "_" + i : '') + ".html";
	win = window.open(hf,"", "left="+wins[n][0]+",top="+wins[n][1]+",width="+wins[n][2]+",height="+wins[n][3]+"dependent=yes,hotkeys=no,status=no,menubar=no,toolbar=no,resizable=no,scrollbars="+wins[n][4]);
	win.focus();
}

function send(frm){
	window.open("pix/px.gif", "Formular", "width=180,height=130,left=200,top=100,status=no,toolbar=no,menubar=no,hotkeys=no,resizeable=no,location=no,dependent=yes,scrollbars=no");
	frm.target = 'Formular';
	frm.action = '_a/action.php';
	frm.submit();
}
