/* ---------------------------------------------------------------
   FILENAME:	lib.js
   CLIENT:		vereinfreundeskreis.ch
   PROJECT:		Website JavaScript Library
   AUTHOR:		Lucien Soltermann  lucien.soltermann@icse.ch
   HISTORY:		05-Nov-2007	Initial Coding
   REVISION:	

   Copyright © 2007 Lucien Soltermann  lucien.soltermann@icse.ch
   --------------------------------------------------------------- */

function ini() {
	if(document.getElementById) {
		SetDate();
} else {
		alert("Ihr Browser kann diese Seiten nicht richtig anzeigen\n\nLes fonctionnalitées des ces pages sont pas supportée par votre navigateur\n\nYour browser cannot display these pages properly");
	}
}

/*
function adventskonzert() {
	var x = screen.availWidth;
	var y = screen.availHeight;
	var wx = Math.floor(y / 1.417);
	var wl = Math.floor((x - wx) / 2);
	var s = "width=" + wx + ", height=" + y + ",left=" + wl + ", top=0";
//	alert(s);
//	var w5 = window.open("htm/info/infoAdventskonzert2008.html", "w5" , "width="wx", height="y",left="wl",top=0");
	var w5 = window.open("htm/info/infoAdventskonzert2008.html", w5 , s, "resizable", "scrollbars");	

};
*/
function Sichtbar() {
document.getElementById("Layer1").style.visibility = 'visible';
}
function Unsichtbar() {
document.getElementById("Layer1").style.visibility = 'hidden';
}


function iniGallery(){
		ini();
//    	loadImages(iCurrentImage);		
		firstImage();
		

}

function SetDate() {
	var n = new Date();
	var s = document.getElementById("pagdat").innerHTML;
//	var s = s.substr(0,(s.length - 4));
	document.getElementById("pagdat").innerHTML = "&copy; 2001 - " + n.getFullYear() + " Verein Freundeskreis des Werk- und Wohnhaus zur Weid - Mettmenstetten";
}


function preloadImages1() {
    var Img1;
	var s;
    for(var i=iFirstImage; i < iLastImage; i++) {
	  Img1 = new Image();
      Img1.src = sImagePath + aImages[i][0];
	  delete Img1;
    } 
}


function showImage(){
//	iImage = iFirstLoadImage + iImage;
//	alert(iCurrentImage);
	document.getElementById("image1").src = sImagePath + aImages[iCurrentImage][0];
	document.getElementById("image1").alt = aImages[iCurrentImage][1];
	document.getElementById("legend1").innerHTML = "<strong>" + aImages[iCurrentImage][2] + "</strong> ";	
//	document.getElementById("mass1").innerHTML = aImages[iCurrentImage][0];
}

function firstImage(){
		iCurrentImage=iFirstImage;
		showImage();

}

function nextImage(){
	if (iCurrentImage < iLastImage){
		iCurrentImage=iCurrentImage+1;
	}
	showImage();
}

function previousImage(){	

	if ( iCurrentImage > iFirstImage) {
		iCurrentImage=iCurrentImage-1;
		showImage();
	}
		
}

function lastImage(){
	iCurrentImage=iLastImage;
	showImage();
}



function loadImages(iLoadImage){
/*
	if  (document.getElementByID.src) {
		alert("Ihr Browser kann diese Seiten nicht richtig anzeigen\n\n");
		return;
	}
*/

	if (iLoadImage > (iLastImage - iShowThumbs)){
		iFirstLoadImage = iLastImage + 1 - iShowThumbs ;
	} else{ 	
		iFirstLoadImage = iLoadImage;
	}	
	
	if (iFirstLoadImage < iFirstImage){
		iFirstLoadImage = iFirstImage;
	}
	//load Thumbs 
	for (var i=0; i < iShowThumbs ; i++){
		var n;	
		document.getElementById("thumb"+i).src=sImagePath + "thumbs/" + getImageName(iFirstLoadImage+i);
		document.getElementById("thumb"+i).alt = aImages[iFirstLoadImage+i][1]+" "+aImages[iFirstLoadImage+i][2];
		document.getElementById("thumb"+i).name = iFirstLoadImage + i;
		document.getElementById("thumb"+i).width = aImages[iFirstLoadImage+i][3];
		document.getElementById("thumb"+i).height = aImages[iFirstLoadImage+i][4];
	}		
	
	// load Arrows
	if 	(iFirstLoadImage == 0){
		document.getElementById("arrowPrevious").src = sRootPath + "sys/img/prevdis.gif"
	} else {
		document.getElementById("arrowPrevious").src = sRootPath + "sys/img/prev.gif"
	}
	if (iFirstLoadImage >= (iLastImage + 1 - iShowThumbs)){
		document.getElementById("arrowNext").src = sRootPath + "sys/img/nextdis.gif"
	} else {
		document.getElementById("arrowNext").src = sRootPath + "sys/img/next.gif"
	}
	
}



