//return selected radio button index
function returnRadioIndex(radioButton) {
  var counter;
  for (counter=0;counter<radioButton.length;counter++) {
    if (radioButton[counter].checked) {
      return counter;
    }
  }
  return 0;
}

//load search results
function loadSearch(searchPhrase,searchType) {
  //alert("searchPhrase="+searchPhrase+"\nsearchType="+searchType);
  var URL="searchList.php?actionType=newSearch\&searchPhrase=" + searchPhrase + "\&searchType=" + searchType;
  //display search
  parent.searchList.location=URL;
  //clear songInfo and downloadSong panels
  var URL="songInfoPanel.php";
  parent.songInfoPanel.location=URL;
  var URL="downloadSong.php";
  parent.downloadSong.location=URL;  
}

//load songInfo and downloadClips for selected song
function loadSong(songNumber) {
  //song info
  var URL="songInfoPanel.php?songLyricID=" + songNumber;
  parent.songInfoPanel.location=URL;
  //download song
  var URL="downloadSong.php?songNumber=" + songNumber;
  parent.downloadSong.location=URL;  
}

//popup window
function popupWindow(URL,popupWidth,popupHeight) {
  //popup configs
  var screenWidth=0;
  var screenHeight=0;
  //centered screen width
  if (screen.width <= popupWidth) {
    //reset width
    popupWidth=screen.width;
  } else {
    screenWidth=(screen.width-popupWidth)/2;
  }
  //centered screen height
  if (screen.height <= popupHeight) {
    //reset height
    popupHeight=screen.height;
  } else {
    screenHeight=200;
    //screenHeight=((screen.height-popupHeight)/2); 
  }

  //open popup window
  eval("popup" + '' + " = window.open(URL, 'popup', 'toolbar=0,scrollbars=1,location=0,status=1,directories=0,menubar=0,resizable=1,width=" + popupWidth + ",height=" + popupHeight + ",left=" + screenWidth + ",top=" + screenHeight + "');");   
  window.popup.resizeTo(popupWidth,popupHeight);
  window.popup.focus();
}

//copy text to clipboard
function copyClipboard(textarea,browser) {
  var text=eval("document."+textarea);
  text.focus();
  text.select();
  //only IE can highlight & copy
  if (browser == "IE") {
    range=text.createTextRange();
    range.execCommand("Copy");
  }
}
