function DisplayOneArtist(ActiveArray,Index) {
       document.write(ActiveArray[Index][ARFirstI] + " " + ActiveArray[Index][ARLastI] + " Style: " +  ActiveArray[Index][ARStyleI]);
	   //document.write("<br><IMG SRC=" + SmallImage + ActiveArray[Index][NumberI] + ".jpg>");
}

function NumberOfWorksByThisArtist(ArtistCode2){
	NumberOfWorks2 = Artworks.length;
	ArtistWorks2=0;
	for (Counter2=0; Counter2<NumberOfWorks2; Counter2++) {
	  if (ArtistCode2==Artworks[Counter2][ARCodeI]) {
		ArtistWorks2++;
	  }
	}
	return(ArtistWorks2);
}

//compare the Artist code from the Artworks list with the Artist code from the Artists list)
function FindArtistName(ArtistCode3){
NumberOfArtists = Artists.length;
ArtistName3="";
	for (Counter3=0; Counter3<NumberOfArtists; Counter3++) {
	  if (ArtistCode3==Artists[Counter3][ARCodeI]) {
	    ArtistName3=Artists[Counter3][ARFirstI] + " " + Artists[Counter3][ARLastI];
	   }
	}
return(ArtistName3);
}

function FindArtistIndex(ArtistCode3){
NumberOfArtists = Artists.length;
FAI_ArtistIndex="No-such-artist-index";
	for (Counter3=0; Counter3<NumberOfArtists; Counter3++) {
	  if (ArtistCode3==Artists[Counter3][ARCodeI]) {
	    FAI_ArtistIndex=Counter3;
	   }
	}
return(FAI_ArtistIndex);
}

//Search any array and return an array indicating which records contain the search text
//function SearchArray(SearchedArray,SearchItem,SearchText){
//  SearchResult = new Array("");
//
//  for (Counter7=0; Counter7<SearchedArray.length; Counter7++) {
//    SearchInThisString=SearchedArray[Counter7][SearchItem];
//	if (SearchInThisString.indexOf(SearchText)>0) {
//	  SearchResult[Counter7]=Counter7;
//	}
//  }
//  return(SearchResult);
//}

function DisplayArtistInformation(DAI_Index){
	//thumbnail
    document.write("<TD width=80 height=90><A href=individual.html?ArtistCode=" + Artists[DAI_Index][ARCodeI] + ">");
	document.write("<IMG SRC=" + ArtistPreviewImageDirectory + "/" +  Artists[DAI_Index][ARCodeI]  + ".jpg border=0></A>");
	//Artist name
    document.write("</TD><TD>");	
    document.write("<A href='individual.html?ArtistCode=");
    document.write(Artists[DAI_Index][ARCodeI] + "' + class=links>" + Artists[DAI_Index][ARFirstI] + " " + Artists[DAI_Index][ARLastI] + "</A>");
	//Style
	document.write("<BR><span class=small>" +  Artists[DAI_Index][ARStyleI] + "</span>");
	//Number of works
	document.write("<BR><span class=small>" + NumberOfWorksByThisArtist(Artists[DAI_Index][ARCodeI]) );
	//Put 'Work' for only 1 Artwork and 'Works' for all others
	if (NumberOfWorksByThisArtist(Artists[DAI_Index][ARCodeI])==1) { document.write(" Work</span>") }
	  else document.write(" Works</span>");
    document.write("</TD>");
}

function DisplayAllArtists(){
NumberOfArtistsPerPage = 9;
//Start table
document.write("<P><table border=0 cellpadding=4 cellspacing=4 width=710 height=339>");
//Fill in artists
for (Counter=StartThisPageAtArtist; Counter<EndThisPageAtArtist; Counter++) {
    document.write("<TR>");
	//Artist-column 1
	DisplayArtistInformation(Counter);
	//Put intermediate column spacer
	document.write("<TD><IMG SRC=images/spacer.gif width=60 height=60></TD>");	
	Counter++;
	//Artist-column 2	
	if (Counter<EndThisPageAtArtist) {
		DisplayArtistInformation(Counter);
		//Put intermediate column spacer
		document.write("<TD><IMG SRC=images/spacer.gif width=60 height=60></TD>");	
	}
	Counter++;
	//Artist-column 3
	if (Counter<EndThisPageAtArtist) {
		DisplayArtistInformation(Counter);
    }
	//Close off Row
	document.write("</TR>");	
}
//One last row
document.write("<tr><td height=100%></td></tr>");
//End table
document.write("</TABLE>");
}


//Create a list of Artworks by this Artist
function BuildArtworksArray(BAA_ArtistCode) {
   SearchResult = new Array('');
   SearchResultArrayCounter = 0;
   for (BAA_Counter=0; BAA_Counter<Artworks.length; BAA_Counter++){
      if (Artworks[BAA_Counter][AWCodeI]==BAA_ArtistCode) {
	    SearchResult[SearchResultArrayCounter] = BAA_Counter;
		SearchResultArrayCounter++;
	  }
   }
   return SearchResult;
}


function delineate2(str)  {
  point = str.lastIndexOf("=");
  returnvalue=str.substring(point+1,str.length);
  if (str.length<1) {returnvalue=0;}
  return(returnvalue);
//  return(str.substring(point+1,str.length));
}

//Extract variables passed in the location string
function getParm(string,parm) {
    // returns value of parm from string
    var startPos = string.indexOf(parm + "=");
    if (startPos > -1) {
        startPos = startPos + parm.length + 1;
        var endPos = string.indexOf("&",startPos);
        if (endPos == -1)
            endPos = string.length;
        return unescape(string.substring(startPos,endPos));
    }
    return '';
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function OpenArtworkWindow(URL) {
    msgWindow = window.open('','targetname','top=50,left=50,width=600,height=550');
    msgWindow.location.href = URL;
    if (msgWindow.opener == null) msgWindow.opener = self;
	setTimeout('msgWindow.focus()',500);
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		home_over = newImage("images/home-over.gif");
		retailers_over = newImage("images/retailers-over.gif");
		consumers_over = newImage("images/consumers-over.gif");
		media_over = newImage("images/media-over.gif");
		technology_over = newImage("images/technology-over.gif");
		creative_technology_over = newImage("images/creative-technology_over.gif");
		creative_over = newImage("images/creative-over.gif");
		contact_over = newImage("images/contact-over.gif");
		client_over = newImage("images/client-over.gif");
		preloadFlag = true;
	}
}

function newWindow(url,windowname,parms) {
    window.open(url,windowname,parms)
  }

function closeWindow(windowname) {
    window.close(windowname)
    return false
  }

function newPhotoWindow(url) {
  //center this window and feed correct dimensions to window opener
  //check if window is open and if so, bring to front
   newWindow(url, 'photopopupWindow','top=0,left=0,width=680,height=560')
}

function WindowClose() {
  setTimeout('window.close()',100)
} 

function OpenNewPageInLauncher(url) {
	//Opens specified URL in launching browser and closes the child window
	opener.location.href = url;
    window.close();
}


