var includeIndexPage = true;
var automaticSlide1 = false;
var automaticSlide1After = 2000; // millisekunden

var automaticMode = false;
var timeBetweenSlides = 5000; // millisekunden

var curSlideShow = null;
var currentSlideShow = null;

var currentOptions = "";
var currentImage = 0;
var imagesToShow = new Array();
var simpleTextPage = false;
var spacingLine = false;
var controlimagesNormal = new Array();
var controlimagesOver = new Array();
var imagePath = "slideshow/images/";
var isMouseOver = false;
var clicks = 0;

var RestoreURL = "";
var RestoreHistoryLength = 0;

var buttonMode = "";


// Allgmeiner Header
if (typeof(scripts) == 'undefined') var scripts = new Object();
// ermöglicht, J-Scripts zu importieren
function ImportjsFile(jsFile)
{
	if (scripts[jsFile] != null)
		return;
	var scriptElt = document.createElement('script');
	scriptElt.type = 'text/javascript';
	scriptElt.src = jsFile;
	document.getElementsByTagName('head')[0].appendChild(scriptElt);
	scripts[jsFile] = jsFile;
}

ImportjsFile("debug.js");
ImportjsFile("browserinfo.js");
ImportjsFile("cookies.js");

// SlideShow.htm - OnLoad()
function OnLoadSlideShow()
{
	//alert("OnLoadSlideShow");

	isDebugging = (document.URL.indexOf("file:")==0);
	
	var tmp = unescape(location.search.substr(1)); // starting '?' wegnehmen.
	tmp = RestoreSlashesInURL(tmp); // Slashes der Pfade wieder reinfudeln

	ParseCommandLine(tmp);
	
	if (!simpleTextPage)
	{
		var browser = new BrowserInfo()
		/*
		if(browser.IsOpera)
		{
			
			alert("Sie verwenden Netscape 5.0(oder höher) ohne der Rendering-Engine vom Microsoft Internet Explorer.\r\n"+
				  "Dadurch fehlt zum Anzeigen dieser Photopräsentation leider ein benötigtes Feature!\r\n"+
			      "(für technisch Interessierte: iframe.document).\r\n \r\n"+
			      "Wenn möglich, schalten Sie auf die Rendering-Engine vom Internet Explorer um,\r\n"+
			      "Menupunkt: View(Ansicht) - Rendering-Engine - Display Page like InternetExplorer\r\n\r\n"+
			      "oder diese Präsentation kann leider nicht angezeigt werden!");
			
			return false;
		}
		*/
	}
	
	ReadSlideShowimages(currentSlideShow);
	
	InitializeControlimages();
	
	ShowAutomaticModeStatus();
	
	if (simpleTextPage)
	{
		ShowImageVisible("imgAutomaticMode","OFF");
		ShowImageVisible("imgPreviousSlide","OFF");
		ShowImageVisible("imgNextSlide","OFF");
	}
	if (automaticSlide1)
	{
		setTimeout(OnShowSlide1AfterTimer,automaticSlide1After);
	}

}
function OnUnLoadSlideShow()
{
}
function InitializeControlimages()
{
	if(buttonMode == "BABSI")
	{	
			imagePath = "buttons/";
			controlimagesNormal[0]	= imagePath + "imkreis.jpg";
			controlimagesNormal[1]	= imagePath + "nachlinks.jpg";
			controlimagesNormal[2]	= imagePath + "nachrechts.jpg";
			controlimagesNormal[3]	= imagePath + "back.jpg";
			controlimagesNormal[4]	= imagePath + "imkreis.jpg";

			controlimagesOver[0]	= imagePath + "imkreis.jpg";
			controlimagesOver[1]	= imagePath + "nachlinks.jpg";
			controlimagesOver[2]	= imagePath + "nachrechts.jpg";
			controlimagesOver[3]	= imagePath + "back.jpg";
			controlimagesOver[4]	= imagePath + "imkreis.jpg";
	}
	else
	{
			imagePath = "slideshow/images/";
			controlimagesNormal[0]	= imagePath + "imkreisn.png";
			controlimagesNormal[1]	= imagePath + "prvn.png";
			controlimagesNormal[2]	= imagePath + "nxtn.png";
			controlimagesNormal[3]	= imagePath + "stpn.png";
			controlimagesNormal[4]	= imagePath + "pausn.png";

			controlimagesOver[0]	= imagePath + "imkreiso.png";
			controlimagesOver[1]	= imagePath + "prvo.png";
			controlimagesOver[2]	= imagePath + "nxto.png";
			controlimagesOver[3]	= imagePath + "stpo.png";
			controlimagesOver[4]	= imagePath + "pauso.png";
	}
	var buttonIds = new Array("imgAutomaticMode","imgPreviousSlide","imgNextSlide","imgBack")
	for(i = 0; i < 4 ; i++)
	{
		image = document.getElementById(buttonIds[i]);
		image.src		= controlimagesNormal[i];
		image.lowsrc	= controlimagesOver[i];
		//alert("Setting image: " + buttonIds[i]+ ".src: " + imagePath + controlimagesNormal[i]);
	}
}

