/***********************************************************************
	file: ClientService.EZTObj.js
	object: EZTClientService
 ***********************************************************************/var strTemp;g_strUpdateLanguageID = null;var g_LumisSubmitName = null;var g_LumisURLSuffix = "";function EZTClientService(){ this.gotoChannel = gotoChannel; this.gotoPortalHome = gotoPortalHome; this.generatePageParam = generatePageParam; this.getCookie = getCookie; this.generateListActionCustomData = generateListActionCustomData; this.addUIPart = addUIPart; this.gotoLocation = gotoLocation; this.logout = logout; this.checkForNoErrors = checkForNoErrors; this.refreshPage = refreshPage; this.verifySelectionSupport = verifySelectionSupport; this.updateLanguage = updateLanguage; this.printPage = printPage; this.postFormToUIPart = postFormToUIPart; this.postParameterToService = postParameterToService; this.postParameterToServiceInst = postParameterToServiceInst; this.postParameterToUIPart = postParameterToUIPart; this.postParameterToUIPartInst = postParameterToUIPartInst; this.resetUIPartForm = resetUIPartForm; this.getSelectedItems = getSelectedItems; this.navigateTo = navigateTo; this.clearAllParameters = clearAllParameters; this.onSubmit = onSubmit; this.onReset = resetUIPartForm; this.onLink = onLink; this.addClientMessage = addClientMessage; function logout() { window.location.href = g_strHTTP+g_strWebSiteHome+"/guestlogin.asp?Logout=1"; } function checkForNoErrors(xmlNode, bDisplayError) { if(bDisplayError == null) bDisplayError = true; var state = xmlNode.readyState; if(state == 4) { var err = xmlNode.parseError; if (err.errorCode != 0) { if(bDisplayError) alert(err.reason); return false; } var pNode = xmlNode.selectSingleNode("error"); if(pNode) { if(bDisplayError) alert(pNode.text); return false; } else return true; } } function onLink(strURL, strUIPartInstUID) { document.forms['_EZTEmailForm_'].action=strURL; postFormToUIPart('_EZTEmailForm_', strUIPartInstUID); } function postFormToUIPart(strFormName, strUIPartInstUID, strViewUID) { if(!strViewUID) strViewUID = g_strViewID; EZTService.gotoChannel(g_strTeamID, strViewUID, g_strSubViewID, EZTService.generatePageParam('SetUIPartParamFromForm', strFormName, strUIPartInstUID, null, null)); return false; } function onSubmit(strFormName, strUIPartInstUID, strViewUID, strURL) { if(strURL) document.forms[strFormName].action=strURL; return postFormToUIPart(strFormName, strUIPartInstUID, strViewUID); } function resetUIPartForm(strUIPartInstUID) { EZTService.gotoChannel(g_strTeamID, g_strViewID, g_strSubViewID, EZTService.generatePageParam('SetUIPartParam', '', strUIPartInstUID, null, null)); return false; } function splitParameters(parametersName) { var formFieldSizeLimit = 100000; var parametersElement = document.forms["_EZTMainForm_"].elements[parametersName]; if (parametersElement == null || parametersElement.length != null) return; if (parametersElement.value.length <= formFieldSizeLimit) return; var parametersRemainingValue = parametersElement.value.substr(formFieldSizeLimit); parametersElement.value = parametersElement.value.substr(0, formFieldSizeLimit); while (parametersRemainingValue.length > 0) { var pInput = document.createElement("input"); pInput.type = "hidden"; pInput.name = parametersName; pInput.value = parametersRemainingValue.substr(0, formFieldSizeLimit); document.forms["_EZTMainForm_"].appendChild(pInput); parametersRemainingValue = parametersRemainingValue.substr(formFieldSizeLimit); } } function clearParameters(parametersName) { var parametersElement = document.forms["_EZTMainForm_"].elements[parametersName]; if (parametersElement.length == null) parametersElement.value = ""; else for (var i = 0; i < parametersElement.length; i++) parametersElement[i].value = ""; } function clearAllParameters() { clearParameters("_EZTPrevPageParameters_"); } function postParameterToService(strParameter, strServiceUID, strViewUID, iFlags) { if(!strViewUID) strViewUID = g_strViewID; if(iFlags == null) iFlags = 4; EZTService.gotoChannel(g_strTeamID, strViewUID, g_strSubViewID, EZTService.generatePageParam('SetUIPartParam', strParameter, null, null, null, strServiceUID),iFlags); } function postParameterToServiceInst(strParameter, strServiceInstUID, strViewUID, iFlags) { if(!strViewUID) strViewUID = g_strViewID; if(iFlags == null) iFlags = 4; EZTService.gotoChannel(g_strTeamID, strViewUID, g_strSubViewID, EZTService.generatePageParam('SetUIPartParam', strParameter, null, null, strServiceInstUID),iFlags); } function postParameterToUIPart(strParameter, strUIPartUID, strViewUID, iFlags) { if(!strViewUID) strViewUID = g_strViewID; if(iFlags == null) iFlags = 4; EZTService.gotoChannel(g_strTeamID, strViewUID, g_strSubViewID, EZTService.generatePageParam('SetUIPartParam', strParameter, null, strUIPartUID, null),iFlags); } function postParameterToUIPartInst(strParameter, strUIPartUID, strViewUID, iFlags) { if(!strViewUID) strViewUID = g_strViewID; if(iFlags == null) iFlags = 4; EZTService.gotoChannel(g_strTeamID, strViewUID, g_strSubViewID, EZTService.generatePageParam('SetUIPartParam', strParameter, null, strUIPartUID, null),iFlags); } function generatePageParam(strActionType, strUIPartParameters, strUIPartInstUID, strUIPartUID, strServiceInstUID, strServiceUID) { var strParam = '<action>'; if(strActionType == 'SetUIPartParam') { if(strUIPartParameters) strParam += '<parameters>'+strUIPartParameters+'</parameters>'; } else if(strActionType == 'SetUIPartParamFromForm') strParam += '<parameters>'+getFormParameters(strUIPartParameters)+'</parameters>'; if(strUIPartInstUID) { if(strUIPartInstUID != strUIPartInstUID.toUpperCase()) alert(strUIPartInstUID+" needs to be in upper case."); strParam += '<UIPartInstUID>'+strUIPartInstUID+'</UIPartInstUID>'; } if(strUIPartUID) { if(strUIPartUID != strUIPartUID.toUpperCase()) alert(strUIPartUID+" needs to be in upper case."); strParam += '<UIPartUID>'+strUIPartUID+'</UIPartUID>'; } if(strServiceInstUID) { if(strServiceInstUID != strServiceInstUID.toUpperCase()) alert(strServiceInstUID+" needs to be in upper case."); strParam += '<ServiceInstUID>'+strServiceInstUID+'</ServiceInstUID>'; } if(strServiceUID) { if(strServiceUID != strServiceUID.toUpperCase()) alert(strServiceUID+" needs to be in upper case."); strParam += '<ServiceUID>'+strServiceUID+'</ServiceUID>'; } strParam += '</action>'; return strParam; } function generateListActionCustomData(strFormName, strCustomAction, strSelectionSupport, strExtraData, strNoItemMsg) { var strFormParams = ""; var pForm = document.forms[strFormName]; var pElement, pElements; var bFoundOne = false; var strCustomData = "<custom>"; if(strSelectionSupport == "one"|| strSelectionSupport == "many") { pElements = pForm.elements["_EZTListItem_"]; if(pElements && !pElements.length) { if(pElements.checked) { strCustomData +="<itemID>"+pElements.value+"</itemID>"; bFoundOne = true; } } else if(pElements) { for(var i=0; i<pElements.length; i++) { if(pElements[i].checked) { strCustomData +="<itemID>"+pElements[i].value+"</itemID>"; bFoundOne = true; if(strSelectionSupport == "one") break; } } } } if(strExtraData && strExtraData.length) strCustomData += "<other>"+strExtraData+"</other>"; strCustomData += "<action>"+strCustomAction+"</action>"; strCustomData += "</custom>"; if(strSelectionSupport == "one"|| strSelectionSupport == "many") { if(bFoundOne) return strCustomData; else { if(strNoItemMsg) alert(strNoItemMsg); return null; } } else return strCustomData; } function verifySelectionSupport(strSelectionSupport, strFormName, strNoItemMsg, strOneItemMsg, pWindow) { var strFormParams = ""; if(!pWindow) pWindow = window; var pForm = pWindow.document.forms[strFormName]; var pElement, pElements; var bFoundOne = false; var bFoundMoreThanOne = false; if(strSelectionSupport == "one"|| strSelectionSupport == "many") { pElements = pForm.elements["_EZTListItem_"]; if(pElements && !pElements.length) { if(pElements.checked) bFoundOne = true; } else if(pElements) { for(var i=0; i<pElements.length; i++) { if(pElements[i].checked) { if(bFoundOne) { bFoundMoreThanOne = true; break; } bFoundOne = true; } } } if(!bFoundOne) { if(strNoItemMsg) pWindow.alert(strNoItemMsg); return false; } if(strSelectionSupport == "one"&& bFoundMoreThanOne) { if(strOneItemMsg) { pWindow.alert(strOneItemMsg); return false; } } } return true; } function addUIPart(strURL, strUIPartUID, strServiceInstUID, strCustomXML, strWidth, strHeight, iFlags, pCallerWindow) { if(!iFlags) iFlags = 0; var strOpenURL = strURL; if(strOpenURL.search("\\?") == -1) strOpenURL += "?"; else strOpenURL += "&"; if(!strCustomXML) strCustomXML = ""; var strPattern = new RegExp(" ", "gi"); strCustomXML = strCustomXML.replace(strPattern, "+"); strOpenURL +="UserSessionID="+g_strUserSID+"&UIPartUID="+strUIPartUID+"&ServiceInstUID="+strServiceInstUID+"&TeamUID="+g_strTeamID+"&CompanyUID="+g_strCompanyUID+"&br="+g_EZTBrowserType+"&ver="+g_EZTBrowserVer+"&CustomXML="+strCustomXML; if(g_strViewID.length) strOpenURL += "&ViewUID="+g_strViewID; if (strOpenURL.length > 2000) { alert(g_arrEZTStrings["STR_TOO_MANY_ITEMS_SELECTED"]); return; } var popWidth = parseInt(strWidth); if (isNaN(popWidth)) popWidth = 0; var popHeight = parseInt(strHeight); if (isNaN(popHeight)) popHeight = 0; var currentWidth = 0; var currentHeight = 0; if (screen.availWidth != null) { currentWidth = screen.availWidth; currentHeight = screen.availHeight; } else if (document.body.clientWidth != null) { currentWidth = document.body.clientWidth; currentHeight = document.body.clientHeight; } else if (window.innerWidth != null) { currentWidth = window.innerWidth; currentHeight = window.innerHeight; } var topPos = parseInt((currentHeight - popHeight) / 2); var leftPos = parseInt((currentWidth - popWidth) / 2); if (topPos < 0) topPos = 0; if (leftPos < 0) leftPos = 0; if(pCallerWindow) { var arrCallerURL = pCallerWindow.document.URL.split("?"); var strCallerURL = arrCallerURL[0]; arrCallerURL = strCallerURL.split("/"); strCallerURL = ""; for(var i=0; i < arrCallerURL.length-1; i++) strCallerURL += arrCallerURL[i]+"/"; pCallerWindow.open(strCallerURL+strOpenURL, "_blank", "HEIGHT="+strHeight+",WIDTH="+strWidth+",resizable,scrollbars,left=" + leftPos.toString() + ",top="+ topPos.toString()); } else window.open(strOpenURL, "_blank", "HEIGHT="+strHeight+",WIDTH="+strWidth+",resizable,scrollbars,left=" + leftPos.toString() + ",top="+ topPos.toString()); } function gotoLocation(strURL, strServiceInstUID, strCustomXML) { window.location.href = strURL+"&ServiceInstUID="+strServiceInstUID+"&CustomXML="+strCustomXML; } function getFormParameters(strFormName) { var strFormParams = ""; var pForm = document.forms[strFormName]; var pElement; var strFormAction = pForm.action; if(strFormAction && strFormAction.length) strFormParams += '<parameter name="_EZTFormAction_"><![CDATA['+strFormAction+']]></parameter>'; for(var i=0; i<pForm.elements.length; i++) { pElement = pForm.elements[i]; if(pElement.type == "button") continue; if(!pElement.name || !pElement.name.length) continue; if(pElement.type == "submit"&& (!g_LumisSubmitName || pElement.name!=g_LumisSubmitName)) continue; else if(pElement.type == "select-one"&& pElement.selectedIndex != -1) strFormParams += '<parameter name="'+pElement.name+'"><![CDATA['+pElement.options[pElement.selectedIndex].value+']]></parameter>'; else if(pElement.type == "select-multiple") { var strValue = ""; for(var j=0; j<pElement.options.length; j++) { if(pElement.options[j].selected) strFormParams += '<parameter name="'+pElement.name+'"><![CDATA['+pElement.options[j].value+']]></parameter>'; } } else if(pElement.type == "checkbox"|| pElement.type == "radio") { if(pElement.checked) strFormParams += '<parameter name="'+pElement.name+'"><![CDATA['+pElement.value+']]></parameter>'; } else strFormParams += '<parameter name="'+pElement.name+'"><![CDATA['+pElement.value+']]></parameter>'; } return strFormParams; } function updateLanguage(strNewLanguage) { g_strUpdateLanguageID = strNewLanguage; EZTService.gotoPortalHome(); } function refreshPage() { EZTService.gotoChannel(g_strTeamID, g_strViewID, g_strSubViewID); } function printPage() { EZTService.gotoChannel(g_strTeamID,g_strViewID,g_strSubViewID,document.forms["_EZTMainForm_"].elements["_EZTPrevPageParameters_"].value,1); } function gotoPortalHome() { EZTService.gotoChannel(null, null, null, null, 2); } function navigateTo(strTeamID, strViewID) { clearParameters("_EZTNewPageParameters_"); clearParameters("_EZTPrevPageParameters_"); EZTService.gotoChannel(strTeamID, strViewID); } function gotoChannel(strTeamID, strViewID, strSubViewID, strPageParam, iFlags) { if(!strTeamID) strTeamID = ""; if(!strViewID) strViewID = ""; if(!strSubViewID) strSubViewID = ""; var strURL = g_strMainPageaction+"?"; if(!strViewID.length) strURL += "Team="+strTeamID; else { if(strViewID.substr(0,9) == "{00000000") strURL += "Team="+strTeamID+"&"; strURL += "View="+strViewID; } if(strSubViewID.length) strURL += "&SubViewID="+strSubViewID; if(g_displayMode != 0) strURL +="&Mode="+g_displayMode; if(g_strUpdateLanguageID) { strURL += "&LangID="+g_strUpdateLanguageID; } if(iFlags) { if(iFlags & 1) strURL += "&Print=1"; if(!g_iInTemplateMode && (iFlags & 2)) strURL += "&GoHome=1"; if(iFlags & 4) { var strURLParams = strPageParam; var strPattern = /<action>/i; strURLParams = strURLParams.replace(strPattern, ""); strPattern = /<\/action>/i; strURLParams = strURLParams.replace(strPattern, ""); strPattern = /<!\[CDATA\[/gi; strURLParams = strURLParams.replace(strPattern, ""); strPattern = /\]\]>/gi; strURLParams = strURLParams.replace(strPattern, ""); strPattern = /<parameters>/i; strURLParams = strURLParams.replace(strPattern, ""); strPattern = /<\/parameters>/i; strURLParams = strURLParams.replace(strPattern, ""); strPattern = /<parameter name="/gi;
				strURLParams = strURLParams.replace(strPattern, "");
				strPattern = /">/gi; strURLParams = strURLParams.replace(strPattern, "="); strPattern = /<\/parameter>/gi; strURLParams = strURLParams.replace(strPattern, ";"); strPattern = /<UIPartUID>/i; strURLParams = strURLParams.replace(strPattern, "&UIPartUID="); strPattern = /<\/UIPartUID>/i; strURLParams = strURLParams.replace(strPattern, ""); strPattern = /<UIPartInstUID>/i; strURLParams = strURLParams.replace(strPattern, "&UIPartInstUID="); strPattern = /<\/UIPartInstUID>/i; strURLParams = strURLParams.replace(strPattern, ""); strPattern = /<ServiceInstUID>/i; strURLParams = strURLParams.replace(strPattern, "&ServiceInstUID="); strPattern = /<\/ServiceInstUID>/i; strURLParams = strURLParams.replace(strPattern, ""); strPattern = /<ServiceUID>/i; strURLParams = strURLParams.replace(strPattern, "&ServiceUID="); strPattern = /<\/ServiceUID>/i; strURLParams = strURLParams.replace(strPattern, ""); strPattern = /</gi; strURLParams = strURLParams.replace(strPattern, ""); strPattern = />/gi; strURLParams = strURLParams.replace(strPattern, "="); strURL += "&params="+strURLParams; } } if(strPageParam) { document.forms["_EZTMainForm_"].elements["_EZTNewPageParameters_"].value = strPageParam; splitParameters("_EZTNewPageParameters_"); } else { clearParameters("_EZTNewPageParameters_"); } splitParameters("_EZTPrevPageParameters_"); if(g_LumisURLSuffix && g_LumisURLSuffix.length) strURL += g_LumisURLSuffix; document.forms["_EZTMainForm_"].action = strURL; document.forms["_EZTMainForm_"].submit(); } function getCookie(sName) { var aCookie = document.cookie.split("; "); for (var i=0; i < aCookie.length; i++) { var aCrumb = aCookie[i].split("="); if (sName == aCrumb[0]) return unescape(aCrumb[1]); } return null; } function getSelectedItems(strFormName, iFlag) { var strSelectedItems=""; var pForm = document.forms[strFormName]; var bFoundOne=false; pElements = pForm.elements["_EZTListItem_"]; if(pElements && !pElements.length) { if(pElements.checked) { strSelectedItems += pElements.value; bFoundOne = true; } } else if(pElements) { for(var i=0; i<pElements.length; i++) { if(pElements[i].checked) { if(bFoundOne) strSelectedItems +=";"; strSelectedItems +=pElements[i].value; bFoundOne=true; if(iFlag == 1) break; } } } return strSelectedItems; } function addClientMessage(message) { var pMsg = document.forms['_EZTMainForm_'].elements['_EZTClientMessage_']; if (pMsg.value != '') pMsg.value += "\n"; pMsg.value += message; }}