/** CMI validation Created 08/12/2005 **/ var CMIVocabularyType_Mode = 1; var CMIVocabularyType_Status = 2; var CMIVocabularyType_Exit = 3; var CMIVocabularyType_Credit = 4; var CMIVocabularyType_Entry = 5; var CMIVocabularyType_Interaction = 6; var CMIVocabularyType_Result = 7 var CMIVocabularyType_TimeLimitAction = 8; function RegexTest(regex, test) { return regex.test(test); } function RegexTestByString(regex, test) { //alert("Test: " + test + " with " + regex); //alert(RegexTest(new RegExp(regex), test)); return RegexTest(new RegExp(regex), test); } function IsCMIBlank(test){ return test == ""; } function IsCMIBoolean(test) { return ((test == "true") || (test == "false")); } function IsCMIDecimal(test) { return RegexTest(/^[\-]?\d*[\.]?\d*$/, test) } function IsCMIIdentifier(test) { if (test == null || test.length > 255) return false; return RegexTest(/^[0-9a-zA-Z\-_]*$/, test); } function IsCMIInteger(test) { if(RegexTest(/^[\d]+$/, test)) { i = parseInt(test); return (i>=0 && i<65536); } else return false; } function IsCMISInteger(test) { if(RegexTest(/^[\-]?[\d]+$/, test)) { i = parseInt(test); return (i>=-32768 && i<32768); } else return false; } function IsCMIString255(test) { return (test.length <= 255); } function IsCMIString4096(test) { return (test.length <= 4096); } function IsCMITime(test) { return RegexTest(/^\d{2}:\d{2}:\d{2}(.\d{1,2}){0,1}$/, test); } function IsCMITimespan(test) { return RegexTest(/^\d{2,4}:\d{2}:\d{2}(.\d{1,2}){0,1}$/, test); } function IsCMIVocabulary(test, type) { switch (type) { case CMIVocabularyType_Mode: switch (test) { case "normal": return true; case "review": return true; case "browse": return true; default: return false; } break; case CMIVocabularyType_Status: switch (test) { case "passed": return true; case "completed": return true; case "failed": return true; case "incomplete": return true; case "browsed": return true; case "not attempted": return true; case "unknown": return true; default: return false; } break; case CMIVocabularyType_Exit: switch (test) { case "time-out": return true; case "suspend": return true; case "logout": return true; case "": return true; case "normal": return true; default: return false; } break; case CMIVocabularyType_Credit: switch (test) { case "credit": return true; case "no-credit": return true; default: return false; } break; case CMIVocabularyType_Entry: switch (test) { case "ab-initio": return true; case "resume": return true; case "": return true; default: return false; } break; case CMIVocabularyType_Interaction: switch (test) { case "true-false": return true; case "choice": return true; case "fill-in": return true; case "matching": return true; case "performance": return true; case "likert": return true; case "sequencing": return true; case "numeric": return true; default: return false; } break; case CMIVocabularyType_Result: if (IsCMIDecimal(test)) return true; switch (test) { case "correct": return true; case "wrong": return true; case "unanticipated": return true; case "neutral": return true; default: return false; } break; case CMIVocabularyType_TimeLimitAction: switch (test) { case "exit,message": return true; case "exit,no message": return true; case "continue,message": return true; case "continue,no message": return true; default: return false; } break; default: return false; } } function IsCMIFeedback(test, type) { return true;//for now } function ChangeVisibility(isVisible, elementList) { //ChangeVisibility.arguments[>=1] = elementList var items = ChangeVisibility.arguments.length var visibility = ""; if(isVisible) { visibility = 'visible'; } else { visibility = 'hidden'; } for(i=1; i= 4) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) ); } else if (this.isMozilla) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ); } else if (this.isSafari) { this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) ); } else if (this.isOpera) { if (ua.indexOf('opera/') != -1) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) ); } else { this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) ); } } else if (this.isKonqueror) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) ); } else if (this.isIcab) { if (ua.indexOf('icab/') != -1) { this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) ); } else { this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) ); } } this.versionMajor = parseInt(this.versionMinor); this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 ); // dom support this.isDOM1 = (document.getElementById); this.isDOM2Event = (document.addEventListener && document.removeEventListener); // css compatibility mode this.mode = document.compatMode ? document.compatMode : 'BackCompat'; // platform this.isWin = (ua.indexOf('win') != -1); this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) ); this.isMac = (ua.indexOf('mac') != -1); this.isUnix = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1) this.isLinux = (ua.indexOf('linux') != -1); // specific browser shortcuts this.isNS4x = (this.isNS && this.versionMajor == 4); this.isNS40x = (this.isNS4x && this.versionMinor < 4.5); this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7); this.isNS4up = (this.isNS && this.versionMinor >= 4); this.isNS6x = (this.isNS && this.versionMajor == 6); this.isNS6up = (this.isNS && this.versionMajor >= 6); this.isNS7x = (this.isNS && this.versionMajor == 7); this.isNS7up = (this.isNS && this.versionMajor >= 7); this.isIE4x = (this.isIE && this.versionMajor == 4); this.isIE4up = (this.isIE && this.versionMajor >= 4); this.isIE5x = (this.isIE && this.versionMajor == 5); this.isIE55 = (this.isIE && this.versionMinor == 5.5); this.isIE5up = (this.isIE && this.versionMajor >= 5); this.isIE6x = (this.isIE && this.versionMajor == 6); this.isIE6up = (this.isIE && this.versionMajor >= 6); this.isIE4xMac = (this.isIE4x && this.isMac); this.isOpera6up = (this.isOpera && this.versionMajor >= 6); } var browser = new BrowserDetectLite(); function ClickButton(e, btnId) { var bt = document.getElementById(btnId); var keyCode = 0; if (typeof bt == 'object') { if(browser.isGecko || browser.isMozilla || browser.isNS) { keyCode = e.which; if (keyCode == 13) { //Replace the first occurence of the URL encoded value %20 with the space character. The encoded character is built into the URL by the .NET framework var btnAction = bt.toString().replace("%20", " "); //Remove all occurences of the URL encoded value %20. Only affects non-IE browsers. btnAction = btnAction.replace(/%20/g, ""); if(btnAction.indexOf("javascript:") >= 0) { eval(btnAction); } else { bt.click(); } return false; } } else { keyCode = e.keyCode; if (keyCode == 13) { bt.click(); return false; } } } } function Properties(obj) { var props = new Hashtable(); for (var elm in obj) { if(typeof(obj[elm]) != "function") { props.put(elm, (obj[elm] == null || obj[elm] =="") ? " " : obj[elm]); } } return props; } function array_size(a){ var size = 0; for (var i in a) { if (a[i] != null) size ++; } return size; } function height() { if (document.all) return (document.body.offsetHeight); else if (document.layers) return (document.body.document.height); } function iframeRequest(url,query) { callToServer(url+'?'+query); } function iframeRequest(url) { callToServer(url); } var IFrameObj; // our IFrame object function callToServer(URL) { if (!document.createElement) {return true}; var IFrameDoc; if (!IFrameObj && document.createElement) { // create the IFrame and assign a reference to the // object to our global variable IFrameObj. // this will only happen the first time // callToServer() is called if (browser.isIE6up || browser.isIE55 ||browser.isNS6up||browser.isOpera6up|| (browser.isIE5up && browser.isMac)) { var tempIFrame=document.createElement('iframe'); tempIFrame.setAttribute('id','RSIFrame'); //tempIFrame.setAttribute('src','~/KeepAlive.aspx'); tempIFrame.style.border='0px'; tempIFrame.style.width='0px'; tempIFrame.style.height='0px'; IFrameObj = document.body.appendChild(tempIFrame); if (document.frames) { // this is for IE5 Mac, because it will only // allow access to the document object // of the IFrame if we access it through // the document.frames array IFrameObj = document.frames['RSIFrame']; } } else { // This is for IE5 PC, which does not allow dynamic creation // and manipulation of an iframe object. Instead, we'll fake // it up by creating our own objects. iframeHTML='