/*-------------------------------GLOBAL VARIABLES------------------------------------*/

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
var bias;
var bgstyleold;
var tplay = 0;
var playing = 0;
var pausing = 0;
var cnt_setpics = 0;
var piccounter_akt = 0;
var picserie = new Array();
/*-----------------------------------------------------------------------------------------------*/

//Browser detect script origionally created by Peter Paul Koch at http://www.quirksmode.org/
getBrowserInfo();

function getBrowserInfo() {
	if (checkIt('konqueror')) {
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari')) browser 	= "Safari";
	else if (checkIt('omniweb')) browser 	= "OmniWeb";
	else if (checkIt('opera')) browser 		= "Opera";
	else if (checkIt('webtv')) browser 		= "WebTV";
	else if (checkIt('icab')) browser 		= "iCab";
	else if (checkIt('msie')) browser 		= "IE";
	else if (checkIt('firefox')) browser 		= "Firefox";
	else if (!checkIt('compatible')) {
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS) {
		if (checkIt('linux')) OS 		= "Linux";
		else if (checkIt('x11')) OS 	= "Unix";
		else if (checkIt('mac')) OS 	= "Mac"
		else if (checkIt('win')) OS 	= "Win"
		else OS 								= "an unknown operating system";
	}
}

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
/*Funktionen Javascript windowsize



*/
function Fensterweite () {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}

function Fensterhoehe () {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}

function neuAufbau () {
  if (Weite != Fensterweite() || Hoehe != Fensterhoehe()){
  /*  location.href = location.href;*/
  document.write("Weite: " + Weite + " Hoehe: " + Hoehe);
  }
}

function initN () {
/* Überwachung von Netscape initialisieren */
if (!window.Weite && window.innerWidth) {
/*   window.onresize = neuAufbau;*/
  Weite = Fensterweite();
  Hoehe = Fensterhoehe();
}
}
function initE () {
/* Überwachung von Internet Explorer initialisieren */
if (!window.Weite && document.body && document.body.offsetWidth) {
/*   window.onresize = neuAufbau;*/
  Weite = Fensterweite();
  Hoehe = Fensterhoehe();
}
}


/*Funktionen Javascript für hkw-Seite


*/
var pnrold = "";
var ovrlpicold= "";
var offsetold= 0;

var pnrakt=0;



function initOpac(pnr,text,istext)
{
if ((browser=='IE')&&(version < 7)) {
document.getElementById('inside').style.right = bias+'px';
document.getElementById('rahmen').style.width = Weite;
}
else {bias=0;
document.getElementById('projdescr').style.left = '0px';}

offset = 0;
ovrlpic = 'ovrl'+pnr;

document.getElementsByName(ovrlpic)[0].className = "opac";
if (istext=="1"){
document.getElementById('textdescr').className = "nontransp";}
else{
document.getElementsByName(pnr)[0].className = "nontransp";}
document.getElementById("bildunterschrift").firstChild.nodeValue = text;
pnrold = pnr;
ovrlpicold=ovrlpic;
offsetold = offset;
istextold = istext;
pnrakt = pnr;
}

function setpics(offset,pnr, text,bias,istext)
{
picserie[cnt_setpics] = new Object();
picserie[cnt_setpics]['offset']=offset;
picserie[cnt_setpics]['pic']=pnr;
picserie[cnt_setpics]['txt']=text;
picserie[cnt_setpics]['bias']=bias;
picserie[cnt_setpics]['istext']=istext;
cnt_setpics+=1;
}
function move(offset,pnr,text,bias,istext,piccounter)
{

piccounter_akt = piccounter;
offset = offset;
ovrlpic = 'ovrl' + pnr;
document.getElementsByName(ovrlpicold)[0].className = "ovrlhidden";
if (istextold=="1"){
document.getElementById('textdescr').className = "transp";}
else{
document.getElementsByName(pnrold)[0].className = "transp";}

offset_bias=eval(offset+bias);
oldoffset=(document.getElementById("inside").style.right);
if (oldoffset=="") {oldoffset = "0px"};
oldoffsetnum=parseInt(oldoffset.replace(/px/g, ""))+bias;

movediv(oldoffsetnum,offset_bias,((offset_bias-oldoffsetnum)/12));

document.getElementsByName(ovrlpic)[0].className = "opac";

if (istext=="1"){
document.getElementById('textdescr').className = "nontransp";}
else{
document.getElementsByName(pnr)[0].className = "nontransp";}

document.getElementById("bildunterschrift").firstChild.nodeValue = text;      

pnrold=pnr;
pnrakt=pnr;
ovrlpicold=ovrlpic;
offsetold = offset;
istextold = istext;
/*
ctchr = document.getElementById("catcher");
if (ctchr) {
bod = document.getElementsByTagName("body")[0];
bod.removeChild(ctchr);
bod.style.backgroundImage = "url(pic/bg.gif)";
bod.style.height = "100%";}
*/
}

function playvorgang() {
if (piccounter_akt < cnt_setpics-1) piccounter_akt+=1;
else piccounter_akt=0;
move(picserie[piccounter_akt]['offset'],picserie[piccounter_akt]['pic'],picserie[piccounter_akt]['txt'],picserie[piccounter_akt]['bias'],picserie[piccounter_akt]['istext'],piccounter_akt);
}

function autoplay(aktion)
{
/*alert (action+" playing:"+playing+" pausing:"+pausing); */
switch (aktion) {
case "play":
if (playing == 0) {
playvorgang();
tplay = window.setInterval("playvorgang()", 4000);
playing = 1;
pausing = 0;
document.CONTROLPIC.src="pic/pause.gif";
document.CONTROLPIC.title="PAUSE";
//alert (document.getElementById("controller").onmouseup);
document.getElementById("controller").onmouseup=function(){autoplay('stop');}
//alert (aktion+" (play)playing:"+playing+" pausing:"+pausing);
}
break;
case "stop":
if (playing == 1) {
playing = 0;
pausing = 0;
window.clearInterval(tplay);

document.CONTROLPIC.src="pic/play.gif";
document.CONTROLPIC.title="PLAY";
document.getElementById("controller").onmouseup=function(){autoplay('play');}
//alert (aktion+" (stop)playing:"+playing+" pausing:"+pausing);
}
break;
case "pause":
if (playing == 1) {
pausing = 1;
playing = 0;
window.clearInterval(tplay);
//alert (aktion+" (pause-ein)playing:"+playing+" pausing:"+pausing);
}
else {
if (pausing == 1) {
pausing = 0;
playing = 1;
//playvorgang();
tplay = window.setInterval("playvorgang()", 4000);
//alert (aktion+" (pause-aus)playing:"+playing+" pausing:"+pausing);
}
}

break;
}

/*document.write ("play:" , playing , " pause:" , pausing); */

}


function playvorgang() {
if (piccounter_akt < cnt_setpics-1) piccounter_akt+=1;
else piccounter_akt=0;
move(picserie[piccounter_akt]['offset'],picserie[piccounter_akt]['pic'],picserie[piccounter_akt]['txt'],picserie[piccounter_akt]['bias'],picserie[piccounter_akt]['istext'],piccounter_akt);
}


function movediv(start,ziel,increment)
{
if (Math.abs(ziel-start) < Math.abs(increment)){start=ziel;}
else {
start=start+increment;}

document.getElementById("inside").style.right = start+'px';
if (Math.abs(ziel-start) > 0){
var t=setTimeout("movediv(" + start +","+ ziel +","+increment+")",40);}else {clearTimeout(t);}
} 

function makebig(bigpic,bildnr,w,h)
{
if (bildnr == pnrakt) {

autoplay('pause');

/*	bod 				= document.getElementById('main');*/
bod 				= document.getElementsByTagName('body')[0];
mainaround				= document.getElementById('main-around')
	overlay 			= document.createElement('div');
	overlay.id			= 'black_v';
		

	inneres = document.createElement('div');
	inneres.id = 'bigpicdiv';
	inneres.innerHTML = "<a href='javascript:kill()'><img src='"+bigpic+"' class='bigpic' id='bigpica' width='"+w+"' height='"+h+"'></a>";
next = document.createElement('div');
next.id = 'nextpic';
	next.innerHTML = "TESTTEXT";	
	bod.appendChild(overlay);
/*	mainaround.appendChild(next);	*/
	bod.appendChild(inneres);
	bgstyleold=bod.style.background;
/*	bod.style.background='black';*/
	}
}
function kill(){
/*	bod 				= document.getElementById('main');*/
bod 				= document.getElementsByTagName('body')[0];
	bod.removeChild(overlay);
	bod.removeChild(inneres);
/*	bod.style.background='#FFFFFF';*/
	

	bod.style.background=bgstyleold;
	bod.style.backgroundImage = bgstyleold;
/*	bod.style.height = "100%"; */
autoplay('pause');
}