var path_to_ftindex_file = "ftindexes.xml";
var ft_index_info = null;
var oLMSAPI_ref = null;
var ftidebug = new Boolean( false );
function set_input_font( dom_obj_id, rfc_lang ){
var font_fam = "";
var s = rfc_lang;
if ( !s ) s = GetItemFromURL('Lang');
switch( s ){
case "ja":  font_fam="MS Gothic"; break;
case "zh-chs": font_fam="SimSum"; break;
case "zh-cht": font_fam="MingLiU"; break;
case "ko":  font_fam="Gulim";  break;
}
if ( font_fam != "" ){
var input_obj = window.document.all( dom_obj_id );
if( input_obj ) input_obj.style.fontFamily = font_fam;
}
}
function get_selected_search_indexes(){
var course_only = window.document.all("idSearchCourse")
var urls = new Array();
if ( !course_only ) urls=get_index_urls();
else {
if ( course_only.checked == false ) urls=get_index_urls();
else {
if ( oLMSAPI_ref ){
var sname = oLMSAPI_ref.LRNGetCurrentManifestID();
urls=get_index_url_by_ref( sname );
}
}
}
return urls;
}
function how_many_courses(){
if ( oLMSAPI_ref == null ) return -1;
else {
var arr = get_index_urls();
return arr.length;
}
}
function load_ft_index_info(){
oLMSAPI_ref = FindLMSAPI();
if ( oLMSAPI_ref == null ) return;
var path = oLMSAPI_ref.LRNGetManifestPath();
path+=path_to_ftindex_file;
var srcdom = xml_load( path, ftidebug );
if ( srcdom == null ) return;
ft_index_info = srcdom;
}
function get_index_urls(){
var ret = new Array();
if ( ft_index_info != null ) {
var nl = ft_index_info.documentElement.selectNodes("./index");
for( var i=0; i < nl.length; i++ ) {
var idref = nl[i].getAttribute("idref");
var test = oLMSAPI_ref.LRNGetResourcesPathByManifestID( idref );
if ( test == "" ) continue;
var path = oLMSAPI_ref.LRNGetManifestPath();
path+=nl[i].getAttribute("src");
ret[ret.length] = path;
}
}
return ret;
}
function get_index_url_by_ref( sname ){
var ret = new Array();
if ( oLMSAPI_ref == null ) return ret;
if ( ft_index_info != null ) {
var node = ft_index_info.documentElement.selectSingleNode("./index[@idref='" + sname + "']");
if ( node != null ) {
var test = oLMSAPI_ref.LRNGetResourcesPathByManifestID( sname );
if ( test == "" ) return ret;
var path = oLMSAPI_ref.LRNGetManifestPath();
path+=node.getAttribute("src");
ret[ret.length] = path;
} else
return get_index_urls();
}
return ret;
}
function getbasepath( str ) {
var la; var lb;
la = str.lastIndexOf("/");
lb = str.lastIndexOf("\\");
if ( la < lb ) la = lb;
if ( la != 0 ) str = str.substr( 0, la );
return str;
}
var NODE_ELEMENT    = 1;
var NODE_TEXT     = 3;
var NODE_DOCUMENT    = 9;
var xmlparsermode     = 0;
var xmlparserversion     = 0.0;
var xmlparsercontrolname    = "";
setlatestknownxmlparser();
function setlatestknownxmlparser() {
var xmltestobj = null;
var xmltext = '<?xml version="1.0" ?><root></root>';
xmlparsermode = 0;
xmlparserversion = 0.0;
xmlparsercontrolname = "";
try {
xmltestobj = new ActiveXObject("Msxml2.DOMDocument.4.0");
xmltestobj.async = false;
if ( xmltestobj.loadXML( xmltext ) ) {
if ( xmlparserversion == 0.0 )  xmlparserversion = 4.0;
if ( xmlparsercontrolname == "" ) xmlparsercontrolname = "Msxml2.DOMDocument.4.0";
xmlparsermode++;
}
} catch( e ) { ; }
try {
xmltestobj = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmltestobj.async = false;
if ( xmltestobj.loadXML( xmltext ) ) {
if ( xmlparserversion == 0.0 )  xmlparserversion = 3.0;
if ( xmlparsercontrolname == "" ) xmlparsercontrolname = "Msxml2.DOMDocument.3.0";
xmlparsermode++;
}
} catch( e ) { ; }
if ( xmlparsermode < 2 ) {
try {
xmltestobj = new ActiveXObject("Msxml2.DOMDocument.2.6");
xmltestobj.async = false;
if ( xmltestobj.loadXML( xmltext ) ) {
if ( xmlparserversion == 0.0 )  xmlparserversion = 2.6;
if ( xmlparsercontrolname == "" ) xmlparsercontrolname = "Msxml2.DOMDocument.2.6";
xmlparsermode++;
}
} catch( e ) { ; }
}
if ( xmlparsermode < 2 ) {
try {
xmltestobj = new ActiveXObject("Msxml2.DOMDocument");
xmltestobj.async = false;
if ( xmltestobj.loadXML( xmltext ) ) {
if ( xmlparserversion == 0.0 )  xmlparserversion = 2.0;
if ( xmlparsercontrolname == "" ) xmlparsercontrolname = "Msxml2.DOMDocument";
xmlparsermode++;
}
} catch( e ) { ; }
}
if ( xmlparsermode < 2 ) {
try {
xmltestobj = new ActiveXObject("Msxml.DOMDocument");
xmltestobj.async = false;
if ( xmltestobj.loadXML( xmltext ) ) {
if ( xmlparserversion == 0.0 )  xmlparserversion = 1.0;
if ( xmlparsercontrolname == "" ) xmlparsercontrolname = "Msxml.DOMDocument";
xmlparsermode++;
}
} catch( e ) { ; }
}
if ( xmlparsermode == 0 ) return false;
return true;
}
function getxmlobject(){
var ret = new ActiveXObject( xmlparsercontrolname );
ret.async = false;
return ret;
}
function xml_load( srcfile, loud ) {
var rxmlobj = getxmlobject();
rxmlobj.async = false;
rxmlobj.resolveExternals = false;
rxmlobj.validateOnParse = false;
rxmlobj.load( srcfile );
rdocument = rxmlobj.documentElement;
if ( rxmlobj.parseError.errorCode != 0 ) {
if ( loud != null ){
if ( loud == false ) return null;
}
alert("Errors loading results XML data..." + " line: " + rxmlobj.parseError.line + "\n"
+ " " + "linepos: " + rxmlobj.parseError.linepos + "\n"
+ " " + "filepos: " + rxmlobj.parseError.filepos + "\n"
+ " " + "url: " + srcfile + "\n'"
+ rxmlobj.parseError.srcText + "'\n"
+ rxmlobj.parseError.reason );
return null;
}
return rxmlobj;
}