function validateEmailAddress(a,c){var b=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;if(b.test(a)==false){c.select();return false}return true}function getSelectedText(){var a="";if(window.getSelection){a=window.getSelection()}else{if(document.getSelection){a=document.getSelection()}else{if(document.selection!=null){a=document.selection.createRange().text}}}if(a==""){if(document.selection!=null){var b=document.selection;if(b.getSelected!=null){a=b.getSelected()}}}return a.toString()}function isChkboxSelected(b){var c=window.document.forms[b];var d=false;for(i=0;i<c.elements.length;i++){var a=c.elements[i];if(a.type=="checkbox"){if(a.checked==true){d=true}}}return d}function resetValues(b){var c=window.document.forms[b];for(i=0;i<c.elements.length;i++){var a=c.elements[i];if(a.type=="checkbox"){a.checked=false;a.disabled=false}else{if(a.type=="text"||a.type=="textarea"){a.value=""}else{if(a.type=="select-one"){a.value="00"}else{if(a.type=="radio"){if(a.value=="exactwords"){a.checked=true}}}}}}}function advancedSearch_is_modified(g){var e=window.document.forms[g];var d,c,f,a;if(g=="advanceSearchForm"){for(i=0;i<e.elements.length;i++){var b=e.elements[i];if(b.type=="checkbox"){if(b.checked!=b.defaultChecked){return true;break}}else{if(b.type=="text"){if(b.value!=b.defaultValue){return true;break}}else{if(b.type=="textarea"){if(b.value!=b.defaultValue){return true;break}}else{if(b.type=="select-one"){a=0,f=false;while(c=b.options[a++]){if(c.defaultSelected){f=true}}a=f?0:1;while(c=b.options[a++]){if(c.selected!=c.defaultSelected){return true}}}else{if(b.type=="radio"){if(b.checked!=b.defaultChecked){return true;break}}}}}}}return false}}function disablePlacesChkbox(d,b,a,g){var e=window.document.forms[d];var f=document.getElementById(g);var h=f.checked;for(i=0;i<e.elements.length;i++){var c=e.elements[i];if(c.type=="checkbox"&&((c.name.indexOf(b)>=0&&c.id!=g)||c.name.indexOf(a)>=0)){c.checked=false;c.disabled=f.checked}if(c.type=="checkbox"&&c.name==f.name&&c.id==g){c.checked=f.checked;c.disabled=false}}}function disableChkbox(c,a,f){var d=window.document.forms[c];var e=document.getElementById(f);var g=e.checked;for(i=0;i<d.elements.length;i++){var b=d.elements[i];if(b.type=="checkbox"&&b.name.indexOf(a)>=0&&b.id!=f){b.checked=false;b.disabled=e.checked}if(b.type=="checkbox"&&b.name==e.name&&b.id==f){b.checked=e.checked;b.disabled=false}}}function toggleCountyCheckboxes(b,e,g){var c=window.document.forms[b];var d;var f=true;for(i=0;i<c.elements.length;i++){var a=c.elements[i];if(a.type=="checkbox"&&a.name.indexOf(g)>=0&&a.checked==false){f=false}if(a.type=="checkbox"&&a.name=="advPlace"&&a.value=="Ireland"){d=a}}d.checked=f}function toggleCheckboxes(b,f,e){var c=window.document.forms[b];var d=document.getElementById(e);for(i=0;i<c.elements.length;i++){var a=c.elements[i];if(a.type=="checkbox"&&a.name.indexOf(f)>=0){a.checked=d.checked}if(a.type=="checkbox"&&a.name=="county"){a.checked=d.checked}}}function checkLoading(formName){try{var origin=eval("opener.document."+formName);if(origin.document.readyState=="loading"){setTimeout("checkLoading('"+formName+"')",2000)}else{document.getElementsByName("cmd")[0].disabled=false}}catch(e){setTimeout("checkLoading('"+formName+"')",2000)}}document.onkeydown=function(){window.status=event.keyCode;var a=0;if(event.keyCode==37){if(event.altKey==true){history.go(-1);window.location.reload(true);return false}}if(event.keyCode==39){if(event.altKey==true){history.go(+1);window.location.reload(true);return false}}};function MM_openBrWindow(c,a,b){window.open(c,a,b)}function submitForm(formName,cmd){var form;try{if(formName!=null&&cmd!=null){form=eval("document."+formName);form.cmd.value=cmd;form.submit()}}catch(e){alert("Error in Form name:"+formName)}}function submitFormValidate(formName,cmd){var form;try{if(formName!=null&&cmd!=null){form=eval("document."+formName);form.cmd.value=cmd;form.fakeSubmitButton.click()}}catch(e){alert("Error in Form name:"+formName)}}function submitFormAndRedirectValidate(formName,cmd,urlForward){var form;try{if(formName!=null&&cmd!=null){form=eval("document."+formName);form.cmd.value=cmd;form.urlForward.value=urlForward;document.forms[formName].fakeSubmitButton.click()}}catch(e){alert(e);alert("Error in Form name:"+formName)}}function submitFormAndRedirect(formName,cmd,urlForward){var form;try{if(formName!=null&&cmd!=null){form=eval("document."+formName);form.cmd.value=cmd;form.urlForward.value=urlForward;form.submit()}}catch(e){alert("Error in Form name:"+formName)}}function deleteConfirm(url){var x=confirm("Are you sure you want to delete this?");if(x){eval("parent.location='"+url+"'")}}function duplicateConfirm(url){var x=confirm("Are you sure you want to duplicate this?");if(x){eval("parent.location='"+url+"'")}}function printNewWindow(formName,checkBox,url){var field=eval("document."+formName+"."+checkBox);var item="itemsToBePrinted=";var param="?";if(field!=null&&field.length>0){for(i=0;i<field.length;i++){if(field[i].checked==true){param+=item+field[i].value+"&"}}url+=param;window.open(url,"print","width=800,height=600,toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,left=0,top=100,screenX=0,screenY=100")}else{alert("No print items selected.")}}function disableFields(oForm){oForm=eval("document."+oForm);var el,opt,hasDefault,i=0,j;while(el=oForm.elements[i++]){switch(el.type){case"text":case"textarea":el.readOnly=true;el.style.backgroundColor="#ccc";break;case"radio":case"select-one":case"select-multiple":case"button":if(el.name!="status"&&el.name!="campaign_id"){el.disabled=true}break}}}function form_is_modified(f){f=document.forms[0];var d,c,e,b=0,a;while(d=f.elements[b++]){switch(d.type){case"text":case"textarea":if(d.value!=d.defaultValue){return true}break;case"checkbox":case"radio":if(d.checked!=d.defaultChecked){return true}break;case"select-one":case"select-multiple":if(d.id!="startMonth"&&d.id!="startYear"&&d.id!="finishMonth"&&d.id!="finishYear"){a=0,e=false;while(c=d.options[a++]){if(c.defaultSelected){e=true}}a=e?0:1;while(c=d.options[a++]){if(c.selected!=c.defaultSelected){return true}}}break}}return false}function form_is_modified_for_salesforecast(f){f=document.forms[0];var d,c,e,b=0,a;while(d=f.elements[b++]){switch(d.type){case"text":case"textarea":if(d.id!="currentPage"){if(removeCommas(d.value)!=removeCommas(d.defaultValue)){return true}}break;case"select-one":case"select-multiple":if(d.id!="pageSize"){a=0,e=false;while(c=d.options[a++]){if(c.defaultSelected){e=true}}a=e?0:1;while(c=d.options[a++]){if(c.selected!=c.defaultSelected){return true}}}break}}return false}function parentForm_is_modified(f){var d,c,e,b=0,a;while(d=f.elements[b++]){switch(d.type){case"text":case"textarea":if(!/^\s*$/.test(d.value)&&d.value!=d.defaultValue){return true}break;case"checkbox":case"radio":if(d.checked!=d.defaultChecked){return true}break;case"select-one":case"select-multiple":a=0,e=false;while(c=d.options[a++]){if(c.defaultSelected){e=true}}a=e?0:1;while(c=d.options[a++]){if(c.selected!=c.defaultSelected){return true}}break}}return false}function IsWholeNumber(b){var d="0123456789";var c=true;var a;for(i=0;i<b.length&&c==true;i++){a=b.charAt(i);if(d.indexOf(a)==-1){c=false}}return c}function IsNumeric(b){var d="-0123456789.";var c=true;var a;for(i=0;i<b.length&&c==true;i++){a=b.charAt(i);if(d.indexOf(a)==-1){c=false}}return}function isNumber(b){var c=/^[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?$/;var a=b.match(c);return a}function IsNumeric2(b){var d="0123456789";var c=true;var a;for(i=0;i<b.length&&c==true;i++){a=b.charAt(i);if(d.indexOf(a)==-1){c=false}}return c}function saveDataAndPagination(c){var d=document.forms[c];var f=d.action;var b=d.originalPageSize[0].value;var e=d.originalCurrentPage[0].value;var g=d.recordCount[0].value;var a=Math.ceil(g/b);if(e<=a&&e!=0){if(form_is_modified_for_salesforecast(c)){if(f.indexOf("?")>0){d.action=f+"&_currentPage="+e+"&_pageSize="+b+"&cmd=save"}else{d.action=f+"?_currentPage="+e+"&_pageSize="+b+"&cmd=save"}}else{if(f.indexOf("?")>0){d.action=f+"&_currentPage="+e+"&_pageSize="+b}else{d.action=f+"?_currentPage="+e+"&_pageSize="+b}}d.submit()}else{alert("The specified page number does not exist.")}}function removeCommas(a){if(a.indexOf(",")>-1){while(a.indexOf(",")>-1){a=a.replace(",","")}}return a}function checkParamValuesIfNumbers(param){var initMsg="One of the values is not a valid number.";var isValidNumber=true;var isValidSPType=true;var strChkIds=eval('document.getElementsByTagName("input");');var strChkIds2=eval('document.getElementsByTagName("select");');var nameList=param.split(",");for(i=0;i<strChkIds.length;i++){if(strChkIds[i].getAttribute("type").toLowerCase()=="text"){for(x=0;x<nameList.length;x++){if(strChkIds[i].getAttribute("name").indexOf(nameList[x])>-1){var number=/^-?\d*(?:\.\d{0,})?$/;strChkIds[i].value=removeCommas(strChkIds[i].value);if(strChkIds[i].value.replace(/\s+/,"").length>0&&!number.test(strChkIds[i].value)){isValidNumber=false;strChkIds[i].focus()}}}}}for(i=0;i<strChkIds2.length;i++){alert(strChkIds2[i].getAttributes());if(strChkIds2[i].getAttribute("name").indexOf("current_sp_type")>-1){if(strChkIds2[i].value.length==0){isValidSPType=false}}}if(!isValidNumber){alert(initMsg)}if(!isValidSPType){alert("Please select a Price type");isValidNumber=false}return isValidNumber}function openBatchProcessWindow(formName,checkBox,url,size){var field=eval("document."+formName+"."+checkBox);var param="&parentFormName="+formName+"&";param+="&componentId=";for(i=0;i<field.length;i++){if(field[i].checked==true){if(i!=0){param+=","}param+=field[i].value}}if(url.indexOf("?")==-1){url+="?"}alert(url);url+=param;window.open(url,"batchProcess",size+"toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,left=0,top=100,screenX=0,screenY=100")}function checkParamValuesIfNumbers2(param){var initMsg="One of the values is not a valid number.";var isValidNumber=true;var strChkIds=eval('document.getElementsByTagName("input");');var nameList=param.split(",");for(i=0;i<strChkIds.length;i++){if(strChkIds[i].getAttribute("type").toLowerCase()=="text"){for(x=0;x<nameList.length;x++){if(strChkIds[i].getAttribute("name").indexOf(nameList[x])>-1){var number=/^-?\d+$/;strChkIds[i].value=strChkIds[i].value.replace(",","");if(strChkIds[i].value.replace(/\s+/,"").length>0&&!number.test(strChkIds[i].value)){isValidNumber=false;strChkIds[i].focus()}}}}}if(!isValidNumber){alert(initMsg)}return isValidNumber}function checkInt(b){var a=b.match(/^-?\d+$/);return(a!=null)}function IsEmpty(a){if(trim(a)==""){return true}else{return false}}function LTrim(b){var a=/\s*((\S+\s*)*)/;return b.replace(a,"$1")}function RTrim(b){var a=/((\s*\S+)*)\s*/;return b.replace(a,"$1")}function trim(a){return LTrim(RTrim(a))}function applyBatchProcess(popupformName,parentFormName){var parentForm=eval("window.opener.document."+parentFormName);var valueStr="";no=parentForm.elements.length;one="true";seperator=",";for(i=0;i<no;i++){if(parentForm.elements[i].type=="checkbox"&&parentForm.elements[i].name=="componentId"){if(parentForm.elements[i].checked){if(one=="false"){valueStr+=(seperator+parentForm.elements[i].value)}else{valueStr=parentForm.elements[i].value}one="false"}}}var currentForm=eval("document."+popupformName);currentForm.componentId.value=valueStr}function openAssignClearFlagWindow(formName,action,parentUrl,size){var param="&parentFormName="+formName+"&parentUrl="+parentUrl;var url="sales_forecast_assign_flag.do";if(action=="clear"){url="sales_forecast_clear_flag.do";var field=eval("document."+formName+".componentId");if(field!=null&&field.length>0){param+="&checkedComponentId=";for(i=0;i<field.length;i++){if(field[i].checked==true){if(i!=0){param+=","}param+=field[i].value}}}}if(url.indexOf("?")==-1){url+="?"}url+=param;window.open(url,"assignflag",size+"toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,left=0,top=100,screenX=0,screenY=100")}function getComponentIdsForFlags(popupformName,parentFormName){var parentForm=eval("window.opener.document."+parentFormName);var valueStr="";no=parentForm.elements.length;one="true";seperator=",";for(i=0;i<no;i++){if(parentForm.elements[i].type=="checkbox"&&parentForm.elements[i].name=="componentId"){if(parentForm.elements[i].checked){if(one=="false"){valueStr+=(seperator+parentForm.elements[i].value)}else{valueStr=parentForm.elements[i].value}one="false"}}}var currentForm=eval("document."+popupformName);currentForm.componentId.value=valueStr}function checkAllSales(){var parentCheckbox=document.getElementById("parentCheckBox");var strChkIds=eval('document.getElementsByName("componentId");');var strChkIdsLen=strChkIds.length;for(i=0;i<strChkIdsLen;i++){if(parentCheckbox.checked==true){strChkIds[i].checked=true}else{strChkIds[i].checked=false}}}function checkMeSales(){var elem;var strChkIds=eval('document.getElementsByName("componentId");');var strChkIdsLen=strChkIds.length;var node;var parentCheckbox;var ctr=0;for(i=0;i<strChkIdsLen;i++){if(strChkIds[i].checked==true){ctr++}else{parentCheckbox=document.getElementById("parentCheckBox");parentCheckbox.checked=false}}}function checkAllPromotion(){var parentCheckbox=document.getElementById("parentCheckBox");var strChkIds=eval('document.getElementsByName("campaignsToBePrinted");');var strChkIdsLen=strChkIds.length;for(i=0;i<strChkIdsLen;i++){if(parentCheckbox.checked==true){strChkIds[i].checked=true}else{strChkIds[i].checked=false}}}function checkMePromotion(){var elem;var strChkIds=eval('document.getElementsByName("campaignsToBePrinted");');var strChkIdsLen=strChkIds.length;var node;var parentCheckbox;var ctr=0;for(i=0;i<strChkIdsLen;i++){if(strChkIds[i].checked==true){ctr++}else{parentCheckbox=document.getElementById("parentCheckBox");parentCheckbox.checked=false}}if(ctr==strChkIdsLen){parentCheckbox=document.getElementById("parentCheckBox");parentCheckbox.checked=true}}function isNumberLengthValid(g,d){var b=g.split(",");var c,a;for(var f=0;f<b.length;f++){c=document.getElementsByName(b[f])[0];a=removeCommas(c.value.toString());var h=(a.indexOf("-")!=-1)?1:0;var e=(a.indexOf(".")!=-1)?a.indexOf("."):(parseFloat(a.length));if(a.substring(h,e).length>d){alert("Your input exceeded the maximum value allowed!");return false}}return true}function validateCheck(cmd){var strChkIds=eval('document.getElementsByName("componentId");');var strChkIdsLen=strChkIds.length;var isChecked=false;for(i=0;i<strChkIdsLen;i++){if(strChkIds[i].checked==true){isChecked=true}}if(isChecked==true){eval(cmd)}else{alert("No Check/s found")}}function validateCheck2(cmd){var strChkIds=eval('document.getElementsByName("componentId");');var strChkIdsLen=strChkIds.length;var isChecked=false;for(i=0;i<strChkIdsLen;i++){if(strChkIds[i].checked==true){isChecked=true}}if(isChecked==true){eval("parent.location='"+cmd+"'")}else{alert("No Check/s found")}}function verifyInput(b,a){if(!isValidNumber(removeCommas(b.value))){alert("Please enter a valid number!");b.value=oldValue;return false}else{if(!isNumberLengthValid(b.name,a)){b.value=oldValue;return false}}return true}function verifyIntegerInput(b,a){if(!checkInt(b.value)){alert("Please use integers only");b.value=oldValue;return false}else{if(!isNumberLengthValid(b.name,a)){b.value=oldValue;return false}}return true}function fetchOldValue(a){oldValue=a.value}function isValidNumber(b){var a=new String(b);var c=/^-?\d*(?:\.\d{0,})?$/;return c.test(a)&&b.length>0}function toggleLayer(c){var a,b;if(document.getElementById){a=document.getElementById(c)}else{if(document.all){a=document.all[c]}}b=a.style;if(b.display==""&&a.offsetWidth!=undefined&&a.offsetHeight!=undefined){b.display=(a.offsetWidth!=0&&a.offsetHeight!=0)?"block":"none"}b.display=(b.display==""||b.display=="block")?"none":"block"}function extractNumber(k,j,l){var n=k.value;var b="[0-9]*";if(j>0){b+="\\.?[0-9]{0,"+j+"}"}else{if(j<0){b+="\\.?[0-9]*"}}b=l?"^-?"+b:"^"+b;b=b+"$";var f=new RegExp(b);if(f.test(n)){return true}var m="[^0-9"+(j!=0?".":"")+(l?"-":"")+"]";var e=new RegExp(m,"g");n=n.replace(e,"");if(l){var h=n.length>0&&n.charAt(0)=="-";var d=/-/g;n=n.replace(d,"");if(h){n="-"+n}}if(j!=0){var c=/\./g;var a=c.exec(n);if(a!=null){var g=n.substring(a.index+a[0].length);g=g.replace(c,"");g=j>0?g.substring(0,j):g;n=n.substring(0,a.index)+"."+g}}k.value=n}function blockNonNumbers(c,g,k,f){var l;var h=false;var d;var a;if(window.event){l=g.keyCode;h=window.event.ctrlKey}else{if(g.which){l=g.which;h=g.ctrlKey}}if(isNaN(l)){return true}d=String.fromCharCode(l);if(l==8||h){return true}a=/\d/;var b=f?d=="-"&&c.value.indexOf("-")==-1:false;var j=k?d=="."&&c.value.indexOf(".")==-1:false;return b||j||a.test(d)}function getIndex(a){if(a.selectedIndex==0){alert("Please select a price type.");return false}else{return true}}String.prototype.endsWith=function(a){return(this.match(a+"$")==a)};function isWholeNumberWithLetterC(b){var e="0123456789";var d="0123456789cC";var c=true;var a;for(i=0;i<b.length&&c==true;i++){a=b.charAt(i);if(i<(b.length-1)){if(e.indexOf(a)==-1){c=false}}else{if(d.indexOf(a)==-1){c=false}}}return c}function IsValidYear(a){var b=false;a=trim(a);if(a.endsWith("c")||a.endsWith("C")){if(a.length==2||a.length==3){b=isWholeNumberWithLetterC(a)}}else{if(a.length<5){b=IsWholeNumber(a)}}return b}function doShowBodyContent(a){document.getElementById("pre_loader").style.display=(a=="1"?"none":"block")};function imposeMaxLength(Object,MaxLen){return(Object.value.length<=MaxLen)}
