	var latestpic = '';
	var NewStartVar = -1;
	var StartUpDiaShow = true;
	var DiaCount = 0;
	var currentdatepath = '';
	var jumptolast = true;
	var jumpintervalcheck;
	var datecheckinterval;
	var diashowrunning = false;
	
	function initializepage(){
		getdatelist();
		refreshInterval = setInterval("refreshpicturelist()",30000);
		
		//new Effect.Opacity(document.getElementById('diastop_img'), { from: 1.0, to: 0.5, duration: 0.0 });
		$('#diastop_img').fadeTo(0.0, 0.5);
		
		
		setTimeout("startupslidestart()", 1000);
		
		//Add DateCheckInterval
		datecheckinterval = setInterval("checkfornewdate()", 240000);
	}

	function changepic(){
		
		//Disable jumptolast
		resetjumptolast();
		
		smallpreload();
		var mypiclist = document.getElementById('picturelist');
		myfilename = mypiclist.options[mypiclist.selectedIndex].value;
		var myfile = '/pictures/' + mypicturesize + '/' + currentdatepath + '/' + mypicturekeywords + myfilename;
		var myoriginal = '/pictures/original/' + currentdatepath + '/' + mypicturekeywords + myfilename;
		
		img = document.getElementById("basepic");
		
		img.src = myfile;
		
		var mylightlink = document.getElementById('lightboxlink');
		mylightlink.href = myoriginal;
	}
	
	function checkfornewdate(){
		if(jumptolast == true){
			 if(diashowrunning == false){
				 var mydate = document.getElementById("datebox").options[0].value;
				 
					$.ajax({
						url: '/services/checkfornewdate.php',
						dataType: 'text',
						type: 'post',
						data:  {latestdate: mydate, id: camid, pictable: campictable},
						success: function( data ) {
							if(data == "true"){
								getdatelist(); 
								 StartUpDiaShow = true;
								 setTimeout("startupslidestart()", 1000);
							}
						}
					});
			 }
		}
	}
	
	function resetjumptolast(){
		
		if(jumpintervalcheck){
			clearTimeout(jumpintervalcheck);
		}
		jumptolast = false;
		jumpintervalcheck = setTimeout("enablejumptolast()", 20000);
	}
	function enablejumptolast(){
		jumptolast = true;
	}
	
	function getdatelist(){

		$.ajax({
			url: '/services/slideshow.php',
			dataType: 'json',
			type: 'post',
			data:   { mode: 'getDateList', id: camid, pictable: campictable},
			success: function( data ) {			  
			//$('#datebox').clear();
				$('#datebox').children().remove();
			 var json = data; //transport.responseText.evalJSON();
			 var opt = document.getElementById('datebox');

				 for (var i=opt.options.length-1; i>=0; i--){
				    opt.options[i] = null;
				  }
				  opt.selectedIndex = -1;

				 for (var key in json) {
				  if (json.hasOwnProperty(key)) {
					opt.options[opt.length] = new Option(key,json[key]);
				}
			 }
				//Fix for Opera select entry
				opt.options[0].selected = true; 
				
			 	getpicturelist();
			}
		});
	}

	function getpicturelist(){
		//Get Selected Date
		var mydatebox = document.getElementById('datebox');
		var datetofetch = mydatebox.options[mydatebox.selectedIndex].value;
		//Get Current date for PicturePath
		currentdatepath = campictable + '-' + camid + '-' + datetofetch.substring(0,4) + '-' + datetofetch.substring(4,8);
		
		$.ajax({
			url: '/services/slideshow.php',
			dataType: 'json',
			type: 'post',
			data:  { mode: 'getPictureList', id: camid, pictable: campictable, searchdate: datetofetch},
			success: function( data ) {			  
				 var json = data; //transport.responseText.evalJSON();
				 var opt = document.getElementById('picturelist');

					 for (var i=opt.options.length-1; i>=0; i--){
					    opt.options[i] = null;
					  }
					  opt.selectedIndex = -1;

				 
				 for (var key in json) {
					  if (json.hasOwnProperty(key)) {
						opt.options[opt.length] = new Option(key,json[key]);
						//Save latest Image for small refreshes
						latestpic = key;
					}
				 }
				 piccount = (opt.options.length - 1);
				 
				 
				//Test for StartDiaShow
				myStartDiaSelection = (piccount - 3);
					if(myStartDiaSelection < 0){
						myStartDiaSelection = 0;
					}
					if(StartUpDiaShow == true){
						myCount = myStartDiaSelection;
						DiaCount = myStartDiaSelection;
					
					}else{
						myCount = piccount;
						DiaCount = piccount;
					}

				 //myCount = piccount;
				 opt.options[myCount].selected = 'true';	
				 opt.selectedIndex = myCount;
				 changepic();
				 opt.focus();
				 
				 if(StartUpDiaShow == true){
					//slideshowstartclicked();
				 }
				 
				//Disable PictureLoadingMEssage
				document.getElementById('loadingpictures').style.display = 'none';
				
				 
				  			 
			}
		});
		
		
	}

	function refreshpicturelist(){
		//Get Selected Date
		var mydatebox = document.getElementById('datebox');
		var datetofetch = mydatebox.options[mydatebox.selectedIndex].value;

		var newcount = 0;
		
		$.ajax({
			url: '/services/slideshow.php',
			dataType: 'json',
			type: 'post',
			data: { mode: 'getPictureList', id: camid, pictable: campictable, searchdate: datetofetch, refresh: latestpic},
			success: function( data ) {			  
				var json = data; //transport.responseText.evalJSON();
				 var opt = document.getElementById('picturelist');

				 for (var key in json) {
					  if (json.hasOwnProperty(key)) {
						  newcount++;
						 opt.options[opt.length] = new Option(key,json[key]);
						//Save latest Image for small refreshes
						latestpic = key;
					}
				 }
				 if(newcount > 0){
				 if(jumptolast == true){
					 if(diashowrunning == false){
						 piccount = (opt.options.length - 1);
						 opt.options[piccount].selected = 'true';	
						 opt.selectedIndex = piccount;
						 changepic();
						 opt.focus();
					 }
				 }
				 }
				 
				 
				  			 
			}
		});
		
	}
	
	/* StartupDiaShow*/
	var startupslideshowinterval;
	function startupslidestart(){
		if(document.getElementById('picturelist').options.length > 1){
		diashowrunning = true;
		
		document.getElementById('slideshowprogress').style.display = 'block';
		document.getElementById('datebox').disabled = true;
		
		//new Effect.Opacity(document.getElementById('diastart_img'), { from: 1.0, to: 0.5, duration: 0.2 });
		$('#diastart_img').fadeTo(200, 0.5);
		//new Effect.Opacity(document.getElementById('diastop_img'), { from: 0.5, to: 1.0, duration: 0.2 });
		$('#diastop_img').fadeTo(200, 1.0);
		
		document.getElementById('diastop_link').href = 'javascript:slideshowstopclicked();';
		document.getElementById('diastart_link').href = '#';
		
		DiaCount = document.getElementById('picturelist').selectedIndex;
		DiaCount++;
		document.getElementById('picturelist').selectedIndex = DiaCount;
		changepic();
		startupslideshowinterval = setInterval("startupslidechange()", 1200);
		}
		else{
			stopSlideShow();
			
		}
	}
	function startupslidechange(){
		DiaCount++;
		if(DiaCount <= document.getElementById('picturelist').options.length - 1 ){
			document.getElementById('picturelist').selectedIndex = DiaCount;
			changepic();
		}else{
			//Stopping it
			clearInterval(startupslideshowinterval);
			StartUpDiaShow = false;
			
			diashowrunning = false;
			
			//new Effect.Opacity(document.getElementById('diastart_img'), { from: 0.5, to: 1.0, duration: 0.2 });
			$('#diastart_img').fadeTo(200, 1.0);
			//new Effect.Opacity(document.getElementById('diastop_img'), { from: 1.0, to: 0.5, duration: 0.2 });
			$('#diastop_img').fadeTo(200, 0.5);
			
			document.getElementById('diastop_link').href = '#';
			document.getElementById('diastart_link').href = 'javascript:slideshowstartclicked();';
			document.getElementById('slideshowprogress').style.display = 'none';
			document.getElementById('datebox').disabled = false;
			
		}
	} 

	/* Dia Show NEW */
	var reverse = false;
	var faderrunning = false;
	var myslideshow;
	
	/*
	function SlideShowControl(){
		if(document.getElementById("PlayDiaShow").innerHTML=="Play"){
			document.getElementById("PlayDiaShow").innerHTML="Stop";
			document.getElementById("PlayDiaShow").style.backgroundColor = "FireBrick";
			startSlideShow();
		}
		else{
			document.getElementById('picmessage').innerHTML = 'SlideShow is stopping...';
			//console.log('Diashow wird beendet..');
			document.getElementById("PlayDiaShow").disabled = true;
			faderrunning = false;
			clearInterval(myslideshow);
			setTimeout('stopSlideShow()', 1000);
			//stopSlideShow();
		}
	}*/
	
	function slideshowstartclicked(){
		diashowrunning = true;
		//Disable Date Selection
		document.getElementById('slideshowprogress').style.display = 'block';
		document.getElementById('datebox').disabled = true;
		
		//new Effect.Opacity(img, {from: 0.0, to: 1.0, duration: 0.0});
		$('#basepic').fadeTo(0.0,1.0);
				
		//new Effect.Opacity(document.getElementById('diastart_img'), { from: 1.0, to: 0.5, duration: 0.5 });
		$('#diastart_img').fadeTo(500, 0.5);
		//new Effect.Opacity(document.getElementById('diastop_img'), { from: 0.5, to: 1.0, duration: 0.5 });
		$('#diastop_img').fadeTo(500, 1.0);
		
		//document.getElementById('diastart_img').style.opacity = 0.5;
		//document.getElementById('diastop_img').style.opacity = 1.0;
		document.getElementById('diastop_link').href = 'javascript:slideshowstopclicked();';
		document.getElementById('diastart_link').href = '#';
		startSlideShow();

	}
	
	function slideshowstopclicked(){
		diashowrunning = false;
		document.getElementById('picmessage').innerHTML = 'SlideShow is stopping...';
		//console.log('Diashow wird beendet..');
		//document.getElementById("PlayDiaShow").disabled = true;
		faderrunning = false;
		clearInterval(myslideshow);
		setTimeout('stopSlideShow()', 1000);
		
		//new Effect.Opacity(document.getElementById('diastop_img'), { from: 1.0, to: 0.5, duration: 0.5 });
		$('#diastop_img').fadeTo(500, 0.5);
		
		document.getElementById('diastop_link').href = '#';
		
	}
	
	function changeSlideShowDirection(){
		if(document.getElementById('slidedirection').innerHTML == "forward"){
			reverse = true;
			document.getElementById('slidedirection').innerHTML = "backward";
		}
		else{
			reverse = false;
			document.getElementById('slidedirection').innerHTML = "forward";	
		}
	}
	
	
	function stopSlideShow(){
		if(StartUpDiaShow == true){
			StartUpDiaShow = false;
		}
		
		//Check if DiaCount is off
		if(DiaCount < 0){
			DiaCount = 0;
		}else if(DiaCount > document.getElementById('picturelist').options.length - 1){
			DiaCount = document.getElementById('picturelist').options.length - 1;
			
		}
				
		var img2 = document.getElementById('pic2');
		img2.style.zIndex = 10;
		img2.style.visibility = 'hidden';
		
		var img = document.getElementById('basepic');
		//img.style.visibility = 'visible';
		img.style.zIndex = 20;
		//img.style.opacity = 100;
		
		//console.log('inside of ' + slideshowswitch);
		//TODO Maybe find gentle way to fade-stop!
		//new Effect.Opacity(img, {from: 0.0, to: 1.0, duration: 0.0});
		$('#basepic').fadeTo(0.0, 1.0);
		//new Effect.Opacity(img2, {from: 0.0, to: 1.0, duration: 0.0});
		$('#pic2').fadeTo(0.0, 1.0);
		
		var endPic = '/pictures/' + mypicturesize + '/' + currentdatepath + '/' + document.getElementById('picturelist').options[DiaCount].value;
		img.src = endPic;
		
		//Reenable Lightbox
		var mylightlink = document.getElementById('lightboxlink');
		mylightlink.href = '/pictures/original/' + currentdatepath + '/' + mypicturekeywords + document.getElementById('picturelist').options[DiaCount].value;
		mylightlink.rel = 'lightbox';
		
		//document.getElementById("PlayDiaShow").innerHTML="Play";
		//document.getElementById("PlayDiaShow").style.backgroundColor = "";
		//document.getElementById("PlayDiaShow").disabled = false;
		
		//new Effect.Opacity(document.getElementById('diastart_img'), { from: 0.5, to: 1.0, duration: 0.5 });
		$('#diastart_img').fadeTo(500, 1.0);
		
		document.getElementById('diastart_link').href = 'javascript:slideshowstartclicked();';
				
		document.getElementById('picmessage').style.display = 'none';
		
		//Enable Date Selection
		document.getElementById('datebox').disabled = false;
		document.getElementById('slideshowprogress').style.display = 'none';
	}
	
	function startSlideShow(){
		
		//console.log('starting to cache');
		fullpreload();
		//console.log('done caching');
		
		faderrunning = true;
		
		//Disable Lightbox
		document.getElementById('lightboxlink').href = '#';
		document.getElementById('lightboxlink').rel = '#';
		 
		
		
		var img = document.getElementById('basepic');
		var img2 = document.getElementById('pic2');
		
		document.getElementById('picmessage').innerHTML = 'Starting SlideShow...';
		document.getElementById('picmessage').style.display = 'block';
		
		img2.style.visibility = 'visible';
		
		DiaCount=document.getElementById("picturelist").selectedIndex;
		
				
		//var nextPic = '/pictures/' + mypicturesize + '/' + currentdatepath + '/' + document.getElementById('picturelist').options[document.getElementById('picturelist').selectedIndex].value;
		//img.src = nextPic;
		//if(reverse == true){
		//	DiaCount = DiaCount - 1;
		//}else{
		//	DiaCount = DiaCount + 1;
		//}
		if(reverse == true){
			if(DiaCount < 0){
				DiaCount = document.getElementById('picturelist').options.length - 1;
			}
		}
		else{
			if(DiaCount >= document.getElementById('picturelist').options.length){
					DiaCount = 0;
			}
		}
		var nextPic = '/pictures/' + mypicturesize + '/' + currentdatepath + '/'  + mypicturekeywords + document.getElementById('picturelist').options[DiaCount].value;
		img2.src = nextPic;
		//new Effect.Opacity(img, { from: 1.0, to: 0.0, duration: 1.0 });
		$('#basepic').fadeTo(1000, 0.0);
		
		document.getElementById('picturelist').options[DiaCount].selected = true;
		if(reverse == true){
			if(DiaCount < 0){
				DiaCount = document.getElementById('picturelist').options.length - 1;
			}
		}
		else{
			if(DiaCount >= document.getElementById('picturelist').options.length){
				DiaCount = 0;
			}
		}
		//if(reverse == true){
		//	DiaCount = DiaCount - 1;
		//}
		//else{
		//	DiaCount = DiaCount + 1;
		//}
		slideshowswitch = 1;
		myslideshow = setInterval("SlideShowRuns()",switchinterval);
		
		if (faderrunning == true){
			//swapPic();
			//setTimeout('swapPic()', 2000);
		}
	
		//console.log('here')
	}
	
	var slideshowswitch;
	function SlideShowRuns(){
		if(slideshowswitch == 1 ){
			slideshowswitch = 2;
			swapPic();	
		}else{
			slideshowswitch = 1;
			swapPic2();
		}
	}
	
	
	function swapPic(){
		if (faderrunning == true){
			//console.log('in swapPic');
			//preloader(5);
			
			var img = document.getElementById('basepic');
			var img2 = document.getElementById('pic2');
			
			//if(DiaCount < document.getElementById('picturelist').options.length){
			if(reverse == true){
				if(DiaCount < 0){
					DiaCount = document.getElementById('picturelist').options.length - 1;
				}
			}
			else{
				if(DiaCount >= document.getElementById('picturelist').options.length){
					if(StartUpDiaShow == true){
						DiaCount = document.getElementById('picturelist').options.length - 1;
						slideshowstopclicked();
						return;
					}else{
						DiaCount = 0;	
					}
				}
			}
			img.style.zIndex = 10;
			img2.style.zIndex = 20;

			
			
			document.getElementById('picturelist').options[DiaCount].selected = true;
			document.getElementById('picmessage').innerHTML = document.getElementById('picturelist').options[document.getElementById('picturelist').selectedIndex].text;
			//console.log('Diacount is ' + DiaCount);
			var nextPic = '/pictures/' + mypicturesize + '/' + currentdatepath + '/' + mypicturekeywords + document.getElementById('picturelist').options[document.getElementById('picturelist').selectedIndex].value;
			if(reverse == true){
				DiaCount = DiaCount - 1;
			}
			else{
				DiaCount++;
			}
			
			//var nextPic = myPictures.pop();
			img.src = nextPic;
			
			//img.style.opacity = 100;
			if (faderrunning == true){
				//new Effect.Opacity(img, {from: 0.0, to: 1.0, duration: 0.0});
				$('#basepic').fadeTo(0.0, 1.0);
				
				//new Effect.Opacity(img, { from: 0.0, to: 1.0, duration: 0.1 });
				
				//new Effect.Opacity(img2, { from: 1.0, to: 0.0, duration: fadeduration});
				$('#pic2').fadeTo(fadeduration, 0.0);
				
				//	setTimeout('swapPic2()', 2000);
			}
			//}else{
			//	DiaShowCount = 0;
				
			//}
		}
		
	}
	
	function swapPic2(){
		if (faderrunning == true){
			//preloader(5);
			//console.log('in swapPic2');
			
			var img = document.getElementById('basepic');
			var img2 = document.getElementById('pic2');
			
		
		
			//if(DiaCount < document.getElementById('picturelist').options.length){
			if(reverse == true){
				if(DiaCount < 0){
					DiaCount = document.getElementById('picturelist').options.length - 1;
				}
			}
			else{
				if(DiaCount >= document.getElementById('picturelist').options.length){
					if(StartUpDiaShow == true){
						DiaCount = document.getElementById('picturelist').options.length - 1;
						slideshowstopclicked();
						return;
						
					}else{
						DiaCount = 0;	
					}
					
				}
			}
				/*switched*/
				img.style.zIndex = 20;
				img2.style.zIndex = 10;
				
				document.getElementById('picturelist').options[DiaCount].selected = true;
				document.getElementById('picmessage').innerHTML = document.getElementById('picturelist').options[document.getElementById('picturelist').selectedIndex].text;
				//console.log('Diacount is ' + DiaCount);
				var nextPic = '/pictures/'+ mypicturesize +'/' + currentdatepath + '/' + mypicturekeywords + document.getElementById('picturelist').options[document.getElementById('picturelist').selectedIndex].value;
				if(reverse == true){
					DiaCount = DiaCount - 1;
				}
				else{
					DiaCount++;
				}			
				img2.src = nextPic;
							
				if (faderrunning == true){
					//new Effect.Opacity(img2, {from: 0.0, to: 1.0, duration: 0.0});
					$('#pic2').fadeTo(0.0, 1.0);
					//new Effect.Opacity(img, { from: 1.0, to: 0.0, duration: fadeduration});
					$('#basepic').fadeTo(fadeduration, 0.0);
				}
				
				
			//}else{
			//	DiaCount = 0;
			//}
			
			
		}
	}
	function smallpreload(){
		//Preload the next 5 pics
		var startpoint = document.getElementById('picturelist').selectedIndex;
		var i = startpoint;
		var endpoint = i + 6;
		//console.log('i is ' + i + ' and end is ' + endpoint);
		//Cache from Current to last in list
		while(i < endpoint){
			if (i < document.getElementById('picturelist').options.length){
				//console.log('cache it');
				var cachePic = '/pictures/'+ mypicturesize +'/' + currentdatepath + '/' + mypicturekeywords + document.getElementById('picturelist').options[i].value;
				myCachePic = new Image;
				myCachePic.src = cachePic;
			}
			i++;
		}
		//console.log('done forward start backward');
		var i = startpoint;
		var endpoint = i - 6;
		//console.log('i is ' + i + ' and end is ' + endpoint);
		//Cache from Current to first in list
		while(i > endpoint){
			if (i >= 0){
				//console.log('doing it');
				var cachePic = '/pictures/'+ mypicturesize +'/' + currentdatepath + '/' + mypicturekeywords + document.getElementById('picturelist').options[i].value;
				myCachePic = new Image;
				myCachePic.src = cachePic;
			}
			i = i - 1;
		}
	}
	
	function fullpreload(){
		var startpoint = document.getElementById('picturelist').selectedIndex;
		var i = startpoint;
		if(reverse == false){
			//Cache from Current to last in list
			while(i < document.getElementById('picturelist').options.length){
				var cachePic = '/pictures/'+ mypicturesize +'/' + currentdatepath + '/' + mypicturekeywords + document.getElementById('picturelist').options[i].value;
				myCachePic = new Image;
				myCachePic.src = cachePic;
				i++;
			}
			i = 0;
			//Cache from start to initial beginning
			while(i < startpoint){
				var cachePic = '/pictures/'+ mypicturesize +'/' + currentdatepath + '/' + mypicturekeywords + document.getElementById('picturelist').options[i].value;
				myCachePic = new Image;
				myCachePic.src = cachePic;
				i++;
			}
		}
		else{
			//Cache from Current to first in list
			while(i >= 0){
				var cachePic = '/pictures/'+ mypicturesize +'/' + currentdatepath + '/' + mypicturekeywords + document.getElementById('picturelist').options[i].value;
				myCachePic = new Image;
				myCachePic.src = cachePic;
				i = i - 1;
			}
			i = document.getElementById('picturelist').options.length - 1;
			//Cache from last in list to initial beginning
			while(i > startpoint){
				var cachePic = '/pictures/'+ mypicturesize +'/' + currentdatepath + '/' + mypicturekeywords + document.getElementById('picturelist').options[i].value;
				myCachePic = new Image;
				myCachePic.src = cachePic;
				i = i - 1;
			}
			
		}
	}
	
	
	/*DiaControls*/
	
	function changeorder(){
		if(reverse == false){
			reverse = true;
			document.getElementById('diaorder_img').src = '/img/diacontrol/dia_up.png';
		
		}else{
			reverse = false;
			document.getElementById('diaorder_img').src = '/img/diacontrol/dia_down.png';
		}
	}
	
	var speed;
	var fadeduration = 1000;
	var switchinterval = 3000;
	function speedchange(){
			if(speed == "fast"){
				speed = "slow";
				document.getElementById('diaspeed_text').innerHTML  = "slow";
				fadeduration = 1.0;
				switchinterval = 3000;							
			}
			else{
				speed = "fast";
				document.getElementById('diaspeed_text').innerHTML  = "fast";
				fadeduration = 0.5;
				switchinterval = 1500;
			}
			//Kill old interval and restart
			clearInterval(myslideshow);
			myslideshow = setInterval("SlideShowRuns()",switchinterval);
	}
			
	/*More Cams*/
	
	var toopener;
	var moreclosedcheck;
	var fastopen = false;
	var moreopen = 0;
	
	
	function showpreviewpicbox(what){
		//console.log('In Show');
		var inn = document.getElementById('innerpic' + what + 'small');
		var ele = document.getElementById('pic' + what + 'big');
		ele.style.display = "block";
		var small = document.getElementById('pic' + what);
		//small.style.backgroundImage = "url(open.png)";
		small.style.zIndex = 50;
		ele.style.zIndex = -1;

		if(iswide == true){
			inn.style.borderTop = '5px solid white';	
		}else{
			inn.style.borderLeft = '5px solid white';
		}
		moreopen = what;
	}
	
	function showpreviewpicboxtimeout(what){
		//console.log('In ShowTIME');
		clearTimeout(moreclosedcheck);
		
		if(moreopen == 0){
			//console.log('open with to');
			toopener = setTimeout('showpreviewpicbox('+what+')', 500);	
		}else{
			if(moreopen == what){
				//console.log('is same direct open');
				showpreviewpicbox(what);
			}else{
				//console.log('not same open retard');
				toopener = setTimeout('showpreviewpicbox('+what+')', 500);
			}
			
			
		}
		
	}
	
	function checkifclosed(what){
		//console.log('check for closed');
		var ele = document.getElementById('pic' + what + 'big');
		if(ele.style.display == "none"){
			//console.log('is none');
			moreopen = 0;
		}
	}
	
	function hidebigpicbox(what){
		//Not needed ?!		
		
	}
	
	function hidepreviewpicbox(what){
		//console.log('In HIDE');
		clearTimeout(toopener);
		
		var inn = document.getElementById('innerpic' + what + 'small');
		
		var ele = document.getElementById('pic' + what + 'big');
		ele.style.display = "none";
		var small = document.getElementById('pic' + what);
		//small.style.backgroundImage = "url(closed.png)";
		small.style.zIndex = 39;

		if(iswide == true){
			inn.style.borderTop = '5px solid #8f99a6';	
		}else{
			inn.style.borderLeft = '5px solid #8f99a6';
		}
		
		moreclosedcheck = setTimeout('checkifclosed('+what+')',1500);

		
			
	}
	
	function showpreviewpicboxtimeouthorizontal(what){
		clearTimeout(moreclosedcheck);
		if(moreopen == 0){
			toopener = setTimeout('showpreviewpicboxhorizontal('+what+')', 500);	
		}else{
			if(moreopen == what){
				//console.log('is same direct open');
				showpreviewpicboxhorizontal(what);
			}else{
				//console.log('not same open retard');
				toopener = setTimeout('showpreviewpicboxhorizontal('+what+')', 500);
			}
			
			
		}
		
	}
	
	
	function showpreviewpicboxhorizontal(what){
		var inn = document.getElementById('innerpic' + what + 'small');
		var ele = document.getElementById('pic' + what + 'big');
		ele.style.display = "block";
		var small = document.getElementById('pic' + what);
		//small.style.backgroundImage = "url(open.png)";
		small.style.zIndex = 50;
		ele.style.zIndex = -1;
		inn.style.borderTop = '5px solid white';	
		moreopen = what;
	}
	function hidepreviewpicboxhorizontal(what){
		clearTimeout(toopener);
		var inn = document.getElementById('innerpic' + what + 'small');
		
		var ele = document.getElementById('pic' + what + 'big');
		ele.style.display = "none";
		var small = document.getElementById('pic' + what);
		//small.style.backgroundImage = "url(closed.png)";
		small.style.zIndex = 39;
		inn.style.borderTop = '5px solid #8f99a6';	
		
		moreclosedcheck = setTimeout('checkifclosed('+what+')',1500);
	}
	
	function openmapwindow(url){
		mapwindow = window.open(url,'Map','resizable=yes,width='+mymapwidth + ',height='+ mymapheight);
	}

	/* Cookie Functions */
	
	function fixedGMTString(datum){
		   var damals=new Date(1970,0,1,12);
		   if (damals.toGMTString().indexOf("02")>0) {
		      datum.setTime(datum.getTime()-1000*60*60*24);
		   }
		   return datum.toGMTString();
		}
	
	function schreibCookie(name,wert,verfall,pfad,dom,secure) {
		   neuerKeks = name + "=" + escape(wert);
		   if (verfall)
		      neuerKeks += "; expires=" + fixedGMTString(verfall);
		   //if (pfad) neuerKeks += "; path=" + path;
		   neuerKeks += "; path=/";
		   if (dom) neuerKeks += "; domain=" + dom;
		   if (secure) neuerKeks += "; secure";
		   document.cookie = neuerKeks;
		}
	
	function showbrowsernotice(){
		document.getElementById('browsernotice').style.display = 'block';
		
	}
	function hidebrowsernotice(){
		document.getElementById('browsernotice').style.display = 'none';
	      var jetzt = new Date();
	      var verfall = new Date(jetzt.getTime() + 1000*60*60*24*60);
	      schreibCookie("HideBrowserWarning", "yes", verfall);

	}
	