function ParseCommandLine(yCommandLine)
{
	if (yCommandLine.indexOf("?") < 0)
		currentSlideShow = yCommandLine;
	else
	{
		strArray = yCommandLine.split("?");
		currentSlideShow = strArray[0]; // liest bis vor das ? Zeichen
		RestoreURL = strArray[1];
		currentOptions = strArray[2];
		
		//alert("currentSlideShow="+currentSlideShow);
		//alert("currentOptions="+currentOptions);
		
		if (currentOptions.indexOf(":AUTO") >=0)
		{
			automaticSlide1 = true;
			automaticMode = true;
		}	
		if (currentOptions.indexOf(":TEXT") >=0)
		{
			simpleTextPage = true;
		}	

	}
}
function OnShowSlide1AfterTimer()
{
	// Starte die Geschichte zeitverzögert
	StartSlideShow();
	
	if(automaticSlide1)
	{
		setTimeout(OnAutomaticSlide1,automaticSlide1After);
	}
	if (automaticMode)
	{
		SetAutomaticModeOn();
	}
}
function Zurueck()
{
	SetAutomaticModeOff();
	if (curSlideShow != null)
	{
		window.status = "";
		if (ThisIsIExplorer())
		{
			history.go(RestoreURL);
		}
		else
		{
		
			//AddDebugInformationAboutAll();
			//AddDebugMessage("Zurueck() zu "+RestoreURL+" History.length: "+history.length);
			location.href=RestoreURL;
			//document.URL = RestoreURL;
			//goBack = Math.min(clicks,parent.history.length)-1;
			//goBack = curSlideShow.History+1;
			//parent.history.go(-goBack )
			//GoBackSteps(goBack);
		}
	}
	else
		alert("Zurueck() - curSlideShow() ist null");
}

// wird nicht verwendet !
function GoBackSteps(ySteps)
{
	for(var i=1; i<=ySteps; i++)
	{
		alert("Gone back: "+i+" of "+ySteps);
		history.go(-1);
	}
}

