var curreent='1';
function slideshow(images){
	var total = images.length;
	document.write('<div style="background-color:#000; width:776px; height:400px; overflow:hidden" class="splash">');
	document.write('<div style="height:400px; overflow: hidden">');
	for(i=1; i<=total; i++){
		iinfo = images[i-1].split("|");
		if (iinfo[1]!=''){
			document.write('<div id="s' + i + '"><a href="' + iinfo[1] + '"><img src="/i/splash/' + iinfo[0] + '.jpg" width="776" height="400" /></a></div>');
		} else {
			document.write('<div id="s' + i + '"><img src="/i/splash/' + iinfo[0] + '.jpg" /></div>');
		}
	}
	document.write('</div>');
	document.write('<div id="splashthumbs">');
	for(i=1; i<=total; i++){
		iinfo = images[i-1].split("|");
		document.write('<div id="thumb' + i + '"><a href="#"><img src="/i/splash/' + iinfo[0] + '-s.jpg" id="ti' + i + '" /></a></div>');		
		$("#thumb" + i).click(function(){ if ('thumb' + curreent != this.id){ changesplash(this.id); } } );
		$("#ti" + i).mouseenter(function(){ if ('ti' + curreent != this.id){ $(this).fadeTo('fast', 0.8); } });
		$("#ti" + i).mouseleave(function(){ if ('ti' + curreent != this.id){ $(this).fadeTo('fast', 0.5); } });
	}
	document.write('</div></div></div>');
	
	var working = 0;
	
	$("div.splash").mouseenter(function(){
		if (working!=1){
			working=1;
			$("#splashthumbs").animate({ top: "-50px"  }, 200, function() {
				working=0;
  			});
		}
	}).mouseleave(function(){ 
		working=1;
		$("#splashthumbs").animate({ top: "-4px"  }, 200, function() {
			working=0;
  		});
	});
	changesplash('thumb1');
}

function changesplash(id){
	slideshowtimer.stop();
	slideshowtimer.start();
	for(i=1; i<=8; i++){ 
		if (document.getElementById('s'+i)){
			$('#s'+i).fadeOut('fast');
			document.getElementById('ti' + i).style.border = "0px";
			document.getElementById('ti' + i).style.margin = "1px";
			$('#ti' + i).fadeTo('fast', 0.5);
		}
	}
	a = id.split("thumb");
	curreent = a[1];
	$('#s' + curreent).fadeIn('slow');
	$('#ti' + curreent).fadeTo('fast', 1);
	document.getElementById('ti' + curreent).style.border = "1px solid #FFF";
	document.getElementById('ti' + curreent).style.margin = "0px";
}

// סכאיהרמף
var Timer = function(){  
	Timer.prototype.init = function(interValSeconds){
		this.intervalPointer = null;
		this.interValSeconds = interValSeconds*1000;
	};
	Timer.prototype.start = function(){
		this.intervalPointer  = setInterval(this.timerEvent, this.interValSeconds );
	};
	Timer.prototype.timerEvent = function(){
		var nextid = 0;
		if (curreent<slideshowarray.length) { nextid = curreent; } nextid++; 
		changesplash('thumb' + (nextid++));
	};
	Timer.prototype.stop = function(){
		clearInterval(this.intervalPointer);
	};
};
var slideshowtimer = new Timer();
slideshowtimer.init(10);
slideshowtimer.start();
