//default view type
var DefinitionViewType = "cc";

//defaut bible translation
var BibleTranslations = "KJV"

//search form field name
var SearchFieldName = "tbScriptures";

function setViewType(viewtype){
	DefinitionViewType = viewtype;
}

function setScripture(tBox){
	var strText = eval("Form." + tBox);
	var selBook = eval("Form." + sender);
		strText.value = selBook.options[selBook.selectedIndex].text + " 1:1";
}

function SetVerse(mTextBox, SelectBox, SelectedItem){
	if (SelectBox.options[SelectedItem].value == "OT" || SelectBox.options[SelectedItem].value == "NT")
		mTextBox.value = "";
	else
		mTextBox.value = SelectBox.options[SelectedItem].text + ' 1:1';
}
			
//get the number of chapters for a given book
function GetScriptures(){
	var Scripture = document.getElementById(SearchFieldName);
	if (Scripture != null)
	{
		if (Scripture.value.length > 3 && Scripture.value != "Enter Scripture here.")
		  BibleSearchMethods.GetScripturesFromText(BibleTranslations, Scripture.value, GetScripturesFromText_callback);
		else
		  alert("Please enter a scripture");
	}
	else
		alert("Errors occured");
}

//Get a list of scriptures by reference id
function GetScripturesFromText_callback(response){
	if (response.error != null)	{
		//error message
		alert("Error. [2001] \n" + response.request.responseText); 
	}
	else	{
		var dsScriptures = response.value;
		if(dsScriptures != null && typeof(dsScriptures) == "object" && dsScriptures.Tables != null)	
		{
			//get a reference to the bible books and the chapters
			for(var i=0; i < dsScriptures.Tables[0].Rows.length; i++)
			{
			   //Display the book and chapter information
				wH(dsScriptures.Tables[0].Rows[i].Version, DefinitionViewType, dsScriptures.Tables[0].Rows[i].TableVerses);
			}
		}
		else { 
			alert("Error. [3001] \n" + response.request.responseText); 
		}
	}
}