function ToggleAutomaticMode()
{
	if (automaticMode)
		SetAutomaticModeOff();
	else
		SetAutomaticModeOn();
}
function ShowAutomaticModeStatus()
{
	automaticLink = document.getElementById("imgAutomaticMode");
	if (automaticMode)
	{
		automaticLink.title = "automatische Diashow beenden";
		if (!isMouseOver)
		{
			automaticLink.src	= controlimagesNormal[4];
			automaticLink.lowsrc = controlimagesOver[4];
		}
		else
		{
			automaticLink.lowsrc = controlimagesNormal[4];
			automaticLink.src = controlimagesOver[4];
		}
	}
	else
	{
		secs = timeBetweenSlides/1000;
		automaticLink.title = "automatische Diashow starten (" + secs + " sec. pro Bild)";
		if (!isMouseOver)
		{
			automaticLink.src	= controlimagesNormal[0];
			automaticLink.lowsrc = controlimagesOver[0];
		}
		else
		{
			automaticLink.lowsrc = controlimagesNormal[0];
			automaticLink.src	= controlimagesOver[0];
		}
	}
}
function SetAutomaticModeOn()
{
	automaticMode = true;
	ShowAutomaticModeStatus();
	//setTimeout(OnNextSlide,timeBetweenSlides);
	OnNextSlide();
	
}
function SetAutomaticModeOff()
{
	automaticMode = false;
	ShowAutomaticModeStatus();
}
function OnAutomaticSlide1()
{
	NextImage();
}

function OnNextSlide()
{
	if (automaticMode)
	{
		NextImage();
		
		if (currentImage == curSlideShow.images.length-1) // ab jetzt würds im Kreis gehen
		{
			SetAutomaticModeOff();
		}
		else
			setTimeout(OnNextSlide,timeBetweenSlides);
	}
}
// hier bin ich im Kontext der geladenen Seite
function OnTargetLoad()
{
	/*
	//AddDebugMessage("OnTargetLoad() ....");
	if (document != null && document.URL != "")
	{
		//alert("OnTargetLoad()"+document.URL);
		curSlideShow = new SlideShow(document.URL);
		curSlideShow.ReadFromDocument();
		curSlideShow.WriteToCookie();
		curSlideShow = null;
		AddDebugMessage("OnTargetLoad() Cookie Write....");

	}
	*/
}
function OnDiaFrameLoad()
{
	/*
	AddDebugMessage("OnDiaFrameLoad():Start: ");

	var wert = HoleCookie("SLIDESPATH");
	if (wert != null) // da ist was zu lesen
	{
		AddDebugMessage("OnDiaFrameLoad(): HoleCookie: "+wert);
		curSlideShow = new SlideShow();
		curSlideShow.ReadFromCookie(); // löscht SLIDESPATH nach dem lesen
	}
	return;
	*/
	clicks++;
	
	if (ThisIsIExplorer())
	{
		diaframeX = document.diaframe;
	}
	else	
		diaframeX = document.getElementById("diaframe");
	
	//alert("OnDiaFrameLoad() document:"+document.URL );
	//alert("OnDiaFrameLoad() diaframeX:"+diaframeX );
	//alert("OnDiaFrameLoad() diaframeX.document:"+diaframeX.document );
	
	if (diaframeX != null)
	{
	    //hier andieser Stelle habe ich ein ziemliches Problem: ich darf in Mozilla auf keine Property des IFrames außer seinem 
	    //Namen zugreifen (nau, sehr supa)
		//AddDebugInformationAboutIFrame(diaframe);

		if (imagesToShow.length > 0)
		{
			//window.status = "Bild " + (currentImage+1) + "/" + imagesToShow.length + " aus:  " + currentSlideShow+"  ..."
			// hier ist das Bild schon gelesen!
				alert("OnDiaFrameLoad() imagesToShow.length > 0");
			return;
		}
		if (diaframeX.document == null && diaframe != null)
		{
			//alert("OnDiaFrameLoad() diaframe-> transformation diaframeX");
			diaframeX = diaframe;
		}
		if (diaframeX.document == null)
		{
			//alert("OnDiaFrameLoad() diaframeX.document ist null!(return)");
			return;
		}
		if (diaframeX.document.URL == "about:blank")
		{
			// dieser Fehler kommt im IE wenn das erste Mal das FrameLoad durchlaufen wird.
			//alert("OnDiaFrameLoad() diaframeX.document ist about.blank(return)!");
			return;
		}
		if (curSlideShow == null)
		{
			//alert("OnDiaFrameLoad() curSlideShow ist noch nicht gesetzt!");
			curSlideShow = new SlideShow("");
			curSlideShow.ReadFromDocument(diaframeX.document);
			//curSlideShow.AddDebugInformation();
		}
		else
		{
			//alert("OnDiaFrameLoad() curSlideShow ist schon gesetzt!");
	 		var docurl = NormalizeURL(diaframeX.document.URL);
 	 		
	  		// zuerst finde die URL im Array
	 	 	for(var i = 0; i < curSlideShow.ImageCount; i++)
	 	 	{
 	 			var imgurl = NormalizeURL(curSlideShow.images[i]);
				//alert("OnClickOnSlideThumbNail() Find: " + docurl + " == "+imgurl);
 	 		 	if (docurl == imgurl)
 	 		 	{
  			 		curSlideShow.CurrentImage = i;
  			 		return;
  			 	}
  			}
		}

		/*
		//alert("OnDiaFrameLoad() Start Loading images from: " + diaframe.document.URL);
		currentImage = -1 // weil steht auf der nicht inder Liste befindlichen Indexpage
		imagesToShow = new Array();
	
		for(i=0; i< diaframe.document.links.length; i++)		
		{
			//alert("Lese Image:" + tmpWindow.document.links[i].href);
			imagesToShow[i] = diaframe.document.links[i].href;
		}
		if (includeIndexPage)
		{
			imagesToShow[imagesToShow.length] = diaframe.document.URL;
			currentImage = imagesToShow.length-1;
		}
		//alert(yDocument.links.length + " images von: " + yDocument.location.href + " gelesen!");

		// alert("OnFrameLoad() Loaded images: " + imagesToShow)
		// diaframe.navigate(imagesToShow[0]);
		*/
		
	}
	else
	{
		alert("OnDiaFrameLoad() - diaframe ist null!");
	}
}

