gals = new Array();
stepSize = 200;
scrollDuration = 0.3;
visiblePic = 0;

fsSmall = 12;
fsMedium = 14;
fsBig = 15;

shownPicInfos = 1;
maxPicInfos = 10;

picInfos = new Array();
picInfos[0] = new Array("el_8",  "el_9",  "el_10", "el_11", "el_12", "el_13");
picInfos[1] = new Array("el_15", "el_16", "el_17", "el_18", "el_19", "el_20");
picInfos[2] = new Array("el_23", "el_24", "el_25", "el_26", "el_27", "el_28");
picInfos[3] = new Array("el_31", "el_32", "el_33", "el_34", "el_35", "el_36");
picInfos[4] = new Array("el_39", "el_40", "el_41", "el_42", "el_43", "el_44");
picInfos[5] = new Array("el_47", "el_48", "el_49", "el_50", "el_51", "el_52");
picInfos[6] = new Array("el_55", "el_56", "el_57", "el_58", "el_59", "el_60");
picInfos[7] = new Array("el_63", "el_64", "el_65", "el_66", "el_67", "el_68");
picInfos[8] = new Array("el_71", "el_72", "el_73", "el_74", "el_75", "el_76");
picInfos[9] = new Array("el_79", "el_80", "el_81", "el_82", "el_83", "el_84");

