// Array.copy() - Copy an array
if( typeof Array.prototype.copy==='undefined' ) {
 Array.prototype.copy = function() {
  var a = [], i = this.length;
  while( i-- ) {
   a[i] = typeof this[i].copy!=='undefined' ? this[i].copy() : this[i];
  }
  return a;
 };
}

function Array_splice(index, delTotal) {
var temp = new Array();
var response = new Array();
var A_s = 0;
for (A_s = 0; A_s < index; A_s++) {
temp[temp.length] = this[A_s];
}
for (A_s = 2; A_s < arguments.length; A_s++) {
temp[temp.length] = arguments[A_s];
}
for (A_s = index + delTotal; A_s < this.length; A_s++) {
temp[temp.length] = this[A_s];
}
for (A_s = 0; A_s < delTotal; A_s++) {
response[A_s] = this[index + A_s];
}
this.length = 0;
for (A_s = 0; A_s < temp.length; A_s++) {
this[this.length] = temp[A_s];
}
return response;
}
if (typeof Array.prototype.splice == 'undefined') {
Array.prototype.splice = Array_splice;
}

// Array.slice() - Copy and return several elements
if( typeof Array.prototype.slice==='undefined' ) {
 Array.prototype.slice = function( a, c ) {
  var i, b, d = [], l = this.length;
  if( !c ) { c = l; }
  if( c<0 ) { c = l + c; }
  if( a<0 ) { a = l - a; }
  if( c<a ) { i = a; a = c; c = i; }
  for( i = 0; i < c - a; i++ ) { d[i] = this[a+i]; }
  return d;
 };
}

// Array.concat() - Join two arrays
if(typeof Array.prototype.concat=='undefined')
Array.prototype.concat=function(a){
var
i=0,
b=this.copy();
for(i;i<a.length;i++)
b[b.length]=a[i];
return b
};

// Array.push() - Add an element to the end of an array, return the new length
if( typeof Array.prototype.push==='undefined' ) {
 Array.prototype.push = function() {
  for( var i = 0, b = this.length, a = arguments, l = a.length; i<l; i++ ) {
   this[b+i] = a[i];
  }
  return this.length;
 };
}

// Array.indexOf( value, begin, strict ) - Return index of the first element that matches value
Array.prototype.indexOf = function( v, b, s ) {
 for( var i = +b || 0, l = this.length; i < l; i++ ) {
  if( this[i]===v || s && this[i]==v ) { return i; }
 }
 return -1;
};

/*Function indexId gets the (numerical) array index value of the element,
i.e. its position in the order of display*/
function indexId(thisArray,thisElement) {
imgIndex=thisArray.indexOf(thisElement);
return imgIndex;
}

function statusLoad() {
  window.status="Gallery Moos"; return true;
}

window.defaultStatus="Gallery Moos";

/*Artist names here. Spaces allowed.
Data structure is: firstName_lastName_on/off, first letter of first and last name uppercase
Format is: 'lastName_firstName_on/off',
Alphabetical order not required.
Enter nfn for firstName if no first name.
NB: No comma after LAST entry*/


artistNames=new Array(
'Anderson_John_on',
'Appel_Karel_off',
'Aspell_Peter_on',
'Bachinski_Walter_on',
'Baj_Enrico_on',
'Beall_Jeff_off',
'Bouchard_Denis_on',
'Chandra_Avinash_on',
'Correa_Leonidas_on',
'Danby_Ken_on',
'Demarche_Josu\&eacute\;_on',
'Dinkin_Larry_on',
'Dona_Lydia_on',
'Etrog_Sorel_on',
'Gaucher_Yves_off',
'Geden_Dennis_on',
'Halahmy_Oded_on',
'Hedrick_Robert_on',
'Hofer_Candida_on',
'Iskowitz_Gershon_on',
'Janvier_Alex_on',
'Jenkins_Paul_on',
'Johnson_Lester_on',
'Kalko_Julius_on',
'Kelley_Paul_on',
'Lazos_William_on',
'Levy_Evan_on',
'Longobardi_Nino_on',
'Mancuso_Vince_on',
'Manzi_Sandra_on',
'McEwen_Jean_off',
'Mitic_Viktor_on',
'Paulino_nfn_on',
'Picasso_Pablo_off',
'Riopelle_Jean-Paul_on',
'Scherman_Tony_on',
'Scott_William_off',
'Tapies_Anton\&iacute\;_off',
'Thaddaeus_nfn_on',
'Urban_David_on',
'White_Ray Charles_on',
'Ash_Marc_on',
'Stockholder_Jessica_on',
'Lukacs_Attila_on',
'Holdsworth_Geoffrey_on',
'Cahen_Oscar_on',
//'Salome_nfn_on',
'Slaughter_Tom_on',
'Ellis_Scott_on',
'Kim_Tschang-Yeul_on',
'Renyi_Hu_on',
'Kramer_Burton_on'
);

