function OpenPopupFromURL(intWidth, intHeight, strURL) { popup = window.open(strURL, 'popup', 'location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes,left=20,top=20,width=' + intWidth + ',height=' + intHeight); } function OpenPopup(intWidth, intHeight, intCustomModuleID) { popup = window.open('/PopUp.aspx?width=' + intWidth + '&subpage=' + intCustomModuleID,'popup','location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes,left=20,top=20,width=' + intWidth + ',height=' + intHeight); } function GetAbsoluteElementPositionX(objElement) { var intPosition = 0; if (objElement.offsetParent) { intPosition = objElement.offsetLeft; while (objElement = objElement.offsetParent) { intPosition += objElement.offsetLeft; } } return intPosition; } function GetAbsoluteElementPositionY(objElement) { var intPosition = 0; if (objElement.offsetParent) { intPosition = objElement.offsetTop; while (objElement = objElement.offsetParent) { intPosition += objElement.offsetTop; } } return intPosition; } function SetFocus(strClientID) { try { document.getElementById(strClientID).focus(); } catch(errorObject) { } } function ClearTextBox(objTextBox, strDefaultValue) { if(objTextBox.value == strDefaultValue) { objTextBox.value = ''; } } function ScrollToElement(strElementID) { if(mrO.isDefined($('#' + strElementID)) && mrO.isDefined($('#' + strElementID).offset())){window.scrollTo(0, $('#' + strElementID).offset().top);} } function AutoResize() { resizeTo(document.body.offsetWidth, document.body.scrollHeight); } function SetElementValue(strElementClientID, strValue) { if(strElementClientID != null && strElementClientID.length > 0 && document.getElementById(strElementClientID) != null) { var objElement = document.getElementById(strElementClientID); if(objElement.tagName == 'SPAN') { objElement.innerHTML = strValue; } else if(objElement.tagName == 'SELECT' && strValue == null) { objElement.selectedIndex = 0; } else if(strValue != null) { objElement.value = strValue; } } } function GetElementValue(strElementClientID) { if(strElementClientID != null && strElementClientID.length > 0 && document.getElementById(strElementClientID) != null) { return document.getElementById(strElementClientID).value; } else { return null; } } function ShowElement(strClientID, strDisplayStyle) { if(strDisplayStyle == null || strDisplayStyle == '') { strDisplayStyle = 'inline'; } if(strClientID.length > 0 && document.getElementById(strClientID) != null) { if(document.getElementById(strClientID).nodeName == 'TR') { document.getElementById(strClientID).style.display = ''; } else if(navigator.userAgent.indexOf('Firefox') != -1 && document.getElementById(strClientID).nodeName == 'TABLE') { document.getElementById(strClientID).style.display = null; } else { document.getElementById(strClientID).style.display = strDisplayStyle; } document.getElementById(strClientID).style.visibility = 'visible'; } }function HideElement(strClientID) { if(strClientID.length > 0 && document.getElementById(strClientID) != null) { document.getElementById(strClientID).style.display = 'none'; } } function ShadowElement(strClientID) { if(strClientID.length > 0 && document.getElementById(strClientID) != null) { document.getElementById(strClientID).style.visibility = 'hidden'; } } function EnableElement(strClientID) { if(strClientID != null && strClientID.length > 0 && document.getElementById(strClientID) != null) { document.getElementById(strClientID).disabled = false; } } function DisableElement(strClientID) { if(strClientID != null && strClientID.length > 0 && document.getElementById(strClientID) != null) { document.getElementById(strClientID).disabled = true; } } function SetElementToReadOnly(strElementClientID) { if(strElementClientID != null && strElementClientID.length > 0 && document.getElementById(strElementClientID) != null) { var objElement = document.getElementById(strElementClientID); objElement.readOnly = true; objElement.colorBackup = objElement.style.color; objElement.style.color = '#808080'; if(objElement.tagName == 'SELECT') { objElement.onfocus = function() { return this.blur(); }; } } } function SetElementToReadAndWrite(strElementClientID) { if(strElementClientID != null && strElementClientID.length > 0 && document.getElementById(strElementClientID) != null) { var objElement = document.getElementById(strElementClientID); objElement.readOnly = false; if(typeof(objElement.colorBackup) !== 'undefined') { objElement.style.color = objElement.colorBackup; } objElement.style.color = '#000'; if(objElement.tagName == 'SELECT') { objElement.onfocus = null; } } } function ToggleElementDisplay(strClientID, strDisplayStyle, arrToShowClientIDs, arrToHideClientIDs) { if(strDisplayStyle == null || strDisplayStyle == '') { strDisplayStyle = 'block'; } if(strClientID != null && strClientID.length > 0 && document.getElementById(strClientID) != null) { if(document.getElementById(strClientID).style.display == 'none') { ShowElement(strClientID, strDisplayStyle); if(arrToShowClientIDs != null) { for(var i = 0; i < arrToShowClientIDs.length; i++) { ShowElement(arrToShowClientIDs[i], strDisplayStyle); } } } else { HideElement(strClientID); if(arrToHideClientIDs != null) { for(var i = 0; i < arrToHideClientIDs.length; i++) { HideElement(arrToHideClientIDs[i]); } } } } return false; }function ToggleElementVisibility(strClientID) { if(strClientID.length > 0 && document.getElementById(strClientID) != null) { if(document.getElementById(strClientID).style.visibility = 'hidden') { document.getElementById(strClientID).style.visibility = 'visible'; } else { document.getElementById(strClientID).style.visibility = 'hidden'; } } } function AddItemToDropDown(strDropDownClientID, strItemText, strItemValue) { if(strItemValue == null || strItemValue == '') { strItemValue = strItemText; }if(strDropDownClientID != null && strDropDownClientID.length > 0 && document.getElementById(strDropDownClientID) != null) { var objDropDown = document.getElementById(strDropDownClientID); var objOption = document.createElement('OPTION'); objOption.text = strItemText; objOption.value = strItemValue; try{ objDropDown.add(objOption,null); } catch(e){ objDropDown.add(objOption); } } } function ClearDropDown(strDropDownClientID) { if(strDropDownClientID != null && strDropDownClientID.length > 0 && document.getElementById(strDropDownClientID) != null) { var objDropDown = document.getElementById(strDropDownClientID); objDropDown.length = 0; } } function StartsWith(strStringToExamine, strStringToSearchFor) { if(strStringToExamine != null && strStringToExamine.length > 0 && strStringToSearchFor != null && strStringToSearchFor.length > 0) { if(strStringToSearchFor.length > strStringToExamine.length) { strStringToSearchFor = strStringToSearchFor.substring(0, strStringToExamine.length); } var intLength = strStringToSearchFor.length; if(strStringToExamine.substring(0, intLength) == strStringToSearchFor) { return true; } else { return false; } } } function EndsWith(strStringToExamine, strStringToSearchFor) { if(strStringToExamine != null && strStringToExamine.length > 0 && strStringToSearchFor != null && strStringToSearchFor.length > 0) { if(strStringToSearchFor.length > strStringToExamine.length) { strStringToSearchFor = strStringToSearchFor.substring(0, strStringToExamine.length); } var intLength = strStringToSearchFor.length; if(strStringToExamine.substring(strStringToExamine.length - intLength, strStringToExamine.length) == strStringToSearchFor) { return true; } else { return false; } } } function SubmitCustomForm(strFormClientID, strTarget) { var objForm = document.getElementById(strFormClientID); if(objForm == null) { alert('Form not found!'); } else { var strOriginalTarget = strTarget; if(strOriginalTarget == null) { strOriginalTarget = objForm.target; } var strCompleteURL = window.location.href; var strURL = ''; var strQueryString = ''; var strProtocol = ''; var strHostName = ''; var strPath = ''; var strDocument = ''; if (strCompleteURL.indexOf('?') != -1) { strURL = strCompleteURL.substring(0, strCompleteURL.indexOf('?')); strQueryString = strCompleteURL.substring(strCompleteURL.indexOf('?') + 1); } else { strURL = strCompleteURL; } strProtocol = strURL.substring(0, strURL.indexOf('/') + 2); strURL = strURL.substring(strURL.indexOf('/') + 2); strHostName = strURL.substring(0, strURL.indexOf('/')); strURL = strURL.substring(strURL.indexOf('/')); strPath = strURL.substring(0, strURL.lastIndexOf('/') + 1); strURL = strURL.substring(strURL.lastIndexOf('/') + 1); strDocument = strURL; var strNewTarget = ''; if(StartsWith(strOriginalTarget, '/') && EndsWith(strOriginalTarget, '/')) { strNewTarget = strProtocol + strHostName + strOriginalTarget; } else { strNewTarget = strProtocol + strHostName + strPath + strDocument; } var arrElements = objForm.elements; var strNewQueryString = ''; for(var i = 0; i < arrElements.length; i++) { if(arrElements[i].type != 'submit' && arrElements[i].id != '__VIEWSTATE') { if(strNewQueryString.length > 0) { strNewQueryString += '&'; } if(arrElements[i].id != null && arrElements[i].id.length > 0) { strNewQueryString += arrElements[i].id; } else { strNewQueryString += arrElements[i].name; } strNewQueryString += '='; strNewQueryString += arrElements[i].value; } } strNewTarget += '?' + strNewQueryString; window.location = strNewTarget; } return false; } function enableDisableFormElement(strClientID) { if(strClientID.length > 0 && document.getElementById(strClientID) != null) { if(document.getElementById(strClientID).disabled == false) { document.getElementById(strClientID).disabled = true; }else{ document.getElementById(strClientID).disabled = false; } } } function KeepDropDownConsistency(strMasterDropDownClientID, strSlaveDropDownClientID, intMode) { var objMasterDropDown = document.getElementById(strMasterDropDownClientID); var objSlaveDropDown = document.getElementById(strSlaveDropDownClientID); if(objMasterDropDown != null && objSlaveDropDown) { var arrMasterDateParts = objMasterDropDown.value.split('/'); var arrSlaveDateParts = objSlaveDropDown.value.split('/'); var objMasterDate = new Date(parseInt(arrMasterDateParts[1]), parseInt(arrMasterDateParts[0]) + 1, 1); var objSlaveDate = new Date(parseInt(arrSlaveDateParts[1]), parseInt(arrSlaveDateParts[0]) + 1, 1); if(intMode == 2) { if(objMasterDate > objSlaveDate) { objSlaveDropDown.value = objMasterDropDown.value; } } else if(intMode == 3) { if(objMasterDate < objSlaveDate) { objSlaveDropDown.value = objMasterDropDown.value; } } else { objSlaveDropDown.value = objMasterDropDown.value; } } }