// versteck oder zeigt ein Image(Contro) wieder an
function ShowImageVisible(yImageID,yStatus)
{
	image = document.getElementById(yImageID);
	//alert("versuche, Image: " + image.id + " zu verstecken ...");
	if (yStatus == "OFF")
		image.width = 0;
	else
		image.width = 31;

}
function SwapImage(yImageID)
{
	isMouseOver = !isMouseOver;
	
	image = document.getElementById(yImageID);
	if (image != null)
	{
		img = image.src
		image.src = image.lowsrc;
		image.lowsrc = img;
	}
}
function StartSlideShow()
{
	if (curSlideShow != null)
		curSlideShow.StartSlideShow();
	else
		alert("StartSlideShow() - curSlideShow() ist null");
	
}
function PreviousImage()
{
	if (curSlideShow != null)
		curSlideShow.PreviousSlide();
	else
		alert("PreviousImage() - curSlideShow() ist null");

}
function NextImage()
{
    clicks++;
	if (curSlideShow != null)
		curSlideShow.NextSlide();
	else
		alert("NextImage() - curSlideShow() ist null");
}
function ReadSlideShowimages(yDokumentURL)
{
	imagesToShow = new Array();
	currentSlideShow = yDokumentURL;

	if (document != null)
	{
		diaframeX = document.getElementById("diaframe")
		if (diaframeX != null)
		{
			//alert("LoadSlideShow() diaframe.Navigate to: " + yDokumentURL);
			//diaframe.navigate(yDokumentURL);
			//diaframeX.location = yDokumentURL;
			diaframeX.src = yDokumentURL;
			//document.getElementById("diaframe").src = yDokumentURL;
			// hat zurfolge, daß im SlideShow.htm ein diaframe.OnLoad ausgelöst wird. ->
			// s.o. OnDiaFrameLoad()
		}
		else
			alert("LoadSlideShow(): diaframe is null!");
			
	}
	else
		alert("LoadSlideShow() für : " + yDokumentURL + " kein dokument gefunden!");
}
//
// merkt sich den State aller Frames fürs Zurück, muß im Onload dann RestoreURLInFrame aufrufen
//
function LoadSlideShowAndSaveFrameURLs(yURL)
{
	//AddDebugInformationAboutWindow();
	//alert("LoadSlideShowAndSaveFrameURLs()");
	
	var theframe = window.window;
	if (theframe != null)
	{
		//alert("SetzeCookie(window.window):"+theframe.name+"LastURL: "+theframe.document.location);
		this.SetzeCookie(theframe.name+"LastURL",theframe.document.location);
	}
	
	for (i = 0; i < window.frames.length; i++) 
	{
		var theframe = window.frames[i];
		if (theframe != null)
		{
			//alert("SetzeCookie():"+theframe.name+"LastURL: "+theframe.document.location);
			this.SetzeCookie(theframe.name+"LastURL",theframe.document.location);
		}
	}
	
	this.LoadSlideShow(yURL);
}
//
// verwenden um den State eines Frames wiederherzustellen
//
function RestoreURLInFrame(yFrameName)
{

	var theframe = document.getElementById(yFrameName);
	if (theframe != null)
	{
		var lastURL = HoleCookie(theframe.name+"LastURL")
		if (lastURL != null)
		{
			//alert("RestoreURLInFrame():"+lastURL);

			theframe.src = lastURL;
			this.LoescheCookie(theframe.name+"LastURL");
		}
		//else
		//	alert("RestoreURLInFrame(): Frame"+yFrameName+" LastURL ist null!");

	}
	//else
	//	alert("RestoreURLInFrame(): Frame"+yFrameName+" gibts nicht!");
}

