window.onload = initLinks;

var myPhoto = new Array(
"gallery/clouds.jpg",
"gallery/harbour.jpg",
"gallery/square.jpg",
"gallery/shop.jpg",
"gallery/brewery.jpg",
"gallery/location.jpg",
"gallery/pilton.jpg",
"gallery/golf.jpg",
"gallery/crankshaft.jpg",
"gallery/bedroom.jpg",
"gallery/cases.jpg",
"gallery/kinged1.jpg",
"gallery/display.jpg");


var myText = new Array(
"&nbsp;",
"Pictures of local scenes",
"Include local events",
"Pictures of you or your staff",
"Show your premises",
"Show your location",
"Include your past projects",
"Show your amenities",
"Display your products",
"Pictures of your accommodation",
"Display your product range",
"Have a gallery of your photographs",
"Show examples of your past work");

var thisPhoto = 0;

function initLinks() {
	document.getElementById("previous").onclick = processPrevious;
	document.getElementById("next").onclick = processNext;
}


function processPrevious() {
	changeOpac(0)
	if (thisPhoto == 0) {
		thisPhoto = myPhoto.length;
	}
	thisPhoto--;
	document.getElementById("myPicture").src = myPhoto[thisPhoto];
	if (document.getElementById("myPicture").src.indexOf("v") != -1)
	{
		document.getElementById("myPicture").style.marginTop = 10 + "px";
	}
	else {
		document.getElementById("myPicture").style.marginTop = 50 + "px";
	}
	document.getElementById('pictureText').innerHTML = myText[thisPhoto];
	opacityShow()
	return false;
}

function processNext() {
	changeOpac(0)
	thisPhoto++;
	if (thisPhoto == myPhoto.length) {
		thisPhoto = 0;
	}
	document.getElementById("myPicture").src = myPhoto[thisPhoto];
	if (document.getElementById("myPicture").src.indexOf("v") != -1)
	{
		document.getElementById("myPicture").style.marginTop = 10 + "px";
	}
	else {
		document.getElementById("myPicture").style.marginTop = 50 + "px";
	}
	document.getElementById('pictureText').innerHTML = myText[thisPhoto];
	opacityShow()
	return false;
}


function opacityFade() {
	timer = 900;
	for(i = 100; i >= 0; i--) {
		setTimeout("changeOpac(" + i + ")",(timer));
		timer=timer+2;
	}
}
function opacityShow() {
	timer = 900;
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ")",(timer));
	timer=timer+2;
	}
}

function changeOpac(opacity) {
	var object = document.getElementById('myPicture').style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