var lastChar1 = new Array(
'Cahen',
//'Salome',
'Hofer',
'Renyi',
'Tapies'
);

var lastChar2 = new Array(
'Cah\&eacute\;n',
//'Salom\&eacute\;',
'H&ouml\;fer',
'Ren Yi',
'Tapi&egrave\;s'
);


//Sort in alphabetical order by last name
artistNames.sort();

/*Allow for special pages
Array element position counting from zero and in alphabetical order!
exCeptMenu is position in active names array (countOn)
exCeptMain is position in all names array (count)*/
//var exCeptMenu = 35;
//var exCeptMain = 39;
var exCeptMenu = 0;
var exCeptMain = 0;
//Special page
//var xCeptGoTo = 'paulino/paulino';
var xCeptGoTo = 'view';

// function stringSplit() to parse the array data into new arrays
function stringSplit ( string, delimiter ) { 
if ( string == null || string == "" ) { 
return null; 
} else if ( string.split != null ) { 
return string.split ( delimiter ); 
} else { 
var ar = new Array(); 
var i = 0; 
var start = 0; 
while( start >= 0 && start < string.length ) { 
var end = string.indexOf ( delimiter, start ) ; 
if( end >= 0 ) { 
ar[i++] = string.substring ( start, end ); 
start = end+1; 
} else { 
ar[i++] = string.substring ( start, string.length ); 
start = -1; 
};
} 
return ar; 
}; 
} 

// Create 2D array to parse artistNames
var firstLastNames = new Array();

//Parse the artistNames array
for (var i=0; i < artistNames.length; i++) {
firstLastNames[i]=stringSplit(artistNames[i], '_' );
}

// Create 3 arrays to hold the 3 array column values -- [i][0] , [i][1] and [i][2] -- of each 2D row element of firstLastNames array
var firstNames = new Array();
var lastNamesTemp = new Array();
var lastNamesLink = new Array();
var onOrOff = new Array();

for (var i=0; i < firstLastNames.length; i++) {
firstNames[i]=firstLastNames[i][1];
lastNamesTemp[i]=firstLastNames[i][0];
lastNamesLink[i]=firstLastNames[i][0];
onOrOff[i]=firstLastNames[i][2];
}

var lastIndex = new Array();
var lastChar1Index = new Array();
var p=0;
var q=0;
for (var i = 0; i < lastNamesTemp.length; i++) {
for (var j = 0; j < lastChar1.length; j++) {
if (lastNamesTemp[i] == lastChar1[j]) {
lastIndex[p++]=indexId(lastNamesTemp,lastChar1[j]);
lastChar1Index[q++]=indexId(lastChar1,lastChar1[j]);
};
};
}

var lastTemp2 = new Array();
for (var i = 0; i < lastChar2.length; i++) {
for (var j = 0; j < lastChar1Index.length; j++) {
lastTemp2[j]=lastChar2[lastChar1Index[j]];
};
}

var lastTemp1 = new Array();
for (var i=0; i < lastIndex.length; i++) {
lastTemp1[i] = lastNamesTemp.splice(lastIndex[i],1,lastTemp2[i]);
}

var lastNames=lastNamesTemp.slice(0);

//Make full first name + last name array
var nameArtist = new Array();
for (var i=0; i < artistNames.length; i++) {
if (firstNames[i] == 'nfn') {
nameArtist[i]=lastNames[i];
}
else {
nameArtist[i]=firstNames[i] + ' ' +  lastNames[i];
};
}

function Array_splice(index, delTotal) {
var temp = new Array();
var response = new Array();
var A_s = 0;
for (A_s = 0; A_s < index; A_s++) {
temp[temp.length] = this[A_s];
}
for (A_s = 2; A_s < arguments.length; A_s++) {
temp[temp.length] = arguments[A_s];
}
for (A_s = index + delTotal; A_s < this.length; A_s++) {
temp[temp.length] = this[A_s];
}
for (A_s = 0; A_s < delTotal; A_s++) {
response[A_s] = this[index + A_s];
}
this.length = 0;
for (A_s = 0; A_s < temp.length; A_s++) {
this[this.length] = temp[A_s];
}
return response;
}
if (typeof Array.prototype.splice == 'undefined') {
Array.prototype.splice = Array_splice;
}

// Array.slice() - Copy and return several elements
if( typeof Array.prototype.slice==='undefined' ) {
 Array.prototype.slice = function( a, c ) {
  var i, b, d = [], l = this.length;
  if( !c ) { c = l; }
  if( c<0 ) { c = l + c; }
  if( a<0 ) { a = l - a; }
  if( c<a ) { i = a; a = c; c = i; }
  for( i = 0; i < c - a; i++ ) { d[i] = this[a+i]; }
  return d;
 };
}
