
//declare menu, submenu and page order arrays
var Menu=new Array();
var SubMenu=new Array();
var PageOrder=new Array();
PageOrder[0]=new Array();
PageOrder[1]=new Array();
PageOrder[2]=new Array();
PageOrder[3]=new Array();
PageOrder[4]=new Array();
PageOrder[5]=new Array();
PageOrder[6]=new Array();
PageOrder[7]=new Array();

//define top level menu
Menu[0]='Paintings';
Menu[1]='Prints';
Menu[2]='Ink Drawings';
Menu[3]='Exhibitions';
Menu[4]='Biography';
Menu[5]='Bibliography';
Menu[6]='Contact Us';
Menu[7]='History';


//define sub level menus
//SubMenu[0]=['Oil Paintings','Mixed Media on Canvas','Mixed Media on Paper','Museum Collections'];
SubMenu[0]=['Large Oils','Medium Oils','Small Oils','Mixed Media on Canvas','Mixed Media on Paper','Museum Collections'];
SubMenu[1]=['Prints'];
SubMenu[2]=['Ink Drawings']
SubMenu[3]=['One Person Shows','Group Shows','Public Collections','Events Schedule'];
SubMenu[4]=['Education','Teaching','Projects','Awards','Publications','Artist Statement'];
SubMenu[5]=['Bibliography'];
SubMenu[6]=['Contact Us'];
SubMenu[7]=['History']

//define page order for submenu elements
PageOrder[0][0]=['','169','172','128','90']; //Paintngs>Large Oils
PageOrder[0][1]=['','174','168','170','171','112']; //Paintngs>Medium Oils
PageOrder[0][2]=['','176','177','178','179','180']; //Paintngs>Small Oils
PageOrder[0][3]=['','1','4','5','9','10']; //Paintings>Mixed Media on Canvas
PageOrder[0][4]=['','5','18','8','10','11']; //Paintings>Mixed Media on Paper
PageOrder[0][5]=['','2','3','4']; //Paintings>Museum Collections

PageOrder[1][0]=[ '','7','9','10','1','5','6','8']; //Prints
PageOrder[2][0]=['','2','3','4','6']; //Ink Drawings
PageOrder[3][0]=['']; //Exhibitions
PageOrder[3][1]=['']; //Exhibitions>One Person Shows
PageOrder[3][2]=['']; //Exhibitions>Group Shows
PageOrder[3][3]=['']; //Exhibitions>Public Collections
PageOrder[3][4]=['']; //Exhibitions>2005 Schedule
PageOrder[4][0]=['']; //Biography
PageOrder[4][1]=['']; //Biography>Education
PageOrder[4][2]=['']; //Biography>Teaching
PageOrder[4][3]=['']; //Biography>Projects
PageOrder[4][4]=['']; //Biography>Awards
PageOrder[4][5]=['']; //Biography>Publications
PageOrder[4][6]=['']; //Biography>Artist Statement
PageOrder[7][0]=['','2','4','5','6','7','9','8','10','14','15','16','17','18','19','32','33','35','37','31','26','67','30','98','53','94','23','20','55','57','59','95','61','63','47','24','104','93','90','91','96','82','100','116','119','120','122']; //History

//locate and isolate any query string
var url=window.location.toString();
var qs=url.split('=');

//determine current file level
var level=url.split('/');
level=(level.length-1).toString();
var dir='';
//Change to -6 for local storage.3
if (level-3>0){
for (p=0;p<(level-3);p++){dir+='../'};
}

//declare copies of menus and submenus which will be altered later
var MenuRepro=new Array();
var SubMenuRepro=new Array(SubMenu.length);
for (m=0;m<SubMenu.length;m++){
SubMenuRepro[m]=new Array(SubMenu[m].length);
}
var SubMenuText='';


function WriteMainMenu() {

	for (i=0;i<Menu.length;i++) {
		//Copy menu names to additional array for modifying
		MenuRepro[i]=Menu[i].toLowerCase();

		//If the menu item contains a space, chop out spaces so that link contains no space.
		if (MenuRepro[i].indexOf(' ')!=-1){
			MenuMod=MenuRepro[i].split(' ');
			MenuRepro[i]='';
			for (j=0;j<MenuMod.length;j++) {
			MenuRepro[i]=MenuRepro[i]+MenuMod[j];
			}

		}




			for (k=0;k<SubMenu[i].length;k++) {
				//Copy submenu names to additional array for modifiying
				SubMenuRepro[i][k]=SubMenu[i][k].toLowerCase();

				//If the submenu item contains a space, chop out spaces so that link contains no space.
				if (SubMenuRepro[i][k].indexOf(' ')!=-1){
					SubMenuMod=SubMenuRepro[i][k].split(' ');
					SubMenuRepro[i][k]='';
					for (l=0;l<SubMenuMod.length;l++) {
						SubMenuRepro[i][k]=SubMenuRepro[i][k]+SubMenuMod[l];
					}
				}
				//look and see if the current window location contains a querystring, and if it is equal to the current menu item
				if (qs.length>1 && qs[1]==i){
					//If this sub menu item is the current page being loaded, color the link white, or else, just grey
					if(qs[0].indexOf(SubMenuRepro[i][k])!=-1){
						SubMenuText=SubMenuText+'&nbsp;&nbsp;- <a href="'+dir+MenuRepro[i]+'/'+SubMenuRepro[i][k]+'.htm?sec='+i+'" style="color:#ffffff;">'+SubMenu[i][k]+'</a><br>';
					} else {
						//build each submenu item in turn
						SubMenuText=SubMenuText+'&nbsp;&nbsp;- <a href="'+dir+MenuRepro[i]+'/'+SubMenuRepro[i][k]+'.htm?sec='+i+'">'+SubMenu[i][k]+'</a><br>';
					}
				}
			}

		//If there is nothing in a menu's submenu, just go to the desired link.
		if(SubMenu[i].length<2) {
			document.write('<img src="'+dir+'images/bullet.gif" width="10" height="13"> <a href="'+dir+MenuRepro[i]+'/'+MenuRepro[i]+'.htm?sec='+i+'"><img src="'+dir+'images/'+MenuRepro[i]+'.gif" width="98" height="13" border="0"></a><br>');			
		} else {
			//write each menu link in turn, adding a querystring to the href
			document.write('<img src="'+dir+'images/bullet.gif" width="10" height="13"> <a href="'+dir+MenuRepro[i]+'/'+SubMenuRepro[i][0]+'.htm?sec='+i+'"><img src="'+dir+'images/'+MenuRepro[i]+'.gif" width="98" height="13" border="0"></a><br>');
			if (qs.length>1 && qs[1]==i){
				//write each submenu item in turn
				document.write(SubMenuText);
			}
		}

		//add a spacer at the bottom of each menu item
		document.write('<img src="'+dir+'images/spacer.gif" width="1" height="19"><br>');
	}

}

