/* ---------------------------------------------------------------
   FILENAME:	lib.js
   CLIENT:		STELLA MATUTINA
   PROJECT:	Website JavaScript Library
   AUTHOR:	Lucien Soltermann  lucien.soltermann@icse.ch
   HISTORY:	25-Sep-2007 Initial Coding
   REVISION:	

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

if(top == self) sfc(unescape(window.location.pathname));
//if(top == self) sfc(window.location.href);

function sfc(MyPag) {
	document.writeln('<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">');
	document.writeln('<HTML>');
	document.writeln('<HEAD>');
	document.writeln('<TITLE>Stella Matutina</TITLE>');
	document.writeln('<META http-equiv=\"Content-Type\" CONTENT=\"text/html; charset=ISO-8859-1\">');
	document.writeln('</HEAD>');
	document.writeln('<FRAMESET COLS=\"180,*\" FRAMEBORDER=\"NO\" BORDER=\"0\" FRAMESPACING=\"0\">');
	document.writeln('    <FRAME SRC=\"../../../../sys/htm/left.html\" NAME=\"sm_left\" MARGINWIDTH=\"0\" MARGINHEIGHT=\"0\" SCROLLING=\"NO\">');
	document.writeln('    <FRAMESET ROWS=\"78,*\" FRAMEBORDER=\"NO\" BORDER=\"0\" FRAMESPACING=\"0\">');
	document.writeln('        <FRAME SRC=\"../../../../sys/htm/head.html\" NAME=\"sm_head\" MARGINWIDTH=\"0\" MARGINHEIGHT=\"0\" SCROLLING=\"NO\">');
	document.writeln('        <FRAME SRC=\"' + MyPag + '\" NAME=\"sm_main\" MARGINWIDTH=\"0\" MARGINHEIGHT=\"0\">');
	document.writeln('    </FRAMESET>');
	document.writeln('</FRAMESET>');
	document.writeln('</HTML>');
	top.sm_main.location.href = MyPag;
}

function ini() {
	if(document.getElementById) {
		SetDate();
} else {
		alert("Your browser is not able to present this pages correctly\n\n");
	}
}

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

}

function SetDate() {
	var n = new Date();
	var s = "&copy; SVS Zurich " 		// Copyright Title
	var c = 2003 							// Creation Date of Site (Start of Copyright)
	if (n.getFullYear() > c){
		document.getElementById("pagdat").innerHTML = s + c +" - " + n.getFullYear();
	}else{
		document.getElementById("pagdat").innerHTML = s +  n.getFullYear();
	}
}


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]+" "+aImages[iCurrentImage][1];

	document.getElementById("legend1").innerHTML = aImages[iCurrentImage][1];	
//	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"
	}
	
}

