// uncomment these three lines if using IIS and/or adjust the URLS to point to the
// IIS directory where you've located these files. And comment out the next three
// lines.

// var spellCheckURL="http://localhost/jspell_proxy.asp"; // change to point to the JSpell Spell Check Servlet
// var styleSheetURL="http://localhost/jspell.css"; 
// var imagePath="http://localhost/images"; // relative URL to JSpell button images directory
var spellCheckURL="/jcore/JSpell.jsp"; // change to point to the JSpell Spell Check Servlet
var styleSheetURL="/jcore_images/eto/jspell.css"; 
var imagePath="/jcore_images/eto/images/jspell"; // relative URL to JSpell button images directory

var blankURL="about:blank";
//var blankURL="/jspellhtml2k4/blank.html"; // uncomment if using SSL

var ww;	// holds reference to popup
var jspellpopupurl="/jcore/jspellpopup.html"; // specify location of jspellpopup.html
var disableLearn=false; // set to true, to remove the Learn words capability
var forceUpperCase=false; // force suggestions and spell checker to use upper case
var ignoreIrregularCaps=false;	// ignore lower case sentence beginnings, etc.
var ignoreFirstCaps=false;	// ignore if first character in a field is lowercase
var ignoreNumbers=false; // ignore words with embedded numbers
var ignoreUpper=false; // ignore words in upper case
var ignoreDouble=false; // ignore repeated words
var confirmAfterLearn=false; // show warning before user 'learns' a word
var confirmAfterReplace=true; // show warning when replacing using a word not in the suggestions list.
var supplementalDictionary=""; // optional supplemental word list kept at server.
var language="";
var hidePreviewPanel=false; // You can use this to hide the preview panel when running in directEdit mode in IE
var directmode=false; // is highlighting done in original text control or is there a preview panel (IE Windows only)
//var modal=false; // should JSpell Spell Checker dialog be launched using a modal window? (only for IE)

function getURLParam(strParamName){
  var strReturn = null;
  var strHref = ww.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?") + 1);
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}

function getSpellCheckItem(jspell_n) {
	var fieldsToCheck;
	var formName = getURLParam('formname');
	var fieldName = getURLParam('fieldname');
	if(formName != null && fieldName != null) {
		fieldsToCheck=new Array();
	    fieldsToCheck[0]='document.forms["' + formName + '"].' + fieldName;
	} else {
		fieldsToCheck=getSpellCheckArray();
	}
	return fieldsToCheck[jspell_n];
}
function updateForm(jspell_m,newvalue) { eval(getSpellCheckItemValue(jspell_m)+"=newvalue"); }
function getSpellCheckItemValue(jspell_j) { return getSpellCheckItem(jspell_j)+".value"; }
function getSpellCheckItemValueValue(jspell_k) { return eval(getSpellCheckItemValue(jspell_k)); }

function spellcheck() {
	var width=520; var height=200;
	if (navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.toLowerCase().indexOf("opera")==-1 && hidePreviewPanel==false) {	
		directmode=true; width=290;
	} 
//	else
//	{
//		modal=false;
//	}

	if(hidePreviewPanel==true)
		width=290;

	var w = 1024, h = 768;
	if (document.all || document.layers)
	{
		w=eval("scre"+"en.availWidth"); h=eval("scre"+"en.availHeight");
	}

	var leftPos = (w/2-width/2), topPos = (h/2-height/2);
	
//	if(!modal)
//	{
		ww=window.open(jspellpopupurl, "checker", "width="+width+",height="+height+",top="+topPos+",left="+leftPos+",toolbar=no,status=no,menubar=no,directories=no,resizable=yes");
		ww.focus();
//	} else
//	{
//		ww=window.showModalDialog(jspellpopupurl, self, "dialogHeight:"+(height+20)+",dialogWidth="+(width+10)+",dialogTop="+topPos+",dialogLeft="+leftPos+",help:no,scroll:no,status:no");
//	}
}

function spellcheckFormField(strFormFieldName) {
	var width=520; var height=200;
	if (navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.toLowerCase().indexOf("opera")==-1 && hidePreviewPanel==false) {	
		directmode=true; width=290;
	} 
//	else
//	{
//		modal=false;
//	}

	if(hidePreviewPanel==true)
		width=290;

	var w = 1024, h = 768;
	if (document.all || document.layers)
	{
		w=eval("scre"+"en.availWidth"); h=eval("scre"+"en.availHeight");
	}

	var leftPos = (w/2-width/2), topPos = (h/2-height/2);
	
//	if(!modal)
//	{
		//strFormFieldName is assumed to contain a concatenated form name and field name 
		//seperated by a '|'
	    var aFormFieldNames = strFormFieldName.split("|");
        var strFormName = aFormFieldNames[0];
        var strFieldName = aFormFieldNames[1];

		var formFieldUrl = jspellpopupurl + "?formname="+strFormName+"&fieldname="+strFieldName;
		ww=window.open(formFieldUrl, "checker", "width="+width+",height="+height+",top="+topPos+",left="+leftPos+",toolbar=no,status=no,menubar=no,directories=no,resizable=yes");
		ww.focus();
//	} else
//	{
//		ww=window.showModalDialog(jspellpopupurl, self, "dialogHeight:"+(height+20)+",dialogWidth="+(width+10)+",dialogTop="+topPos+",dialogLeft="+leftPos+",help:no,scroll:no,status:no");
//	}
}

function spellCheckClosed()
{
    // Place code here that will execute when the spell check dialog is closed.
}