// ******************************************************************************
// Title          LivingWord Bible Reading Plan Component for Joomla
// Author         Mike Leeper
// Version        1.x
// Copyright      © by Mike Leeper
// License        This is free software and you may redistribute it under the GPL.
//                LivingWord Bible Reading Plan comes with absolutely no warranty. 
//                For details, see the license at http://www.gnu.org/licenses/gpl.txt
//                YOU ARE NOT REQUIRED TO KEEP COPYRIGHT NOTICES IN
//                THE HTML OUTPUT OF THIS SCRIPT. YOU ARE NOT ALLOWED
//                TO REMOVE COPYRIGHT NOTICES FROM THE SOURCE CODE.
// *******************************************************************************

function validatep1() { 
valid = true;

if( document.settingspage.selectversion.selectedIndex == 0 )
{
alert(selectbv);
valid = false;
return valid;
}

if( document.settingspage.selectplan.selectedIndex == 0 )
{
alert(selectbp);
valid = false;
return valid;
}
}

function clearText() {
var inp = document.getElementById("sentry");
if(inp.value == selectkw)
inp.value = '';
}

function showDictLink(){
var dictsource = document.toolspage.selectdict.selectedIndex;
if(dictsource == 0){
alert(selectdict);
return false;
} else {
  var anchors = document.getElementsByTagName("a");
    for(var i=0; i<anchors.length; i++)
    {
      var anchor = anchors[i];
      var letter = anchor.getAttribute("id");
      if(anchor.getAttribute("href"))
      {
        anchor.href = 'http://www.biblegateway.com/resources/dictionaries/dict_letter.php?source='+dictsource+'&letter='+letter
      }
    }
}
return true;
}

function showComLink(){
var comsource = document.toolspagecom.selectcomment.value;
if(comsource == 0){
alert(selectcom);
return false;
}else{
  var anchors = document.getElementsByTagName("a");
    for(var i=0; i<anchors.length; i++)
    {
      var anchor = anchors[i];
      var book = anchor.getAttribute("id");
      if(book == 'songofsongs') book = 'song';
      if(anchor.getAttribute("href"))
      {
        anchor.href = 'http://eword.gospelcom.net/comments/'+book+'/'+comsource+'/'+book+'intro.htm';
      }
    }
}
return true;
}

function submitDictLookup(){
var lookupText = document.toolspage.sentry.value;
var criteria = document.toolspage.selectcrit.selectedIndex;
var dictsource = document.toolspage.selectdict.selectedIndex;
if(dictsource == 0){
alert(selectdict);
return false;
}
if(criteria == 0) {
alert(selectcrit);
return false;
}
if(lookupText == "" || lookupText == selectkw){
alert(selectkws);
return false;
}
return 'http://www.biblegateway.com/resources/dictionaries/dict_searchresults.php?source='+dictsource+'&search='+lookupText+'&searchtype='+criteria;
}

function reloadParentOnClose(){
var str=window.top.location.reload();
setTimeout(str,3000);
}

function setNTAOptions(){
var selPlan = document.settingspage.selectplan;
var selIndex = document.settingspage.selectversion.selectedIndex;
if(document.settingspage.selplan.value == 0){
document.settingspage.selplan.value = document.settingspage.selectplan.selectedIndex;
}
var title = document.settingspage.selectversion.options[selIndex].title;
titlearray = title.split(/;/);
var nt = titlearray[0];
var audio = titlearray[1];
var av = titlearray[2];
document.settingspage.audioversion.value=av;
var a = optionTmp;
if(audio == 0){
  if( nt == 1 ){
    selPlan.options.length = 0;
    selPlan.options[selPlan.options.length] = new Option(selectbp,0);
    selPlan.options[selPlan.options.length] = new Option(a[6][0],a[6][1]);
  }
  else {
    selPlan.options.length = 0;
    for(i=0;i<7;i++){
    selPlan.options[i] = new Option(a[i][0],a[i][1]);
    }
  }
}
else {
  if( nt == 1 ){
    selPlan.options.length = 0;
    selPlan.options[selPlan.options.length] = new Option(selectbp,0);
    selPlan.options[selPlan.options.length] = new Option(a[10][0],a[10][1]);
  }
  else {
    selPlan.options.length = 0;
    selPlan.options[selPlan.options.length] = new Option(selectbp,0);
    for(i=1,j=7;j<11;j++,i++){
    selPlan.options[i] = new Option(a[j][0],a[j][1]);
    }
  }
}
document.settingspage.selectplan.selectedIndex = 0;
return true;
}

