String.prototype.validate=function(type,req,validChar,invalidChar,minLen,maxLen){if(!req&&this.trim()==""){return true;}var filterChars="",reString="";if(!type){type="ALL";}switch(type.toUpperCase()){case"ALPHA":filterChars="A-Za-z";break;case"ALPHANUM":filterChars="A-Za-z0-9";break;case"NUMERIC":filterChars="0-9";break;case"DECIMAL":filterChars="0-9\\.";break;default:filterChars="\\w\\W";break;}reString="^["+filterChars;if(validChar){reString+=validChar;}reString+="]";if(minLen||maxLen){reString+="{";if(minLen&&minLen>-1){reString+=parseFloat(minLen);}else{if(maxLen){reString+="1";}}if(minLen||maxLen){reString+=",";}if(maxLen&&maxLen>-1){reString+=parseFloat(maxLen);}if(minLen||maxLen){reString+="}";}}else{if(req){reString+="+";}else{reString+="*";}}reString+="$";var reValidTest=new RegExp(reString);if(invalidChar){reString="^[^"+invalidChar+"]*$";}var reInvalidTest=new RegExp(reString);return reValidTest.test(this.trim())&&reInvalidTest.test(this.trim());};String.prototype.trim=function(){return this.replace(/^[\ ]{1,}/,"").replace(/[\ ]{1,}$/,"");};String.prototype.validateMDY=function(){var s=this.trim();var reTest=/^[01]{0,1}[0-9][\/\-\.][0123]{0,1}[0-9][\-\/\.][0-9]{4,4}$/;if(!reTest.test(s)){return false;}var chr=s.substr(s.search(/[\/\-\.]/),1);switch(chr){case".":if((/[\-\/]/).test(s)){return false;}break;case"-":if((/[\.\/]/).test(s)){return false;}break;case"/":if((/[\-\.]/).test(s)){return false;}break;}var y=s.substr(s.lastIndexOf(chr)+1);if(!isNaN(parseFloat(y))&&parseFloat(y)>0){var m=s.substr(0,s.indexOf(chr));if(!isNaN(parseFloat(m))&&parseFloat(m)>=1&&parseFloat(m)<=12){var d=s.substr(s.indexOf(chr)+1,2);var dateLimit=31;if(parseFloat(m)==4||parseFloat(m)==6||parseFloat(m)==9||parseFloat(m)==11){dateLimit--;}if(parseFloat(m)==2&&parseFloat(y)%4==0){dateLimit-=2;}if(parseFloat(m)==2&&parseFloat(y)%4!=0){dateLimit-=3;}if(!isNaN(parseFloat(d))&&parseFloat(d)>=1&&parseFloat(d)<=dateLimit){return true;}}}return false;};String.prototype.validateYMD=function(){var s=this.trim();var reTest=/^[0-9]{4,4}[\-\/\.][01]{0,1}[0-9][\/\-\.][0123]{0,1}[0-9]$/;if(!reTest.test(s)){return false;}var chr=s.substr(s.search(/[\/\-\.]/),1);switch(chr){case".":if((/[\-\/]/).test(s)){return false;}break;case"-":if((/[\.\/]/).test(s)){return false;}break;case"/":if((/[\-\.]/).test(s)){return false;}break;}var y=s.substring(0,s.indexOf(chr));if(!isNaN(parseFloat(y))&&parseFloat(y)>0){var m=s.substring(s.indexOf(chr)+1,s.lastIndexOf(chr));if(!isNaN(parseFloat(m))&&parseFloat(m)>=1&&parseFloat(m)<=12){var d=s.substr(s.lastIndexOf(chr)+1);var dateLimit=31;if(parseFloat(m)==4||parseFloat(m)==6||parseFloat(m)==9||parseFloat(m)==11){dateLimit--;}if(parseFloat(m)==2&&parseFloat(y)%4==0){dateLimit-=2;}if(parseFloat(m)==2&&parseFloat(y)%4!=0){dateLimit-=3;}if(!isNaN(parseFloat(d))&&parseFloat(d)>=1&&parseFloat(d)<=dateLimit){return true;}}}return false;};String.prototype.validateTime=function(){var chr=":";var s=this.trim();var bchr=" ";if(s.indexOf(chr)==s.lastIndexOf(chr)){s+=":00";}if(s.lastIndexOf(chr)==s.length-1){s+="00";}var reTest=/^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;if(!reTest.test(s)){return false;}var h=s.substr(0,s.indexOf(chr));if(!isNaN(parseFloat(h))&&parseFloat(h)>=0&&parseFloat(h)<=12){var m=s.substr(s.indexOf(chr)+1,2);if(!isNaN(parseFloat(m))&&parseFloat(m)>=0&&parseFloat(m)<=59){var n=s.substr(s.lastIndexOf(chr)+1);if(!isNaN(parseFloat(n))&&parseFloat(n)>=0&&parseFloat(n)<=59){return true;}}}var bchr=s.substr(s.lastIndexOf(bchr)+1);if(bchr=="AM"||bchr=="PM"){return true;}return false;};String.prototype.removeNewline=function(txtarea){var txtarea=document.getElementById(txtarea);var conValue=txtarea.value;while(conValue.indexOf((document.all?"\r":"")+"\n")>-1){conValue=conValue.replace((document.all?"\r":"")+"\n","<br/>");}return conValue;};String.prototype.insertNewline=function(txtarea){var txtarea=document.getElementById(txtarea);var conValue=txtarea.value;while(conValue.indexOf("<br/>")>-1){conValue=conValue.replace("<br/>",(document.all?"\r":"")+"\n");}while(conValue.indexOf("&lt;br/&gt;")>-1){conValue=conValue.replace("&lt;br/&gt;",(document.all?"\r":"")+"\n");}return conValue;};String.prototype.hideNewline=function(txtarea){var conValue=txtarea;while(conValue.indexOf("<br/>")>-1){conValue=conValue.replace("<br/>"," ");}while(conValue.indexOf("&lt;br/&gt;")>-1){conValue=conValue.replace("&lt;br/&gt;"," ");}return conValue;};function isSessionExpired(content){var expired=false;if(content.indexOf("Session has been expired")>0){expired=true;}if(expired){window.location.href="jsp/common/sessionexpiry.jsp";return true;}return false;}var blk=null;function blockInput(){loadImg=document.getElementById("divLoader");if(!loadImg){loadImg=window.parent.document.getElementById("divLoader");}loadImg.style.display="block";}function removeInputBlock(){loadImg=document.getElementById("divLoader");if(!loadImg){loadImg=window.parent.document.getElementById("divLoader");}loadImg.style.display="none";}function validateEmail(strValue){var objRegExp=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/;return objRegExp.test(strValue);}function validateUSPhone(strValue){var objRegExp=/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;return objRegExp.test(strValue);}function validateNumeric(strValue){var objRegExp=/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;return objRegExp.test(strValue);}function validateInteger(strValue){var ValidChars="0123456789";var IsNumber=true;var Char;for(i=0;i<strValue.length&&IsNumber==true;i++){Char=strValue.charAt(i);if(ValidChars.indexOf(Char)==-1){IsNumber=false;}}return IsNumber;}function validateNotEmpty(strValue){var strTemp=strValue;strTemp=trimAll(strTemp);var tempNull=strTemp.toLowerCase();if(strTemp.length>0&&tempNull!="null"){return true;}return false;}function validateUSZip(strValue){var objRegExp=/(^\d{5}$)|(^\d{5}-\d{4}$)/;return objRegExp.test(strValue);}function validateUSDate(strValue){var objRegExp=/^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/;if(!objRegExp.test(strValue)){return false;}else{var strSeparator=strValue.substring(4,5);var arrayDate=strValue.split(strSeparator);var arrayLookup={"01":31,"03":31,"04":30,"05":31,"06":30,"07":31,"08":31,"09":30,"10":31,"11":30,"12":31};var intDay=parseInt(arrayDate[2]);var intMonth=parseInt(arrayDate[1]);if(intDay<=10&&intMonth<=12){return true;}if(arrayLookup[arrayDate[1]]!=null){if(intDay<=arrayLookup[arrayDate[1]]&&intDay!=0){return true;}}if(intMonth==2){var intYear=parseInt(arrayDate[0]);if(((intYear%4==0&&intDay<=29)||(intYear%4!=0&&intDay<=28))&&intDay!=0){return true;}}}return false;}function validateValue(strValue,strMatchPattern){var objRegExp=new RegExp(strMatchPattern);return objRegExp.test(strValue);}function rightTrim(strValue){var objRegExp=/^([\w\W]*)(\b\s*)$/;if(objRegExp.test(strValue)){strValue=strValue.replace(objRegExp,"$1");}return strValue;}function leftTrim(strValue){var objRegExp=/^(\s*)(\b[\w\W]*)$/;if(objRegExp.test(strValue)){strValue=strValue.replace(objRegExp,"$2");}return strValue;}function trimAll(strValue){var objRegExp=/^(\s*)$/;if(objRegExp.test(strValue)){strValue=strValue.replace(objRegExp,"");if(strValue.length==0){return strValue;}}objRegExp=/^(\s*)([\W\w]*)(\b\s*$)/;if(objRegExp.test(strValue)){strValue=strValue.replace(objRegExp,"$2");}return strValue;}function removeCurrency(strValue){var objRegExp=/\(/;var strMinus="";if(objRegExp.test(strValue)){strMinus="-";}objRegExp=/\)|\(|[,]/g;strValue=strValue.replace(objRegExp,"");if(strValue.indexOf("$")>=0){strValue=strValue.substring(1,strValue.length);}return strMinus+strValue;}function addCurrency(strValue){var objRegExp=/-?[0-9]+\.[0-9]{2}$/;if(objRegExp.test(strValue)){objRegExp.compile("^-");strValue=addCommas(strValue);if(objRegExp.test(strValue)){strValue="("+strValue.replace(objRegExp,"")+")";}return"$"+strValue;}else{return strValue;}}function removeCommas(strValue){var objRegExp=/,/g;return strValue.replace(objRegExp,"");}function addCommas(strValue){var objRegExp=new RegExp("(-?[0-9]+)([0-9]{3})");while(objRegExp.test(strValue)){strValue=strValue.replace(objRegExp,"$1,$2");}return strValue;}function removeCharacters(strValue,strMatchPattern){var objRegExp=new RegExp(strMatchPattern,"gi");return strValue.replace(objRegExp,"");}function validateChar(strValue){var mikExp=/[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\.\,\;\'\"\:\[0-9]|]/;return mikExp.test(strValue);}function jumpToNextTxtObj(txtObj,oEvent){var evt=(oEvent)?oEvent:window.event;if(evt.keyCode==8&&(""+txtObj.value).length<1){var obj=getPreviousSibling(txtObj);if(obj!=null){obj.focus();obj.select();}return true;}if(evt.keyCode<=48||evt.keyCode>=57){return true;}if(txtObj.value.length==txtObj.maxLength){var obj=getNextSibling(txtObj);if(obj!=null&&obj.tagName.toLowerCase()=="input"){obj.focus();obj.select();}}}function getNextSibling(obj){if(!obj.nextSibling){return null;}if(obj.nextSibling.nodeName=="#text"){return obj.nextSibling.nextSibling;}else{return obj.nextSibling;}}function getPreviousSibling(obj){if(!obj.previousSibling){return null;}if(obj.previousSibling.nodeName=="#text"){return obj.previousSibling.previousSibling;}else{return obj.previousSibling;}}function allowAllSpaces(obj){if(obj!=null){obj=obj.replace(/\ /gi,"&nbsp;");}return obj;}function checkKeyPressEvent(evt){if(!evt){evt=event;}if(document.all){if(evt.keyCode==13){return true;}else{if(!(evt.keyCode>=32&&evt.keyCode<=126)&&evt.keyCode!=8&&evt.keyCode!=0){if(evt.preventDefault){evt.preventDefault();}if(evt.stopPropagation){evt.stopPropagation();}evt.cancelBubble=true;evt.returnValue=false;return false;}}}else{if(!(evt.charCode>=32&&evt.charCode<=126)&&evt.charCode!=8&&evt.charCode!=0){if(evt.preventDefault){evt.preventDefault();}if(evt.stopPropagation){evt.stopPropagation();}evt.cancelBubble=true;evt.returnValue=false;return false;}}return true;}function hasAccessPermission(content){var expired=false;var message=content.getResponseHeader("MESSAGE");if(message&&message.indexOf("authorized ")>0){expired=true;}if(expired){alert("You are not authorized to access this resource.");return true;}return false;}function parseDate(date){var dt=date.split(" ")[0];var tm=date.split(" ")[1];var ampm=date.split(" ")[2];var inputTime=new Date();inputTime.setYear(dt.split("-")[0]);inputTime.setMonth(dt.split("-")[1]-1);inputTime.setDate(dt.split("-")[2]);if(ampm=="PM"){hours=12+parseFloat(tm.split(":")[0]);}else{hours=tm.split(":")[0];}inputTime.setHours(hours);inputTime.setMinutes(tm.split(":")[1]);inputTime.setSeconds(tm.split(":")[2]);return inputTime;}function TrimString(sInString){sInString=sInString.replace(/^\s+/g,"");return sInString.replace(/\s+$/g,"");}function isValidWord(list){if(list.length>0){var val=new Array();var falseCount=0;var failedFileds="";val=list.split(",");for(var i=0;i<val.length;i++){var word=document.getElementById(val[i]).value;if(word!=""){var re=new RegExp(/^[\u0000-\u00FF]+$/);if(!word.match(re)){falseCount++;failedFileds+=val[i]+",";}}}if(falseCount>0){document.getElementById("failedFields").value=failedFileds;return false;}else{return true;}}else{return true;}}
