/* encoding utf8 */
/*
* author: Michael Scherer
* copyright: 2006 Michael Scherer, beWERK
*/

var months = new Array();

 months[1]='Januar';
 months[2]='Februar';
 months[3]= "März";
 months[4]= "April";
 months[5]= "Mai";
 months[6]= "Juni";
 months[7]= "Juli";
 months[8]= "August";
 months[9]= "September";
 months[10]= "Oktober";
 months[11]= "November";
 months[12]= "Dezember";
 
 

function mainNavHighlightItem (action, navid, imageName){
	
	if(action == 'over'){
		if(navid != aktPage) {
			
			document.images[imageName].src = 'images/' + navid + 'Over.gif';
			document.images[imageName + '_bild'].src = 'images/' + navid + 'bOver.jpg';
			
		}
	}
 	
   	if(action == 'out') {
   		if(navid != aktPage) {
   			
   			document.images[imageName].src = 'images/' +navid + '.gif';
			document.images[imageName+ '_bild'].src = 'images/' + navid + 'b.jpg';
   		}
   	}
}


function navHighlightItem (action, navid, imageName){
	
	if(action == 'over'){
		if(navid != aktPage) {
			
			document.images[imageName].src = 'images/' + navid + 'Over.gif';
			document.images[imageName + '_bild'].src = 'images/' + navid + 'bOver.jpg';
			
		}
	}
 	
   	if(action == 'out') {
   		if(navid != aktPage) {
   			
   			document.images[imageName].src = 'images/' +navid + '.gif';
			document.images[imageName+ '_bild'].src = 'images/' + navid + 'bGreen.jpg';
   		}
   	}
}



function showRef(refNr, onCol){

// wenn eine referenz bereits offen, dann schliessen


for (i=1; i <= numberOfRef;  i++){
 
 obj = document.getElementsByTagName("div");
    
    id = "ref" + i;
     
    if ( i == refNr ){
      obj[id].style.display = 'block';
      obj[onCol].style.display = 'none';
    }
     else {
     
    	obj[id].style.display = 'none';
   }
    
}


}


function moveRef(direction, colNum, colHide){

var hideRef = false;

obj = document.getElementsByTagName("div");

for (i=1; i <= numberOfRef;  i++){
 
  	id = "ref" + i;
    
   	if ( obj[id].style.display == 'block'){
      		obj[id].style.display = 'none';
      		obj[colHide].style.display = 'block';
      		hideRef = true;
   	}	
    
}
    
if (!hideRef || (direction == 'previous')){
	while(colNum > 0){
			moveCol(direction);
			colNum--;
	}	
}

}


function moveMonth(direction){
	
	moveSomeCol(direction, 3);
	
	if (direction == 'next'){
		isMonth++;
		if(isMonth==13){
		    isMonth = 1;
		    isYear++;
		    SetText("year", isYear);
		}
		SetText("month", months[isMonth]);
	}
	if (direction == 'previous'){
		isMonth--;
		if(isMonth==0){
		    isMonth = 12;
		    isYear--;
		    SetText("year", isYear);
		}
		SetText("month", months[isMonth]);
	}
	return true;
}


function moveSomeCol(direction, colNum){


	while(colNum > 0){
			moveCol(direction);
			colNum--;
			
	}	

}

function moveCol(direction){
	
	if (direction == 'next'){
	  /*zurück-Pfeil anzeigen*/
	  Show('prev');
	  if(maxCol > lastCol) {
	   
		  col = 'col' + firstCol;
		  DisplayHide(col);
		   	 
		 firstCol++;
	     lastCol++;
	     
	      col = 'col' + lastCol;
	      DisplayHide(col);
	      
	      if(maxCol == lastCol){
		      	Hide('next');
	      }
	    }
	}
	
	if (direction == 'previous'){
	
	  if(firstCol > 1){
	  Show('next');
	  col = 'col' + lastCol;
	  DisplayHide(col);
      lastCol--;
	  
	  firstCol--;
	  col = 'col' + firstCol;
	  DisplayHide(col);
	  
	  
	  
	  if(firstCol == 1){
	   Hide('prev');
	  }
	  
      }
       
     
	}


}


function SetText(id, val){
	 obj = document.getElementsByTagName("span");
	 var AnzahlZeichen = obj[id].firstChild.nodeValue.length;
	 obj[id].firstChild.deleteData(0, AnzahlZeichen);
	 obj[id].firstChild.insertData(0, val);
}


function DisplayHide(id) {
         obj = document.getElementsByTagName("div");
         
    if (obj[id].style.display == "block"){
    obj[id].style.display = "none";
    }
    else {
    	
    obj[id].style.display = encode_utf8('block');
    }
    
    
    
}		



function Hide(id) {
    obj = document.getElementsByTagName("div");
    if (obj[id].style.visibility == 'visible'){
    obj[id].style.visibility = 'hidden';
    }
   
    
    
}		

function Show(id) {
    obj = document.getElementsByTagName("div");
    if (obj[id].style.visibility == 'hidden'){
    obj[id].style.visibility = 'visible';
    }
   
    
    
}		


function encode_utf8(rohtext) {
             // dient der Normalisierung des Zeilenumbruchs
             rohtext = rohtext.replace(/\r\n/g,"\n");
             var utftext = "";
             for(var n=0; n<rohtext.length; n++)
                 {
                 // ermitteln des Unicodes des  aktuellen Zeichens
                 var c=rohtext.charCodeAt(n);
                 // alle Zeichen von 0-127 => 1byte
                if (c<128)
                     utftext += String.fromCharCode(c);
                 // alle Zeichen von 127 bis 2047 => 2byte
                else if((c>127) && (c<2048)) {
                     utftext += String.fromCharCode((c>>6)|192);
                     utftext += String.fromCharCode((c&63)|128);}
                 // alle Zeichen von 2048 bis 66536 => 3byte
                 else {
                     utftext += String.fromCharCode((c>>12)|224);
                     utftext += String.fromCharCode(((c>>6)&63)|128);
                     utftext += String.fromCharCode((c&63)|128);}
                 }
             return utftext;
         }

         
 function decode_utf8(utftext) {
            var plaintext = ""; var i=0; var c=c1=c2=0;
             // while-Schleife, weil einige Zeichen uebersprungen werden
             while(i<utftext.length)
                 {
                 c = utftext.charCodeAt(i);
                 if (c<128) {
                     plaintext += String.fromCharCode(c);
                     i++;}
                 else if((c>191) && (c<224)) {
                     c2 = utftext.charCodeAt(i+1);
                     plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
                    i+=2;}
                 else {
                     c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
                     plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
                     i+=3;}
                }
            return plaintext;
         }
