/* orangeSlides
 * Creates slideshow like presentations with jQuery
 *
 * @author David Bongard  (mail@bongard.net | www.bongard.net)
 * @version 0.9 - 20070601
 * @licence  http://www.opensource.org/licenses/mit-license.php MIT License
 *
 * Copyright (c) 2007 David Bongard
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

//configuration
browseDiv = {
	displayTime: 4000, //in milliseconds
	playbackMode: 0, //0 = pause, 1 = play
	transitionSpeed: 'fast', //'fast', 'normal', 'slow' or milliseconds
	currentDiv: 1,
	playSymbol: 'Play',
	pauseSymbol: 'loading...',
	containerId: '#images'
};
//getting the data (JSON)
data = '["<h2>Welcome to orangeSlides!</h2><p>Please use the &quot;Next&quot; button below to switch to the second slide!</p>",'
+ '"<h2>Possibilities:</h2><p>Show more than just pictures!<br/>Each slide displays pure XHTML-markup.</p><p>Use it for content-splitting, presentations or even complete image-galleries...</p><p><a href=\\"javascript:orangeSlides.go(1);\\">Next slide &gt;&gt;</a></p>",'
+ '"<h2>Discover more:</h2><p>Click <a href=\\"javascript:orangeSlides.togglePlayback();\\">here</a> to start auto-playback or  use the large button below to toggle playback.</p>",'
+ '"<h2>Another slide...</h2>","<h2>... and a last one.</h2>"]';
slides = eval(data);

browseDiv.init = function(number){
	$("#images > div").hide();
	imgsTotal = $(browseDiv.containerId).find('div'); 
	//alert(imgsTotal.length);
	$("#all_div").html(imgsTotal.length); // zaehler

	this.first();
};

browseDiv.go = function(number){
	
  $("#images div#img_" + this.currentDiv + "").hide(); 
	if(this.currentDiv+number <= imgsTotal.length && this.currentDiv+number > 0){
		this.currentDiv = this.currentDiv+number;
	}else{
	
		this.currentDiv = 1;
	}
	
	//$(this.containerId).fadeOut(this.transitionSpeed, function(){
	  $("#images div#img_" + this.currentDiv + "").fadeIn("slow"); 
		//$(browseDiv.containerId).html(imgsTotal[browseDiv.currentDiv-1]).fadeIn(this.transitionSpeed);
		$("#current_div").html(browseDiv.currentDiv);
//	});
  };
  
browseDiv.first = function(){
    $("#images div#img_" + this.currentDiv + "").fadeIn("slow"); 
};
  
browseDiv.last = function(){
	 this.go(slides.length-this.currentDiv);
  }

//init
$(document).ready(function() {
	browseDiv.init();
});

