/**
 * This function changes the content of the marginal column
 * Needs jQuery to run!
 * @param int contentNumber: number of div to display
 * @param string contentType: type of div to display
 */
var currentlyActive = 'default';
var currentDiv = false;
function changeMargCol(contentNumber, contentType) {
		
	// Hide the currently active div
	currentDiv = document.getElementById(currentlyActive);
	currentDiv.style.display = 'none';
	
	// We want to show this div
	currentlyActive = contentType + contentNumber;
	currentDiv = document.getElementById(currentlyActive);

	// Initialise the var
	eval("var init"+currentlyActive+";");
	
	// If the div is currently set to display=none, show it
	if (currentDiv.style.display == 'none' || !currentDiv.style.display) {
		currentDiv.style.display = 'block';
		
		
		// Add scrollbar first time only
		// If the var does not hold a number, it has just been initialised, so this is the first time
		if (isNaN(eval("init"+currentlyActive))) {
			$('#marginal-'+currentlyActive).jScrollPane({showArrows:true, scrollbarWidth: 13});
			eval("init"+currentlyActive+" = 1;");
		}
	}
	
	// Reset galleries
	if (divID > 0) {
		// Disable the current image...
		document.getElementById("gal-"+divID+'-'+currentGalImage).style.display = 'none';
		currentGalImage = 0;
		// ... and enable the next/previous image
		document.getElementById("gal-"+contentNumber+'-'+currentGalImage).style.display = 'block';
	}
}


/**
 * This function changes image gallery images and texts
 * @param int numberOfImages: number of images in this gallery
 * @param int kennID: element to identify
 * @param string direction: move 'forw' or 'back'
 */
var currentGalImage = 0;
var divID = 0;
function changeGallery(numberOfImages, kennID, direction) {
	
	// Show NEXT image
	if (direction == 'forw') {
		// If the next image exists, show it
		if (currentGalImage < numberOfImages-1) {
			newGalImage = currentGalImage+1;
		}
		// If no next image exists, return to the first one
		else {
			newGalImage = 0;
		}
	}
	
	// Show PREVIOUS image
	else if (direction == 'back') {
		// If the previous image exists, show it
		if (currentGalImage > 0) {
			newGalImage = currentGalImage-1;
		}
		// If no previous image exists, return to the first one
		else {
			newGalImage = numberOfImages-1;
		}
	}
	
	// In any case, disable the current image...
	document.getElementById("gal-"+kennID+'-'+currentGalImage).style.display = 'none';
	
	// ... and enable the next/previous image
	document.getElementById("gal-"+kennID+'-'+newGalImage).style.display = 'block';
	
	// Store for next call
	currentGalImage = newGalImage;
	divID = kennID;
}


/**
 * This function loads things on startup
 */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


/*function disableJSWarning() { 
  document.getElementById("javascript-warnung").style.display = 'none';
}
addLoadEvent(disableJSWarning);

function centerIE7() {
	var hei = $("#container").height();
	if (document.documentElement.clientHeight > hei) {
		document.getElementById("container").style.marginTop = ((document.documentElement.clientHeight-hei)/2)+"px";
	}
}
*/


function scroller() {
	$('#scroll-container').jScrollPane({showArrows:true, scrollbarWidth: 13});
}
addLoadEvent(scroller);