//-------------------------------------------------------------------------
function addFormEvents() {
	if (document.getElementById("el_104")) {
		document.getElementById("el_104").onclick = function() { 
			if (document.getElementById("el_104").checked) setElementDisplay("private", "block");
			else setElementDisplay("private", "none");
		}
	}

	if (document.getElementById("el_110")) {
		document.getElementById("el_110").onclick = function() { 
			if (document.getElementById("el_110").checked) setElementDisplay("science", "block");
			else setElementDisplay("science", "none");
		}
	}
/*
	if (document.getElementById("form_formular")) {
		document.getElementById("form_formular").onsubmit = function() { 
			for (i=(shownPicInfos + 1); i <= maxPicInfos; i++) {
				if (document.getElementById("info"+i)) {
					for (j=0; j<picInfos[i-1].length; j++) {
						$(picInfos[i-1][j]).remove();					
					}
					$('info'+i).remove();
				}
			}
			return true;
		}
	}
*/
}
//-------------------------------------------------------------------------
function addPicInfo() {
	shownPicInfos++;
	if (shownPicInfos <= maxPicInfos) {
		setElementDisplay("info"+shownPicInfos, "block");
	}
	if (shownPicInfos >= maxPicInfos) {
		shownPicInfos = maxPicInfos;
		setElementDisplay("furtherPicInfo", "none");
	}
}
//-------------------------------------------------------------------------
function setElementDisplay (id, displayStr) {
	document.getElementById(id).style.display = displayStr;
}
//-------------------------------------------------------------------------
function updateFontSizes () {
	// all h1
	h1s = document.getElementsByTagName("h1");
	for (i=0; i<h1s.length; i++) h1s[i].style.fontSize = fsMedium + "px";

	// all h2
	h2s = document.getElementsByTagName("h2");
	for (i=0; i<h2s.length; i++) h2s[i].style.fontSize = fsBig + "px";

	// all p
	ps = document.getElementsByTagName("p");
	for (i=0; i<ps.length; i++) ps[i].style.fontSize = fsMedium + "px";

	// all li
	lis = document.getElementsByTagName("li");
	for (i=0; i<lis.length; i++) lis[i].style.fontSize = fsMedium + "px";

	// overwrite p for p.picsub
	ppss = getElementsByClass(document.getElementById("content"),"picsub", "p");
	for (i=0; i<ppss.length; i++) ppss[i].style.fontSize = fsSmall + "px";

	// overwrite p for p.picAndSub
	ppass = getElementsByClass(document.getElementById("content"),"picAndSub", "p");
	for (i=0; i<ppass.length; i++) ppass[i].style.fontSize = fsSmall + "px";
}
//-------------------------------------------------------------------------
function sizeUp () {
	fsSmall += 1;
	fsMedium += 1;
	fsBig += 1;
	updateFontSizes();
}
//-------------------------------------------------------------------------
function sizeDown () {
	fsSmall -= 1;
	fsMedium -= 1;
	fsBig -= 1;
	updateFontSizes();
}
//-------------------------------------------------------------------------
function setGalBigPic (gal, picIndex) {
	document[gal['bigPicElem']].src = gal['pics'][picIndex];
	visiblePic = picIndex;
}
//-------------------------------------------------------------------------------------------------------
function setGalPicSubtitle(galId, picIndex) {
	ps = document.getElementById("picsub"+galId);
	ps.innerHTML = gals[galId]['subtitles'][picIndex];

	pc = document.getElementById("galbigpic"+galId);
//	pc.alt = gals[galId]['subtitles'][picIndex];
	altsub = gals[galId]['subtitles'][picIndex];
	altsub = altsub.replace(/&Auml;/g, "Ä");
	altsub = altsub.replace(/&Ouml;/g, "Ö");
	altsub = altsub.replace(/&Uuml;/g, "Ü");
	altsub = altsub.replace(/&auml;/g, "ä");
	altsub = altsub.replace(/&ouml;/g, "ö");
	altsub = altsub.replace(/&uuml;/g, "ü");
	altsub = altsub.replace(/&szlig;/g, "ß");
	altsub = altsub.replace(/&amp;/g, "&");
	pc.alt = altsub;
	
}
//-------------------------------------------------------------------------
function scrollToLeft(gal) {
	gal['curScrollPos'] -= stepSize;
	if (Math.abs(gal['curScrollPos']) > gal['maxScrollPos']) gal['curScrollPos'] = -(gal['maxScrollPos']);
	new Effect.Move(gal['scrollableThumbsElem'], { x: gal['curScrollPos'], y: 0, duration: scrollDuration, mode: 'absolute' }); 
	return false;	
}
//-------------------------------------------------------------------------
function scrollToRight(gal) {
	gal['curScrollPos'] += stepSize;
	if (gal['curScrollPos'] > 0) gal['curScrollPos'] = 0;
	new Effect.Move(gal['scrollableThumbsElem'], { x: gal['curScrollPos'], y: 0 , duration: scrollDuration, mode: 'absolute' }); 
	return false;
}
//-------------------------------------------------------------------------------------------------------
function viewDetailPic (galId) {
//	newWin = window.open ("http://wemove.com", "newWin", "toolbar=0,location=0,directories=0,status=0,menubar=0");
newWin = window.open (
		gals[galId]['fullPics'][visiblePic],
//		"",
		"newWin", // Name des neuen Fensters
		+"toolbar=0" // Toolbar 
		+",location=0" // Adress-Leiste
		+",directories=0" // Zusatzleisten
		+",status=0" // Statusleiste
		+",menubar=0" // Menü
		);
//	newWin.location.href = gals[galId]['fullPics'][visiblePic];
}
//----------------------------------------------------------------------------------------
// get elements by class by dustin diaz http://www.dustindiaz.com/getelementsbyclass/
function getElementsByClass(node,searchClass,tag) {
	var classElements = new Array();
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("\b"+searchClass+"\b");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
//-------------------------------------------------------------------------
/**
 * Function : dump()
 * Arguments: The data - array,hash(associative array),object
 *    The level - OPTIONAL
 * Returns  : The textual representation of the array.
 * This function was inspired by the print_r function of PHP.
 * This will accept some data as the argument and return a
 * text that will be a more readable version of the
 * array/hash/object that is given.
 * Docs: http://www.openjs.com/scripts/others/dump_function_php_print_r.php
 */
function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects 
		for(var item in arr) {
			var value = arr[item];
			
			if(typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	} else { //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}
