
function openWordUrl(bookId,chapterId,wordId,paneUin,verseNo){
	navigateToBookChapterVerse(new GreekURLCommand(bookId,chapterId,wordId,paneUin,verseNo));
}

function openStrongReferenceUrl(bookId,chapterId,strongRefId,paneUin,verseNo){
	navigateToBookChapterVerse(new KJVURLCommand(bookId,chapterId,strongRefId,paneUin,verseNo));
}

function navigateToBookChapterVerse(urlCommand){
	var openerWin = top.opener
	if (openerWin && !openerWin.closed){
		openerWin.focus();
		urlCommand.openURL(openerWin);
	}else{
		if (top.gbsPopup && !top.gbsPopup.closed){
			top.gbsPopup.focus();
			urlCommand.openURL(top.gbsPopup);
			return;
		}
		urlCommand.openURLinNewWin();
	}
}

function URLCommand(bookId,chapterId,textElementId,paneUin,verseNo,paramName){
	this.bookId = bookId
	this.chapterId = chapterId
	this.textElementId = textElementId
	this.paneUin = paneUin
	this.verseNo = verseNo

	this.dialogId = "TextContentDialog"
	this.paramName = paramName
}

URLCommand.prototype.openURL = function(openerWin){}

URLCommand.prototype.openURLinNewWin = function(){
	var paramString = !this.bookId? "" : "&bookId="+this.bookId
			+"&chapterId="+this.chapterId
			+"&"+this.paramName+"="+this.textElementId
			+"&paneUin="+this.paneUin
			+"&verseNo="+this.verseNo;
	top.gbsPopup = top.open("main.do?mainContent=true"+paramString,
		"gbs", "menubar=yes,location=yes,toolbar=yes,status=yes,resizable=yes,scrollbars=yes");
}

function GreekURLCommand(bookId,chapterId,wordId,paneUin,verseNo){
	this.base = URLCommand
	this.base(bookId,chapterId,wordId,paneUin,verseNo,"wordId")
}

GreekURLCommand.prototype = new URLCommand()

GreekURLCommand.prototype.openURL = function(openerWin){
	openerWin.dlgWindow.registry[this.dialogId].openWordUrl(this.bookId,this.chapterId,this.textElementId,this.paneUin,this.verseNo);
}

function KJVURLCommand(bookId,chapterId,strongRefId,paneUin,verseNo){
	this.base = URLCommand
	this.base(bookId,chapterId,strongRefId,paneUin,verseNo,"strongRefId")
}

KJVURLCommand.prototype = new URLCommand()

KJVURLCommand.prototype.openURL = function(openerWin){
	openerWin.dlgWindow.registry[this.dialogId].openStrongRefUrl(this.bookId,this.chapterId,this.textElementId,this.paneUin,this.verseNo);
}

function DefaultCommand(){
	this.base = URLCommand
	this.base(null,null,null,null,null,null)
}

DefaultCommand.prototype = new URLCommand()

DefaultCommand.prototype.openURL = function(openerWin){
	// nope
}

function areLinksEnabled(doc, disabledLinkClassName){
	var links = doc.links;
	if (links[0].className == "uselessLink") return false;
	for (var i = 0; i < links.length; i++){
		var link = links[i];
		link.className = "uselessLink";
		link.onmouseover = null;
	}
	wholeVerseTip.mouseOutHandler();
	return true;
}

function familyListOnLoadHandler(frameId){
//alert('from onLoadHandler\nparent = ' + parent + '\nfunc = ' + parent.resetFrameHeight)
	if (parent && parent.resetFrameHeight) {
	//alert('call parent.resetFrameHeight')
		//setTimeout("parent.resetFrameHeight('" + frameId + "')",3000)
		parent.resetFrameHeight(frameId)
	}
}