// JavaScript Document

// Cristina Wiltsey
// Created October 2010; Updated June 2011; Updated July 2011

// -------------------- begin THUMBNAIL IMAGE ROLLOVER FUNCTION --------------------
function rollState(imgName, imgSrc) 
{
	// Change thumbnail image src
	if (document.images) {
		document.images[imgName].src = imgSrc;
	}
}
// -------------------- end THUMBNAIL IMAGE ROLLOVER FUNCTION --------------------

// -------------------- begin CLICK THROUGH PROJECT IMAGES FUNCTIONS (WITH INAGE SOURCE ARRAYS) --------------------
// "next" direction cycles through the images (beginning at 1) 2-5, then repeats 1-5, 1-5, 1-5, .....
// "prev" direction steps backward through the images that have been previously viewed.
// "next" link is invisible when last project image is displayed.
// "prev" link is invisible when first project image is displayed.

// Image src arrays
var ourWorkProj1 = ["images/proj_imgs/ow1_1.jpg", "images/proj_imgs/ow1_2.jpg", "images/proj_imgs/ow1_3.jpg", "images/proj_imgs/ow1_4.jpg", "images/proj_imgs/ow1_5.jpg"];
var ourWorkProj2 = ["images/proj_imgs/ow2_1.jpg", "images/proj_imgs/ow2_2.jpg"];
var ourWorkProj3 = ["images/proj_imgs/ow3_1.jpg", "images/proj_imgs/ow3_2.jpg"];
var ourWorkProj4 = ["images/proj_imgs/ow4_1.jpg", "images/proj_imgs/ow4_2.jpg"];
var ourWorkProj5 = ["images/proj_imgs/ow5_1.jpg", "images/proj_imgs/ow5_2.jpg"];
var solutionsProj1 = ["images/proj_imgs/s1_1.jpg", "images/proj_imgs/s1_2.jpg"];
var solutionsProj2 = ["images/proj_imgs/s2_1.jpg", "images/proj_imgs/s2_2.jpg"];
var solutionsProj3 = ["images/proj_imgs/s3_1.jpg", "images/proj_imgs/s3_2.jpg"];

var i = 0;

//Switch project images displayed for Our Work Project 1:
function switchOW1(direction, imgName, id1, id2)
{
	if (document.images) {
		if(direction == "next") {
			i = ++i;
		}
		else if(direction == "prev") {
			i = --i;
		}
		if(i >= ourWorkProj1.length) {
			i = 0;
		}
		document.images[imgName].src = ourWorkProj1[i];
	}

	if (i == 0) {
		document.getElementById(id1).style.visibility = "hidden";
	} else {
		document.getElementById(id1).style.visibility = "visible";
	}

	if (i == ourWorkProj1.length - 1) {
		document.getElementById(id2).style.visibility = "hidden";
	} else {
		document.getElementById(id2).style.visibility = "visible";
	}
}

//Switch project images displayed for Our Work Project 2:
function switchOW2(direction, imgName, id1, id2)
{
	if (document.images) {
		if(direction == "next") {
			i = ++i;
		}
		else if(direction == "prev") {
			i = --i;
		}
		if(i >= ourWorkProj2.length) {
			i = 0;
		}
		document.images[imgName].src = ourWorkProj2[i];
	}

	if (i == 0) {
		document.getElementById(id1).style.visibility = "hidden";
	} else {
		document.getElementById(id1).style.visibility = "visible";
	}

	if (i == ourWorkProj2.length - 1) {
		document.getElementById(id2).style.visibility = "hidden";
	} else {
		document.getElementById(id2).style.visibility = "visible";
	}
}

//Switch project images displayed for Our Work Project 3:
function switchOW3(direction, imgName, id1, id2)
{
	if (document.images) {
		if(direction == "next") {
			i = ++i;
		}
		else if(direction == "prev") {
			i = --i;
		}
		if(i >= ourWorkProj3.length) {
			i = 0;
		}
		document.images[imgName].src = ourWorkProj3[i];
	}

	if (i == 0) {
		document.getElementById(id1).style.visibility = "hidden";
	} else {
		document.getElementById(id1).style.visibility = "visible";
	}

	if (i == ourWorkProj3.length - 1) {
		document.getElementById(id2).style.visibility = "hidden";
	} else {
		document.getElementById(id2).style.visibility = "visible";
	}
}

