var ie = (document.all) ? 1 : 0;
var p = (ie) ? "filter" : "MozOpacity";

/* n is the element node
   v is the opacity value, from 0 to 100. */

function opac(n,v){
	n.style.opacity = v;
	if(ie) {
		v = (ie) ? "alpha(opacity="+v*100+")" : v/100;
		n.style[p] = v;
	}
}

var slidet = 0;
var slidex = 0;
var slideo = 0;
var slidem = 3;
var slide_caption = new Array;
var slide_move = new Array;
var slidetimeout = 300;
var slideshow_top = 0;

slide_caption[1] = "Quality Conveyancing";
slide_caption[2] = "Contact Us Today";
slide_caption[3] = "Peace of Mind";

slide_move[1] = 0;
slide_move[2] = 1;
slide_move[3] = -1;

var cslidex = 0;

var slideshowid = new Array;

function doevents() {
	if(slidet==0) {
		document.getElementById('slideshowbg').style.backgroundImage = "none";
		slidex++;
		if(slidex>slidem) slidex = 1;
		slideo = 0;
		var pslidex = cslidex;
		do {
			cslidex = Math.ceil(3*Math.random())
		} while(pslidex==cslidex);
		//document.getElementById('slideshow').style.opacity = slideo;
		opac(document.getElementById('slideshow'), slideo);
		document.getElementById('slideshow').style.backgroundImage = "url('slideshow/"+cslidex+".jpg')";
		document.getElementById('slideshow').style.display = "block";
		if(slide_move[cslidex]==0 || slide_move[cslidex]==-1) {
			slideshow_top = 0;
		}
		else
			slideshow_top = -200;
		document.getElementById('slideshow').style.backgroundPosition = "0px "+slideshow_top+"px";
		document.getElementById('slideshow-caption').innerHTML = "<img src=images/blank.gif width=103 height=1>"+slide_caption[cslidex];
		document.getElementById('slideshow-captionb').innerHTML = "<img src=images/blank.gif width=103 height=1>"+slide_caption[cslidex];
		slidet++;
	}
	else if(slidet==100 && slideo<1) {
		slideo+=0.01;
		//document.getElementById('slideshow').style.opacity = slideo;
		opac(document.getElementById('slideshow'), slideo);
		slideshow_top += slide_move[cslidex]*0.3;
		document.getElementById('slideshow').style.backgroundPosition = "0px "+slideshow_top+"px";
	}
	else if(slidet>100 && slidet<100+slidetimeout) {
		slideshow_top += slide_move[cslidex]*0.3;
		document.getElementById('slideshow').style.backgroundPosition = "0px "+slideshow_top+"px";
		slidet++;
	}
	else if(slidet==100+slidetimeout && slideo>=0) {
		slideshow_top += slide_move[cslidex]*0.3;
		document.getElementById('slideshow').style.backgroundPosition = "0px "+slideshow_top+"px";
		slideo-=0.01;
		//document.getElementById('slideshow').style.opacity = slideo;
		opac(document.getElementById('slideshow'), slideo);
		if(slideo<=0) {
			slidet = 0;
		}
	}
	else
		slidet++;
}
setInterval(doevents,10);

