﻿// JavaScript Document
<!--
var mypix1=new Array("gallery/home/homepage_09.jpg","gallery/home/homepage_18.jpg","gallery/home/homepage_03.jpg","gallery/home/homepage_17.jpg","gallery/home/homepage_09.jpg"); // this is the array of 1st images
var mypix2 = new Array("gallery/home/titles/homepage_09.gif","gallery/home/titles/homepage_18.gif","gallery/home/titles/homepage_03.gif","gallery/home/titles/homepage_17.gif","gallery/home/titles/homepage_09.gif"); // this is the array of 2nd images

function whichpic() {
	// get the previous picture
	theimage1=document.picture; // this is the name of the 1st image to switch
	theimage2 = document.caption; // this is the name of the 2nd image to switch
	var np=loadpic();
	np++;
	if (np>=mypix1.length) {
		np=0;
	}
    theimage1.src=mypix1[np];
    theimage2.src=mypix2[np];
	savepic(np);
}

function savepic(numpic) { // save the pic number to a cookie!
	var expire = new Date ();
	var timer = expire.getTime() + (2 * 60 * 60 * 1000); //that's two hours
	expire.setTime(timer);
	document.cookie="np="+numpic+"; path=/; expires="+expire.toGMTString();
}
	
function loadpic() { //get the pic number "np" from a cookie
	tempArray = document.cookie.split(";");		
	for (tA = 0; tA < tempArray.length; tA++) {
		if (tempArray[tA].indexOf('np') > -1) { //found the np section in cookie
			cookieval = tempArray[tA].split("=");
			return parseInt(cookieval[1]);
		}
	}
	// no cookie found ... return -1!
	return -1;
}
	
//-->
