var storyInfoIsVisible = 0;
function sayHello(){
	alert("hello");	
}
function getInfo(wer,navLayer){
	if(wer == "contact" || wer == "bio" || wer == "news" || wer == "publi" || wer=="Gallery"){
		location.href = "info.php?pageID=" + thisPageNum + "&inf=" + wer+"&navLayer="+navLayer;
		//alert('fscript '+ wer+' pageNum='+thisPageNum+' navLayer='+navLayer);
	}
	else{
		alert("coming soon...");
	}
}
function navclicked(pageID, navLayer) {

			if(storyInfoIsVisible == 1){
					if(isNaN(pageID) != true && pageID <=9){
						location.replace("index2.php?pageID=" + pageID + "&navLayer=" + navLayer);
						}
						else{
						location.replace("index2.php?id=" + pageID);
					}
									
					act_page = pageID;	
			}
			else{
	
					fade_out_done = 0;
					  if (!this.doOut) {
							this.doOut = window.setInterval ('navclicked(\"'+pageID+'\", \"'+navLayer+'\")', 20);
					  }
					  else {
						var elem = document.getElementById("img_fade");
					   
						var img_opacity;
					
						if (!elem.filters) {//Moz
						  img_opacity = !elem.style.opacity ? 1 : parseFloat(elem.style.opacity);
						  
						}
						//IE
						else {
						  img_opacity = !elem.filters.alpha.opacity ? 1 : parseFloat (elem.filters.alpha.opacity);
						  
						 }
					
					  if (!elem.filters){
							if (img_opacity > 0.025) {//alert("moz: " + img_opacity);//Moz
								img_opacity -= 0.15;
								elem.style.opacity = img_opacity;
							}else {
								window.clearInterval (this.doOut);
								fade_out_done = 1;
								this.doOut = null;
										if(isNaN(pageID) != true && pageID <=9){
										location.replace("index2.php?pageID=" + pageID + "&navLayer=" + navLayer);
										}
										else{
											location.replace("index2.php?id=" + pageID);
										}
									
										act_page = pageID;			
								
							}
					  }
						else{
							 if (img_opacity > 1) {//alert("ie: " + img_opacity);// IE
								img_opacity -= 15;
								elem.filters.alpha.opacity = img_opacity;
							}else {//alert("else: " + img_opacity);
								window.clearInterval (this.doOut);
								fade_out_done = 1;
								this.doOut = null;
										if(isNaN(pageID) != true && pageID <=9){
										location.replace("index2.php?pageID=" + pageID + "&navLayer=" + navLayer);
										}
										else{
											location.replace("index2.php?id=" + pageID);
										}
									
										act_page = pageID;	  		
								
							}
						}
							  
						
						
					  }
			}//else storyInfoIsVisible == 1
}
/*
function navclicked(pageID, navLayer){
	if(isNaN(pageID) != true && pageID <=9){
	location.replace("index2.php?pageID=" + pageID + "&navLay=" + navLayer);
	}
	else{
		location.replace("index2.php?id=" + pageID);
	}

	act_page = pageID;	
}
*/

	
/*function menu_mouse(wer){

			for(var s=1; s<=pagesNum; s++){
				if(s != thisPageNum ){
				document.getElementById("story" + s).style.backgroundColor = "#DCD5D1";
				}
			}
			if(wer!=0){
				document.getElementById("story" + wer).style.backgroundColor = "#A9958B";
			}
}
*/

function init(){

	picNum = 0;
	if(nopageid != "0"){
				clearBioCvContact(nopageid);
				document.getElementById("imgArea").innerHTML = '<iframe src="' + nopageid +'.php" name="Bildframe" width="560" height="451" align="center" scrolling="no" marginheight="0" marginwidth="0" frameborder="0">';
		}
		
	if(thisPageNum == 0 && nopageid == "0"){
		
		var bildNummer = (Math.round(Math.random() * bilderNum - 1));
		if(bildNummer < 1){bildNummer = 1;}
		
		home_fade_out(bilder[bildNummer]);
	}
	
	if(thisPageNum > 0){
	
	viewPic("1", bilder[1], currentPagePath, "1");
	
	
	for(pfeile=1; pfeile<=3; pfeile++){
		
			
					document.getElementById("switch" + pfeile).style.visibility = "visible";
				
				
	for(xtd=1; xtd<=5; xtd++){
					document.getElementById("thumb" + xtd).style.backgroundColor = "#ffffff";
					document.getElementById("thumb" + xtd).style.visibility = "visible";
			}
				
	}
		if(currentPage){
			  for(i = 1; i<= pagesNum; i++){
			  document.getElementById("story" + i).style.backgroundColor = "#DCD5D1";
			  }
			  document.getElementById("story" + navLayer).style.backgroundColor = "#A9958B";

			 
			 getThumbs(currentPage,currentPagePath);
		}
		
	}
  		 
}