//
// Spezialfunktion für reine Textseiten, wo keine Imageliste ausgelesen werden braucht.
//
function LoadTextPage(yDokumentURL)
{
	LoadSlideShow(yDokumentURL,":TEXT");
}
//
// lädt eine Diaschau unter der angegeben URL in das SlideShow-Control(SlideShow.htm) und 
// start den Krempel  
//
function LoadSlideShow(yDokumentURL,yOptions) // into mainframe
{
	//AddDebugInformationAboutWindow();
	
	if (window.parent.name == "mainframe")
		currentMainFrame = window.parent;
	else if (window.parent.name == "")
		currentMainFrame = window.parent;
	else if (window.self.name == "mainframe")
		currentMainFrame = window.self;
	else
		currentMainFrame = null;
	
	if (currentMainFrame != null)
	{
		//parentDocument = currentMainFrame.parent.document;
		//mainControl = parentDocument.getElementById("lnkMainSlideControl");
		//mainControl.href = yDokumentURL;
		//mainControl.alt = yOptions;
		RestoreURL = currentMainFrame.location;
		// die folgnende Geschichte für den Opera-Browser, der nämlich auf Slashes im
		// string allergisch reagiert. deswegen zuerste verstecken, unf im OmLoadSlideShow wieder restaurieren 
		var startSlideShowCommand = "slideshow.htm?"
		startSlideShowCommand += escape(yDokumentURL)+"?"
		startSlideShowCommand += escape(RestoreURL )+"?"
		startSlideShowCommand += escape(yOptions);
		
		startSlideShowCommand = HideSlashesInURL(startSlideShowCommand);
		
		currentMainFrame.location = startSlideShowCommand;

		if (isDebugging)
		{
			//AddDebugInformationAboutIFrame(currentMainFrame)
			//diaframe = document.getElementById("diaframe")
			//AddDebugMessage("diaframe="+diaframe.name)
		}
	}
	else
	{
		alert("für Diashow: " + yDokumentURL + " kein mainFrame gefunden!");
	}
	
}
function RestoreSlashesInURL(str)
{
	return replaceCharacters(str,"_","/");
}

