function openphoto() {
  //0 -- Same window
  //1 -- New Window
  //2 -- Top of the Same Window

  var winTarget = "";
  if (ST == 1) {
      var winTarget="_blank";
  } else if (ST == 2) {
      var winTarget="_top";
  } else {
      var winTarget="_self";
  }

  //window.open(SU,winTarget,"menubar=no,scrollbars=yes,status=no,location=no,width=500,height=720");
  window.open(SU,winTarget,"menubar=no,scrollbars=yes,status=no,location=no");
}

function openhelp() {
  //0 -- Same window
  //1 -- New Window
  //2 -- Top of the Same Window

  var winTarget = "";
  if (HT == 1) {
      var winTarget="_blank";
  } else if (HT == 2) {
      var winTarget="_top";
  } else {
      var winTarget="_self";
  }

  //window.open(HU,winTarget,"menubar=no,scrollbars=yes,status=no,location=no,width=500,height=720");
  window.open(HU,winTarget,"menubar=no,scrollbars=yes,status=no,location=no");
}

function showTip(show) {
  document.getElementById(show).style.display = "block";
  document.getElementById(show).style.visibility = "visible";
}
function hideTip(hide) {
  document.getElementById(hide).style.display = "none";
  document.getElementById(hide).style.visibility = "hidden";
}

function objectExists () {
  if (typeof(aData) == "undefined") {
    return;
  }
}

function initSelect() {

  // check if object exists
  if (typeof(aData) == "undefined") {
    return;
  }

  // defnie the parent and child dropdown
  var pSelect = document.getElementById('selectYour');
  var cSelect = document.getElementById('selectFavorite');

  if (pSelect == null) {
    return;
  }

  if (cSelect == null) {
    return;
  }

  // load the data from the first array if no index has been selected
  var lData   = "";

  if (pSelect.selectedIndex != "") {
    lData = aData[pSelect.selectedIndex];
  } else {
    lData = aData[1];
  }

  // one more safe guard
  if (lData == "") {
    return;
  }

  // check if the selected child data exists
  var cValue = document.gomSubmitForm._selectedFavorite.value;

  // always initialize the first one to this
  cSelect.options[0] = new Option('Select Your Favorite','');
                                                                                    
  // loop through to set the data
  for (iCtr=0;iCtr<=lData.length;iCtr+=1) {

    if (typeof(lData[iCtr]) != "undefined") {

      var lDisp = lData[iCtr].split("-0");
      cSelect.options[iCtr+1] = new Option(lDisp[0],lData[iCtr]);

      // select the selected
      if (cSelect.options[iCtr].value ==  cValue) {
        cSelect.options[iCtr].selected = true;
      }
    }
  }
}

function popSelect(iSelect,ctrlName) {

  var cSelect = document.getElementById(ctrlName);

  // this we need in order to reset the dropdown value, so i case we
  //  less data it does not show the data from  the previous one
  cSelect.options.length = 0;

  // check if data exists for some weird reason if it does not
  if (typeof(aData) == "undefined") {
    return;
  }

  // get the array data for the selected index
  if (iSelect != 0) {
      var lData = aData[iSelect];
  } else {
      lData = aData[1];
      //cSelect.options[0].selected = true;
  }

  // if no data selected then do not do anything
  if (lData == "") {
    return;
  }

  // make the second dropdown with the data from the first selected
  cSelect.options[0] = new Option('Select Your Favorite','');
 
  // loop through to set the data
  for (iCtr=0;iCtr<lData.length;iCtr+=1) {
    var lDisp = lData[iCtr].split("-0");
    cSelect.options[iCtr+1] = new Option(lDisp[0],lData[iCtr]);
  }
}

function imposeMaxLength(Object, MaxLen)
// Only allows user to enter MaxLen chars into textarea
{
  return (Object.value.length <= MaxLen);
}
