// alert("Start of script One");
	//var imageDir = "images/front page/";
	var imageNum = 0;
	//set image array
	imageArray = new Array();
	imageArray[0]=["images/front page/home_slide1.jpg"]
	imageArray[1]=["images/front page/home_slide2.jpg"]
	imageArray[2]=["images/front page/home_slide3.jpg"]
	imageArray[3]=["images/front page/home_slide4.jpg"]
	imageArray[4]=["images/front page/home_slide5.jpg"]
	imageArray[5]=["images/front page/home_slide6.jpg"]
	
/* If it's not random, we just increment the imageNum by 1. Then to make sure we don't go over 
the total number of images, we use the handy dandy modulus operator (%). This will give us 
a remainder of 1, as soon as we go over the total number, but will just return the incremented 
imageNum until then. So when we go over, we go back to the beginning! Neat huh? */ 

	function getNextImage() {
	
	var new_image = imageArray[imageNum];

		if (imageNum == imageArray.length - 1)
		{
		 	 imageNum = 0;
		}
		else
		{
		 		imageNum = (imageNum + 1);
		}
		
	return(new_image);

	}
	
function getRand()	{
var randomnumber=(Math.floor(Math.random()*4)+5 )* 1000;
return randomnumber ;

}

// Start of opacity funtions

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

// change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

// End of opacity funtions

function switchImage(place) {
				// alert("switchImage One");

				  var new_image = getNextImage();
					document[place].src = new_image;

					var recur_call = "switchImage('slideImg')";
					timerID = setTimeout(recur_call, getRand()); 

}

function fadImage() {
				 opacity('slideImg',100,0,2000);
				 switchImage('slideImg')

}

function unfadImage() {
				 opacity('slideImg',0,100,2000);

}