function HideSlashesInURL(str)
{
	return replaceCharacters(str,"/","_");
}
function replaceCharacters(conversionString,inChar,outChar)
{
  var convertedString = conversionString.split(inChar);
  convertedString = convertedString.join(outChar);
  return convertedString;
}
/*
function OnMainFrameLoad()
{
	mainframe = document.getElementById("mainframe")
	
	if (mainframe != null)
	{
		//alert("nach dem OnMainFrameLoad:" + mainframe.document.title);
		if (mainframe.document.title == "SlideShow")
		{
			// wir sind also gerade dabei einen SlideShow reinzuziehen ...
			// hol dir das Control parallel zu mainframe, in das die URL eigetragen wurde
			parentDocument = mainframe.parent.document;
			mainControl = parentDocument.getElementById("lnkMainSlideControl");
			//alert(mainControl.href);
			// und übertrags in
			//slideControl = mainframe.document.getElementById("lnkSlideShowControl")
			//slideControl.href = mainControl.href;
			//slideControl.alt = mainControl.alt;
			
			//LoadSlideShow(mainframe.document,"buch/bauchimkopf.htm")
			
		}
	}
	else
		alert("OnMainFrameLoad(): mainframe is null!");

}
*/
function TestIt()
{
	if (curSlideShow != null)
		curSlideShow.AddDebugInformation();
	else
		AddDebugMessage("curSlideShow ist null!");
}
//
// als EIN objekt weil mir sonst der Cookie speicher ausgeht!
// der ist: MAX 20 Stück Variablen und MAX 4KB
//
function SlideShow(yDocumentURL)
{
	this.images = new Array();
	this.StartHistory = history.length;
	this.History = 1;
	this.ImageCount = 0;
	this.CurrentImage = 0;
	this.URL = "";
	if (yDocumentURL != null && yDocumentURL != "")
		this.URL = yDocumentURL;
	
	// Methoden definition
	//this.AddSlide = AddSlide;
	this.GetCurrentSlide = SlideShowGetCurrent;
	this.WriteToCookie = SlideShowWriteToCookie;
	this.ReadFromCookie = SlideShowReadFromCookie;
	this.ReadFromDocument = SlideShowReadFromDocument;
	
	this.StartSlideShow = SlideShowStart;
	this.PreviousSlide = SlideShowPrevious;
	this.NextSlide = SlideShowNext;
	this.ShowCurrentImage = SlideShowShowCurrentImage;
	
	this.AddDebugInformation = AddSlideShowDebugInformation;
}
/*
function AddSlide(yImageURL)
{
	var imageFile  = GetFileName(yImageURL); // das letzte gewinnt!
	this.ImagePath = GetBasePath(yImageURL);
	this.images[this.ImageCount++] = imageFile;
}
*/
function SlideShowGetCurrent()
{
	return this.images[this.CurrentImage];
}
function SlideShowReadFromDocument(yDocument)
{
	this.CurrentImage = -1 // weil steht auf der nicht in der Liste befindlichen Indexpage
	this.URL = yDocument.URL;
	this.images = new Array();
	// wenn die Seite kein Bilder erlaubt -> tu gar nix(kann bei about:blank sein o.ä.)
	if (yDocument.links.length == 0)
	{
		//alert("OnDiaFrameLoad() diaframe.document "+ diaframe.document.URL + " enthält keine Links/ bzw Bilder!");
		//AddDebugInformationAboutDocument(diaframe.document)
	}
	else
	{
		for(i = 0; i < yDocument.links.length; i++)
		{
			//AddDebugMessage("images "+i+" auslesen: "+document.links[i].href);
			// NICHT MEHR: this.AddSlide(document.links[i].href);
			window.status = "Bild " + (i+1) + "/" + this.images + " aus:  " + this.URL+"  ..."
			this.images[this.ImageCount++] = yDocument.links[i].href;
		}
		if (includeIndexPage)
		{
			this.images[this.ImageCount] = yDocument.URL;
			this.ImageCount++;
			this.CurrentImage = this.ImageCount-1; // gleich auf diese Page positionieren
		}
	}
	window.status = "Slideshow(©jak).Showing: ["+this.URL+"]" + " Step:("+history.length+")";

}
function SlideShowStart()
{
	this.History --;
	this.currentImage = 0;
	this.ShowCurrentImage(currentImage);
}
function SlideShowPrevious()
{
	if (this.CurrentImage > 0)
		this.CurrentImage--;
	else
		this.CurrentImage = this.ImageCount-1;
		
	this.ShowCurrentImage();

}
function SlideShowNext()
{
	if (this.CurrentImage < this.ImageCount-1)
		this.CurrentImage++;
	else
		this.CurrentImage = 0;
	
	this.ShowCurrentImage();
}
function SlideShowShowCurrentImage()
{
	//alert("SlideShowShowCurrentImage"+this.GetCurrentSlide());
	diaframe = document.getElementById("diaframe");
	if (diaframe != null)
	{
		this.History ++;
		document.getElementById("diaframe").src = this.GetCurrentSlide();
		window.status = "Slideshow(©jak).Showing: ["+curSlideShow.GetCurrentSlide()+"]";
			
	}
	else
		alert("ShowImage(): diaframe is null!");
}
function SlideShowWriteToCookie()
{
	SetzeCookieOnPath("SLIDESPATH",this.URL);
	SetzeCookieOnPath("SLIDESCOUNT",this.ImageCount);
	
	var imagestr = ""
	for(var i = 0; i < this.ImageCount; i++)
	{
		 imagestr += (imagestr != "" ? "?" : "") + this.images[i];
		 
	}
	SetzeCookieOnPath("SLIDES",imagestr);
}
function SlideShowReadFromCookie()
{
	this.images = new Array();
	var url = HoleCookie("SLIDESPATH"); // wenn die SlideShow was hat, dann zumindsest eine URL
	if (url != null)
	{ 
		this.URL = url;
		this.ImageCount = parseInt(HoleCookie("SLIDESCOUNT"));
		var imgArray = HoleCookie("SLIDES").split("?");
		for(var i = 0; i < this.ImageCount; i++)
		{
			this.images[i] = imgArray[i];
		}
	}
	LoescheCookieOnPath("SLIDESPATH");
}

