function SlideShow() {
	var this1 = this;
	logit("start SlideShow");

	this1.randMenu 		= null;				// RandMenu object
	this1.nextPic 		= null;				// NextPic object
	this1.mapDisplay  = null;				// mapDisplay object
	var borderColorSaved = "#00CCFF";	// Original border Color before pause
	
	var startshow   = true;
	
	this1.nextPic 		= new NextPic();
	this1.randMenu   	= new RandMenu();
	logit("displaysize:"+this1.nextPic.displaySize);
	
	this1.stop = function() {
		startshow = false;
		this1.randMenu.stop();
	}
	this1.start = function() {
		startshow = true;
		this1.randMenu.start();
	}
	this1.setWidthHeight = function(width,height) {
		this1.nextPic.setWidthHeight(width,height);
	}
	this1.stoppit = function() {
	}
	
	this1.randMenu.trigger 			= trigger_func;
	this1.randMenu.cb_key 			= function(key) {
		logit("key from randMenu:"+key);
		switch(key) {
			case 107:
			this1.nextPic.def_fade_speed += 250;
			if (this1.nextPic.def_fade_speed > 2000) {this1.nextPic.def_fade_speed = 2000;}
			logit("new fade speed:"+this1.nextPic.def_fade_speed);
			break;
			case 109: 
			this1.nextPic.def_fade_speed -= 250;
			if (this1.nextPic.def_fade_speed < 0) {this1.nextPic.def_fade_speed = 0;}
			logit("new fade speed:"+this1.nextPic.def_fade_speed);
			break;
			case 27: /* escape */
			this1.stoppit();
			break;
			default:
			logit("key pressed:"+key);
		}
	}
	this1.nextPic.onready = onready_func;
	if (this1.nextPic.displaySize != 'thumb') {
		this1.mapDisplay 	= new MapDisplay();
		this1.randMenu.showMap = function() {this1.mapDisplay.show(this1.nextPic.pic.point,this1.nextPic.pic.imagethumb,this1.nextPic.pic.pictext,this1.nextPic.pic.fileName);}
		this1.randMenu.showPic  		= this1.mapDisplay.release;
		$("#map_canvas2").hide();
		$("#randomTumb").hide();
		this1.nextPic.changestatus = function() {
			logit('nextPic.changestatus:'+this1.nextPic.statuscd);
			switch (this1.nextPic.statuscd) {
		  case "loading":
		    this1.randMenu.setconsole("running.",true);
		    //this1.randMenu.mapAvail(false);
		    break;
		  case "received":
		    this1.randMenu.setconsole("running..",true);
				if (this1.nextPic.pic.point.lat != null) {
					this1.randMenu.mapAvail(true);
				} else {
					this1.randMenu.mapAvail(false);
				}
		    break;
		  case "error":
		    this1.randMenu.setconsole("not found...",false);
		    break;
		  case "notfound":
		    this1.randMenu.setconsole("not found...",false);
		    break;
		  case "swapped":
		    this1.randMenu.setconsole("running...",true);
				$('#imageMap1').attr("src",this1.nextPic.pic.geomap.src);
		    break;
		  case "ready":
		    this1.randMenu.setconsole("running",true);
		    this1.randMenu.currentFileName = this1.nextPic.pic.fileName; 
		    break;
		  default:
		    break;
			}
		}
	}		

 	if (this1.nextPic.displaySize == 'thumb') {
		this1.randMenu.cb_pauseOn = function() {
			logit("set border to pause on");
			borderColorSaved = $(".borderThumb").css("border-color");
			$(".borderThumb").css("border-color","#FF0000");
		};
		this1.randMenu.cb_pauseOff = function() {
			logit("set border to pause off");
			//$(".borderThumb").css("border","1px solid #00CCFF");
			$(".borderThumb").css("border-color",borderColorSaved);
		};
	}
 	if (this1.nextPic.displaySize == 'popupslide') {
		this1.randMenu.cb_pauseOn = function() {
			logit("set border to pause on");
			//$(".borderPopupslide").css("border","2px solid #FF0000");
			borderColorSaved = $(".borderPopupslide").css("border-color");
			$(".borderPopupslide").css("border-color","#FF0000");
		};
		this1.randMenu.cb_pauseOff = function() {
			logit("set border to pause off");
			//$(".borderPopupslide").css("border","2px solid #00CCFF");
			$(".borderPopupslide").css("border-color",borderColorSaved);
		};
	}

	Shadowbox.init({
		onClose: function(currentElement) {
			this1.randMenu.pauseOff();
			this1.randMenu.ready();
			//onpauseoff_func();
		},
		onOpen: function(currentElement) {
			this1.randMenu.pauseOn();
			//onpauseon_func();
    }
 	});

	function trigger_func(func) {
		logit('trigger_func');
		repeatPic(func);
	}
	function onready_func() {
		logit('onready_func:'+this1.nextPic.statuscd);
		this1.randMenu.ready();
	}
	
	function repeatPic(func) {
		logit("repeatPic="+this1.randMenu.pause+'/'+func);
	  
	  this1.nextPic.getfunc 		= func;
	  this1.nextPic.getcountryIso 	= this1.randMenu.selcountry;
	  this1.nextPic.getkeywords = this1.randMenu.selkeyword;
		this1.nextPic.get();
	}
	function logit(text) {
		logitAll("SlideShow-"+text);
	}
	repeatPic('last');   // get first picture => last stored in cookie
}