//Switch project images displayed for Our Work Project 4:
function switchOW4(direction, imgName, id1, id2)
{
	if (document.images) {
		if(direction == "next") {
			i = ++i;
		}
		else if(direction == "prev") {
			i = --i;
		}
		if(i >= ourWorkProj4.length) {
			i = 0;
		}
		document.images[imgName].src = ourWorkProj4[i];
	}

	if (i == 0) {
		document.getElementById(id1).style.visibility = "hidden";
	} else {
		document.getElementById(id1).style.visibility = "visible";
	}

	if (i == ourWorkProj4.length - 1) {
		document.getElementById(id2).style.visibility = "hidden";
	} else {
		document.getElementById(id2).style.visibility = "visible";
	}
}

//Switch project images displayed for Our Work Project 5:
function switchOW5(direction, imgName, id1, id2)
{
	if (document.images) {
		if(direction == "next") {
			i = ++i;
		}
		else if(direction == "prev") {
			i = --i;
		}
		if(i >= ourWorkProj5.length) {
			i = 0;
		}
		document.images[imgName].src = ourWorkProj5[i];
	}

	if (i == 0) {
		document.getElementById(id1).style.visibility = "hidden";
	} else {
		document.getElementById(id1).style.visibility = "visible";
	}

	if (i == ourWorkProj5.length - 1) {
		document.getElementById(id2).style.visibility = "hidden";
	} else {
		document.getElementById(id2).style.visibility = "visible";
	}
}

//Switch project images displayed for Solutions Project 1:
function switchS1(direction, imgName, id1, id2)
{
	if (document.images) {
		if(direction == "next") {
			i = ++i;
		}
		else if(direction == "prev") {
			i = --i;
		}
		if(i >= solutionsProj1.length) {
			i = 0;
		}
		document.images[imgName].src = solutionsProj1[i];
	}

	if (i == 0) {
		document.getElementById(id1).style.visibility = "hidden";
	} else {
		document.getElementById(id1).style.visibility = "visible";
	}

	if (i == solutionsProj1.length - 1) {
		document.getElementById(id2).style.visibility = "hidden";
	} else {
		document.getElementById(id2).style.visibility = "visible";
	}
}

//Switch project images displayed for Solutions Project 2:
function switchS2(direction, imgName, id1, id2)
{
	if (document.images) {
		if(direction == "next") {
			i = ++i;
		}
		else if(direction == "prev") {
			i = --i;
		}
		if(i >= solutionsProj2.length) {
			i = 0;
		}
		document.images[imgName].src = solutionsProj2[i];
	}

	if (i == 0) {
		document.getElementById(id1).style.visibility = "hidden";
	} else {
		document.getElementById(id1).style.visibility = "visible";
	}

	if (i == solutionsProj2.length - 1) {
		document.getElementById(id2).style.visibility = "hidden";
	} else {
		document.getElementById(id2).style.visibility = "visible";
	}
}

//Switch project images displayed for Solutions Project 3:
function switchS3(direction, imgName, id1, id2)
{
	if (document.images) {
		if(direction == "next") {
			i = ++i;
		}
		else if(direction == "prev") {
			i = --i;
		}
		if(i >= solutionsProj3.length) {
			i = 0;
		}
		document.images[imgName].src = solutionsProj3[i];
	}

	if (i == 0) {
		document.getElementById(id1).style.visibility = "hidden";
	} else {
		document.getElementById(id1).style.visibility = "visible";
	}

	if (i == solutionsProj3.length - 1) {
		document.getElementById(id2).style.visibility = "hidden";
	} else {
		document.getElementById(id2).style.visibility = "visible";
	}
}
// -------------------- end CLICK THROUGH PROJECT IMAGES FUNCTIONS (WITH INAGE SOURCE ARRAYS) --------------------