function GetBasePath(yUrl)
{
	yUrl = UnBackslash(yUrl);
	var i = yUrl.lastIndexOf("/");
	if (i >= 0)
	  return yUrl.substr(0,i)+"/"; // inclusive '/'
	else
	  return "";  
}
function GetFileName(yUrl)
{
	yUrl = UnBackslash(yUrl);
	var i = yUrl.lastIndexOf("/");
	if (i >= 0)
	  return yUrl.substr(i+1); // exclusive '/'
	else
	  return yUrl;  
}
function UnBackslash(str)
{
	while(true)
	{
		var i = str.indexOf("\\");
		if (i >=0)
		  str = str.substr(0,i) + "/" + str.substr(i+1);
		else
			break;  
	}
	return str;
}
function NormalizeURL(str)
{
	// alle \ -> /
	while (str.indexOf("\\") >= 0)
		str = str.replace("\\","/");
	// alle "///" -> "//"
	while (str.indexOf("///") >= 0)
		str = str.replace("///","//");
	
	return str;
}
function AddSlideShowDebugInformation()
{
	if (!isDebugging)
		return;
		
	AddDebugMessage("Current SlideShow: ("+document.title+")--------------------");
	AddDebugMessage("HistoryCount="+this.History);
	AddDebugMessage("URL="+this.URL);
	AddDebugMessage("CurrentImage="+this.CurrentImage);
	AddDebugMessage("ImageCount="+this.ImageCount);
	
	for(var i = 0; i < this.ImageCount; i++)
	{
		AddDebugMessage("SLIDE"+i+"="+this.images[i]);
	}
}
