// JavaScript Document

//****image preloader????
var sliderwidth="92px" //Specify the slider's width (in pixels)
var sliderheight="300px" //Specify the slider's height
var slidespeed=1 //Specify the slider's slide speed (larger is faster 1-10)
slidebgcolor="#E5DCCC" //configure background color

var nPic=52;		//nr de poze din baza de date


var imagegap='<img src="images/spacer.gif" width="1" height="5"><br>' //Specify gap between each image (use HTML):
var slideshowgap=0 //Specify pixels gap between each slideshow rotation (use integer):


var copyspeed=slidespeed

var lefttime


var iedom=document.all||document.getElementById
/*if (iedom)
	document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-9000px;left:-100px">'+leftrightslide+'</span>')
*/
var actualheight=435
var ns_slide
var cross_slide
var cross_slide2
var rand_pic

function put0(pic) {
	if (pic>99) return pic;
	if (pic>9) return '0'+pic;
	return '00'+pic;
}

function get_rand() {
	rand_pic=new Array()
	var x, xr, rand_dif
	for (x=0; x<=4; x++) rand_pic[x]=0
	for (x=0; x<=4; x++) {
		rand_dif=0;
		while (rand_dif==0) {
			xr = Math.round(Math.random()*(nPic-1))
			rand_dif=1;
			for (y=0; y<=4; y++)
				if (rand_pic[y]==(xr+1)) rand_dif=0;
			}
		rand_pic[x]=xr+1;
		}
}



function fillup(slide_no){
	if (iedom){
		var leftrightslide=new Array() //Specify the slider's images

		get_rand();
		//alert(rand_pic);
		for (var x=0; x<=4; x++) {			//???void() nu e suportat de opera?
					leftrightslide[x]='<a href="javascript:void()"><img style="border:1px solid #8B95A2" src="pictures/gobelin/g' +put0(rand_pic[x])+ '.gif" width="80" height="80" onClick="fjs(event)"></a><br>'
		}
		
		//leftrightslide='<br>'+leftrightslide.join(imagegap)+'</br>'
		leftrightslide=leftrightslide.join(imagegap) //creare ..
		
		if (slide_no==1) cross_slide.innerHTML=leftrightslide
		if (slide_no==2) cross_slide2.innerHTML=leftrightslide
		}
	}


var ysl=1;	time_out=30;time_out2=1;
function slideleft(){
	if (iedom){
	/*
	ysl++;
	if (ysl>40) ysl=0;
if (ysl<20)	{time_out=30} else {time_out=30}*/

//if (time_out<0) {copyspeed=0;}

		if (parseInt(cross_slide.style.top)>(actualheight*(-1)+8)) {
			cross_slide.style.top=parseInt(cross_slide.style.top)-copyspeed+"px"
			}
		else {
			cross_slide.style.top=parseInt(cross_slide2.style.top)+actualheight+slideshowgap+"px"
			fillup(1);
//					copyspeed=slidespeed;
			}
		if (parseInt(cross_slide2.style.top)>(actualheight*(-1)+8)) {
			cross_slide2.style.top=parseInt(cross_slide2.style.top)-copyspeed+"px"
			}
		else {
			cross_slide2.style.top=parseInt(cross_slide.style.top)+actualheight+slideshowgap+"px"
			fillup(2);
			}
			
		//Temporizare la oprire
		if (time_out!=30) {time_out=time_out+(time_out-30)}
		if (time_out>90) {copyspeed=0}
		
		setTimeout("slideleft()",time_out)
		}
	}	

function startscroll() {
	if (iedom||document.layers){
		with (document){

			if (iedom){
				write('<div style="position:relative;width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden">')
				write('<div style="position:absolute;width:'+sliderwidth+';height:'+sliderheight+';background-color:'+slidebgcolor+'" onMouseover="time_out++" onMouseout="copyspeed=slidespeed;time_out=30">')
				write('<div id="test2" style="position:absolute;left:5px;top:0px"></div>')
				write('<div id="test3" style="position:absolute;left:5px;top:0px"></div>')
				
				write('<div style="position:absolute;left:0px;top:0px"><img src="images/scroll.gif" width="136" height="20"></div>')
				write('<div style="position:absolute;left:0px;top:280px"><img src="images/scroll2.gif" width="136" height="20"></div>')
				write('</div></div>')
			
				cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
				cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
				}
			}
		}
	
	fillup(1)
	fillup(2)
	cross_slide2.style.top=actualheight+slideshowgap+"px"
//	lefttime=setInterval("slideleft()",30)
slideleft();
}


