var lastrequest = "" var timerid = 0; var myx=0; function addslashes(str) { str=str.replace(/\'/g,'\\\''); str=str.replace(/\"/g,'\\"'); str=str.replace(/\\/g,'\\\\'); str=str.replace(/\0/g,'\\0'); return str; } function stripslashes(str) { str=str.replace(/\\'/g,'\''); str=str.replace(/\\"/g,'"'); str=str.replace(/\\\\/g,'\\'); str=str.replace(/\\0/g,'\0'); return str; } function showbuttons() { if (document.getElementById('questiontitle').innerHTML.length>600) { document.getElementById('questiontitle').className = "questiontext4"; } else if (document.getElementById('questiontitle').innerHTML.length>500) { document.getElementById('questiontitle').className = "questiontext3"; } else if (document.getElementById('questiontitle').innerHTML.length>300) { document.getElementById('questiontitle').className = "questiontext2"; } else { document.getElementById('questiontitle').className = "questiontext"; } var oDiv = document.getElementById('questionoptions'); var maxchars = 0; if(oDiv.firstChild) { var oChild = oDiv.firstChild; while(oChild) { if(oChild.nodeType==1 && oChild.nodeName == "DIV") { if (oChild.innerHTML.length>maxchars) {maxchars = oChild.innerHTML.length;} } oChild = oChild.nextSibling; } if (maxchars>80) { oChild = oDiv.firstChild; while(oChild) { oChild.className="questionbutton5"; oChild.style.height="120px"; oChild = oChild.nextSibling; } } else if (maxchars>60) { oChild = oDiv.firstChild; while(oChild) { oChild.className="questionbutton4"; oChild = oChild.nextSibling; } } else if (maxchars>40) { oChild = oDiv.firstChild; while(oChild) { oChild.className="questionbutton3"; oChild = oChild.nextSibling; } } else if (maxchars>20) { oChild = oDiv.firstChild; while(oChild) { oChild.className="questionbutton2"; oChild = oChild.nextSibling; } } } } function collectanswers(totalanswers) { myansers = ""; for (x=1;x<=totalanswers;x++) { if (document.getElementById("answer"+x).style.backgroundColor == 'teal') { myansers = myansers + 1+"{}[]{}"; } else { myansers = myansers + 0+"{}[]{}"; } } return myansers; } function uncolorotheroptions() { for (x=0;x<45;x++) { if (document.getElementById("answer"+x)) { if (document.getElementById("answer"+x).style.backgroundColor == 'teal') { document.getElementById("answer"+x).style.backgroundColor = 'white'; } } } } function uncolorexclusiveoptions() { for (x=0;x<45;x++) { if (document.getElementById("answer"+x)) { if (document.getElementById("answer"+x).exclusive == 'yes') { document.getElementById("answer"+x).style.backgroundColor = 'white'; } } } } function findPosX(obj) { var curleft = 0; if(obj.offsetParent) { while(1) { curleft += obj.offsetLeft; if(!obj.offsetParent) {break;} obj = obj.offsetParent; } } else if(obj.x) { curleft += obj.x; } return curleft; } function findPosY(obj) { var curtop = 0; if(obj.offsetParent) { while(1) { curtop += obj.offsetTop; if(!obj.offsetParent) {break;} obj = obj.offsetParent; } } else if(obj.y) { curtop += obj.y; } return curtop; } function toCamelCase( sInput ) { var oStringList = sInput.split('-'); if(oStringList.length == 1) return oStringList[0]; var ret = sInput.indexOf("-") == 0 ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0]; for(var i = 1, len = oStringList.length; i < len; i++){ var s = oStringList[i]; ret += s.charAt(0).toUpperCase() + s.substring(1) } return ret; } function getStyle(el, style) { if(!document.getElementById) return; var value = el.style[toCamelCase(style)]; if(!value) { if(document.defaultView) { value = document.defaultView.getComputedStyle(el, "").getPropertyValue(style); } else if (el.currentStyle) { value = el.currentStyle[toCamelCase(style)]; } } return value; } function showwaiting() { // document.getElementById("questiontitle").innerHTML = " "; // document.getElementById("questionoptions").innerHTML = document.getElementById("waitingwindowdiv").innerHTML; } function hidewaiting() { // document.getElementById("waitingwindowdiv").style.visibility = "hidden"; } function trim(s) { return rtrim(ltrim(s)); } function ltrim(s) { var l=0; while(l < s.length && s[l] == ' ') { l++; } return s.substring(l, s.length); } function rtrim(s) { var r=s.length -1; while(r > 0 && s[r] == ' ') { r-=1; } return s.substring(0, r+1); } function Ajax() { this.toString = function() { return "Ajax"; } this.http = new HTTP(); this.makeRequest = function(_method, _url, _callbackMethod) { clearTimeout(timerid); myx=0; lastrequest = _url + "&tt=" + Date(); document.getElementById("questioninfo").innerHTML = "Please wait while we progress to the next question"; document.getElementById("questiontitle").innerHTML = " "; document.getElementById("questionoptions").innerHTML = '
 
'; // // document.getElementById("questionoptions").innerHTML = '
Please wait while the survey progresses to the next question

'; // document.getElementById("body2").innerHTML = "If you've been waiting for the question to appear longer than than 10 seconds and it appears frozen, (the progress bar above is not moving) please click this link"; // document.getElementById("body2a").innerHTML = "If you've been waiting for the question to appear longer than than 10 seconds and it appears frozen, (the progress bar above is not moving) please click this link"; // document.getElementById("body").innerHTML = "current page trying - " + _url; this.request = (window.XMLHttpRequest)? new XMLHttpRequest(): new ActiveXObject("MSXML2.XMLHTTP"); this.request.onreadystatechange = _callbackMethod; this.request.open(_method, _url + "&tt=" + Date(), true); this.request.send(_url + "&tt=" + Date()); timerid = setTimeout("achecktimer()", 1000); // showwaiting(); } this.checkReadyState = function(_id, _1, _2, _3) { switch(this.request.readyState) { case 1: // document.getElementById(_id).innerHTML = _1; break; case 2: // document.getElementById(_id).innerHTML = _2; break; case 3: // document.getElementById(_id).innerHTML = _3; break; case 4: mystatus = this.http.status(this.request.status); if (mystatus == "OK") { myx=0; // document.getElementById(_id).innerHTML = ""; return mystatus; } } if (myx>20) { clearTimeout(timerid); timerid = setTimeout('tryagain("' + lastrequest + '");', 1000); } else { clearTimeout(timerid); timerid = setTimeout("achecktimer()", 1000); } } } function achecktimer() { myx++; ajax.checkReadyState('body', 'loading1', 'loading2', 'loading3'); } function tryagain(theurl) { // document.getElementById("body3").innerHTML = "Asdfasdf"; ajax.makeRequest("GET", theurl, onResponse); } function onResponse() { if(ajax.checkReadyState('body', 'loading1', 'loading2', 'loading3') == "OK") { clearTimeout(timerid); var data = trim(ajax.request.responseText); // document.getElementById("subtext").innerHTML = data.replace("<", "<").replace(">", ">"); var thing = data.split("{||}"); // hidewaiting(); if (thing[0] == 0) { document.getElementById("questionprogress").innerHTML = thing[2]; ajax.makeRequest('GET', thing[1], onResponse); } else if (thing[0] == 1 || thing[0] == 8) { if (Get_Cookie("debug") == "yes") { document.getElementById("questioninfo").innerHTML = thing[1]; } else { document.getElementById("questioninfo").innerHTML = ""; } document.getElementById("questiontitle").innerHTML = thing[2]; document.getElementById("questionprogress").innerHTML = thing[4]; if (thing[3].toLowerCase().indexOf(" 0) { document.getElementById("questionoptions").innerHTML = '
' + thing[3] + '
'; // document.getElementById("questionoptions").innerHTML = thing[3]; } else { document.getElementById("questionoptions").innerHTML = '
' + thing[3] + '
'; // document.getElementById("questionoptions").innerHTML = "
" + thing[3] + "






"; showbuttons(); } if (thing[0] == 8) { document.getElementById('theeightquestiondiv').style.display = 'none'; setTimeout("document.getElementById('theeightquestiondiv').style.display='block';", 10000); } else if (document.getElementById('answer')) { setTimeout("document.getElementById('answer').focus()", 1); } } } else { } } function HTTP() { this.toString = function() { return "HTTP"; } this.status = function(_status) { var s = _status.toString().split(""); switch(s[0]) { case "1": return this.getInformationalStatus(_status); break; case "2": return this.getSuccessfulStatus(_status); break; case "3": return this.getRedirectionStatus(_status); break; case "4": return this.getClientErrorStatus(_status); break; case "5": return this.getServerErrorStatus(_status); break; } } this.getInformationalStatus = function(_status) { // Informational 1xx // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1 switch(_status) { case 100: return "Continue"; break; case 101: return "Switching Protocols"; break; } } this.getSuccessfulStatus = function(_status) { // Successful 2xx // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2 switch(_status) { case 200: return "OK"; break; case 201: return "Created"; break; case 202: return "Accepted"; break; case 203: return "Non-Authoritative Information"; break; case 204: return "No Content"; break; case 205: return "Reset Content"; break; case 206: return "Partial Content"; break; } } this.getRedirectionStatus = function(_status) { // Redirection 3xx // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3 switch(_status) { case 300: return "Multiple Choices"; break; case 301: return "Moved Permanently"; break; case 302: return "Found"; break; case 303: return "See Other"; break; case 304: return "Not Modified"; break; case 305: return "Use Proxy"; break; case 306: return "(Unused)"; break; case 307: return "Temporary Redirect"; break; } } this.getClientErrorStatus = function(_status) { // Client Error 4xx // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4 switch(_status) { case 400: return "Bad Request"; break; case 401: return "Unauthorized"; break; case 402: return "Payment Required"; break; case 403: return "Forbidden"; break; case 404: return "File not found."; break; case 405: return "Method Not Allowed"; break; case 406: return "Not Acceptable"; break; case 407: return "Proxy Authentication Required"; break; case 408: return "Request Timeout"; break; case 409: return "Conflict"; break; case 410: return "Gone"; break; case 411: return "Length Required"; break; case 412: return "Precondition Failed"; break; case 413: return "Request Entity Too Large"; break; case 414: return "Request-URI Too Long"; break; case 415: return "Unsupported Media Type"; break; case 416: return "Requested Range Not Satisfiable"; break; case 417: return "Expectation Failed"; break; } } this.getServerErrorStatus = function(_status) { // Server Error 5xx // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5 switch(_status) { case 500: return "Internal Server Error"; break; case 501: return "Not Implemented"; break; case 502: return "Bad Gateway"; break; case 503: return "Service Unavailable"; break; case 504: return "Gateway Timeout"; break; case 505: return "HTTP Version Not Supported"; break; } } } var ajax = new Ajax(); function checkfornumber(e) { var keynum; var keychar; var numcheck; if(window.event) { keynum = e.keyCode; } else if (e.which) { keynum = e.which; } if (keynum >= 48 && keynum <= 57) { return true; } else if (keynum == 8) { return true; } else if (keynum >= 37 && keynum <= 40) { return true; } else if (keynum >= 96 && keynum <= 105) { return true; } else { return false; } } function Get_Cookie( check_name ) { // first we'll split this cookie up into name/value pairs // note: document.cookie only returns name=value, not the other components var a_all_cookies = document.cookie.split( ';' ); var a_temp_cookie = ''; var cookie_name = ''; var cookie_value = ''; var b_cookie_found = false; // set boolean t/f default f for ( i = 0; i < a_all_cookies.length; i++ ) { // now we'll split apart each name=value pair a_temp_cookie = a_all_cookies[i].split( '=' ); // and trim left/right whitespace while we're at it cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, ''); // if the extracted name matches passed check_name if ( cookie_name == check_name ) { b_cookie_found = true; // we need to handle case where cookie has no value but exists (no = sign, that is): if ( a_temp_cookie.length > 1 ) { cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') ); } // note that in cases where cookie is initialized but no value, null is returned return cookie_value; break; } a_temp_cookie = null; cookie_name = ''; } if ( !b_cookie_found ) { return null; } }