/* 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
orangeSlides = {
	displayTime: 4000, //in milliseconds
	playbackMode: 0, //0 = pause, 1 = play
	transitionSpeed: 'normal', //'fast', 'normal', 'slow' or milliseconds
	currentSlide: 1,
	playSymbol: 'Play',
	pauseSymbol: '<img src="images/tiny_red.gif" border="0" /> Pause',
	containerId: '#slide'
};
//getting the data (JSON)
data = '["<a href=../investments.php target=_top><img src=../img/sliderlogos/AHT.gif /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/artifacts.gif /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/bioklogo.gif /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/Biodiesel.jpg /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/bks.jpg /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/elmarco.jpg /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/fourtelecom.jpg /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/IFE.gif /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/lmf.gif /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/schiebel.gif /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/vst.gif /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/yxlon.gif /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/zach.jpg /></a>",'
+ '"<a href=../investments.php target=_top><img src=../img/sliderlogos/zima.gif /></a>"]';
slides = eval(data);

orangeSlides.init = function(number){
	$("#all_slides").html(slides.length);
	this.first();
	//this.togglePlayback();
	//document.write(slides.length);
};
orangeSlides.go = function(number){
	if(this.currentSlide+number <= slides.length && this.currentSlide+number > 0){
		this.currentSlide = this.currentSlide+number;
	}
	/*
	if(this.currentSlide-1 > slides.length){
     this.go(eval('-'+this.currentSlide)+1);
	}
	if((this.currentSlide+number <= 0)||(this.currentSlide == (slides.length-1))){
		this.currentSlide = (slides.length);
	}
	if(this.currentSlide+number == (slides.length)){
		this.currentSlide = (slides.length);
	}
	*/
	$(this.containerId).fadeOut(this.transitionSpeed, function(){
			$(orangeSlides.containerId).html(slides[orangeSlides.currentSlide-1]).fadeIn(this.transitionSpeed);
			$("#current_slide").html(orangeSlides.currentSlide);
	});
};

orangeSlides.first = function(){
	this.go(eval('-'+this.currentSlide)+1);
};

orangeSlides.last = function(){
	this.go(slides.length-this.currentSlide);
};
/*
orangeSlides.play = function(){
		if(this.currentSlide < slides.length){
			this.playbackTimeout = setTimeout('orangeSlides.go(1)',this.displayTime);
		}else{
			this.playbackTimeout = setTimeout('orangeSlides.first()',this.displayTime);
		}
		this.playbackTrigger = setTimeout('orangeSlides.play()',this.displayTime);
};
orangeSlides.togglePlayback = function(){
	if(this.playbackMode==1){
		this.play();
		$("#switch").html(this.pauseSymbol); // pause symbol
		this.playbackMode=0;
	}else{
		$("#switch").html(this.playSymbol); // play symbol
		clearTimeout(this.playbackTimeout);
		clearTimeout(this.playbackTrigger);
		this.playbackMode=1;
	}
};
*/
//init
$(document).ready(function() {
	orangeSlides.init();
});