gals = new Array();
stepSize = 314;
scrollDuration = 0.3;

fsPicsubPercent = 80;
fsNormalPt = 11;
fsBigPx = 19;

visiblePic = 0;
//-------------------------------------------------------------------------
function updateFontSizes () {
	// all h1
	h1s = document.getElementsByTagName("h1");
	for (i=0; i<h1s.length; i++) h1s[i].style.fontSize = fsBigPx + "px";

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

	// all p (needed p and p.lila_fett)
	ps = document.getElementsByTagName("p");
	for (i=0; i<ps.length; i++) ps[i].style.fontSize = fsNormalPt + "pt";

	// overwrite p for p.picsub
	ppss = getElementsByClass(document.getElementById("all-contents"),"picsub", "p");
	for (i=0; i<ppss.length; i++) ppss[i].style.fontSize = fsPicsubPercent + "%";

	// overwrite p for p.lila_gross_fett
	plgfs = getElementsByClass(document.getElementById("all-contents"),"lila_gross_fett", "p");
	for (i=0; i<plgfs.length; i++) plgfs[i].style.fontSize = fsBigPx + "px";
}
//-------------------------------------------------------------------------
function sizeUp () {
	fsPicsubPercent += 10;
	fsNormalPt += 1;
	fsBigPx += 1;
	updateFontSizes();
}
//-------------------------------------------------------------------------
function sizeDown () {
	fsPicsubPercent -= 10;
	fsNormalPt -= 1;
	fsBigPx -= 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];
	ps.setAttribute('style', 'width:'+gals[galId]['subtitleWidths'][picIndex]+'px;');
}
//-------------------------------------------------------------------------
function scrollUp(gal) {
	gal['curScrollPos'] += stepSize;
	if (gal['curScrollPos'] > 0) gal['curScrollPos'] = 0;
	new Effect.Move(gal['scrollableThumbsElem'], { x: 0, y: gal['curScrollPos'], duration: scrollDuration, mode: 'absolute' }); 
	return false;
}
//-------------------------------------------------------------------------
function scrollDown(gal) {
	gal['curScrollPos'] -= stepSize;
	if (Math.abs(gal['curScrollPos']) > gal['maxScrollPos']) gal['curScrollPos'] = -(gal['maxScrollPos']);
	new Effect.Move(gal['scrollableThumbsElem'], { x: 0, y: gal['curScrollPos'], duration: scrollDuration, mode: 'absolute' }); 
	return false;	
}
//-------------------------------------------------------------------------------------------------------
function viewDetailPic (galId) {
	newWin = window.open (
		"",
		"Caricatura Museum Galerie Detail", // 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;
}