// JavaScript Document
// Next-Previous Image Gallery 2 :: Solomon :: http://www.sleuthz.com/
// Create an Array of Image Locations

// altered to randomly load an image and description from the arrays

var myImg= new Array()
	myImg[0]= "st-johns-wood-apartments/images/1.jpg";
	myImg[1]= "geneva-house/images/1.jpg";
	myImg[2]= "advanced-dental-clinic/images/1.jpg";
	myImg[3]= "hampstead-apartment/images/1.jpg";
	myImg[4]= "maplehouse-orthodontics/images/3.jpg";
	myImg[5]= "antibes-house/images/1.jpg";
// Create an Array of Captions
var myCap= new Array()
	myCap[0]= "<p><b>Richard Mitzman Architects</b> is a design-lead award winning practice with 5 architects, all experts at different aspects of the building process, forming a complimentary team.</p><p>We are particularly interested in the planning process and to-date have been successful in all the 52 planning applications we have made. </p><p>We like to work on exciting projects with like-minded clients. </p><p>Our projects include a number of medical and dental ones as Richard Mitzman is also a dentist. He practiced in Wimpole Street for 20 years and then left his successful practice to become a sculptor, but then wanted to push his work in a spatial direction, enrolled to study Architecture.</p>";
	myCap[1]= "<p><b>Richard Mitzman Architects</b> is a design-lead award winning practice with 5 architects, all experts at different aspects of the building process, forming a complimentary team.</p><p>We are particularly interested in the planning process and to-date have been successful in all the 52 planning applications we have made. </p><p>We like to work on exciting projects with like-minded clients. </p><p>Our projects include a number of medical and dental ones as Richard Mitzman is also a dentist. He practiced in Wimpole Street for 20 years and then left his successful practice to become a sculptor, but then wanted to push his work in a spatial direction, enrolled to study Architecture.</p>";
	myCap[2]= "<p><b>Richard Mitzman Architects</b> is a design-lead award winning practice with 5 architects, all experts at different aspects of the building process, forming a complimentary team.</p><p>We are particularly interested in the planning process and to-date have been successful in all the 52 planning applications we have made. </p><p>We like to work on exciting projects with like-minded clients. </p><p>Our projects include a number of medical and dental ones as Richard Mitzman is also a dentist. He practiced in Wimpole Street for 20 years and then left his successful practice to become a sculptor, but then wanted to push his work in a spatial direction, enrolled to study Architecture.</p>";
	myCap[3]= "<p><b>Richard Mitzman Architects</b> is a design-lead award winning practice with 5 architects, all experts at different aspects of the building process, forming a complimentary team.</p><p>We are particularly interested in the planning process and to-date have been successful in all the 52 planning applications we have made. </p><p>We like to work on exciting projects with like-minded clients. </p><p>Our projects include a number of medical and dental ones as Richard Mitzman is also a dentist. He practiced in Wimpole Street for 20 years and then left his successful practice to become a sculptor, but then wanted to push his work in a spatial direction, enrolled to study Architecture.</p>";
	myCap[4]= "<p><b>Richard Mitzman Architects</b> is a design-lead award winning practice with 5 architects, all experts at different aspects of the building process, forming a complimentary team.</p><p>We are particularly interested in the planning process and to-date have been successful in all the 52 planning applications we have made. </p><p>We like to work on exciting projects with like-minded clients. </p><p>Our projects include a number of medical and dental ones as Richard Mitzman is also a dentist. He practiced in Wimpole Street for 20 years and then left his successful practice to become a sculptor, but then wanted to push his work in a spatial direction, enrolled to study Architecture.</p>";
	myCap[5]= "<p><b>Richard Mitzman Architects</b> is a design-lead award winning practice with 5 architects, all experts at different aspects of the building process, forming a complimentary team.</p><p>We are particularly interested in the planning process and to-date have been successful in all the 52 planning applications we have made. </p><p>We like to work on exciting projects with like-minded clients. </p><p>Our projects include a number of medical and dental ones as Richard Mitzman is also a dentist. He practiced in Wimpole Street for 20 years and then left his successful practice to become a sculptor, but then wanted to push his work in a spatial direction, enrolled to study Architecture.</p>";


// Create Number of Images Variable
var n = myImg.length;

// Create Number Variable
var i = Math.round(Math.random()*(n-1));

// Create Image Number Variable
var m = 1;


// Create Function to Load Image
function loadImg(){
// Gives "imgSrc" a Source with Number Variable
	document.imgSrc.src = myImg[i];
// Gives "caption" DIV a content
	document.getElementById("caption").innerHTML = myCap[i];
// Gives "imgNum" DIV the image number
//	document.getElementById("imgNum").innerHTML = "Image&nbsp;" + m + "/" + n ;
}

// Create Link Function to Switch Image Backward
function prev(){
// Create If/Else Statement to Stop at Certain Image
// If the Number Variable is Less Than 1
	if(i<1){
// Create Another Next Number Variable which Equals to Number Variable
		var l = i = n-1;
// Create Current Number Variable which Equals to Image Number Variable
		var c = m = n;
// Otherwise
	}else{
// Next Number Variable Equals to Number Variable - 1
		var l = i-=1;
// Current Number Variable Equals to Image Number Variable - 1
		var c = m-=1;
	}
// Gives "imgSrc" a Source with an Alternative "l" Variable
	document.imgSrc.src = myImg[l];
// Gives "caption" DIV a content
	document.getElementById("caption").innerHTML = myCap[i];
// Gives "imgNum" DIV the image number
	document.getElementById("imgNum").innerHTML =  "Image&nbsp;" + c + "/" + n;
}

// Create Link Function to Switch Image Forward
function next(){
// Create If/Else Statement to Stop at Certain Image
// If the Number Variable is More Than [Minus 1 of the Number of Arrays]
	if(i>n-2){
// Create Next Number Variable which Equals to Number Variable
		var l = i = 0;
// Create Current Number Variable which Equals to Image Number Variable
		var c = m = 1;
// Otherwise
	}else{
// Next Number Variable Equals to Number Variable + 1
		var l = i+=1;
// Current Number Variable Equals to Image Number Variable + 1
		var c = m+=1;
	}
// Gives "imgSrc" a Source with Next Number Variable
	document.imgSrc.src = myImg[l];
// Gives "caption" DIV a content
	document.getElementById("caption").innerHTML = myCap[i];
// Gives "imgNum" DIV the image number
	document.getElementById("imgNum").innerHTML =  "Image&nbsp;" +  m + "/" + n;
}

// Load function after page loads
window.onload = loadImg;