function viewInfotext(itxt){
	if(itxt == "blank"){
	document.getElementById("infotext").innerHTML = "&nbsp";
	}
	else{
	document.getElementById("infotext").innerHTML = itxt;
	}
}

var curStartThumb = 0;
var actualArrNum = 0;
var thumbNum = 0;
var storyNum = 0;
function getThumbs(layerNum,ordner){

	storyNum = layerNum;
	thumbNum = bilder.length-1;
	curStartThumb = 1;
	actualArrNum = 1;
	document.getElementById("viewPicsNum").innerHTML =  "<span class='thumbcounter'>&nbsp; 01</span> / " + thumbNum;
	//document.getElementById("thumb1").style.backgroundColor = "#BAAAA2";
	document.getElementById("powerdby").innerHTML = "";
	for(d=1; d<=5; d++){
		document.getElementById("thumb" + d).style.visibility = "hidden";
	}
	
if(thumbNum	> 5){
	thumbAnzahl = 5;
	document.getElementById("switch4").style.visibility = "visible";
}
else{
	thumbAnzahl = thumbNum;
	document.getElementById("switch4").style.visibility = "hidden";
}


	
	for(td=1; td<=thumbAnzahl; td++){
		
	document.getElementById("thumb" + td).style.visibility = "visible";
	document.getElementById("thumb" + td).innerHTML = "<a href='javascript:viewPic(\"" + td + "\",\"" + bilder[td] + "\",\"" + ordner + "\",\"" + td + "\")' onFocus='this.blur()'><img src='thumbs/" + ordner + "/" + bilder[td] + "' border='0'/></a>";
	}
	
}
var tcurPic;
var tpicName;
var tordner;
var tpicNum;
var storyTextScroll = 0;
function showStoryInfo(){
	if(storyInfoIsVisible == 0){
	document.getElementById("imgArea").innerHTML = '<iframe src="storytext.php?pageID=' + thisPageNum + '" id="mainframe" width="560" height="451" align="center" scrolling="no" marginheight="0" marginwidth="0" frameborder="0">';
	storyInfoIsVisible = 1;
	// 	document.getElementById("storyInfo").innerHTML = "<a href='#' onclick='showStoryInfo()' onMouseOut='MM_swapImgRestore()' onMouseOver='MM_swapImage(\"Image11\",\"\",\"img/information_close_on.gif\",1)' onFocus='this.blur()'><img src='img/information_close_off.gif' alt='Close Information On Story' name='Image11' width='24' height='24' border='0'></a>";
	document.getElementById("storyInfo").innerHTML = "<a href='#' onclick='showStoryInfo()' onMouseOut='MM_swapImgRestore()' onMouseOver='MM_swapImage(\"Image11\",\"\",\"img/information_close_on.gif\",1)' onFocus='this.blur()'><img src='img/information_close_off.gif' alt='Close Information On Story' name='Image11' width='32' height='24' border='0'></a>";
	document.getElementById("switch1").style.visibility = 'hidden';
	document.getElementById("switch2").style.visibility = 'hidden';
	document.getElementById("viewPicsNum").style.visibility ='hidden';
	}
	else{

		document.getElementById("imgArea").innerHTML = "<img id='img_fade' style='FILTER: alpha(opacity=100); opacity:1;' src='img/trans3px.gif' border='0' name='imgregion' onMouseOut='viewInfotext(\"blank\")' onMouseOver='viewInfotext(\"" + infotext[tpicNum] + "\")' onFocus='this.blur()'/>";
		storyInfoIsVisible = 0;
		//  		document.getElementById("storyInfo").innerHTML = '<a href="#" onclick="showStoryInfo()" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Image11\',\'\',\'img/information_open_on.gif\',1)" onFocus="this.blur()"><img src="img/information_open_off.gif" alt=" Open Information On Story" name="Image11" width="24" height="24" border="0"></a>';
		document.getElementById("storyInfo").innerHTML = '<a href="#" onclick="showStoryInfo()" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Image11\',\'\',\'img/information_open_on.gif\',1)" onFocus="this.blur()"><img src="img/information_open_off.gif" alt=" Open Information On Story" name="Image11" width="32" height="24" border="0"></a>';
		img_fade_out(tcurPic, tpicName, tordner, tpicNum);
		document.getElementById("switch1").style.visibility = 'visible';
		document.getElementById("switch2").style.visibility = 'visible';
		document.getElementById("viewPicsNum").style.visibility = 'visible';
	}
}



var actualCell=1;

