var HTML_FIND = new Array(""", "<", ">", "
", "" );
var HTML_REPLACE = new Array("\"", "<", ">", "\r\n", "\r\n" );
var unWantedCharSet = "[<>|\"]";
var unWantedChars = new RegExp(unWantedCharSet); // last char is space "\\ "
var ERROR_COLOR = "pink";
var MOUSE_OVER_MENU_COLOR = "black";//"xp: black";//lbank: "#006633"
var TRACK_SESSION = true;
var IS_CHILD_WINDOW = false;
function changeColor(whichObject,colorId){
whichObject.style.backgroundImage = (colorId==1) ? "url('/"+CTX_PATH+"/images/rowMouseOverImage.gif')" : "";
}
function changeMenuColor(whichObject,colorId){
whichObject.style.backgroundColor = (colorId==1) ? MOUSE_OVER_MENU_COLOR : "";
whichObject.style.borderTop = (colorId==1) ? "1px solid orange" : "";
whichObject.style.borderBottom = (colorId==1) ? "1px solid orange" : "";
whichObject.style.cursor = (colorId==1) ? "pointer" : "";
}
function hideMenu(whichMenu){
setTimeout(
function(){
makeHidden(whichMenu);
}, 20);
currentMenu = "";
}
function makeHidden(whichMenu){
if(currentMenu!=whichMenu){
document.getElementById(whichMenu).style.display = "none";
document.getElementById(whichMenu).style.visibility = "hidden";
}
}
function removeAllOptions(givenForm,selectName){
var totalOptions = givenForm.elements[selectName].options.length; //from GUI, removed the displayed ones
for(var i=0; i=0)
{
givenValue = givenValue.replace(new RegExp(HTML_FIND[i],'g'),HTML_REPLACE[i]);
}
}
return givenValue;
}
function attachEvents(whichForm){
//alert("Total Elements in the form: "+whichForm.elements.length)
for(var i=0;i"+whichForm.elements[i].name + "
" + err.message);
}
}
}
}
function checkPositiveValue(eventObject){
var fieldValue = parseFloat(eventObject.value);
if(isNaN(eventObject.value)==false && fieldValue>0) {eventObject.style.backgroundColor="white";return true;};
eventObject.style.backgroundColor="pink";
alert("Field value should be number and greater than 0");
return false;
}
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validateFormData(givenForm){
var noOfElements = givenForm.elements.length;
var isValid = true;
for(var i=0; i0 || givenForm.elements[i].required=="true" || givenForm.elements[i].required==true) && givenForm.elements[i].value==""){
isValid = false;
fieldValid = false;
}
if(givenForm.elements[i].alt) {
var reqMinValue = parseInt(givenForm.elements[i].alt);
var inputValue = parseInt(givenForm.elements[i].value);
if(inputValue < reqMinValue){
isValid = false;
fieldValid = false;
}
}
if(givenForm.elements[i].accept){
var reqMaxValue = parseInt(givenForm.elements[i].accept);
var inputValue = parseInt(givenForm.elements[i].value);
if(inputValue > reqMaxValue){
isValid = false;
fieldValid = false;
}
}
if(givenForm.elements[i].accessKey){
var dataType = givenForm.elements[i].accessKey;
if(dataType=="date" && isValidDate(givenForm.elements[i].value)==false){
if(givenForm.elements[i].value!=""){
isValid = false;
fieldValid = false;
}
}
if(dataType=="email"){
if(givenForm.elements[i].value!="" && validateEmail(givenForm.elements[i].value)==false){
isValid = false;
fieldValid = false;
}
}
}
if((givenForm.elements[i].type=="text" || givenForm.elements[i].type=="password" || givenForm.elements[i].type=="textarea") && (givenForm.elements[i].dir || givenForm.elements[i].minLength)) { //dir=minLength
var fLen = (givenForm.elements[i].dir) ? givenForm.elements[i].dir : givenForm.elements[i].minLength;
var reqMinLength = parseInt(fLen);
var inputLength = givenForm.elements[i].value.length;
if(inputLength= 0 ){
var firstPart = givenValue.substring(0, givenValue.indexOf(","));
var lastPart = givenValue.substring(givenValue.indexOf(",")+1, givenValue.length);
givenValue = firstPart + "." + lastPart;
}
return parseFloat(givenValue);
}
function refreshLanguage(){
var request = getAjaxObject();
request.open("GET", "LoginController?userAction=4", true)
request.onreadystatechange = function() {//Call a function when the state changes.
//("Language data refreshed.");
}
request.send(null)
}
var SECURITY_KEYS = new Array(116,0);
document.onkeydown=function(e) {
e=e||window.event;
for(var i=0; i= (SESSION_DURATION - (nextCall*3)) ){ //expire 15 seconds before it has to expire, otherwise session object will be null
if(IS_CHILD_WINDOW==true){
self.close();
return;
}
autoLogout();
return;
}else{
SESSION_OUT_TIME = SESSION_OUT_TIME + nextCall;
setTimeout("sessionTimer()", nextCall);
}
}
function autoLogout(){
window.location.href = "LoginController?userAction=5" + getCSRFToken();
}
function isValidHost(AUTHORIZED_URL){
try{
var openedURL = top.location.href;
if(openedURL.indexOf(AUTHORIZED_URL)==-1){
return false;
}
return true;
}catch(err){ //IMPORTANT NOTE: required if other site does this inside iframe, then top.frames will return error
return false;
}
}
function openAssistFrame(frameURL, width, height){
increaseClientSession();
toggleBackground(true);
var assisFrameObject = document.getElementById("assistFrame");
var winWidth = arguments[1]==null ? 500 : width;
var winHeight = arguments[2]==null ? 350 : height;
assisFrameObject.style.display = "block";
assisFrameObject.style.width = winWidth;
assisFrameObject.style.height = winHeight;
assisFrameObject.style.top = ((document.body.clientHeight - winHeight)/2);
assisFrameObject.style.left = ((document.body.clientWidth - winWidth)/2);
assisFrameObject.src = frameURL;
assisFrameObject.focus();
}
function closeAssistFrame(){
var assisFrameObject = document.getElementById("assistFrame");
assisFrameObject.style.display = "none";
toggleBackground(false);
}
function getIFrameObject(iFrameName){
var searchFrame = window.frames[iFrameName].contentWindow;
if(!searchFrame){
searchFrame = window.frames[iFrameName];
}
return searchFrame;
}
function browserSupported(){
/*
var browserName = navigator.userAgent.toUpperCase();
if( browserName.indexOf("MSIE")>=0 || browserName.indexOf("CHROME")>=0 || browserName.indexOf("FIREFOX")>=0){
return true;
}
*/
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
// At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !!window.chrome && !isOpera; // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
if(isFirefox==true || isChrome==true || isIE==true){
return true;
}
return true;
}
function changeTextContent(contentId,contentText){
var browserName = navigator.userAgent.toUpperCase();
if( browserName.indexOf("MSIE")>=0 || browserName.indexOf("CHROME")>=0) {
document.getElementById(contentId).innerText = contentText;
}else{
document.getElementById(contentId).textContent = contentText;
}
}
function getInnerText(elementName){
var browserName = navigator.userAgent.toUpperCase();
if( browserName.indexOf("MSIE")>=0 || browserName.indexOf("CHROME")>=0) {
return document.getElementById(elementName).innerText;
}else{
return document.getElementById(elementName).textContent;
}
}
function sendAjaxRequest(controllerClass,reqData,callBackFunction){
reqData = reqData + "&CSRF_TOKEN=" + getCookie("csrf") + ignoreTokenGeneration();
var request = getAjaxObject();
request.open("POST",controllerClass,true);
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
request.send(reqData); //resetType=1 is password
request.onreadystatechange = function() {//Call a function when the state changes.
if (request.readyState==4 && request.status==200){
callBackFunction(request.responseText);
}
}
}
function showProgressing(containerId){
document.getElementById(containerId).innerHTML = "";
}
function addOption(whichForm, selectName, optionValue, optionText, selectNewlyAddedOption){
var totalOptions = whichForm.elements[selectName].options.length;
whichForm.elements[selectName].options[totalOptions] = new Option(optionText, optionValue);
if(selectNewlyAddedOption || selectNewlyAddedOption==true){
whichForm.elements[selectName].options[totalOptions].selected = true;
}
}
function toggleErrorField(whichObject, isError){
whichObject.style.backgroundColor = isError==true ? ERROR_COLOR : "";
}
function toFixed(value, precision) {
var precision = precision || 0,
power = Math.pow(10, precision),
absValue = Math.abs(Math.round(value * power)),
result = (value < 0 ? '-' : '') + String(Math.floor(absValue / power));
if (precision > 0) {
var fraction = String(absValue % power),
padding = new Array(Math.max(precision - fraction.length, 0) + 1).join('0');
result += '.' + padding + fraction;
}
return result;
}
var documentViewWindow = null;//let this variable be here
function openDocumentViewWindow(actionClass, params) {
if(documentViewWindow && documentViewWindow!=null){
documentViewWindow.focus();
}
var windowWidth = 700;
var windowHeight = 500;
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", actionClass);
form.setAttribute("target", 'view');
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
var left = ((screen.width - windowWidth)/2);
var top = ((screen.height - windowHeight)/2);
documentViewWindow = window.open('', 'view', "height="+windowHeight+", width="+windowWidth+", top="+top+", left="+left+", toolbar=no, titlebar=0, scrollbars=yes, resizable=no, location=no, directories=0");
documentViewWindow.moveTo(left, top);
documentViewWindow.resizeTo(windowWidth, windowHeight);
form.submit();
}
function isLocalhost(){
return (AUTHORIZED_URL.indexOf("http://localhost")>=0)
}
function checkTopFrame(){
try{
var topFrameNotExist = (top.frames["myTopFrame"]==null);
if(topFrameNotExist==true && isLocalhost()==false){
top.location.href = AUTHORIZED_URL + "/" + CTX_PATH;
}
if(top.location.href.indexOf(AUTHORIZED_URL)==-1 && isLocalhost()==false){
top.location.href = AUTHORIZED_URL + "/" + CTX_PATH;
}
}catch(err){//IMPORTANT NOTE: required if other site does this inside iframe, then top.frames will return error
top.location.href = AUTHORIZED_URL + "/" + CTX_PATH;
}
}
function openSecureURL(event){
event.preventDefault ? event.preventDefault() : (event.returnValue = false);
var sourceElement = event.currentTarget? event.currentTarget : event.srcElement ;
var currentVal = sourceElement.attributes["onclick"].value;
var newURL = currentVal.substring(currentVal.indexOf("=")+2, currentVal.length-1);
if(newURL.indexOf("?")>0){
newURL = newURL + getPageId() + getCSRFToken();
} else {
newURL = newURL + getPageIdNoAndPrefix() + getCSRFToken();
}
console.log(newURL);
window.location.href = newURL;
}
function appendId(){
var p = document.getElementsByName("applink");
for(var i=0; i