/*
  COPYWRITE

  This javascript library file is the sole property of Art Main and GoldCoastDesign and may
  not be reproduced, sold, or used in whole or in part for any purpose other than intended.
  All rights to this code is not transfered to the client it was provided for.  This code
  may be used for the single domain and purpose as provided by Art Main and GoldCoastDesign
  to the client it is intended for.

  Questions or concerns may be directed to info@goldcoastdesign.org

*/

/*
  Function list:

  * deleteByIndex(array myArray,index) -> array
  * deleteByValue(array myArray,value) -> array
  * showArray(array what,string title) -> alert(string)
  * getIndexByValue(array myArray,value) -> index
  * inArray(myArray,value) -> true/false

*/


function deleteByIndex(myArray,index) {
  //showArray(myArray, "before");
  myArray.splice(index,1);
  //showArray(myArray, "after");
  return myArray;
}

function deleteByValue(myArray,value) {
  //showArray(myArray, "before");
  mylength = myArray.length;
  i = 0;
  do {
    if (myArray[i] == value) {
      return myArray.splice(i,1);
    }
    i++;
  } while (i<mylength);
}

function showArray(what, title) {
  myString = (title) ? title : "";
  if (what) {
    items = what;
    for (i in items) {
      myString += i + "=" + items[i] + "\n";
    }
  }
  alert(myString);
}

function getIndexByValue(myArray,value) {
  mylength = myArray.length;
  i = 0;
  do {
    if (myArray[i] == value) {
      return i;
    }
    i++;
  } while (i<mylength);
}

function inArray(myArray,value) {
  mylength = myArray.length;
  i = 0;
  do {
    if (myArray[i] == value) {
      return true;
    }
    i++;
  } while (i<mylength);
  return false;
}
