// (c) 2000 SpellChecker.net, Inc.  All rights reserved.  www.SpellChecker.net
// PLEASE DO NOT EDIT THIS FILE. THE SYSTEM MIGHT FAIL TO WORK IF THE FILE WAS CHANGED.

// (c) 2000 SpellChecker.net, Inc.  All rights reserved.  www.SpellChecker.net
//
//var service_host = "http://service.host.name/and_path_if_requierd";
//
var schema_url 		= "";
var spp_langs		= "";

var service_host = "http://cgi1.ezboard.com/spellcheck/";
var customerid = "1147458082";
var schema = "6";

var bnr = "0";
var c_lang = "";
var ci_lang = "";

var int_lang = "en";

var hide = "";

var doc_blank = "/lf/blank.html";
var doc_blankform = "/lf/blankform.html";
var doc_process = "script/ssrv.cgi";

var mid_doc;
var is_window_opened = false;

function set_mid_doc(doc) {
	mid_doc = doc;
}

function doSpell( lang, ctrl, url, force_reload, intlang, fctrlname, saw, unloadurl) {
//	alert(is_window_opened);
	if ( (navigator.appName == 'Netscape') && 
	     ( (navigator.appVersion.indexOf('4.5') != -1) || (navigator.appVersion.indexOf('3.0') != -1) ) ) {
		alert('Sorry, currently we do not support Netscape Navigator 3.0, 4.5, 6.0, Internet Explorer 3.0.\nPlease upgrade your browser.');
		return;
	}

	if ( (navigator.appName == 'Netscape') && 
	     ( (navigator.appVersion.indexOf('4.5') != -1) || (navigator.appVersion.indexOf('3.0') != -1) ) ) {
		alert('We are currently not support  Netscape Navigator 3.0, 4.5, 6.0, Internet Explorer 3.0.\nPlease upgrade your browser.');
		return;
	}

	if ( c_lang != '' ) lang = c_lang;

	if ( intlang == '' ) intlang = int_lang;

	var isMSIE = (navigator.appName == 'Microsoft Internet Explorer');
	var Ver = navigator.appVersion;
	if ( (isMSIE && parseInt (navigator.appVersion) < 4) ) {
		alert("Our SpellChecker feature does not support Internet Explorer 3.0.  However, it does support the following browsers: IE 4+, Netscape 4+ ( 6.0).");
		return;
	}
    ////////////////////////////////////////////////////////////////
	var ctrlObj;
	var ctrlName = '';
	var formNum	 = -1;
	var wWidth   = 488;
	var wHeight  = hide==''?440:260;
		
	if (ctrl.constructor && ctrl.constructor == String)
	{
		ctrlName = ctrl;
		formNum  = -1;
		
		ctrlObj  = eval(ctrl);
		wWidth   = ctrlObj.clientWidth < wWidth ? wWidth : ctrlObj.clientWidth;
		wHeight  = (ctrlObj.clientHeight > wHeight ? ctrlObj.clientHeight : wHeight);
	}
	else
	{
		var i = 0;
		for (i = 0; i < document.forms.length; i++)
		{
			if (document.forms[i] == ctrl.form)
				break;
		}
		if (i==document.forms.length)
			formNum = -1;
		else
			formNum = i;

		ctrlName = ctrl.name;
		ctrlObj  = ctrl;
	}
	////////////////////////////////////////////////////////////////	
	if ((ctrlObj.value ? ctrlObj.value : ctrlObj.innerHTML) == '') {
		alert('Nothing to check.');
		return
        }

	if ( lang == '' ) lang = 'en';
	if ( window.name == '' ) window.name = 'sp_ch_opener_window';
	wndname = window.name;

///+++++++++BEGIN++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	var spellWin;
	if (window.bEmbedded && window.bEmbedded == 'true')
		spellWin = window;
	else
		spellWin = window.open("", "spch" + getHostStr(document.location.host), "width=" + wWidth + ",height=" + wHeight + ",toolbar=no,resizable=no");
///+++++++++END++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	var d = spellWin.document;

	var botf = 150;
	if ( (intlang == 'fr') || (intlang == 'ge') ) botf=157;
	if (intlang == 'it') botf=159;
	botf = 159;
///+++++++++BEGIN++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	var s = '';

if (!is_window_opened) {
	if (window.bEmbedded)
	{
		s =
		'<script>' + 
		'\n var cFlag = 1;' +
		'\nfunction uHandler(){ if (cFlag) open("' + url + '?cmd=terminate&txt_ctrl=' + ctrl.name + '");}' +
		'</script>' +
		'<title>Spellchecker.net</title>' + 
		'<frameset onUnload="javascript:uHandler()" rows="'+((bnr==1)?96:30)+',*,'+botf+',0" frameborder="No" framespacing=0 border=0>'
	}
	else
	{
		s =
		'<title>Spellchecker.net</title>' +                       
		'<frameset rows="'+((bnr==1)?96:30)+',*,'+botf+',0'+(hide!=''?',0':'')+'" frameborder="No" framespacing=0 border=0>'
	}	
		s +=
		'    <frame name="navbar" src="' + service_host + doc_blank + '" marginwidth="2" marginheight="0" noresize scrolling="no" frameborder="no" framespacing=0>' +
		'    <frame name="mid" src="about:blank" marginwidth="0" marginheight="0" noresize scrolling="auto" frameborder="no" framespacing=0>' +
		'    <frame name="bot" src="' + service_host + doc_blankform + '" marginwidth=1 marginheight=1 noresize scrolling="auto" frameborder="no" framespacing=0>' +
		'    <frame name="spellsuggestall" src="' + service_host + doc_blank + '" marginwidth=1 marginheight=1 noresize scrolling="no" frameborder="no" framespacing=0>';
		if (hide != '')
			s +=
			'    <frame name="unload" src="' + unloadurl + '" marginwidth=1 marginheight=1 noresize scrolling="no" frameborder="no" framespacing=0>';
		s += '</frameset\>';
///+++++++++END++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++        
	d.open();
	d.write(s);
	d.close();


	if (spellWin.cFlag)
		spellWin.cFlag	= 1;	
	d = spellWin.frames[1].document;
}
	if ( d ) {
		
if (!is_window_opened) {
		var s = 
			'<body>' +
			'<form name=frmSpell method=post action="' + service_host + doc_process + '" lang=' + lang + '>' +
			'<input type=hidden name=slang value="">' +
			'<input type=hidden name=intlang value="">' +
			'<input type=hidden name=text value="">' +
			'<input type=hidden name=cmd value="">' +
			'<input type=hidden name=trg_url value="">' +
			'<input type=hidden name=trg_wnd value="">' +
			'<input type=hidden name=txt_ctrl value="">' +
			'<input type=hidden name=svc_time value="">' +
			'<input type=hidden name=statinfo value="">' +
			'<input type=hidden name=customerid value="">' +
			'<input type=hidden name=schema value="">' +
			'<input type=hidden name=schema_url value="">' +
			'<input type=hidden name=spp_langs value="">' +
			'<input type=hidden name=bnr value="">' +
			'<input type=hidden name=hide value="">' +
			'<input type=hidden name=saw value="">' +
			'</form>' +
			'<center><h2>Loading...</h2>';
			if ( hide != '' )
				s = s + '<a href="" onclick="parent.opener.'+fctrlname+'.focus(); parent.close() //document.location = \''+service_host+doc_process+'?cmd=eos&customerid='+customerid+'&sessionid=0&bnr='+bnr+'&schema='+schema+'&hide='+hide+'\'; return false//parent.close(); return false">Abort SpellChecker</a>&nbsp;&nbsp;' +
					'<a href="" onclick="eval(\'parent.opener.\'+(parent.opener.'+saw+'.send_action)); parent.opener.focus(); document.location = \''+service_host+doc_process+'?cmd=eos&customerid='+customerid+'&sessionid=0&bnr='+bnr+'&schema='+schema+'&hide='+hide+'\'; return false">Send Without Checking</a>';
		    s =	s + '<center></center>' +
			'</body>';
                
		d.open();
		d.writeln(s);
		d.close();
}                	
		var f_dst;
		if (!is_window_opened)
			f_dst = d.forms[0];
		else {
			f_dst = spellWin.frames[4].document.forms[0];
			f_dst.action = service_host + doc_process;
//			f_dst.lang = lang;
		}

		f_dst.cmd.value = 'spell';
		f_dst.slang.value = lang;
		f_dst.intlang.value = intlang;
		f_dst.text.value = ctrlObj.value ? ctrlObj.value : ctrlObj.innerHTML;
		f_dst.trg_url.value = url;
		f_dst.trg_wnd.value = wndname;
///+++++++++BEGIN++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		if ( fctrlname ) {
			f_dst.txt_ctrl.value = fctrlname;
		} else {
			if (formNum != -1)
				f_dst.txt_ctrl.value = force_reload ? 'document.forms[' + i + '][\'' + ctrlName + '\']' : '';
			else
				f_dst.txt_ctrl.value = force_reload ? ctrlName : '';
		}
///+++++++++END++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++        
		f_dst.svc_time.value = (new Date()).getTime();
		f_dst.customerid.value = customerid?customerid:'';
		f_dst.schema.value = schema?schema:'';
		f_dst.schema_url.value = schema_url;
		f_dst.spp_langs.value = spp_langs;
		f_dst.bnr.value = bnr;
		f_dst.hide.value = hide;
		f_dst.saw.value = saw;
		f_dst.submit();
		spellWin.focus();

		if (hide != "")	is_window_opened = true;
	}
}

function getHostStr(str)
{
    var res = getSplitStr(str, ".");
    res = getSplitStr(res, ":");
    res = getSplitStr(res, "-");
   
    return res;
}

function getSplitStr(str, del)
{
    var res = "";
    var arr = str.split(del);
    for(var i = 0; i < arr.length; i++)
    {
      if (res != "")
        res = res +"_";
      res = res + arr[i];
    }
    return res;
}

