// JavaScript Document
// Easy stuff
var active_thumb; // = document.getElementById('thumb_0'); // main picture
var loaded_img = new Array(25);
var page_thumb;

function switch_image ( url, image, sender, big_pic, next_pic ) {
	
	switch_pics (next_pic);
	
	if ( active_thumb == undefined ) {
    	active_thumb = document.getElementById('thumb_0'); // main picture	
	}
	if ( active_thumb.id != sender.id) {	
		active_thumb.className = 'thumb';
		active_thumb = sender;
		sender.className = 'activ_thumb';
		
		//var pic_preview = document.getElementById(image);
		//pic_preview.src = url;
		big_picture = big_pic;
		//pic_preview.onClick = function () {th_popUp(big_pic)};
		//pic_preview.setAttribute('onClick',function () {th_popUp(big_pic)});
    }
}

function preloader ( list ) {

	 for (var i = 0; i < list.length; i++){
        loaded_img[i] = document.createElement('img');
        loaded_img[i].setAttribute('src',list[i]);
	}
}
function th_popUp(URL) {      
   if (page_thumb != undefined ) {
	page_thumb.close();
   }
   page_thumb = window.open(URL, 'art_thumb', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=520,height=520,left = 440,top = 312');
}
function show_text (text) {
   	 var pic_preview = document.getElementById('des_id').innerHTML = text;
}
/* ------------------------------------------------------------------------------ */
var slideshow2_slideIndex = 'big_pic_0';
var slideshow2_slideIndexNext = ''; //'big_pic_1';
var slideshow2_fadingSpeed = 1;	// Speed of fading
//var slideshow2_timeBetweenSlides = 500;	// Amount of time between each image(1000 = 1 second)
var slideshow2_currentOpacity = 100;	// Initial opacity
var one_fade_running = false;

function switch_pics (next_pic) {
	
	if (slideshow2_slideIndex == next_pic || slideshow2_slideIndexNext == next_pic) return; 

    if (one_fade_running == true ) {
   
		slideshow2_currentOpacity = 100;
    if (document.all){
		document.getElementById(slideshow2_slideIndex).style.filter = 'alpha(opacity='+slideshow2_currentOpacity+')';
		document.getElementById(slideshow2_slideIndexNext).style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity)+')';
	} else {
		document.getElementById(slideshow2_slideIndex).style.opacity = Math.max(0.01,slideshow2_currentOpacity/100);	// Can't use 1 and 0 because of screen flickering in FF
		document.getElementById(slideshow2_slideIndexNext).style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity/100)));
	}
		document.getElementById(slideshow2_slideIndex).style.visibility = 'hidden';	
		document.getElementById(next_pic).style.visibility = 'visible';	
		
        //slideshow2_currentOpacity = 100;
		one_fade_running = false;
    }

    slideshow2_slideIndexNext = next_pic; // take next picture
	slideshow2_currentOpacity = 100;
	document.getElementById(next_pic).style.visibility = 'visible';	
	
//Mittig ausrichten
	var middle = Math.round(150 - parseInt(document.getElementById(next_pic).height)/2);
	document.getElementById(next_pic).style.marginTop = middle.toString()+'px';	
	
	one_fade_running = true;
	fadeImage();
}
function end_fade () {
	slideshow2_slideIndex = slideshow2_slideIndexNext;
	one_fade_running = false;
}
function fadeImage() {
	if (one_fade_running == false ) return;
		
	slideshow2_currentOpacity = slideshow2_currentOpacity-4;
	if (document.all){
		document.getElementById(slideshow2_slideIndex).style.filter = 'alpha(opacity='+slideshow2_currentOpacity+')';
		document.getElementById(slideshow2_slideIndexNext).style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity)+')';
	} else {
		document.getElementById(slideshow2_slideIndex).style.opacity = Math.max(0.01,slideshow2_currentOpacity/100);	// Can't use 1 and 0 because of screen flickering in FF
		document.getElementById(slideshow2_slideIndexNext).style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity/100)));
	}
	if(slideshow2_currentOpacity>0){
		setTimeout('fadeImage()',slideshow2_fadingSpeed);
	} else {
		document.getElementById(slideshow2_slideIndex).style.visibility = 'hidden';	
		end_fade();
	}
}

/* Open Close windows */

var box_list = new Array();
var box_timer;
var box_step = 20;
var box_speed = 1;

function box_do (bx_id, this_id) {
       
   if (box_list[bx_id] == undefined ) {
	    box_list[bx_id] = new Array();
	    box_list[bx_id]['item'] = document.getElementById(bx_id);
		box_list[bx_id]['inner_item'] = document.getElementById(bx_id+'_inner');
   }
   
   /* Check if box allready in moove if so then exit */
   if (box_list[bx_id]['item'].offsetHeight != 0 && box_list[bx_id]['inner_item'].offsetHeight != box_list[bx_id]['item'].offsetHeight ) {
     return;	   
   }
   if (box_list[bx_id]['item'].offsetHeight != 0) { // Close
	  var what = 'close';
	  this_id.className = 'plus_icon';
   } else { /* Open */
	  var what = 'open'; 
	  this_id.className = 'minus_icon';
   }
   box_timer=setTimeout("make_box_effect('"+bx_id+"', '"+what+"')", box_speed);
   
   

}

function make_box_effect(bx_id, direction) {

 if (direction == 'close') {

     /* What todo: if box is nicely closed then end */
	  if (box_list[bx_id]['item'].offsetHeight != 0) {  
	  
	   if (box_list[bx_id]['item'].offsetHeight < box_step ) {
		 box_list[bx_id]['item'].style.height = '0px';  
	   } else {
	     box_timer=setTimeout("make_box_effect('"+bx_id+"', '"+direction+"')",box_speed);
		 box_list[bx_id]['item'].style.height = (box_list[bx_id]['item'].offsetHeight-box_step)+'px';
	   }
	  }
  } else { /* Open */

	  if (box_list[bx_id]['item'].offsetHeight != box_list[bx_id]['inner_item'].offsetHeight) {  
	  
	   if (box_list[bx_id]['inner_item'].offsetHeight-box_list[bx_id]['item'].offsetHeight < box_step ) {
		 box_list[bx_id]['item'].style.height = box_list[bx_id]['inner_item'].offsetHeight+'px';  
	   } else {
	     box_timer=setTimeout("make_box_effect('"+bx_id+"', '"+direction+"')",box_speed);
    	 box_list[bx_id]['item'].style.height = (box_list[bx_id]['item'].offsetHeight+box_step)+'px';
	   }
	  }
 }
}
