﻿// slideshow control script
var id
var i
var n
var pageReady = false
var ImageArr = new Array(n)
var TextArr  = new Array(n)
var placeholder = new Image
var nextPic = new Image
var currentPic = new Image
var playOver = new Image
var playOff  = new Image


playOver.src = "images/buttons/playhov.gif"
playOff.src  = "images/buttons/play.gif"

i  = 0	// loop counter
id = 1	// image number
n  = 6	// number of images

placeholder.src = "images/placeholder.gif"
for (i=1;i<=n;i++) {
	ImageArr[i] = new Image
	TextArr[i] = new String
	ImageArr[i].src = "images/inslideshow/inside"+i+".jpg"
}

// define strings to accompany images
TextArr[1] = "Spacious living room featuring exposed stone wall"
TextArr[2] = "Extendable farmhouse dining table dressed with local, blue &amp; white Burleigh ware"
TextArr[3] = "Beautiful kitchen boasts a lofty, beamed ceiling and rural views"
TextArr[4] = "Exposed stone wall sets off the twin/superking-sized beds on the ground floor"
TextArr[5] = "Comfortable twin-bedded room with its handsome, en-suite shower-room"
TextArr[6] = "Traditional and antique funiture and fabrics make for a romantic, double bedroom"


i=0
function checkifReady() {
	if (document.images) { 
		pageReady = true
	}
	else {
		i=i+1
		if ( i<10 ) { setTimeout("checkifReady()",1000) }
	}
}

function over() {
	document.play.src = playOver.src
}

function out() {
	document.play.src = playOff.src
}

function swapImage(n) {
	document.slideshow.src = ImageArr[n].src
	if (document.getElementById) {
		document.getElementById("slideshowtext").innerHTML = TextArr[n]
	}
}


function cycleImages() {
	if (pageReady) {
		over()
		id++
		var nextimageNumber = id-(n*(Math.floor((id-1)/n)))
		document.slideshow.src = placeholder.src
		nextPic.src = ImageArr[nextimageNumber].src
		nextPic.onload = swapImage(nextimageNumber);setTimeout("out()",1000)

	}	
}