function viewPic(curPic, picName, ordner, picNum){
if(storyInfoIsVisible == 1){
	showStoryInfo();
	
}
	tcurPic = curPic;
	tpicName = picName;
	tordner = ordner;
	tpicNum = picNum;
	
	actualArrNum = parseInt(picNum);
	actualCell = parseInt(curPic);
	for(xtd=1; xtd<=5; xtd++){
		//document.getElementById("thumb" + xtd).style.backgroundColor = "#ffffff";
		//document.getElementById("thumbbg" + xtd).style.visibility = "hidden";
		document.getElementById("thumb" + xtd).style.backgroundImage="url('img/thumbIndicatorBar_off.gif')";
	}

	document.getElementById("thumb" + curPic).style.backgroundImage="url('img/thumbIndicatorBar_on.gif')";
		//document.getElementById("thumb" + curPic).style.backgroundColor = "#BAAAA2";
		//document.getElementById("thumbbg" + curPic).style.visibility = "visible";
		
		img_fade_out(curPic, picName, ordner, picNum);
		
		anzeige = picNum;
		picNr = (anzeige < 10)? "0" + anzeige : anzeige;
		document.getElementById("viewPicsNum").innerHTML = "<span class='thumbcounter'>&nbsp; " + picNr + "</span> / " + bilderNum;
		
		if(backToStart = 1){backToStart = 0;}

}
function toggleThumbs(direct){
	
if(storyInfoIsVisible == 1){
	showStoryInfo();
	
}
	
	if(direct == "prev" && curStartThumb > 1){
	curStartThumb = curStartThumb - 5; 
	}
	if(direct == "next"  && curStartThumb < thumbNum ){
	curStartThumb = curStartThumb + 5; 
	}
	
var test=curStartThumb;

	if(test <= thumbNum){//alert(test + " - " + thumbNum);
		
	if(curStartThumb > 1){
		document.getElementById("switch3").style.visibility = "visible";	
	}
	else{
		document.getElementById("switch3").style.visibility = "hidden";	
	}
	
	
		for(ntd=curStartThumb, td=1; td<= 5; ntd++, td++){
		 	
			
			if(bilder[ntd] && ntd <= thumbNum){
			document.getElementById("switch4").style.visibility = "visible";
			document.getElementById("thumb" + td).style.visibility = "visible";
			document.getElementById("thumb" + td).innerHTML = "<a href='javascript:viewPic(\"" + td + "\",\"" + bilder[ntd] + "\",\"" + currentPagePath + "\",\"" + ntd + "\")' onMouseOut='viewInfotext(\"blank\")' onMouseOver='viewInfotext(\"blank\")' onFocus='this.blur()'><img src='thumbs/" + currentPagePath + "/" + bilder[ntd] + "' border='0' /></a>";
			
			
			}
			
			else{
			document.getElementById("thumb" + td).innerHTML = "<img src='img/trans9px.gif' border='0' />";
			document.getElementById("thumb" + td).style.visibility = "hidden";
			document.getElementById("switch4").style.visibility = "hidden";
			
			}
		  
		}
	
		viewPic("1", bilder[curStartThumb], currentPagePath, curStartThumb);
		
			//picNr = (picNum < 10)? "0" + picNum : picNum;
			//document.getElementById("viewPicsNum").innerHTML = picNr + " / " + bilderNum;
	}// End if(test <= thumbNum)
	else{
			curStartThumb = curStartThumb - 5; 
	}
	
}

function switchThumbs(direct){
	
	if(storyInfoIsVisible == 0){
	
	if(direct == "prev"){
		prevNum = parseInt(actualArrNum) - 1;
		prevCell = parseInt(actualCell) - 1;
		
			if(actualArrNum == 1 && navLayer != 1){//alert(actualArrNum);
				prevPage = thisPageNum - 1;
				prevNavLayer = navLayer - 1;
				prevStory = stories[parseInt(currentStory) - 1];
				
				navclicked(prevStory, prevNavLayer);
			}

			if(actualArrNum != 0 && prevNum % 5 == 0 ){//alert("toggle");
					toggleThumbs('prev');
			}
			else if(actualArrNum != 0 && prevNum % 5 != 0){//alert("viewPic");
				
					viewPic(prevCell, bilder[prevNum], currentPagePath, prevNum);
					
			}
				
	}
	
	if(direct == "next"){
		nextNum = parseInt(actualArrNum) + 1;
		nextCell = parseInt(actualCell) + 1;
		if(actualArrNum > thumbNum-1){
		
			nextPage = thisPageNum + 1;
			nextNavLayer = navLayer + 1;
			nextStory = stories[parseInt(currentStory) + 1];
			
			if(nextStory<=pagesNum){
				navclicked(nextStory, nextNavLayer);
			}
			else{
				navclicked(stories[1],"1");
			}
		
		}
		//if(actualArrNum == thumbNum){//alert("getThumbs");	
		//viewPic(nextCell, "text_thumb", currentPagePath, nextNum);
		//}
		else if(actualArrNum != 0 && actualArrNum % 5 == 0 && actualArrNum != thumbNum){//alert("toggle");
			toggleThumbs('next');
			
		}
		else if(actualArrNum == 0 || actualArrNum % 5 != 0 && actualArrNum != thumbNum){//alert(nextNum);
		
			viewPic(nextCell, bilder[nextNum], currentPagePath, nextNum);
			
			
		}
	}
	}//if(storyInfoIsVisible == 0){
}