function WriteLinksMenuOld() {

	for (n = 0;n<Menu.length;n++) {	    
		if(SubMenu[n].length<1) {
			document.write('<a href="'+dir+MenuRepro[n]+'/'+MenuRepro[n]+'.htm?sec='+n+'">'+Menu[n]+'</a> <span style="color:#fc9604;">|</span> ');						
		} else {
			document.write('<a href="'+dir+MenuRepro[n]+'/'+SubMenuRepro[n][0]+'.htm?sec='+n+'">'+Menu[n]+'</a> <span style="color:#fc9604;">|</span> ');			
		}
	}
	document.write('<a href="'+dir+'index.htm">Home</a>');

}
function WriteLinksMenu() {
	document.write('<a href="paintings/oilpaintings.htm?sec=0">Paintings</a> <span style="color:#fc9604;">| </span>');  
	document.write('<a href="prints/prints.htm?sec=1">Prints</a> <span style="color:#fc9604;">| </span>'); 
	document.write('<a href="inkdrawings/inkdrawings.htm?sec=2">Ink Drawings</a> <span style="color:#fc9604;">| </span>');  
	document.write('<a href="exhibitions/onepersonshows.htm?sec=2">Exhibitions</a> <span style="color:#fc9604;">| </span>'); 
	document.write('<a href="biography/education.htm?sec=3">Biography</a> <span style="color:#fc9604;">| </span>');  
	document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>');
	document.write('<a href="bibliography/bibliography.htm?sec=4">Bibliography</a> <span style="color:#fc9604;">| </span>');  
	document.write('<a href="contactus/contactus.htm?sec=5">Contact Us</a> <span style="color:#fc9604;">| </span>');  
	document.write('<a href="history/history.htm?sec=7">History</a> <span style="color:#fc9604;">| </span>'); 
	document.write('<a href="/">Home</a>');
	document.write('&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>');
	
}

function WriteBackNext(WhichSubMenu,ThisPageNumber) {	
	//check to see if we have the "sec" querystring, and that it's value is numeric.
	if (qs.length>1 && !isNaN(qs[1])){
		//declare variables
		var ArrayElement;
		var Previous;
		var Next;
		
		//loop through the submenu array, and work out the position of the section we're looking at.
		window.status = qs[1] + ' ' + WhichSubMenu;
		for (o=0;o<PageOrder[qs[1]][WhichSubMenu].length;o++){
			if (PageOrder[qs[1]][WhichSubMenu][o]==ThisPageNumber) {
				ArrayElement = o;
			}
		}
		
		//DEBUG document.write( "ArrayElement: " + ArrayElement + "//<br>");		
		
		//if we're at the very first page, the "Back" link has to point to the last page.
		if (ArrayElement==0){
			Previous = PageOrder[qs[1]][WhichSubMenu].length-1;
		} else {
			Previous = ArrayElement-1;
		}
		
		//if we're at the very last page, the "Back" link has to point to the first page.
		if (ArrayElement==PageOrder[qs[1]][WhichSubMenu].length-1){
			Next = 0;
		} else {
			Next = ArrayElement+1;
		}
		
		//create our URLs.
		Previous = SubMenu[qs[1]][WhichSubMenu].toLowerCase().replace(/ +/g,'')+PageOrder[qs[1]][WhichSubMenu][Previous]+'.htm?sec='+qs[1];
		Next = SubMenu[qs[1]][WhichSubMenu].toLowerCase().replace(/ +/g,'')+PageOrder[qs[1]][WhichSubMenu][Next]+'.htm?sec='+qs[1];
		
		//write out the links to the page.
		document.write('< <a href="'+Previous+'">Back</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="'+Next+'">Next</a> >');
	}
}

function WriteTheYear(){
         var curdate = new Date();
		 var year = curdate.getYear();
		 if(year<1000) year+=1900;
		 document.write(year + "<BR>");
}