RootURL = "http://www.macmillanprofessionallearning.com.au/"; /* --------------------------------------------------------------------------------------------------------------- */ /* Generic wrapper functions */ function GetArticleInfo(Section, Subsection) { viewResults = new Array; Result = DoFilterSearch("Subsections", Section, Subsection, "", 1, 1); try { eval(Result); } catch (err) { alert(err); } return viewResults[1]; } function GetOrderedListByKeywords(Section, Subsection, KeywordCat, SubKeyword, MaxItems) { viewResults = new Array; Result = DoFilterSearch("Multi", Section, Subsection, ":" + KeywordCat + ">" + SubKeyword, 1, MaxItems); try { eval(Result); } catch (err) { alert(err); } return viewResults; } function SearchFor(Query, MaxItems) { searchResults = new Array; Result = DoSearch(Query, 1, MaxItems, 1); try { eval(Result); } catch (err) { alert(err); } return searchResults; } function SearchForOrderBy(Query, MaxItems, OrderBy) { searchResults = new Array; Result = DoSearch(Query, 1, MaxItems, OrderBy); try { eval(Result); } catch (err) { alert(err); } return searchResults; } function GetBioList(MaxItems) { viewResultsBio = new Array; Result = DoBioSearch(MaxItems); Result = Result.replace(/\n/gi, " "); try { eval(Result); } catch (err) { alert(err); } return viewResultsBio; } /* --------------------------------------------------------------------------------------------------------------- */ /* Higher level search functions */ function DoFilterSearch(FilterType, Section, Subsection, Extras, Start, Count) { // Uses: viewObject URL = "filter.js?readform&type=" + FilterType + "&cat=" + escape(Section) + ">" + escape(Subsection) + Extras + "&start=" + Start + "&count=" + Count + "&rnd=" + rnd(1000); Result = CallAjaxSync("GET", URL); return DoSearchFix(Result); } function DoSearch(Query, Start, Count, SearchOrder) { // 1 relevance, 2 date asc, 3 date desc, 4 view order // Uses: searchObject URL = "search.js?open&query=" + Query + "&start=" + Start + "&count=" + Count + "&SearchOrder=" + SearchOrder + "&rnd=" + rnd(1000); Result = CallAjaxSync("GET", URL); return DoSearchFix(Result); } function DoBioSearch(Count) { // Uses: viewObjectBio URL = "bioresults.js?readform&type=All&startkey=A&count=" + Count; Result = CallAjaxSync("GET", URL); return DoSearchFix(Result); } function DoSearchFix(Result) { iLoc = Result.indexOf("Array;"); if (iLoc > 0) { FixedResult = Result.substring(iLoc + 7); return FixedResult; } else { return ""; } } function viewObjectBio(viewDocID, viewBioName, viewBioJobTitle, viewBioDescription, viewBioCategories, viewBioPhone, viewBioEmail, viewBioMobile, viewCategories, viewBioStatus) { this.viewDocID = unescape(viewDocID); this.viewBioName = unescape(viewBioName); this.viewBioJobTitle = unescape(viewBioJobTitle); this.viewBioDescription = unescape(viewBioDescription); this.viewBioCategories = unescape(viewBioCategories); this.viewBioPhone = unescape(viewBioPhone); this.viewBioEmail = unescape(viewBioEmail); this.viewBioMobile = unescape(viewBioMobile); this.viewCategories = unescape(viewCategories); this.viewBioStatus = unescape(viewBioStatus); } function searchObject(viewDocID, viewTitle, viewSummary, viewArticleAuthorName, viewPageDate, viewIssue, viewSection, viewCategories, viewGeography, viewCompanies, viewTreePath) { this.viewDocID = unescape(viewDocID); this.viewTitle = unescape(viewTitle); this.viewSummary = unescape(viewSummary); this.viewArticleAuthorName = unescape(viewArticleAuthorName); this.viewPageDate = unescape(viewPageDate); this.viewIssue = unescape(viewIssue); this.viewSection = unescape(viewSection); this.viewCategories = unescape(viewCategories); this.viewGeography = unescape(viewGeography); this.viewCompanies = unescape(viewCompanies); this.viewTreePath = unescape(viewTreePath); } function viewObject(viewDocID, viewTitle, viewSummary, viewArticleAuthorName, viewPageDate, viewIssue, viewSection, viewStoryAccess, viewParentID, viewCategories, viewGeography, viewCompanies, viewTreePath) { this.viewDocID = unescape(viewDocID); this.viewTitle = unescape(viewTitle); this.viewSummary = unescape(viewSummary); this.viewArticleAuthorName = unescape(viewArticleAuthorName); this.viewPageDate = unescape(viewPageDate); this.viewIssue = unescape(viewIssue); this.viewSection = unescape(viewSection); this.viewStoryAccess = unescape(viewStoryAccess); this.viewParentID = unescape(viewParentID); this.viewCategories = unescape(viewCategories); this.viewGeography = unescape(viewGeography); this.viewCompanies = unescape(viewCompanies); this.viewTreePath = unescape(viewTreePath); } /* --------------------------------------------------------------------------------------------------------------- */ /* Ajax routines */ function CallAjaxSync(CallType, URL) { try { var xmlhttp = null; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { try { xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); } catch (e) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } } else return xmlhttp.open(CallType, URL, false); xmlhttp.send(null); return xmlhttp.responseText; } catch (ex) { } } /* --------------------------------------------------------------------------------------------------------------- */ /* Generic routines */ function rnd(max) { var rndnum = max * Math.random(); rndnum = Math.ceil(rndnum); return rndnum; } /* Helper routines */ function SetInnerHtml(htmlid, data) { var obj = document.getElementById(htmlid); if (obj == null) { obj.innerHTML += ""; } else { obj.innerHTML += data; } } function SetDocumentLink(htmlid, docID) { var obj = document.getElementById(htmlid); if (obj == null) { obj.href = ""; } else { obj.href = "articleIDs/" + docID + "?open&template=Default"; } } /* --------------------------------------------------------------------------------------------------------------- */ /* Header/Footer Loader */ function WriteTemplate(templateName) { htmlData = CallAjaxSync("GET", "templates/" + templateName); if (htmlData == null) return; if (htmlData == "") return; document.write(htmlData); } function LoadValueAsLink(selectObject) { var hRefSel = ""; if (selectObject.selectedIndex != -1) hRefSel = selectObject.value; if (hRefSel != "") { document.location.href = hRefSel; } } function DynBubbleSort(theArray, Property) { for (var i = 1; i < (theArray.length - 1); i++) { for (var j = i + 1; j < theArray.length; j++) { if (eval("theArray[j]." + Property + " < theArray[i]." + Property)) { var dummy = theArray[i]; theArray[i] = theArray[j]; theArray[j] = dummy; } } } } /* --------------------------------------------------------------------------------------------------------------- */ /* Include File JS Routines */ function htPageInit() { var getHeadline = document.getElementById("PageHeading"); if (getHeadline != null) { var gFormElements = document.getElementsByName("Headline"); if (gFormElements != null) { if (gFormElements.length >= 1) getHeadline.innerHTML = unescape(gFormElements[0].value); } } htQuickCoursesInit(); htLeftPanelInit(); } function htQuickCoursesInit() { try { myResultSet = SearchFor("([Subsection]=CourseList)", 100); DynBubbleSort(myResultSet, "viewTitle"); hpCL = document.getElementById("qcListing"); if (hpCL != null) { for (iC = 0; iC < myResultSet.length; iC++) { if (myResultSet[iC] != null) { if (myResultSet[iC] != "No items available.") { var oNew = document.createElement("OPTION"); oNew.text = myResultSet[iC].viewTitle; oNew.value = "/mpl/site/articleIDs/FFDD834895CEC202CA2574EC001A03B0?open&template=Default"; hpCL.options.add(oNew); } } } } } catch (ex) { } } function htLeftPanelInit() { try { myResultSet = SearchFor("([Subsection]=WhatWeCanOffer)", 100); DynBubbleSort(myResultSet, "viewTitle"); lpWWCO = document.getElementById("lpOfferList"); if (lpWWCO != null) { for (iC = 0; iC < myResultSet.length; iC++) { if (myResultSet[iC] != null) { if (myResultSet[iC].viewTitle != "No items available.") { if (myResultSet[iC].viewSummary == "NOLINK") { lpWWCO.innerHTML += "
" + myResultSet[iC].viewTitle + "
"; } else { lpWWCO.innerHTML += "
" + myResultSet[iC].viewTitle + "
"; } } else { lpWWCO.innerHTML += myResultSet[iC].viewTitle + "

"; } } } } myResultSet = GetOrderedListByKeywords("Courses", "CourseList", "WebsiteOptions", "FeaturedCourse", 1); lpFeatCourse = document.getElementById("lpFeatured"); if (lpFeatCourse != null) { for (iC = 0; iC < myResultSet.length; iC++) { if (myResultSet[iC] != null) { if (myResultSet[iC].viewTitle != "No items available.") { lpFeatCourse.innerHTML += "

" + myResultSet[iC].viewTitle + "

"; lpFeatCourse.innerHTML += "
View Details
"; } else { lpFeatCourse.innerHTML += myResultSet[iC].viewTitle + "

"; } } } } } catch (ex) { } }