String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); }; function fillDiv(divName, includePage) { toframe("/template/divFiller.jsp?divName=" + divName + "&page=" + urlencode(includePage)); } function toframe(url) { var iframe = document.getElementById('remoteFrame'); // our IFrame object iframe.src = url; } function confirmAutoMerge() { if (confirm("Are you sure you want to automatically merge contact records? This " + "option will permanently merge all records that have been marked as duplicates " + "of each other. Make sure you have run the Dup Checker first by clicking the " + "link above.")) { window.location = "/Thread/quickStartAutoMerger.jsp"; } } function optedOut(contactId) { alert("This person has opted out of all email campaigns. You will no longer be able to send emails to them"); } function openFile(id){ if(id=="0" || id==""){ alert("You must select a file to preview!"); return false; } else { window.location = "/Download?Id=" + id; } } function openFileSelect(what){ var id = what.options[what.options.selectedIndex].value; openFile(id); } function openTask(str, stay){ if(!stay) { openAdminHW("/Task/manageTask.jsp" + str, 550, 575); } else { window.location = "/Task/manageTask.jsp" + str; } } function openApptmnt(str, stay){ if(!stay) { openAdminHW("/Appointment/manageAppointment.jsp" + str, 550, 575); } else { window.location = "/Appointment/manageAppointment.jsp" + str; } } function openHistory(view, id){ openAdminHW("/ContactAction/manageContactAction.jsp?view=" + view + "&ID=" + id, 550, 575); } function openAppointment(view, id, addtl){ var idStr = (id>0) ? "&ID=" + id : ""; openAdminHW("/Appointment/manageAppointment.jsp?view=" + view + idStr + addtl, 550, 575); } function openLog(str){ openAdminTall("/HourLog/popHourLog.jsp" + str); } function openCC(str){ openAdminHW("/CreditCard/popCreditCard.jsp" + str, 550, 575); } function openSmall(str){ var small = open(str,"small","width=20,height=20"); window.focus(); } function sendBlankEmail(address, contactId) { var email = openAdminHW("/Mail/filter/blank.jsp?to=" + address + "&contactId=" + contactId, 575, 800); } function sendBlankEmailFromField(field, contactId, optedOut){ if(optedOut) { alert("The contact you are sending to has opted out of marketing. You will be able to send individual " + "emails, but batch and " + "campaign emails will no longer be delivered."); } var val = document.getElementById(field).value; sendBlankEmail(val, contactId); } function popLink(str){ if(str!=''){ if(str.indexOf('http')==-1){ var local = open("http://" + str,"popup"); }else{ var local = open(str,"popup"); } } } function confirmIt(str){ return confirm(str); } function changeO(id, what) { if(document.all) { document.all[id].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + what + ");"; } else { del(id).style.MozOpacity=(what / 100); } } function getKeyCode(e) { var bd = navigator.appName; var key; if(bd=='Netscape'){ key=e.which; } else { key=event.keyCode; } return key; } function urlencode(strText) { return escape(strText).replace(/\+/g, '%2B').replace(/\//g, '%2F').replace(/\"/g,'%22').replace(/\'/g, '%27'); } function pressDate(e,what){ var key = getKeyCode(e); var letter = String.fromCharCode(key); if(letter=='i'){ var help = "Quick Date Keys\n\n" + "t: Set date to today\n" + "= : Add one day\n" + "+ : Subtract one day\n" + "w : Add one week\n" + "k : Subtract one week\n" + "y : Add one year\n" + "e : Subtract one year\n" + "m : Add one month\n" + "h : Subtract one month\n" + "q : Clear the date\n" + "f : Go to the first day of the month\n" + "l : Go to the last day of the month\n" + "z : Go to Monday of the week selected\n" + "x : Go to Tuesday of the week selected\n" + "c : Go to Wednesday of the week selected\n" + "v : Go to Thursday of the week selected\n" + "b : Go to Friday of the week selected\n"; alert(help); return false; } if(letter=='q'){ what.value = ""; return false; } var skip = /[a-z+=]/; var isSkip = skip.test(letter); var isNum = /[\/\-0-9]/; if(isNum.test(letter) || key == 8 || key==0) return true; else if(!isSkip || (what.value=='' && letter != 't')) return false; else{ var dt = new Date() var dateArray = what.value.split("-"); var size = dateArray.length; if(size==1) { dt = new Date(); } if(size==2) { if (false) { dt = new Date(2003,parseInt(dateArray[1],10)-1,parseInt(dateArray[0],10)); } else { dt = new Date(2003,parseInt(dateArray[0],10)-1,parseInt(dateArray[1],10)); } } else { if (false) { dt = new Date(parseInt(dateArray[2],10),parseInt(dateArray[1],10)-1,parseInt(dateArray[0],10)); } else { dt = new Date(parseInt(dateArray[2],10),parseInt(dateArray[0],10)-1,parseInt(dateArray[1],10)); } } if(dt=="Invalid Date") { dt = new Date(); } switch(letter){ case "f" : what.value = formatDate(dateAdd("day",-dt.getUTCDate()+1,dt)); return false; case "l" : what.value = formatDate(dateAdd("day",-dt.getUTCDate(),dateAdd("month",1,dt))); return false; case "t" : dt = new Date(); what.value = formatDate(dt); return false; case "+" : what.value = formatDate(dateAdd("day",-1,dt)); return false; case "=" : what.value = formatDate(dateAdd("day",1,dt)); return false; case "y" : what.value = formatDate(dateAdd("year",1,dt)); return false; case "e" : what.value = formatDate(dateAdd("year",-1,dt)); return false; case "m" : what.value = formatDate(dateAdd("month",1,dt)); return false; case "h" : what.value = formatDate(dateAdd("month",-1,dt)); return false; case "w" : what.value = formatDate(dateAdd("day",7,dt)); return false; case "k" : what.value = formatDate(dateAdd("day",-7,dt)); return false; case "z" : what.value = formatDate(dateAdd("day",-dt.getDay()+1,dt)); return false; case "x" : what.value = formatDate(dateAdd("day",-dt.getDay()+2,dt)); return false; case "c" : what.value = formatDate(dateAdd("day",-dt.getDay()+3,dt)); return false; case "v" : what.value = formatDate(dateAdd("day",-dt.getDay()+4,dt)); return false; case "b" : what.value = formatDate(dateAdd("day",-dt.getDay()+5,dt)); return false; default: return false; break; } return false; } } function dateAdd(type,num,dt){ if(dt=='' || dt == "Invalid Date") dt = new Date(); if(type=='day'){ var isit = dt.getUTCDate(); var foo = dt; dt.setUTCDate(dt.getUTCDate() + num); var now = dt.getUTCDate(); //alert(isit + ":" + now + ":" + foo); } if(type=='month'){ dt.setUTCMonth(dt.getUTCMonth() + num); } if(type=='year'){ dt.setUTCFullYear(dt.getUTCFullYear() + num); } return dt; } function formatDate(dt){ var month = dt.getMonth() + 1; month = (month<10) ? "0" + month : month; var day = (dt.getDate()<10) ? "0" + dt.getDate() : dt.getDate(); if(isNaN(month) || isNaN(day) || isNaN(dt.getFullYear())) { return formatDate(new Date()); } if (false) { return day + "-" + month + "-" + dt.getFullYear(); } else { return month + "-" + day + "-" + dt.getFullYear(); } } function selval(selEl) { selVal(selEl); } function selVal(selEl){ if(typeof selEl == "string") { selEl = del(selEl); } return selEl.options[selEl.options.selectedIndex].value; } function formatDollar(thisone){ if(thisone.value=='') return ""; var prefix="$" return prefix + formatDouble(thisone); } function formatDoubleEl(el){ return formatDouble(el.value); } function formatDouble(thisone){ var prefix = ""; var wd if (thisone.charAt(0)=="$") return wd="w" var tempnum=thisone for (i=0; i < tempnum.length; i++){ if (tempnum.charAt(i)=="."){ wd="d" break } } if (wd=="w") return prefix+tempnum+".00" else{ if (tempnum.charAt(tempnum.length-2)=="."){ return prefix+tempnum+"0" }else{ tempnum=Math.round(tempnum*100)/100 return prefix+tempnum } } } function hideSelects(divName){ var theDiv = document.getElementById(divName); if(theDiv){ hideElementDiv("select", theDiv); } } function showSelects(){ showElementDiv("select"); } function hideElementDiv(elmID, overDiv) { if(ie) { for( i = 0; i < document.getElementsByTagName(elmID).length; i++ ){ obj = document.getElementsByTagName(elmID)[i]; if(!obj || !obj.offsetParent) { continue; } // Find the element's offsetTop and offsetLeft relative to the BODY tag. objLeft = obj.offsetLeft; objTop = obj.offsetTop; objParent = obj.offsetParent; while( objParent.tagName.toUpperCase() != "BODY" ) { objLeft += objParent.offsetLeft; objTop += objParent.offsetTop; objParent = objParent.offsetParent; } objHeight = obj.offsetHeight; objWidth = obj.offsetWidth; if((overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft ); else if((overDiv.offsetTop + overDiv.offsetHeight) <= objTop ); else if(overDiv.offsetTop >= (objTop + objHeight)); else if(overDiv.offsetLeft >= (objLeft + objWidth)); else if(getDiv(obj).name!=overDiv.name) { obj.style.visibility = "hidden"; } } } } function getDiv(node) { var n=node; while(n=n.parentNode){ if((n.tagName) && n.tagName.toLowerCase()=="div") return n; } //alert("found none"); } function addEmail(el, returnCode){ addEmail(el, returnCode, ""); } function addEmail(el, returnCode, extras){ var selVal = el.options[el.options.selectedIndex].value; openAdminHW("/SystemEmail/manageSystemEmail.jsp?view=add&returnEl=" + el.name + "&returnVal=" + selVal + "&returnCode=" + returnCode + extras, 700, 900); } function editEmail(el, returnCode) { editEmail(el,returnCode, ""); } function editEmail(el, returnCode, extras) { if(el.options.selectedIndex>0) { var selVal = el.options[el.options.selectedIndex].value; openAdminHW("/SystemEmail/manageSystemEmail.jsp?view=edit&ID=" + selVal + "&returnEl=" + el.name + "&returnVal=" + selVal + "&returnCode=" + returnCode + extras, 700, 900); } else { alert("You must select an email to edit!"); } } function getMasterWindow(){ var tmp = window; while(tmp!=null){ if(tmp.opener){ tmp = tmp.opener; } else { return tmp; } } } function openMaster(url){ getMasterWindow().location=url; } function editContactTemplate(elName){ var el = document.getElementById(elName); if(el.options.selectedIndex>0){ openAdminHW('/ContactTemplate/manageContactTemplate.jsp?return=' + elName + '&view=edit&ID=' + selVal(el), 750, 1150); } else { alert("You must select a template to edit first"); } } function editEmailTemplate(elName){ var el = document.getElementById(elName); if(el.options.selectedIndex>0){ openAdminHW('/SystemEmail/manageTemplate.jsp?return=' + elName + '&view=edit&ID=' + selVal(el), 600, 800); } else { alert("You must select a template to edit first"); } } function addContactTemplate(elName, context){ if(context=="") { context = "Contact"; } if(name != "") { name = "&ContactTemplate0TemplateName=" + name; } openAdminHW('/ContactTemplate/manageContactTemplate.jsp?return=' + elName + name + '&view=add&ContactTemplate0ActionContext=' + context, 750, 1150); } function addEmailTemplate(elName, context){ openAdminHW('/SystemEmail/manageTemplate.jsp?return=' + elName + '&view=add', 600, 800); } function delFromSel(elName, id) { var el = document.getElementById(elName); var _options = el.options; for(i=0; i<_options.length; i++){ var currOptionValue = _options[i].value; if(currOptionValue == id) { _options[i] = null; } } } function addToSel(elName, id, text) { var el = document.getElementById(elName); var _options = el.options; for(i=0; i<_options.length; i++){ var _c = _options[i].value; if(_c == id) { _options[i].text = text; return; } } el.options[el.options.length] = new Option(text, id); el.options.selectedIndex = el.options.length - 1; } function _edit(object, elName, width, height) { try { var el = document.getElementById(elName); if(el) { if(el.options.selectedIndex == 0) { alert("You must have an item selected to edit it."); return; } var id = el.options[el.options.selectedIndex].value; openAdminHW("/" + object + "/manage" + object + ".jsp?view=edit&ID=" + id, height, width); return; } }catch(error){ alert(error.message); } } function arycontains(ary, contains) { for(i=0; i addme) { break; } } data.push(addme); data.sort(); } this.contains = new function(which) { for(i=0;i < data.length; i++) { if(data[i]==which) return true; if(data[i] > which) return false; } return false; } this.remove = new function(which) { var tmp = new Array(); for(i=0; i < data.length; i++) { if(data[i] != which) tmp.push(data[i]); } this.data = tmp; } } function reloadCampaigns(id) { document.getElementById("CampaignValue").value = id; remote('campaign-fill', 'CampaignField,CampaignValue'); }