// JavaScript Document - Ipswich Jazz Clubb

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*******************************************************************************
MENU Writing functions
*******************************************************************************/
function writeNavBar() {
navBarString='<ul id="nav">'
navBarString+='<li><a href="index.html">HOME</a></li>'
navBarString+='<li><a href="gigs.htm">GIGS</a></li>'
navBarString+='<li><a href="links.htm">LINKS</a></li>'
navBarString+='<li><a href="photo_gallery.htm">Photo Gallery</a></li>'
navBarString+='<li><a href="contact_us.htm">Contact Us</a></li>'
navBarString+='</ul>'

document.write(navBarString);
}

function writeNavBarHOME() {
navBarString='<ul id="nav">'
navBarString+='<li><a href="index.html">HOME</a></li>'
navBarString+='<li><a href="gigs.htm">GIGS</a></li>'
navBarString+='<li><a href="links.htm">LINKS</a></li>'
navBarString+='<li><a href="photo_gallery.htm">Photo Gallery</a></li>'
navBarString+='<li><a href="contact_us.htm">Contact Us</a></li>'
navBarString+='</ul>'

document.write(navBarString);
}

/*******************************************************************************
	The following code sets the MASTER list of artists who have visited the club. YOU must assemble it in the required order - alphabetical, date visited or whatever. The ' - ' is the separator between the artist's name and dates visited to IJC it is therefore important and must have a space BEFORE and AFTER it.
	
	NOTE - the name in the list and the picture file title MUST be exactly the same.
	
	A cookie is required to pass the value of 'ijcList' across the pages on the site
	because JS variables cannot be carried from page to page.
	
	Add the following code to the HEAD of each page that needs to use the 'ijcArray' ...

	<script src="IJC.js"></script>
	<script type="text/JavaScript">
	<!--
		getCookie();
	-->
	</script>
	
	So to add a picture make it 226 pixels wide / 170 pixels high and 72 ppi. Add it to the photo directory making sure the title is that of the artist and years visitied as per the first paragraph above.
	Add that name and dates to the 'ijcList' below where you want it to appear and next time the album
	is 	called it will automatically be flown in.
*******************************************************************************/
	// Set date for cookie to expire in 1 month ...
	var expireDate = new Date();
	expireDate.setMonth(expireDate.getMonth()+1);
	
	// Set 'ijcList' to store - note '|' end marker ...
	
	var ijcList='Artist Index List,Howard Alden - 2006,Gilad Atzmon - 1998/2000/2/4/8/9,The Barcodes - 2006,Alan Barnes - 1998/2001/2/6/9,Alan Barns David Newton - 2009,Roger Beaujolais - 2000/03/07,Cubana Bop - 2007,Liane Carroll - 2007,Mark Crooks - 2002/04/06,Jamie Cullum - 2003,Geoff Eales - 2004,Julie Edwards - 2007/08,John Etheridge - 2003/08,Chris Garrick - 2008,Polly Gibbons - 2007/08,Todd Gordon - 2007,Scott Hamilton - 2001/2/5/6/7/8/9/10,Mick Hansen - 1998/2001/04/09,Gwyneth Herbert - 2004,Claire Hirst - 1998/1999/2002/05,Eriko Ishihara - 2002/04,Toni Kofi - 2006,Swing Machine - 2004/2005,Georgia Mancio - 2008,Tina May - 1998/2000/01/03,Esther Miller - 2007/08,Sarah Moule - 1998/2003/05,Allison Neale - 2006,David Newton Michael Hanson - 2009,Sue Richardson - 2008/10,Karen Sharp - 2003/4/6/8/9,Ian Siegal - 2007,Kaz Simmonds - 2009,Simon Spillett - 2008,Clare Teal - 2003,Ben Waters - 2004/05,Lewis Wright - 2007|'
	
	// Set cookie ...
	document.cookie = "ijcList=" + ijcList + ";expires=" + expireDate.toGMTString();

	// Now read cookie back and process ...
	// Get first part of string ...
	var ijcList=document.cookie.split("ijcList=")[1]
	// Strip end part using special marker '|' ...
	ijcList=ijcList.split("|")[0]
	// Create an array from 'ijcList' ...
	var ijcArray = ijcList.split(",");
/******************************************************************************/


/*******************************************************************************
	This function is called as required on entry to a page that needs the 'ijcList'...
*******************************************************************************/
function getCookie() {
	// Get first part of string ...
	var ijcList=document.cookie.split("ijcList=")[1]
	// Strip end part using special marker '|' ...
	ijcList=ijcList.split("|")[0]
	// Create an array from 'ijcList' ...
	var ijcArray = ijcList.split(",");
} // eoF ********************************************************************************


/*******************************************************************************
	This function builds the table and shows the pictures as per the 'artistArray'...
*******************************************************************************/
function showImages() {
	var i = 0;
	for (r=1; r <= Math.ceil(ijcArray.length/3); r=r+1) {
		document.write('<tr>');
		for (c=1; c <=3; c=c+1) {
			i = i+1;
			if (i < ijcArray.length) {
					var artistName = ijcArray[i];
					if (artistName.indexOf("-") != -1) {
						artistPic = artistName.split(" - ")[0]
					} else {
						artistPic = artistName
				}
			document.write('<td align="center" valign="middle" class="picCapBlu"><div align="center"><img src="photo_album/'+artistPic+'.jpg"><br>'+artistName+'</div></td>');
			}
		} // end of FOR
		document.write('</tr>');
	} // end of FOR
} // eoF ********************************************************************************


/*******************************************************************************
	This function PRELOADS the pictures as per the 'artistArray'...
*******************************************************************************/
function em_loadImages() {

	for (r=1; r <= ijcArray.length; r=r+1) {

		var artistName = ijcArray[r];
			if (artistName.indexOf("-") != -1) {
				artistPic = artistName.split(" - ")[0]
			} else {
				artistPic = artistName
			}
			
			artistPic = "photo_album/'+artistPic+'.jpg"
			MM_preloadImages(artistPic)
			
	} // end of FOR
} // 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 ARTIST picture for display on the 'home' page.
*******************************************************************************/
function getRanImage() {
	var whichImage = getRandom(1, ijcArray.length-1);
	var artistName = ijcArray[whichImage];
	if (artistName.indexOf("-") != -1) {
		artistPic = artistName.split(" - ")[0]
	} else {
		artistPic = artistName
	}
	//document.write('<div align="center" valign="middle"><img class="picCapBlu" src="photo_album/'+artistPic+'.jpg"><br>');
	document.write('<div style="float:left"><img class="picCapBlu" src="photo_album/'+artistPic+'.jpg"><br>');
	document.write('<div class="picCapBlu">'+ artistName)
	
} // eoF 

/*******************************************************************************
	This function selects a random INTERIOR picture for display on the 'home' page.
*******************************************************************************/
function getRandInt() {
	var intPics = new Array()
	// Build array as required ...
	intPics[1] = "Int_1";
	intPics[2] = "Int_2";
	
	var whichImage = getRandom(1, intPics.length-1);
	var intPic = intPics[whichImage]

	document.write('<div align="center" valign="middle"><img src="image_files/'+intPic+'.jpg"></div>');
	//document.write('<div align="center" valign="middle"><img class="picCapBlu" src="image_files/'+intPic+'.jpg"></div>');
} // eoF *******************************************************************************