//================================================================================== // cross-browser compatible function function e(sID) { return document.getElementById(sID); } function GetInnerText(sID) { var oObject = document.getElementById(sID); if (oObject.innerText == undefined) return oObject.textContent; // Firefox else return oObject.innerText; } function SetInnerText(sID, sText) { var oObject = document.getElementById(sID); if (oObject.innerText == undefined) oObject.textContent = sText; // Firefox else oObject.innerText = sText; } function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;} function ShowModalDialogCentered(url, args, options) { // Convert the options string into an object. var pairs = options.replace(/\s+/g, "").split(";"); var option = {}; for (var n=0; n= 0) { // delete in reverse, so that the auto length change won't cause a problem oSelect.options[nListLength]=null; } oSelect.length = 0; } // for both IE & FF function clearSelection(frmName,srcGroupName) { var form = eval( 'document.' + frmName ); var srcList = eval( 'form.' + srcGroupName ); var nListLength = srcList.length; while (--nListLength >= 0) { // delete in reverse, so that the auto length change won't cause a problem srcList[nListLength] = null; } srcList.length = 0; } function AddSelectionElement(oSelect, sItemText, sItemValue, bUniqueID) { if (bUniqueID == true) { // Multiple elements in the list CANNOT have same Value for(var i=0; i< oSelect.length; i++) { if(oSelect.options[i].value == sItemValue) return; // Element already exists } } var nIndex = oSelect.length; oSelect.length = nIndex + 1; oSelect.options[nIndex] = new Option(sItemText, sItemValue); } // for both IE & FF function AddSelection(frmName, srcGroupName, sItemText, sItemValue, bUniqueID) { var form = eval( 'document.' + frmName ); var oSelect = eval( 'form.' + srcGroupName ); if (bUniqueID == true) { // Multiple elements in the list CANNOT have same Value for(var i=0; i< oSelect.length; i++) { if(oSelect[i].value == sItemValue) return; // Element already exists } } var nIndex = oSelect.length; oSelect.length = nIndex + 1; oSelect[nIndex] = new Option(sItemText, sItemValue); } // for both IE & FF function setSelection(frmName,srcGroupName,value) { var form = eval( 'document.' + frmName ); var srcList = eval( 'form.' + srcGroupName ); var srcLen = srcList.length; for(var i=0; i< srcLen; i++) { if(srcList[i].value == value) { srcList.selectedIndex = i; break; } } } function MoveSelectedOptions(oSelect, bMoveUp) { var n, sValue, sText, bSelected; if (oSelect.options.length == 0) return; // select is empty if (bMoveUp == true) { if (oSelect.options[0].selected == true) return; // first item is selected, we can't move any higher for(n=1; n=0; n--) { if (oSelect.options[n].selected == true) { sValue = oSelect.options[n+1].value; sText = oSelect.options[n+1].text; bSelected = oSelect.options[n+1].selected; oSelect.options[n+1].value = oSelect.options[n].value; oSelect.options[n+1].text = oSelect.options[n].text; oSelect.options[n+1].selected = oSelect.options[n].selected; oSelect.options[n].value = sValue; oSelect.options[n].text = sText; oSelect.options[n].selected = bSelected; } } } } // for both IE & FF function setSelectedRadio(frmName,srcGroupName,value) { var form = eval( 'document.' + frmName ); var srcList = eval( 'form.' + srcGroupName ); var srcLen = srcList.length; for (var i=0; i < srcLen; i++) { if (srcList[i].value == value) { srcList[i].checked = true; break; } } } // for both IE & FF function getSelectedRadio( frmName, srcGroupName ) { var form = eval( 'document.' + frmName ); var srcGroup = eval( 'form.' + srcGroupName ); if (srcGroup[0]) { for (var i=0, n=srcGroup.length; i < n; i++) { if (srcGroup[i].checked) { return srcGroup[i].value; } } } else { if (srcGroup.checked) { return srcGroup.value; } // if the one button is checked, return zero } // if we get to this point, no radio button is selected return null; } function SelectRadioByValue(oRadio, sValue) { for (var i = 0; i < oRadio.length; i++) { if (oRadio[i].value == sValue) { oRadio[i].checked = true; break; } } } function GetSelectedRadioValue(oRadio) { for (var i = 0; i < oRadio.length; i++) { if (oRadio[i].checked) return(oRadio[i].value); } return (""); // None selected ?? } function ClearDocumentSelection() { // Internet Explorer 4.xx if (navigator.appVersion.search("MSIE 4") != -1) { document.clear(); } // Internet Explorer 5.xx if (document.selection) { document.selection.clear(); } if (window.getSelection) { // Firefox, Safari, Opera var selection = window.getSelection(); //selection.deleteFromDocument(); // The deleteFromDocument does not work in Opera. Work around this bug if (!selection.isCollapsed) { document.execCommand("Delete"); } } } function ServerCrypt( Name ) { var sName sName = Name; sName = sName.replace( /Z/g, "Z1" ); sName = sName.replace( /&/g, "Z2" ); sName = sName.replace( /%/g, "Z5" ); // sName = sName.replace(/\t/gi,"%09"); sName = sName.replace(/\x03/gi,"%03"); return( sName); } /* function DisplayBytes( Value ) { var sDisplay; var nTemp; nTemp = Number(Value); sDisplay = Value; if ((nTemp > 0) && ((nTemp % 1024) == 0)) { nTemp = nTemp / 1024; if ((nTemp > 0) && ((nTemp % 1024) == 0)) { nTemp = nTemp / 1024; sDisplay = nTemp + "M"; } else { sDisplay = nTemp + "K"; } } return( sDisplay ); } function BytesDisplay( Display ) { var nValue; var sTemp; var nState; nValue = ""; nState = 0; nValue = "0"; for (i=0; i< Display.length; i++) { sTemp = Display.charAt(i); if (nState == 0) { if (sTemp != " ") { nState = 1; } } if (nState == 1) { if ((sTemp >= "0")&&(sTemp <= "9")) { nValue += sTemp; } else { nState = 2; } } if (nState == 2) { if (sTemp != " ") { if ((sTemp == "k")||(sTemp == "K")) { nValue = nValue * 1024; } else { if ((sTemp == "m")||(sTemp == "M")) { nValue = nValue * 1024 * 1024; } } nState = 3; } } } return(nValue); } */ function DisplayBytes(sValue) { // Convert from bytes to 100, 10K, 10M etc var sResult, nValue; nValue = Number(BytesDisplay(String(sValue))); sResult = sValue; if (nValue == 0) return(sResult); if ((nValue % 1024) == 0) { // value is multiple of 1024, hence can be shown as xxxK or xxxM nValue /= 1024; if ((nValue % 1024) == 0) sResult = String(nValue / 1024) + "M"; else sResult = String(nValue) + "K"; } return(sResult); } function BytesDisplay(sDisplay) { // Convert from 100, 10K, 10M etc to bytes var sDisplay, nValue; sDisplay = String(sDisplay); sDisplay = sDisplay.replace(/\s/gi,""); // remove spaces nValue = parseInt(sDisplay); if (isNaN(nValue)) return("0"); // not a number if (sDisplay.length > 0) { switch (sDisplay.charAt(sDisplay.length-1)) { case "k": case "K": nValue = nValue * 1024; break; case "m": case "M": nValue = nValue * 1024 * 1024; break; case "g": case "G": nValue = nValue * 1024 * 1024 * 1024; break; } } return(String(nValue)); } // Convert HH:MM:SS to seconds function TimeToSecs(sTime) { var aData; var nHour, nMin, nSec; nHour = nMin = nSec = 0; aData = sTime.split(":"); if (aData.length > 0) nHour = Number(aData[0]); if (aData.length > 1) nMin = Number(aData[1]); if (aData.length > 2) nSec = Number(aData[2]); return((nHour*3600) + (nMin*60) + nSec); } function Trim(sValue) { sValue = sValue.replace(/^\s+/gi, ""); // trim leading spaces sValue = sValue.replace(/\s+$/gi, ""); // trim trailing spaces return sValue; } function setCookie(sCookieName, sValue) { var today = new Date(); var expire = new Date(); var sCookie; expire.setTime(today.getTime() + 1000 * 60 * 60 * 24 * 30); sCookie = sCookieName + "=" + escape(sValue) + "; path=/; expires=" + expire.toGMTString(); document.cookie = sCookie; } function readCookie(cookieName) { var theCookie=""+document.cookie; var ind=theCookie.indexOf(cookieName + "="); if (ind==-1 || cookieName=="") return ""; var ind1=theCookie.indexOf(';',ind); if (ind1==-1) ind1=theCookie.length; return unescape(theCookie.substring(ind+cookieName.length+1,ind1)); } function DocumentWrite(sContent) { // This is method is needed to work arround the problem caused by // Update for windows XP (KB912945). document.write(sContent); } //===================================================================================== function pSetCTICookie(sKey, sValue, bSessionCookie) { var sCookies, aCookies, n, nMax, bFound; var sCookieName, dExpire; sCookieName = bSessionCookie?"CTICookieS":"CTICookie"; sKey = sKey.toString().toUpperCase(); sValue = sValue.toString().replace(/\*/gi,"\xff"); sCookies = readCookie(sCookieName); aCookies = sCookies.split("*"); if (sCookies == "") aCookies.length = 0; nMax = aCookies.length; bFound = false; for (n=0; n < nMax; n+=2) { if (aCookies[n] == sKey) { // existing entry found, update the value of it aCookies[n+1] = sValue; bFound = true; break; } } if (bFound == false) { // This is a new cookie, add it to the end of the list aCookies[nMax] = sKey; aCookies[nMax+1] = sValue; } sCookies = aCookies.join("*"); if (bSessionCookie == true) { // this is session cookie, no expiry time document.cookie = sCookieName + "=" + escape(sCookies) + "; path=/"; } else { // this is permanent cookie, set the expiry time dExpire = new Date(); dExpire.setTime(dExpire.getTime() + 1000 * 60 * 60 * 24 * 30); document.cookie = sCookieName + "=" + escape(sCookies) + "; path=/; expires=" + dExpire.toGMTString(); } } function pGetCTICookie(sKey, bSessionCookie) { var sCookies, aCookies, n, nMax; var sCookieName; sCookieName = bSessionCookie?"CTICookieS":"CTICookie"; sKey = sKey.toString().toUpperCase(); sCookies = readCookie(sCookieName); aCookies = sCookies.split("*"); if (sCookies == "") aCookies.length = 0; nMax = aCookies.length; for (n=0; n < nMax; n+=2) { if (aCookies[n] == sKey) { // existing entry found, update the value of it return(aCookies[n+1].replace(/\xff/gi,"*") ); } } // cookie is not found return(""); } function SetCTICookie(sKey, sValue) { pSetCTICookie(sKey, sValue, false); } function SetCTISessionCookie(sKey, sValue) { pSetCTICookie(sKey, sValue, true); } function GetCTICookie(sKey) { return(pGetCTICookie(sKey, false)); } function GetCTISessionCookie(sKey) { return(pGetCTICookie(sKey, true)); } //===================================================================================== function GlobalValidation_Name(sLabel, sValue, nMaxLen) { sValue = sValue.replace(/^\s+/g, ""); // remove leading spaces sValue = sValue.replace(/\s+$/g, ""); // remove trailing spaces if (sValue == "") { alert(sLabel + " cannot be blank. Please enter a valid " + sLabel + "."); return(false); } if (sValue.search(/[^0-9a-zA-Z_\$£\-,\s\(\)\\\/']/g) >= 0) { alert(sLabel + " is invalid. Valid " + sLabel + " should only consist of the characters 0-9, a-z, $, £, underscore, brackets, apostrophe or slash."); return(false); } if ((nMaxLen > 0) && (sValue.length > nMaxLen)) { // Length is specified, and the value is too long alert(sLabel + " is too long. Please reduce it by " + (sValue.length - nMaxLen) + " characters."); return(false); } return(true); } // Same as above, but also allow '&' sign as valid chars // function GlobalValidation_Name2(sLabel, sValue, nMaxLen) { sValue = sValue.replace(/^\s+/g, ""); // remove leading spaces sValue = sValue.replace(/\s+$/g, ""); // remove trailing spaces if (sValue == "") { alert(sLabel + " cannot be blank. Please enter a valid " + sLabel + "."); return(false); } if (sValue.search(/[^0-9a-zA-Z_\$£\-\&\s\(\)\\\/']/g) >= 0) { alert(sLabel + " is invalid. Valid " + sLabel + " should only consist of the characters 0-9, a-z, $, £, &, underscore, brackets, apostrophe or slash."); return(false); } if ((nMaxLen > 0) && (sValue.length > nMaxLen)) { // Length is specified, and the value is too long alert(sLabel + " is too long. Please reduce it by " + (sValue.length - nMaxLen) + " characters."); return(false); } return(true); } function OpenDialog(sURL, sDialogParams) { while((sURL != null) && (sURL != "")) { n = sURL.indexOf("\t"); if (n > 0) { // format is ''. Split the two. sDialogParams = sURL.substr(0, n); sURL = sURL.substr(n+1); } if (sDialogParams == "") { // dialog params is missing? sDialogParams = "dialogHeight:412px;dialogWidth:620px;center:yes;resizable:no;status:no;help:no"; } sURL = ShowModalDialogCentered("/Common/Misc/DialogHost.aspx?URL=" + escape(sURL), this, sDialogParams); sDialogParams = ""; if (sURL != null) { if (sURL.substr(0, 9).toUpperCase() == "AJAXCALL:") { // url is to an AJAX call (usually to work around popup-blockers); make the AJAX call, and finish. AJAXRequest("GET", sURL.substr(9), "", null, Ajax_ErrorAlert, false); sURL = ""; } } } } function CloseDialog() { window.top.close(); } function GetDialogParent() { var oCaller = null; var oCaller = window.top.dialogArguments; if (oCaller == null) oCaller = window.top.opener; return(oCaller); } function GetIncludeExcludeText(ID) { var sValue = ""; switch(ID) { case 0: sValue = "Exclude"; break; case 1: sValue = "Include"; break; } return(sValue); } function GetCallTypeText(ID) { var sValue = ""; switch(ID) { case 0: sValue = "Involving"; break; case 1: sValue = "From"; break; case 2: sValue = "To"; break; case 4: sValue = "Between"; break; } return(sValue); } function displayIncludeExcludeDiv(divId, width, height, left, top) { document.getElementById(divId).style.width = width + 'px'; document.getElementById(divId).style.height = height + 'px'; document.getElementById(divId).style.left = left + 'px'; document.getElementById(divId).style.top = top + 'px'; document.getElementById(divId).className = 'dimming'; document.getElementById(divId).style.visibility = "visible"; document.getElementById(divId).style.display = ""; } function EnableSelectImg(id,radName,img,sToolTip) { document.getElementById(id).src = "/App_Themes/Standard/CTI/Icons/" + img; document.getElementById(id).alt = sToolTip; SetRadioValue(radName); } function SetRadioValue(radName) { var radVal; var rad = document.getElementsByName(radName); for (var i=0; i < rad.length; i++) { if (rad[i].checked) { radVal = rad[i].value; switch(radName) { case "radIncludeExclude": nIncludeID = Number(radVal); sIncludeName = GetIncludeExcludeText(nIncludeID); break; case "radInvolving": nInvolvingID = Number(radVal); sInvolvingName = GetCallTypeText(nInvolvingID); break; } } } } function MoveMouseOut(evnt, elementID) { var oElement = e(elementID); //if (!event.fromElement.contains(event.toElement) &&!document.getElementById(s).contains(event.toElement)) // setTimeout("document.getElementById('"+s+"').style.visibility = 'hidden'", 1000); if(triggerMouseArea(evnt,oElement)) { setTimeout("document.getElementById('"+elementID+"').style.visibility = 'hidden'", 1000); } } function xContains (container, containee) { var isParent = false; do { if ((isParent = container == containee)) break; if(containee) containee = containee.parentNode; } while (containee != null); return isParent; } function triggerMouseArea(e,el) { var rel = (window.event) ? e.toElement : e.relatedTarget; return !(xContains(el,rel)); } //========================================================================================== var jsOKOnly = 0; // Display OK button only. var jsOKCancel = 1; // Display OK and Cancel buttons. var jsAbortRetryIgnore = 2; // Display Abort, Retry, and Ignore buttons. var jsYesNoCancel = 3; // Display Yes, No, and Cancel buttons. var jsYesNo = 4; // Display Yes and No buttons. var jsRetryCancel = 5; // Display Retry and Cancel buttons. var jsCritical = 16; // Display Critical Message icon. var jsQuestion = 32; // Display Warning Query icon. var jsExclamation = 48; // Display Warning Message icon. var jsInformation = 64; // Display Information Message icon. var jsDefaultButton1 = 0; // First button is default. var jsDefaultButton2 = 256; // Second button is default. var jsDefaultButton3 = 512; // Third button is default. var jsDefaultButton4 = 768; // Fourth button is default. var jsOK = 1; // OK var jsCancel = 2; // Cancel var jsAbort = 3; // Abort var jsRetry = 4; // Retry var jsIgnore = 5; // Ignore var jsYes = 6; // Yes var jsNo = 7; // No var __MsgBoxParams = { sPrompt: '', nFlags: 0, sTitle: '', sVerticalAlign: 'middle', aOptions: null, nButtonPressed: 0, nSelectionOption: 0 }; function GetMsgBoxParams() { return __MsgBoxParams; } function MsgBox(sPrompt, nFlags, aOptions, sVerticalAlign, sHeight, sWidth, sTitle) { if (nFlags == undefined) nFlags = jsOKOnly; if (sWidth == undefined) sWidth = "500px"; if (sHeight == undefined) sHeight = "125px"; if (aOptions == undefined) aOptions = null; if (sVerticalAlign == undefined) sVerticalAlign = "middle"; if (sTitle == undefined) sTitle = ""; __MsgBoxParams.sPrompt = sPrompt; __MsgBoxParams.nFlags = nFlags; __MsgBoxParams.aOptions = aOptions; __MsgBoxParams.sVerticalAlign = sVerticalAlign; __MsgBoxParams.sTitle = sTitle; __MsgBoxParams.nButtonPressed = 0; __MsgBoxParams.nSelectionOption = 0; ShowModalDialogCentered("/Common/Misc/MsgBox.aspx", this, "dialogHeight:" + sHeight + ";dialogWidth:" + sWidth + ";center:yes;resizable:no;status:yes;help:no;scroll:no"); return __MsgBoxParams.nButtonPressed; } function GetMsgBoxSelection() { return __MsgBoxParams.nSelectionOption; } //========================================================================================== function ReloadIFrame(sID) { var sURL, sReload, n; var nReloadCount = 1; var oIFrame = document.getElementById(sID); sURL = oIFrame.src; n = sURL.lastIndexOf("&_Reload="); if (n >= 0) { // we already have a _Reload postfix; increment the counter sReload = sURL.substr(n); sURL = sURL.substr(0, n); n = sReload.indexOf("="); nReloadCount = Number(sReload.substr(n+1)) + 1; } if (sURL.indexOf("?") < 0) sURL += "?"; oIFrame.src = sURL + "&_Reload=" + nReloadCount; } function ClickToDial(bIsExtension, sDigits) { ShowModalDialogCentered("/TMS/CallCtrl/ClickToDial.aspx?IsExtn=" + (bIsExtension?"1":"0") + "&Digits=" + sDigits, this, "dialogHeight:260px;dialogWidth:400px;center:yes;resizable:no;status:yes;help:no;scroll:No"); }