// JavaScript Library for www.migrationsfamilien.de
// copyright stephanjanz.de, 2007

var resultCounter=0;

// check index and frame set

function loadIndex() {
	if (top.location.href.lastIndexOf("index.html")==-1) {
		top.document.location.href='index.htm'
	}
}

function loadFrameSet() {
	if (top.location.href.lastIndexOf("/content")!=-1) {
		top.document.location.href='../index.htm'
	}
}

// navigation menu

function hideDiv(id){
	if(document.layers)
		top.frames[0].document.layers[id].style.display='none';
	else
		top.frames[0].document.getElementById(id).style.display='none';
}
function restoreAllDiv(){
	for (var i=1; i<10; i++) {
		if(document.layers) {
			top.frames[0].document.layers['menu_'+i].style.display='block';
			top.frames[0].document.layers['submenu_'+i].style.display='none';
		}
		else {
			top.frames[0].document.getElementById('menu_'+i).style.display='block';
			top.frames[0].document.getElementById('submenu_'+i).style.display='none';
		}
	}
}
function setRubrik(id,hint){
	restoreAllDiv();
	hideDiv('menu_'+id)
	if(document.layers) {
		top.frames[0].document.layers['submenu_'+id].style.display='block';
	}
	else {
		top.frames[0].document.getElementById('submenu_'+id).style.display='block';
	}
	setPic();
}

// iframe resize

function getWinHeight() {
	var winHeight;
	if ((navigator.appName.indexOf("Mozilla")>=0)||(navigator.appName.indexOf("Netscape")>=0))
		winHeight=window.innerHeight;
	else
		winHeight=document.body.offsetHeight;
	return(winHeight);
}

function setObjectHeight(id,height){
	if(document.layers)
		document.layers[id].height=height;
	else
		document.getElementById(id).height=height;
}

function resizeObject(id,offset){
	var objectHeight;
	objectHeight=getWinHeight()-offset;
	setObjectHeight(id,objectHeight);
}

function resizeHinweisGlossar(offset, percent) {
	var winHeight;
	var topHeight;
	var bottomHeight;
	winHeight=getWinHeight()-offset;
	topHeight=Math.floor(winHeight*percent/100);
	bottomHeight=Math.floor(winHeight-topHeight);
	setObjectHeight('hinweis',topHeight);
	setObjectHeight('glossar',bottomHeight);
}

// hinweise

function hinweis(file) {
	top.frames[2].frames[0].location.href='../hinweis/'+file;
}

function glossar(anker) {
	top.frames[2].document.getElementById('glossarHead').firstChild.nodeValue='Glossar';
	top.frames[2].frames[1].location.href='../hinweis/glossar_box.htm'+anker;
}

function download(file) {
	top.frames[2].document.getElementById('glossarHead').firstChild.nodeValue='Download';
	top.frames[2].frames[1].location.href='../hinweis/'+file;
}

// fotos

function preLoadImages() {
	var picArray = new Array ('images/pic_aglaia.jpg', 'images/pic_bali.jpg', 'images/pic_guelsen.jpg', 'images/pic_holger.jpg', 'images/pic_joerg.jpg', 'images/pic_kathrin.jpg', 'images/pic_kati.jpg', 'images/pic_luetje.jpg', 'images/pic_martin.jpg', 'images/pic_merve.jpg', 'images/pic_nina.jpg', 'images/pic_rochus.jpg', 'images/pic_saarl.jpg', 'images/pic_sushi.jpg', 'images/pic_thomas.jpg');
	for (i=0; i < picArray.length; i++) {
		var picture = new Image();
		picture.src = picArray[i];
	}
}

function changePic(file) {
	top.frames[0].document.images['foto'].src='images/'+file;
}

function setPic() {
	var datum = new Date();
	var fotoIndex = Math.floor(datum.getMilliseconds()/60);
	var picArray = new Array ('aglaia', 'bali', 'guelsen', 'holger', 'joerg', 'kathrin', 'kati', 'luetje', 'martin', 'merve', 'nina', 'rochus', 'saarl', 'sushi', 'thomas');
	if ((fotoIndex >= 0) && (fotoIndex < 15)) {
		document.images[0].src='images/pic_'+picArray[fotoIndex]+'.jpg'
	}
}

// quiz auswerten

function quizResult() {
	// set to no if selected at all
	for (var i=0; i<3; i++) {
		if (document.quiz.question_1[i].checked == true) {
			top.answer[1] = 'n'}
		if (document.quiz.question_2[i].checked == true) {
			top.answer[2] = 'n'}
		if (document.quiz.question_3[i].checked == true) {
			top.answer[3] = 'n'}
		if (document.quiz.question_4[i].checked == true) {
			top.answer[4] = 'n'}
		if (document.quiz.question_5[i].checked == true) {
			top.answer[5] = 'n'}
		if (document.quiz.question_6[i].checked == true) {
			top.answer[6] = 'n'}
		if (document.quiz.question_7[i].checked == true) {
			top.answer[7] = 'n'}
		if (document.quiz.question_8[i].checked == true) {
			top.answer[8] = 'n'}
		if (document.quiz.question_9[i].checked == true) {
			top.answer[9] = 'n'}
	}
	// set to yes if selected correctly
	if (document.quiz.question_1[2].checked == true) {
		top.answer[1] = 'y'}
	if (document.quiz.question_2[1].checked == true) {
		top.answer[2] = 'y'}
	if (document.quiz.question_3[3].checked == true) {
		top.answer[3] = 'y'}
	if (document.quiz.question_4[2].checked == true) {
		top.answer[4] = 'y'}
	if (document.quiz.question_5[3].checked == true) {
		top.answer[5] = 'y'}
	if (document.quiz.question_6[3].checked == true) {
		top.answer[6] = 'y'}
	if (document.quiz.question_7[1].checked == true) {
		top.answer[7] = 'y'}
	if (document.quiz.question_8[0].checked == true) {
		top.answer[8] = 'y'}
	if (document.quiz.question_9[1].checked == true) {
		top.answer[9] = 'y'}
}

function showResults() {
	resultCounter=0;
	for (var i=1; i<10; i++) {
		if (top.answer[i] == 'y') {
			document.getElementById(i+'.y').style.display='block';
			resultCounter++;
		}
		if (top.answer[i] == 'x') {
			document.getElementById(i+'.x').style.display='block';
			document.getElementById(i+'.e').style.display='block';
		}
		if (top.answer[i] == 'n') {
			document.getElementById(i+'.n').style.display='block';
			document.getElementById(i+'.e').style.display='block';
		}
	}
}

