/* ****************************TripAgent Template*******************************
File:				gallery.js

Copyright:			2008 theThinkery
Homepage: 			http://www.thethinkery.net
Version: 			1.1                 
License:			GNU/GPL http://www.gnu.org/copyleft/gpl.html
***TripAgent based on EstateAgent Improved by Manos Orfanoudakis http://www.eaimproved.eu***
*************************************************************************** */

function EAGallery(cp,pa) {

	this.currentPic	= cp;
	this.picamount	= pa;
	this.highlight		= new Array("#C64934","#FFFFFF");
	this.slideshow	= 1;
	this.speed			= 5000;
		
	// Gallery Methods
	this.firstPic		= firstPic;
	this.lastPic		= lastPic;
	this.nextPic		= nextPic;
	this.previousPic = previousPic;
	this.showPic		= showPic;
	this.mark			= mark;
	this.startSls		= startSls;
	this.stopSls		= stopSls;
	this.slowerSls	= slowerSls;
	this.fasterSls		= fasterSls;
	
}

function mark(p,c){
	var e = document.getElementById(p);
    e.style.borderColor = this.highlight[c];
}

function firstPic(){
	this.currentPic = 1;
	this.showPic();
}

function lastPic(){
	this.currentPic = this.picamount;
	this.showPic();
}

function previousPic(){
	if(this.currentPic == 1){
		alert("First picture reached!");
	}
	else{
		this.currentPic = this.currentPic -1;
		this.showPic();
	}
}

function nextPic(){	
	if(gl.slideshow == 0){
		if(this.currentPic == this.picamount){
			alert("Last picture reached!");
		}
		else{
			this.currentPic = this.currentPic +1;
			this.showPic();
		}
	}
	else{
		if(gl.currentPic == gl.picamount){
			gl.currentPic = 1;
		}
		else{
			gl.currentPic = gl.currentPic +1;
		}
		sp = gl.speed;			
		setTimeout("showPic()",sp);
	}
}

function startSls(){
	this.slideshow = 1;
	this.showPic();
}

function stopSls(){
	this.slideshow = 0;
}

function slowerSls(){
	if(this.speed < 10000) {
    	this.speed	+= 1000;
    }
    else{
    	alert("Slowest Speed Reached!");
    }
}

function fasterSls(){
	if(this.speed > 1000) {
    	this.speed	-= 1000;
    }
    else{
    	alert("Fastest speed reached!");
    } 
}

function showPic(){		
	var img = eval('document.images[\'eaimage\']');
	
	if(gl.slideshow == 0){
		nr = this.currentPic;
		img.src = pic[nr].picpath + pic[nr].name + pic[nr].type;
	}
	else{
		nr = gl.currentPic;
		img.src = pic[nr].picpath + pic[nr].name + pic[nr].type;
		gl.nextPic();
	}
}

function EAImage(pp,t,d,fn,tp) {			
    this.picpath		= pp;
    this.title				= t;
    this.description	= d;
    this.name 			= fn;
    this.type			= tp;		
}


