var TimeOutID = 0; var PollingTimeOutID = 0; function SetMenuTimeout() { ResetTimeout(); TimeOutID = setTimeout('ClearDownMenu();',2000); } function ClearDownMenu() { MM_showHideLayers('MenuCompanies','','hide','MenuContacts','','hide','MenuVacancies','','hide','MenuBookings','','hide','MenuCandidates','','hide','MenuNotifications','','hide','MenuBookmarks','','hide','MenuReports','','hide','MenuAdministration','','hide','MenuBookmarksCo','','hide','MenuBookmarksCt','','hide','MenuBookmarksVc','','hide','MenuBookmarksCa','','hide','MenuAgencies','','hide'); document.frmUserNavigation.recordjumpurl.style.visibility='visible'; } function ResetTimeout() { clearTimeout(TimeOutID); } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i 0) { // split the entered string at the @ sign, if // there aren't at least 2 array elements created // no @ sign was entered so therefore it is an // invalid email address so return false. string = formname.value; check_for_at = string.split("@"); if ( ! check_for_at[0] || ! check_for_at[1] ) { alert(fieldname + ' must be a valid email address'); return false; } else { // If there is a valid @ sign, split the second // half of the string by the first dot. If // there aren't at least 2 array elements created // no . was entered so therefore it is an // invalid email address so return false. check_for_dot = check_for_at[1].split("."); if ( ! check_for_dot[0] || ! check_for_dot[1] ) { alert(fieldname + ' must be a valid email address'); return false; } } } return true; } function CheckBlank(formname,fieldname) { // If nothing has been entered return false var CurrentValue; CurrentValue = formname.value; CurrentValue = trim(CurrentValue); formname.value = CurrentValue; if (CurrentValue.length < 1) { alert('Please complete the "' + fieldname + '" field.'); return false; } else { return true; } } function CheckSelect(formname,fieldname,bMulti,Maxnoitems,bNoItems) { // If this is NOT a multi select if ( ! bMulti ) { // If the user is NOT allowed to select nothing (sounds a bit // strange but bear with me...) if ( ! bNoItems ) { // Check they haven't just selected the default option // or even just not selected anything at all. If this is // the case return false. mySelectedIndex = formname.selectedIndex; if ( formname.options[mySelectedIndex].value<1 || formname.options[mySelectedIndex].value=="" ) { alert('Please select ' + fieldname); return false; } } return true; // If this IS a multi select list } else { // If the user is NOT allowed to select nothing (sounds a bit // strange but bear with me...) if ( ! bNoItems ) { // If selectedIndex is a negative value nothing // has been selected so print error and return false mySelectedIndex = formname.selectedIndex; if ( mySelectedIndex < 0 ) { alert('Please select ' + fieldname); return false; } // If a maximum number of items has been set check // that the user hasn't selected more. If they have // print the error and return false. if ( Maxnoitems > 0 ) { numSelected = 0; for ( i=0; i Maxnoitems ) { alert('Only ' + Maxnoitems + ' options can be selected from the ' + fieldname + ' list'); return false; } } return true; } else { // If the user IS allowed to select nothing, just check that // they haven't selected more than the maximum allowed (if // it is set) if ( Maxnoitems > 0 ) { numSelected = 0; for ( i=0; i Maxnoitems ) { alert('Only ' + Maxnoitems + ' options can be selected from the ' + fieldname + ' list'); return false; } } return true; } } } function contains(smstring,lrgstring) { //returns true if lrgstring contains smstring. strlen1 = smstring.length strlen2 = lrgstring.length istrue = false for (i=0;i<=strlen2;i++) { comp=lrgstring.substring(i-1,strlen2) comp = comp.substring(0,strlen1) if (comp == smstring) { istrue = true break } } return istrue } function lcase(str) { //returns str in all lowercase letters. return str.toLowerCase() } function left(str,n) { //returns the left n characters from str. return str.substring(0,n) } function leftOf(smstring,lrgstring) { //returns leftmost characters of lrgstring up to smstring. //If user passes an empty string, change that to a space. if (smstring == ""){smstring = " "} strlen1 = smstring.length strlen2 = lrgstring.length foundat = 0 for (i=0;i<=strlen2;i++) { comp=lrgstring.substring(i-1,strlen2) comp = comp.substring(0,strlen1) if (comp == smstring) { foundat = i break } } return lrgstring.substring(0,(foundat-1)) } function mid(str,start,n) { //returns a substring of str starting at 'start' that's n characters long. strlen = str.length var jj = str.substring(start-1,strlen) jj = jj.substring(0,n) return jj } function pcase(str) { //returns str in proper-noun case (first letter uppercase) strlen = str.length jj = str.substring(0,1).toUpperCase() jj = jj + str.substring(1,strlen).toLowerCase() for (i = 2; i <= strlen; i++) { if (jj.charAt(i)==" ") { lefthalf = jj.substring(0,i+1) righthalf = jj.substring(i+1,strlen) righthalf = righthalf.substring(0,1).toUpperCase()+righthalf.substring(1,strlen) jj=lefthalf+righthalf } } return jj } function right(str,n) { //returns the right n characters of str strlen = str.length return str.substring(strlen-n,strlen) } function rightOf(smstring,lrgstring) { //returns the rightmost characters of lrgstring back to smstring. //If user passes an empty string, change that to a space. if (smstring == ""){smstring = " "} strlen1 = smstring.length strlen2 = lrgstring.length foundat = 0 for (i=strlen2;i>=0;i--) { comp=lrgstring.substring(i-1,strlen2) comp = comp.substring(0,strlen1) if (comp == smstring) { foundat = i break } } return lrgstring.substring(foundat,255) } function spot(smstring,lrgstring) { //returns a number indicating the spot where smstring appears in lrgstring. strlen1 = smstring.length strlen2 = lrgstring.length foundat = 0 for (i=0;i<=strlen2;i++) { comp=lrgstring.substring(i-1,strlen2) comp = comp.substring(0,strlen1) if (comp == smstring) { foundat = i break } } return foundat } function ucase(str) { //returns str in all uppercase letters. return str.toUpperCase() } // Submit a form (rather than using a submit image) and set the command value function submitForm(formname,strCommand) { var thisObj = eval("document." + formname); thisObj.command.value = strCommand; thisObj.submit(); } function setCookie(name, value, expires, path, domain, secure) { // name - name of the cookie // value - value of the cookie // [expires] - expiration date of the cookie (defaults to end of current session) // [path] - path for which the cookie is valid (defaults to path of calling document) // [domain] - domain for which the cookie is valid (defaults to domain of calling document) // [secure] - Boolean value indicating if the cookie transmission requires a secure transmission // * an argument defaults when it is assigned null as a placeholder // * a null placeholder is not required for trailing omitted arguments var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = curCookie; } function getCookie(name) { // name - name of the desired cookie // * return string containing value of specified cookie or null if cookie does not exist var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } function deleteCookie(name, path, domain) { // name - name of the cookie // [path] - path of the cookie (must be same as path used to create cookie) // [domain] - domain of the cookie (must be same as domain used to create cookie) // * path and domain default if assigned null or omitted if no explicit argument proceeds if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } function fixDate(date) { // date - any instance of the Date object // * hand all instances of the Date object to this function for "repairs" var base = new Date(0); var skew = base.getTime(); if (skew > 0) date.setTime(date.getTime() - skew); } function check_date(field,fieldname){ var checkstr = "0123456789"; var DateField = field; var Datevalue = ""; var DateTemp = ""; var seperator = "/"; var day; var month; var year; var leap = 0; var err = 0; var i; err = 0; DateValue = DateField.value; /* Delete all chars except 0..9 */ for (i = 0; i < DateValue.length; i++) { if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) { DateTemp = DateTemp + DateValue.substr(i,1); } } DateValue = DateTemp; /* Always change date to 8 digits - string*/ /* if year is entered as 2-digit / always assume 20xx */ if (DateValue.length == 6) { year = DateValue.substr(4,2); if (year <= 50) { DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); } else { DateValue = DateValue.substr(0,4) + '19' + DateValue.substr(4,2); } } if (DateValue.length != 8) { err = 19;} /* year is wrong if year = 0000 */ year = DateValue.substr(4,4); if (year == 0) { err = 20; } /* Validation of month*/ month = DateValue.substr(2,2); if ((month < 1) || (month > 12)) { err = 21; } /* Validation of day*/ day = DateValue.substr(0,2); if (day < 1) { err = 22; } /* Validation leap-year / february / day */ if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) { leap = 1; } if ((month == 2) && (leap == 1) && (day > 29)) { err = 23; } if ((month == 2) && (leap != 1) && (day > 28)) { err = 24; } /* Validation of other months */ if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) { err = 25; } if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) { err = 26; } /* if 00 ist entered, no error, deleting the entry */ if ((day == 0) && (month == 0) && (year == 00)) { err = 0; day = ""; month = ""; year = ""; seperator = ""; } /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */ if (err == 0) { DateField.value = day + seperator + month + seperator + year; } /* Error-message if err != 0 */ else { alert("Please enter a valid date (dd/mm/yyyy) in the " + fieldname + "field"); DateField.select(); DateField.focus(); return false; } return true; } function CheckLength (formname,fieldname,minlength,maxlength) { if (minlength != 0) { if (formname.value.length < minlength) { alert(fieldname + ' must be greater than ' + minlength + ' characters.'); return false; } } if (maxlength != 0) { if (formname.value.length > maxlength) { alert(fieldname + ' must be less than ' + maxlength + ' characters.'); return false; } } return true; } function cleanNumber(inputNum, bIsFloat) { var i; var ch; var outputNum = ""; // walk through the string character by character to build a new string with numbers only i = 0; while (i < inputNum.length) { // get the current character ch = inputNum.substring(i, i+1); if ((ch >= "0") && (ch <= "9")) { // if the current character is a digit then add it to the numbers-only string we're building outputNum += ch; } else { if ((bIsFloat) && (ch == ".")){ outputNum += ch; } } i++; } // we got here if we didn't fail, so return what we built return outputNum; } function DisplayHelp (url) { var strFile strFile = '/' + url strFile = leftOf('.asp',strFile); strFile = rightOf('/',strFile); strFile = '/help.asp?topic=' + strFile window.open(strFile,'help','left=1,top=1,height=500,width=620,scrollbars=yes'); } function CheckTime (formfield,fieldname,blankallowed) { var timevalid = true; var hours; var mins; if (formfield.value == '' && !blankallowed) { alert('Please complete the ' + fieldname + ' field.'); return false; } if (formfield.value != '') { if (formfield.value.length == 5) { hours = formfield.value.substring(0,2); if (hours.substring(0,1) == '0') { hours = hours.substring(1,2); } // alert('hours = ' + hours); mins = formfield.value.substring(3,5); if (mins.substring(0,1) == '0') { mins = mins.substring(1,2); } // alert('mins = ' + mins); if (!IsNumeric(hours,false)) { timevalid = false; } if (timevalid && (hours < 0 || hours > 23)) { // alert('hours not valid'); timevalid = false; } if (timevalid && !IsNumeric(mins,false)) { timevalid = false; } if (timevalid && (mins < 0 || mins > 59)) { // alert('mins not valid'); timevalid = false; } } else { timevalid = false; } if (!timevalid) { alert(formfield.value + ' is not a valid time. Please enter in HH:MM format.'); return false; } } return true; } function CheckNumeric (formfield,fieldname,blankallowed,isfloat) { if (formfield.value == '' && !blankallowed) { alert('Please complete the ' + fieldname + ' field.'); return false; } else { if (formfield.value != '') { if (!IsNumeric(formfield.value,isfloat)) { alert('Please enter numbers only in the ' + fieldname + ' field.'); return false; } } } return true; } function IsNumeric (number,isfloat) { var numvar; if (isfloat) { numvar = parseFloat(number); } else { numvar = parseInt(number); } // alert('numvar = ' + numvar); // alert('number = ' + number); // alert(numvar == number); if (numvar == 'NaN' || numvar != number) { return false; } return true; } function OpenNRPopup (url, winname, width, height, options) { var w = 480, h = 340; if (document.all || document.layers) { w = screen.availWidth; h = screen.availHeight; } var leftPos = (w-width)/2, topPos = (h-height)/2; //error is here window.open(url,winname,'width=' + width + ',height=' + height + ',top=' + topPos + ',left=' + leftPos + ',' + options); } function OpenActionNote (ussnid, action, entity, link, width, height, options) { var strURL; strURL = '/frmActionAdd.asp?ussnid=' + ussnid + '&act_id=' + action + '&syse=' + entity + '&link=' + link; OpenNRPopup (strURL, 'actionadd', width, height, options); } function OpenOfferPlacement(ussnid, vacancyId, offerYesNo, candidateId, winname, width, height, options){ // Firstly check how many candidateIds they've selected var intSelected = 0; var i, n; var strURL; for (i=0,n=document.frmVacancy.elements.length;i 1){ alert('You may only place one candidate at a time. Please select only one candidate, and then try again.'); return false; } strURL = '/frmVacancyPlacement.asp?ussnid=' + ussnid + '&vc_id=' + vacancyId + '&offer=' + offerYesNo + '&ca_id=' + candidateId; OpenNRPopup (strURL, winname, width, height, options); } function updateDepartments (deptlistname,officeid,nonetext) { var list = eval(deptlistname); // Delete all entries from the Department list // except the first and select the first entry list.length = 1; list.selectedIndex = 0; if (officeid > 0) { list[0].text = ' '; var arrDeptNames = eval('arrDeptNames' + officeid); var arrDeptIds = eval('arrDeptIds' + officeid); list.length = 1 + arrDeptNames.length; var i; for (i=0; i < arrDeptNames.length; i++) { list[i + 1].text = arrDeptNames[i]; list[i + 1].value = arrDeptIds[i]; } if (arrDeptNames.length==0) { list[0].text = nonetext; } } else { list[0].text = nonetext; } } function GenerateCorrespondence(strType, strUssnid, strA, strB, strC, strD, strE, strF, strG, strH){ var strLinkURL if (strType == '0' || strType == '') { alert('You must firstly select a correspondence type.'); return false; } strLinkURL = '/scnCorrespondenceGenerate.asp?ussnid=' + strUssnid + '&type=' + strType + '&a=' + strA + '&b=' + strB + '&c=' + strC + '&d=' + strD + '&e=' + strE + '&f=' + strF + '&g=' + strG + '&h=' + strH; strJavascript = OpenNRPopup(strLinkURL,'Correspondence',780,500,'scrollbars=yes'); } function ActionEvent(strUssnid, intPlannerID, strReturnURL) { strLinkURL = '/frmEventAction.asp?ussnid=' + strUssnid + '&returnurl=' + escape(strReturnURL) + '&pln_id=' + intPlannerID; strJavascript = OpenNRPopup(strLinkURL,'ActionEvent',500,410,'scrollbars=yes'); } function ScheduleEvent(strUssnid, intSystemEntity, intCompany, intContact, intVacancy, intCandidate, intPlacement, intBooking, strReturnURL) { strLinkURL = '/frmPlannerSchedule.asp?ussnid=' + strUssnid + '&syse=' + intSystemEntity + '&co_id=' + intCompany + '&ct_id=' + intContact + '&vc_id=' + intVacancy + '&ca_id=' + intCandidate + '&pl_id=' + intPlacement + '&bk_id=' + intBooking + '&returnurl=' + escape(strReturnURL) strJavascript = OpenNRPopup(strLinkURL,'LogEvent',500,270,'scrollbars=yes'); } function OpenScheduleEvent(strUssnid, intSystemEntity, intCompany, intContact, intVacancy, intCandidate, intPlacement, intBooking, strReturnURL, width, height,options) { strLinkURL = '/frmPlannerSchedule.asp?ussnid=' + strUssnid + '&syse=' + intSystemEntity + '&co_id=' + intCompany + '&ct_id=' + intContact + '&vc_id=' + intVacancy + '&ca_id=' + intCandidate + '&pl_id=' + intPlacement + '&bk_id=' + intBooking + '&returnurl=' + escape(strReturnURL) strJavascript = OpenNRPopup(strLinkURL,'LogEvent',width,height,options); } function setCheckAll(OnOffFlip) { // 0=off, 1=on, other=flip var cb=document.getElementsByTagName('input'); for (var i=0;i',xml.responseText)){ // Invalid response //alert('Please contact HotLizard quoting error: \n\n Unrecognised polling response.'); } else { if (left(xml.responseText,15) == '!!!TERMINATE!!!'){ // Force expiry location.replace('/frmUserLogin.asp?mode=terminated&ussnid=' + strSessionID + '&returnurl=%2FlstPlanner%2Easp'); } else { // Message to be displayed ResponseText = xml.responseText; // Put text in invisible comparespan, so that when innerHTML is referenced // it is the same as that we are trying to compare (comments stripped etc.) CompareSpan.innerHTML = ResponseText; if (CompareSpan.innerHTML != MessageSpan.innerHTML){ // Only update span, if it hasn't changed // This is to prevent scrolling oddities MessageSpan.innerHTML = ResponseText; } CompareSpan.innerHTML = ""; // Make a noise if it's got the ALERT tag if (contains('',xml.responseText)){ try { document.sndNotification.play(); } catch (e) {} } } } } } } var MessagePollingPoll_xml = false; var MessagePollingPoll_timeSend; var MessagePollingPoll_timeCompleted; var MessagePollingPoll_func; // func that takes no arguments (has correct userid, sessionid embedded) function MessagePollingPoll(lngCurrentUserId, strSessionID) { var INTERVAL = 15000; // 15 seconds var MAX_INTERVAL = 4*INTERVAL; if (!MessagePollingPoll_func) { MessagePollingPoll_func = new Function('MessagePollingPoll(' + lngCurrentUserId + ',\'' + strSessionID + '\');'); } var curTime = (new Date).getTime(); // Performs the message polling from xml_NotificationsPoll.asp (if one isn't already in progress) if (MessagePollingPoll_xml) { //alert('in progress: ' + Math.abs(curTime - MessagePollingPoll_timeSend)); if (Math.abs(curTime - MessagePollingPoll_timeSend) >= MAX_INTERVAL) { // taking a bit too long; let's assume the ajax request is foobar //alert('too long'); MessagePollingPoll_xml.onreadystatechange = MessagePollingPoll_helper2; // abort() makes the readystate go to 4, so will trigger the onreadystate call back, so we'll just set it to a NO OP function if (MessagePollingPoll_xml.abort) { //alert('about to abort'); MessagePollingPoll_xml.abort(); //alert('aborted'); } } else { // another call is still going on; let's give it some more time to complete... //alert('rescheduling'); PollingTimeOutID = setTimeout(MessagePollingPoll_func, INTERVAL); return; } } // There may not be one in progress, but one may have just completed, so we may want to delay // before making another call if (MessagePollingPoll_timeCompleted) { if (Math.abs(curTime - MessagePollingPoll_timeCompleted) < INTERVAL) { //alert('rescheduling2: ' + (INTERVAL - Math.abs(curTime - MessagePollingPoll_timeCompleted))); PollingTimeOutID = setTimeout(MessagePollingPoll_func, INTERVAL - Math.abs(curTime - MessagePollingPoll_timeCompleted)); return; } } if (MessagePollingPoll_xml) { // Abort a currently ongoing polling request in case there's one ongoing MessagePollingPoll_xml.onreadystatechange = MessagePollingPoll_helper2; // abort() makes the readystate go to 4, so will trigger the onreadystate call back, so we'll just set it to a NO OP function if (MessagePollingPoll_xml.abort) { try { MessagePollingPoll_xml.abort(); } catch (e) { } } } else { // Create the XML object if we haven't already got one MessagePollingPoll_xml = MessagePolling_getRequestObject(); //new ActiveXObject("Microsoft.XMLHTTP"); } // Perform the postback if (MessagePollingPoll_xml) { MessagePollingPoll_xml.open("post", "/xml_NotificationsPoll.asp", true); MessagePollingPoll_xml.onreadystatechange = MessagePollingPoll_helper; MessagePollingPoll_xml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); MessagePollingPoll_xml.send("rand=" + Math.random() + "&us_id=" + lngCurrentUserId + "&ussnid=" + strSessionID + "&command=POLL"); MessagePollingPoll_timeSend = (new Date).getTime(); // milliseconds since midnight 01/01/1970 } PollingTimeOutID = setTimeout(MessagePollingPoll_func, INTERVAL); } function MessageClear(lngCurrentUserId, strSessionID, lngMessageStackId) { clearTimeout(PollingTimeOutID); // Create the XML object var xml = false; xml = MessagePolling_getRequestObject(); //new ActiveXObject("Microsoft.XMLHTTP"); // Perform the postback if (xml) { xml.open("post", "/xml_NotificationsPoll.asp", true); xml.onreadystatechange = function() { if (xml.readyState == 4) { if (xml.responseText) { if (xml.status != '200'){ //alert('Please contact HotLizard quoting error: \n\n ' + xml.status + " : " + xml.statusText + '\n\nduring message clear.'); } //alert(xml.responseText); // Debug only if (!contains('',xml.responseText)){ // Invalid response //alert('Please contact HotLizard quoting error: \n\n Unrecognised message clear response.'); } } xml.onreadystatechange = new Function; // memory leak prevention } } xml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xml.send("rand=" + Math.random() + "&us_id=" + lngCurrentUserId + "&ussnid=" + strSessionID + "&msgst_id=" + lngMessageStackId + "&command=CLEAR"); } // we need to fool MessagePollingPoll into thinking no request is ongoing, and no request has // taken place recently otherwise it won't do anything if (MessagePollingPoll_xml) { MessagePollingPoll_xml.onreadystatechange = MessagePollingPoll_helper2; // abort() makes the readystate go to 4, so will trigger the onreadystate call back, so we'll just set it to a NO OP function if (MessagePollingPoll_xml.abort) { //alert('about to abort'); MessagePollingPoll_xml.abort(); //alert('aborted'); } } MessagePollingPoll_timeCompleted = 0; MessagePollingPoll(lngCurrentUserId, strSessionID); } function ChangePassword(ussnid){ var strURL; strURL = '/frmPasswordChange.asp?ussnid=' + ussnid; OpenNRPopup(strURL,'ChangePassword',500,380,'scrollbars=yes'); } function ExportCSV(strUssnid, intSystemEntity, strSource, intLinkId) { strLinkURL = '/frmCSVExport.asp?ussnid=' + strUssnid + '&syse=' + intSystemEntity + '&src=' + strSource + '&linkid=' + intLinkId; strJavascript = OpenNRPopup(strLinkURL,'ExportCSV',500,340,'scrollbars=yes'); }