function bookmarksite(title,url){
    title=stripslashes(title)
    //Firefox
    if (window.sidebar) {
      window.sidebar.addPanel(title, url, "");
    }
    else if(window.opera && window.print){
      var elem = document.createElement('a');
      elem.setAttribute('href',url);
      elem.setAttribute('title',title);
      elem.setAttribute('rel','sidebar');
      elem.click();
    }
    else if(document.all) {
      window.external.AddFavorite(url, title);
    }
  }

  function stripslashes(str) {
    str=str.replace(/\\'/g,'\'');
    str=str.replace(/\\"/g,'"');
    str=str.replace(/\\\\/g,'\\');
    str=str.replace(/\\0/g,'\0');
    return str;
  }

  function confirmRestore() {
    var agree=confirm("Are you sure you want to restore the default picture?");
    if (agree) {
      return true;
    }
    else {
      return false;
    }
  }

  function restore() {
    if (confirmRestore()){
      document.getElementById("restoreIT").value="1";
      //document.addPic.action="<?php $_SERVER["PHP_SELF"];?>";
      document.addPic.submit();
      return true;
    }
    else {
      return false;
    }
  }

  function confirmRemove() {
    var agree=confirm("Are you sure you want to remove\nthe special event picture?");
    if (agree) {
      return true;
    }
    else {
      return false;
    }
  }

  function remove() {
    if (confirmRemove()){
      document.addPic['removeIT'].value="1";
      //document.addPic.action="<?php $_SERVER["PHP_SELF"];?>";
      document.addPic.submit();
      return true;
    }
    else {
      return false;
    }
  }

  function confirmAction(theAction,theNum) {
    var contribID='contributor~:;:~'+theNum
    var cityID='city~:;:~'+theNum
    var stateID='state~:;:~'+theNum
    var testID='testimony~:;:~'+theNum

    var theContribObj = document.getElementById(contribID);
    var theContrib = trim(theContribObj.value);

    var theCityObj = document.getElementById(cityID);
    var theCity = trim(theCityObj.value);

    var theStateObj = document.getElementById(stateID);
    var selStateObj = document.getElementById(stateID).selectedIndex;

    var theTestObj = document.getElementById(testID);
    var theTest = trim(theTestObj.value);

    if (theAction=="add") {
      var msg = "Are you sure you wish to "+theAction+" a new testimony entry?";
    }
    else {
      var msg = "Are you sure you wish to "+theAction+" this testimony entry?";
    }
    var agree=confirm(msg);
    if (agree) {
      if (theAction != "add" && theAction != "delete") {
        if (theContrib == "") {
          alert("Unable to save this testimony.\n\nPlease enter the contributor(s) name...");
          document.getElementById("errorMsg").innerHTML = "";
          theContribObj.focus();
          return false;
        }
        if (theCity == "") {
          alert("Unable to save this testimony.\n\nPlease enter a city name...");
          document.getElementById("errorMsg").innerHTML = "";
          theCityObj.focus();
          return false;
        }
        if (selStateObj == 0) {
          alert("Unable to save this testimony.\n\nPlease select a state...");
          document.getElementById("errorMsg").innerHTML = "";
          theStateObj.focus();
          return false;
        }
        if (theTest == "") {
          alert("Unable to save this testimony.\n\nPlease enter the testimony...");
          document.getElementById("errorMsg").innerHTML = "";
          theTestObj.focus();
          return false;
        }
      }
      theRequest = theAction + '~:;:~' + theNum;
      document.testimony_form.theAction.value=theRequest;
      document.testimony_form.submit();
    }
    else {
      document.testimony_form.theAction.value="";
      return false;
    }
  }

  function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g,"");
  }

  function getPosition(theElement) {
    var positionX = 0;
    var positionY = 0;
    while (theElement != null) {
      positionX += theElement.offsetLeft;
      positionY += theElement.offsetTop;
      theElement = theElement.offsetParent;
    }
    return [positionX, positionY];
  }

  function findPosX(obj) {
       var curleft = 0;
       if (obj.offsetParent) {
            while (obj.offsetParent) {
                 curleft += obj.offsetLeft
                 obj = obj.offsetParent;
            }
       }
       else if (obj.x)
            curleft += obj.x;
       return curleft;
  }

  function findPosY(obj){
       var curtop = 0;
       if (obj.offsetParent){
            while (obj.offsetParent){
                 curtop += obj.offsetTop
                 obj = obj.offsetParent;
            }
       }
       else if (obj.y)
            curtop += obj.y;
       return curtop;
  }

  function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
      curleft = obj.offsetLeft
      curtop = obj.offsetTop
      while (obj = obj.offsetParent) {
        curleft += obj.offsetLeft
        curtop += obj.offsetTop
      }
    }
    var theValue = curleft+"px "+curtop+"px";
    return theValue;
  }

  function showStatus(sMsg) {
    window.status = sMsg ;
    return true ;
  }

  function chgLookOver(someID) {
    if (document.getElementById(someID).className == "main_inputs") {
     document.getElementById(someID).className = "inputHighlighted";
    }
    if (document.getElementById(someID).className == "tbuttons") {
      document.getElementById(someID).className = "tbuttons-hover";
    }
    if (document.getElementById(someID).className == "tinputs") {
      document.getElementById(someID).className = "tinputs-hover";
    }
    else if (document.getElementById(someID).className == "linputs") {
      document.getElementById(someID).className = "linputs-hover";
    }
  }

  function chgLookOut(someID) {
    if (document.getElementById(someID).className == "inputHighlighted") {
      document.getElementById(someID).className = "main_inputs";
    }
    if (document.getElementById(someID).className == "tbuttons-hover") {
      document.getElementById(someID).className = "tbuttons";
    }
    if (document.getElementById(someID).className == "tinputs-hover") {
      document.getElementById(someID).className = "tinputs";
    }
    if (document.getElementById(someID).className == "linputs-hover") {
      document.getElementById(someID).className = "linputs";
    }
  }

  function printURL(sHref) {
    if(document.getElementById && document.all && sHref){
      if(!self.oPrintElm){
        var aHeads = document.getElementsByTagName('HEAD');
        if(!aHeads || !aHeads.length)
          return false;
        if(!self.oPrintElm)
          self.oPrintElm = document.createElement('LINK');
        self.oPrintElm.rel = 'alternate';
        self.oPrintElm.media = 'print';
        aHeads[0].appendChild(self.oPrintElm);
      }
      self.oPrintElm.href = sHref;
      self.focus();
      self.print();
      return true;
    }
    else
      return false;
    }

  //Submit form when "enter" is pressed (need to put the following code into the last input, not the submit input/button):
  // onKeyPress="return submitenter(this,event)"
  function submitenter(myfield,e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

    if (keycode == 13) {
      myfield.form.submit();
      return false;
    }
    else
      return true;
  }
  function clearText(field) {
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
  }
