// JavaScript Document for Ipswich Art Society


/************************************************
	The following code sets the MASTER list of
	current artists - YOU must assemble it 
	in alphabetical order.
	The cookie is required to pass the value of
	'artistList' across the pages in the site.
************************************************/
	// Set date to expire in 1 month ...
	var expireDate = new Date();
	expireDate.setMonth(expireDate.getMonth()+1);
	
	// Set 'artistList' to store - note '|' end marker ...
	var artistList='Artist Index Page,Mark Beesley,Wendy Brooke-Smith,Derek Chambers,Chris Edmondson,Dorin Elvin,Robert Allen Forster,George William Gill,Jennifer Hall,Lindsay Harris,Malcolm Moseley,Nick Milner,Anne-Marie Oshelda,Christopher H Pettitt,Peter Polaine,Beryl Scott,Margaret Wyllie|'
	
	// Set cookie ...
	document.cookie = "artistList=" + artistList + ";expires=" + expireDate.toGMTString();

	// Now read cookie back and process ...
	// Get first part of string ...
	var artistList=document.cookie.split("artistList=")[1]
	// Strip end part using special marker '|' ...
	artistList=artistList.split("|")[0]
	// Create an array from 'artistList' ...
	var artistArray = artistList.split(",");
	// Set where we are ...
	var curArtist = document.title
	// Look for it in the array ...
	for (i in artistArray) {
		if (artistArray[i]==document.title){
		curIndex = i
		}
	}
/***********************************************/


/***********************************************
	This function is called as required on entry to 
	a page that needs the 'artistList'.
***********************************************/
function getCookie() {
	// Get first part of string ...
	var artistList=document.cookie.split("artistList=")[1]
	// Strip end part using special marker '|' ...
	artistList=artistList.split("|")[0]
	// Create an array from 'artistList' ...
	var artistArray = artistList.split(",");
	// Set where we are ...
	var curArtist = document.title
	// Look for it in the array ...
	for (i in artistArray) {
		if (artistArray[i]==document.title){
		curIndex = i
		}
	}
} // eoF *****************************************


/***********************************************
	Generates a random integer.
	To call: random1 = getRandom(1, 10)
************************************************/
function getRandom(min, max) {
	return Math.floor(Math.random()*((max-min)+1))+min;
} // eoF ****************************************

/***********************************************
	This function selects a random picture for
	display on the 'home' page.
************************************************/
function getImage() {
	var whichImage = getRandom(1, artistArray.length-1);

	document.write('<img src="artists/'+artistArray[whichImage]+'.jpg"><br>');
	document.write(artistArray[whichImage])
} // eoF ***************************************


/************************************************
Functions to display a message on 'mousedown'
click on a picture - set id="leImage".
To call:  onmousedown="disable()"
************************************************/
function message() {
	alert("Please do not copy this picture.");
	return false;
}
function disable() {
var	artist$="TEST";
	//alert("Hallo");
	document.getElementById('leImage').onmousedown=message
} // eoF ****************************************
