function submitForm(form) {if (form.fireEvent) {if(form.fireEvent("onsubmit")) {form.submit();
}
} else if(form.onsubmit) {if(form.onsubmit(form)) {form.submit();
}
}
}
function bookMarkSite(url,name) {if ($.browser.sie) { // IE
window.external.AddFavorite(url, name);
} else if ($.browser.mozilla) {window.sidebar.addPanel(name,url,"");
} else if ($.browser.opera || $.browser.chrome || $.browser.webkit) {alert("Please press Ctrl+D to bookmark this page.");
} else {PopupWindow('bookmarkSite.sdi','BookmarkSite','400','300','no');
}
}
function checkHTML(field_id) {var field = document.getElementById(field_id);
if (field == null) return true;var html = field.value.toString();
if (html.length == 0) return true;var cbox_name = field.name + "_saveanyway";var cbox = document.getElementById(cbox_name);
if (cbox != null && cbox.checked) return true;doWaitedXmlHttpRequest('checkHTMLfield.sdi', null, "POST", 'div_id=' + field.name + '_invalid_tags' + '&html=' + encodeURIComponent(html));
var section = document.getElementById(field.name + '_invalid_tags');
if (section == null) {return true;}
var tags = req.responseXML.documentElement.getElementsByTagName("invalid_tags");
if (tags.length == 0 || tags[0].firstChild == null) {section.innerHTML = '';return true;}
var invalid_tags=tags[0].firstChild.data;help_link = "Click on help to learn why this failed and how to write acceptable HTML.";section.innerHTML = '
';return false;}
function setCellValue(id, value) {var mycel = document.getElementById(id);
if (mycel == null) {alert("setCellValue called with invalid id=" + id);
return;}
while(mycel.childNodes.length)
mycel.removeChild(mycel.childNodes[0]);
mycel.appendChild(document.createTextNode(value));
}
function getCellValue(id) {var mycel = document.getElementById(id);
if (mycel == null) {alert("getCellValue called with invalid id=" + id);
return "";}
return mycel.firstChild.nodeValue;}
function addTableRow(tbl, tbl_extra, row_contents) {addTableRowAt(tbl, tbl_extra, row_contents, -1);
}
function addTableRowAt(tbl, tbl_extra, row_contents, insert_at_idx) {var row_id="";var tr_end_idx = row_contents.indexOf(">");
var id_idx = row_contents.substring(0,tr_end_idx+1).indexOf("id=");
if (id_idx > 0) {row_id = row_contents.substring(0,tr_end_idx+1).substring(id_idx+3);
var delim=row_id.substring(0,1);
row_id=row_id.substring(1);
row_id=row_id.substring(0,row_id.indexOf(delim));
}
if(tbl.outerHTML && insert_at_idx == -1 && !($.browser.chrome || $.browser.webkit)) {if($(tbl).children(':first').is('tbody')){$(tbl).children(':first').append(row_contents);
}else{$(tbl).append(row_contents);
}
} else {row_contents = row_contents.substring(tr_end_idx + 1);
var idx=row_contents.lastIndexOf("");
row_contents = row_contents.substring(0, idx);
var new_row=tbl.insertRow(insert_at_idx);
new_row.id=row_id;try {new_row.innerHTML=row_contents;} catch (err) {while (row_contents.indexOf("= 0) {var startidx=row_contents.indexOf(">");
var endidx=row_contents.indexOf(" | ");
var new_td=new_row.insertCell();
var cell_attribs=row_contents.substring(row_contents.indexOf("=0) {cell_attribs=cell_attribs.substring(cell_attribs.indexOf("colspan=")+8);
idx=cell_attribs.indexOf(" ");
if (idx<0) idx=cell_attribs.indexOf(">");
if (idx >= 0) {new_td.colSpan=cell_attribs.substring(0,idx).replace(/['"]/g,''); // strip off quotes
} else {new_td.colSpan=cell_attribs.replace(/['"]/g,''); // strip off quotes
}
}
if (cell_attribs.indexOf("align=")>=0) {cell_attribs=cell_attribs.substring(cell_attribs.indexOf("align=")+6);
idx=cell_attribs.indexOf(" ");
if (idx<0) idx=cell_attribs.indexOf(">");
if (idx >= 0) {new_td.setAttribute("align", cell_attribs.substring(0,idx).replace(/['"]/g,''));
} else {new_td.setAttribute("align", cell_attribs.replace(/['"]/g,''));
}
}
var cell_contents=row_contents.substring(startidx+1, endidx);
new_td.innerHTML=cell_contents;row_contents = row_contents.substring(endidx+5);
}
}
}
if (row_id.length > 0 && $("#"+row_id).length > 0) {initDatepicker($("#"+row_id).get(0));
} else {initDatepicker(tbl);
}
parentResizeInner();
}
function fullyQualifiedURL(url) {if (!url) return "";if (url.indexOf('http')>=0) return url;if (url.indexOf('/')!=0) url = '/' + url;return location.protocol + "//" + location.host + url;}
function initDatepicker(ele) {var $elements;if (ele) {$elements = $(ele).find("input.datepicker, input.datepicker_if_able");
} else {$elements = $("input.datepicker, input.datepicker_if_able");
}
if ($elements.length == 0) return;$elements.datepicker({showOn: "button",
buttonImage: fullyQualifiedURL("/cityofpowaycsd/show-calendar.gif"), // must use fully-qualified URL for ACM screen scraper
buttonText: "Date Picker",
buttonImageOnly: true,
dateFormat: 'M d, yy',
beforeShow: function(dateText, inst) {$(this).keydown();
}
});
if (ele) {$(ele).find("input.datepicker_if_able").datepicker("option", "onAble", true);
} else {$("input.datepicker_if_able").datepicker("option", "onAble", true);
}
}
function removeTableRow(tbl, row_index) {if (tbl.rows.length > 0 && row_index < tbl.rows.length) tbl.deleteRow(row_index);
parentResizeInner();
}
function removeAllTableRows(tbl) {if (tbl != null){while(tbl.rows.length > 0){tbl.deleteRow(0);
}
}
parentResizeInner();
}
function allFieldsValid(form){with(form){for(var i=0;i tag.
*/
var _keep_alive_wait_timer=null;var authtoken=null;function sdiOnLoad(pageAuthToken, tabId, noKeepAlive, isStaffSession) {try {var el = parent.document.getElementById(self.name);
if (el && el.className=='content_iframe') {el.style.width="";}
} catch (err){}
try {initialResize();
} catch (err) {}
try {if (typeof(pageAuthToken)!='undefined' && pageAuthToken!=null && pageAuthToken.length > 0) {authtoken = pageAuthToken;for(i=0; i < document.forms.length; i++) {var elem = document.createElement("input");
elem.setAttribute("type", "hidden");
elem.setAttribute("name", "sdireqauth");
elem.setAttribute("value", pageAuthToken);
document.forms[i].appendChild(elem);
}
for (i=0; i < document.links.length; i++) {var link = document.links[i];if (!link.href || link.href.substr(0,11)=="javascript:" || link.href.indexOf(".sdi")<0 || link.href.indexOf("sdireqauth=")>0) continue;if ($.browser.msie) {var inner_html = link.innerHTML;link.href += (link.href.indexOf('?') < 0 ? "?" : "&") + "sdireqauth=" + authtoken;if (inner_html != link.innerHTML) link.innerHTML = inner_html; // Fix display issue when text has '@' (AN-22986)
} else {link.href += (link.href.indexOf('?') < 0 ? "?" : "&") + "sdireqauth=" + authtoken;}
}
}
} catch (err) {}
try {_keep_alive_wait_timer=setTimeout(function() { _keep_alive_wait_timer = null; }, keep_alive_delay_minutes*60000);
for (var i = 0; i < document.forms.length; i++) {var form = document.forms[i];if(!form.action || form.action.length == 0) return;for (var j = 0; j=0) {var version = navigator.userAgent.substring(index).split("/")[1];if(parseFloat(version)>=0.1)FFExtra=32;}
try {var list = parent.document.getElementsByTagName('iframe');
for(i=0;i=0) {var version = navigator.userAgent.substring(index).split("/")[1];if(parseFloat(version)>=0.1)FFextraHeight=32;}
parentResizeInner();
var list = document.getElementsByTagName('iframe');
for(i=0;i= 0 ? getElementBodyWidth(el) : getBodyWidth();
if (document.documentElement && document.documentElement.offsetWidth && document.documentElement.offsetWidth < content_width) {el.style.width = content_width;}
} catch (error) {}
}
if (el.addEventListener){el.addEventListener("load", readjustIframe, false);
el.addEventListener("resize", readjustIframe, false);
}
else if (el.attachEvent){el.detachEvent("onload", readjustIframe);
el.attachEvent("onload", readjustIframe);
el.detachEvent("onresize", readjustIframe);
el.attachEvent("onresize", readjustIframe);
}
}
function readjustIframe(loadevt) {var crossevt=(window && window.event)? event : loadevt;var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement;if (iframeroot && typeof(resizeIframe)!='undefined'){resizeIframe(iframeroot.id);
}
}
function resizeIFrameForApp(target_tab_id) {if(!target_tab_id || target_tab_id.length == 0) {var content_nav_frame = findFrame("sdi_main_nav");
if (content_nav_frame) {target_tab_id = content_nav_frame.findContentTabIdForMenu();
}
}
if (target_tab_id && target_tab_id.length > 0) {try {var el = parent.document.getElementById(target_tab_id + '_content_iframe');
if (!el) el = parent.parent.document.getElementById(target_tab_id + '_content_iframe');
if (el) {el.style.height='100%';el.style.width='100%';el.style.overflow="auto";el.scrolling = "auto";}
} catch (err) { }
}
}
function textAreaExpand(img,field){var fld = "";for (var i = 0; i < document.forms.length; i++) {fld = eval("document.forms["+i+"]."+field);
if(fld != null){break;}
}
if(fld.rows<10){img.name="clicked";for (i = 0; i < document.images.length; i++) {var docImg = document.images[i];if(docImg.name==img.name){var imgEnable = document.images[i+1];imgEnable.style.display = '';}
}
img.name="";}
if(fld.rows<100){fld.rows+=10;parentResizeInner();
}
}
function textAreaContract(img,field){var fld = "";for (var i = 0; i < document.forms.length; i++) {fld = eval("document.forms["+i+"]."+field);
if(fld != null){break;}
}
if(fld.rows>10){fld.rows-=10;parentResizeInner();
}
if(fld.rows<10){img.style.display = 'none';img.name="clicked";for (i = 0; i < document.images.length; i++) {var docImg = document.images[i];if(docImg.name==img.name){var imgEnable = document.images[i];imgEnable.style.display = 'none';}
}
img.name="";}
}
function toggleDisplay(id){var elem=document.getElementById(id);
if (!elem) return;elem.style.display=elem.style.display ? '' : 'none';parentResizeInner();
}
function setIframeDisplay(iframe,id,display){if(frames) {var elem=frames(iframe).document.getElementById(id);
if(elem)elem.style.display=display ? '' : 'none';}
}
function setDisplay(elem,display){if (elem && typeof(elem).toLowerCase()=='string') {elem = document.getElementById(elem);
}
if(!elem) return;elem.style.display=display ? '' : 'none';parentResizeInner();
}
function isDisplayed(elem){if (elem && typeof(elem).toLowerCase()=='string') {elem = document.getElementById(elem);
}
if(!elem) return false;return elem.style.display=='';}
function toggleBodyTriangle(id){setBodyTriangle(id,isDisplayed(id + "_body"));
}
function setBodyTriangle(id,v){setDisplay(id + "_downtriangle",v);
setDisplay(id + "_righttriangle",!v);
}
function toggleGroupBody(id){toggleDisplay(id + "_body");
toggleBodyTriangle(id);
}
function setGroupBody(id,v){setDisplay(id + "_body",v);
setBodyTriangle(id,v);
}
function setDisabledState(elem, disabled_state){if (elem && typeof(elem).toLowerCase()=='string') {var str = elem;try {elem = document.getElementById(str);
} catch(e) {}
if (!elem || typeof(elem)=='undefined') {try {elem = document.getElementsByName(str)[0];} catch(e) {}
}
}
if(elem)elem.disabled = disabled_state;}
function setDisabledAll(disabled_state) {for (var i = 0; i < document.forms.length; i++) {var form = document.forms[i];for (var j = 0; j 10) {alert("Bank routing number is too long");
routing_number.focus();
return false;}
if (account_number.value.length == 0) {alert("Missing bank account number");
account_number.focus();
return false;}
if (cardIsMasked(account_number.value) != cardIsMasked(routing_number.value)) {alert("Both the bank account and routing numbers must be specified");
account_number.focus();
return false;}
if(cardIsMasked(account_number.value)) {if (account_number.value != account_number.defaultValue || routing_number.value != routing_number.defaultValue) {alert("You cannot modify the bank account or routing numbers without specifying both");
return false;}
return true;}
wallet_id.value="";_callback_context = new encryptCallbackContext(account_type.form);
_callback_context.account_number=account_number;_callback_context.routing_number=routing_number;_callback_context.wallet_id = wallet_id;_callback_context.time = new Date().getTime();
_callback_context.key = maskCard(account_number.value);
with (account_type.form) {var modulus = eval(wallet_id.name + "_modulus.value");
var exponent = eval(wallet_id.name + "_exponent.value");
}
if (modulus == "error") {alert("A communication error with credit card services is preventing your order from being processed at this time");
_callback_context=null;return false;}
if (modulus == "no encrypt") {_callback_context=null;return true;}
if (modulus == "localdemo") {account_number.value=maskCard(account_number.value);
routing_number.value = maskCard(routing_number.value);
wallet_id.value = "Demo AccountID";_callback_context=null;return true;}
var request = new AMS.AccountInfo();
request.setAccountType(account_type.value);
request.setAccountNumber(account_number.value);
request.setBankID(routing_number.value);
request.setAccountOwner(holder);
request.setModulus(modulus);
request.setExponent(exponent);
try {var cipher_text = AMS.getCipher(request);
if (cipher_text) {_callback_context.timer = setTimeout("walletIDTimeout()", 20*1000);
params = 'modulus=' + encodeURIComponent(modulus) + '&cipher_text=' + encodeURIComponent(cipher_text) + '&time=' + _callback_context.time + '&key=' + _callback_context.key + '\n';wallet_req = getAjaxRequest();
doAjaxRequest(wallet_req, "generateAMSAccountID.sdi", walletIDCallback, "POST", params);
return false;} else {alert('Cannot encrypt the bank information');
_callback_context=null;return false;}
} catch(e) {if (e == "InvalidToken"){alert('Error: the token is invalid. Try again.');
} else if (e == "AccountInfoMessageTooLong"){alert('Error: The input account information message is too long. Try again.');
}
_callback_context=null;return false;}
}
function cleanupCCNumber(cc_number,wallet_id) {try {if (!cc_number || !wallet_id) {return;}
with (cc_number.form) {modulus = eval(wallet_id.name + "_modulus.value");
}
if (modulus == "no encrypt") {return;}
if(!cardIsMasked(cc_number.value)) {cc_number.value = "";}
} catch(e) {alert("Cleanup error\n" + e.name + "\n" + e.message);
return;}
}
function encryptCCData(cc_number,cc_expiry,card_type_id,wallet_id,account_holder,account_zip,csc) {try {return doEncryptCCData(cc_number,cc_expiry,card_type_id,wallet_id,account_holder,account_zip,csc);
} catch(e) {alert("Error encrypting credit card\n" + e.name + "\n" + e.message);
_callback_context=null;return false;}
}
function doEncryptCCData(cc_number,cc_expiry,card_type_id,wallet_id,account_holder,account_zip,csc) {if (_callback_context!=null) {alert("Busy encrypting credit card, please try again");
return false;}
if (!cc_number || !cc_expiry || !account_holder || (typeof account_zip == 'undefined') || !wallet_id) {alert("Missing parameter to encryptCCData method");
return false;}
if (typeof(csc)=='undefined' || csc==null || emptyField(csc) || csc.disabled) {csc = null;}
if (emptyField(cc_number)) {alert("Please enter a card number");
cc_number.focus();
return false;}
if(empty(cc_expiry,"Card Expiration")) return false;if(!validExpiry(cc_expiry,"Card Expiration")) return false;holder = account_holder.form ? account_holder.value : account_holder;if (holder.length == 0) {alert("Missing account holder");
if (account_holder.form) account_holder.focus();
return false;}
zip = account_zip.form ? account_zip.value : account_zip;if(cardIsMasked(cc_number.value)) {if (cc_number.value != cc_number.defaultValue) {alert("You cannot modify the credit card number without specifying the entire number");
return false;}
if (csc != null && csc.value!= "sss" && csc.defaultValue!="sss") {alert("Both the security code and the credit card number must be specified");
return false;}
/*
if (cc_expiry.value != cc_expiry.defaultValue || (account_zip.form && account_zip.value != account_zip.defaultValue)) {alert("debugging: have wallet id but expiry or zip changed");
}
*/
if (wallet_id.value != "Demo AccountID") {if (cc_expiry.value != cc_expiry.defaultValue || (account_zip.form && account_zip.value != account_zip.defaultValue)) {_callback_context = new encryptCallbackContext(cc_number.form);
_callback_context.cc_expiry=cc_expiry;_callback_context.account_zip=account_zip;_callback_context.wallet_id = wallet_id;_callback_context.timer = setTimeout("walletUpdateTimeout()", 30*1000);
wallet_update_req = getAjaxRequest();
doAjaxRequest(wallet_update_req, "walletUpdateFunction.sdi?wallet_id=" + encodeURIComponent(wallet_id.value) + "&cc_expiry=" + cc_expiry.value + "&account_zip=" + zip, walletUpdateCallback, 'GET', '');
return false;}
}
return true;}
wallet_id.value="";card_type_name=null;card_validation=0;type_to_check = 0;if (card_type_id != null) {type_to_check = card_type_id.form ? card_type_id.value : card_type_id;}
if (type_to_check>0) {for(i=0;i 0 ? ": " + error_msg : ""));
_callback_context.wallet_id.value="";_callback_context = null;return;}
_callback_context.wallet_id.value=wallet_id;if (_callback_context.cc_number != null) {_callback_context.cc_number.value=maskCard(_callback_context.cc_number.value);
_callback_context.cc_number.defaultValue=_callback_context.cc_number.value;if (_callback_context.account_zip.form) _callback_context.account_zip.defaultValue=_callback_context.account_zip.value;_callback_context.cc_expiry.defaultValue=_callback_context.cc_expiry.value;} else if (_callback_context.account_number != null) {_callback_context.account_number.value=maskCard(_callback_context.account_number.value);
_callback_context.account_number.defaultValue=_callback_context.account_number.value;_callback_context.routing_number.value=maskCard(_callback_context.routing_number.value);
_callback_context.routing_number.defaultValue=_callback_context.routing_number.value;}
var form = _callback_context.form;_callback_context = null;submitForm(form);
}
} catch(err){}
}
function walletUpdateTimeout(){if (_callback_context.fnNotificationCallback) {var fn = _callback_context.fnNotificationCallback;var ckey = _callback_context.key;_callback_context = null;fn(null, ckey, 'Unable to save new expiration and/or zip code');
} else {alert('Unable to save new expiration and/or zip code');
}
_callback_context=null;}
var wallet_update_req;function walletUpdateCallback(){try {if (wallet_update_req.readyState == 4) {if (_callback_context == null) {return;}
if (_callback_context.timer != null) {clearTimeout(_callback_context.timer);
_callback_context.timer = null;}
if (wallet_update_req.status != 200) {alert('Communication error attempting to update credit card information');
_callback_context=null;return;}
var response = wallet_update_req.responseXML.documentElement;if (response.getElementsByTagName("error")[0].childNodes.length > 0) {var error = response.getElementsByTagName("error")[0].childNodes[0].nodeValue;if (error != null && error.length > 0) {alert(error);
_callback_context = null;return;}
}
var wallet_id=response.getElementsByTagName("wallet_id")[0].firstChild.data;if (wallet_id==null || wallet_id.length==0 || wallet_id=='null') {alert("Unable to encrypt sensitive financial data");
_callback_context = null;return;}
_callback_context.wallet_id.value=wallet_id;_callback_context.account_zip.defaultValue=_callback_context.account_zip.value;_callback_context.cc_expiry.defaultValue=_callback_context.cc_expiry.value;var form = _callback_context.form;_callback_context = null;if (form && form != null) {submitForm(form);
}
}
} catch(err){}
}
var cc_validation_to_card_type=["1","1","Visa","2","2","MasterCard",];
function maskCard(cc_number){cc_number = trimString(cc_number);
digits_to_show = cc_number.length > 4 ? 4 : cc_number.length;return "xxx" + cc_number.substring(cc_number.length - digits_to_show);
}
function cardIsMasked(cc_number) {return cc_number.indexOf("xxx") == 0;}
function cardTypeFromValidationType(validation_type) {for(var i=0;i= 0; i--, odd_toggle = !odd_toggle) {digit = parseInt(my_cc_number.charAt(i), 10);
if (isNaN(digit)) return false;if (odd_toggle) {if (digit * 2 > 9) {check_sum += 1 + (digit * 2) % 10;} else {check_sum += digit * 2;}
} else {check_sum += digit;}
}
return (check_sum % 10) == 0;}
function validOnlineExpiry(month_field,year_field,composite_field,msg) {month = month_field.value;if (!isInteger(month) || isNaN(parseInt(month)) || month < 1 || month > 12) {alert(msg+" month is invalid");
month_field.focus();
return false;}
year = year_field.value;if (!isInteger(year) || isNaN(parseInt(year))) {alert(msg+" year is invalid");
year_field.focus();
return false;}
if (year.length==2) year = "20" + year;this_year = new Date().getFullYear();
if (year > this_year + 10) {alert(msg+" year is more than 10 years in the future");
year_field.focus();
return false;}
composite_field.value = month + "/" + year;if (month==12) {month=0;year++;}
var expdate = new Date();
expdate.setFullYear(year,month,1); // first day of month following expiration
if (expdate < new Date()) {alert(msg+" is in the past");
year_field.focus();
return false;}
return true;}
function validExpiry(field,msg,pastAllowed) {if (!validExpiryValue(field.value, msg, field, pastAllowed)) {field.focus();
field.value = "";return false;}
return true;}
function validExpiryValue(expiry_value,msg,field,pastAllowed) {if(expiry_value.length==0)return true;var month = 0;var year = 0;if ((index = expiry_value.indexOf("/")) > 0) {if ((index != 1 && index != 2) || index+1>=expiry_value.length || expiry_value.lastIndexOf("/") != index) {alert(msg+" contains invalid date");
return false;}
month=expiry_value.substring(0,index);
year=expiry_value.substring(index+1);
} else {if (expiry_value.length==3 || expiry_value.length==5){month=expiry_value.substring(0,1);
year=expiry_value.substring(1);
} else if (expiry_value.length==4 || expiry_value.length==6) {month=expiry_value.substring(0,2);
year=expiry_value.substring(2);
} else {alert(msg+" contains invalid date");
return false;}
}
if (!isInteger(month)) {}
if (!isInteger(month) || isNaN(parseInt(month)) || month < 1 || month > 12) {alert(msg+" month is invalid");
return false;}
if (!isInteger(year) || isNaN(parseInt(year))) {alert(msg+" year is invalid");
return false;}
if (year.length==2) year = "20" + year;this_year = new Date().getFullYear();
if (year > this_year + 10) {alert(msg+" year is more than 10 years in the future");
return false;}
if (field && field.value != null && typeof(field)!='undefined' ) {field.value = (month.length == 1 ? "0" : "") + month + "/" + year;}
if (month==12) {month=0;year++;}
var expdate = new Date();
expdate.setFullYear(year,month,1); // first day of month following expiration
if(!pastAllowed){if (expdate < new Date()) {alert(msg+" is in the past");
return false; // expiration date is in the past
}
}
return true;}
function capitalizeMe(field) {if (emptyField(field))return;var first_letter=field.value.substring(0,1);
if(first_letter.toUpperCase()==first_letter)return;newVal = '';val = field.value.toLowerCase().split(' ');
for(var c=0; c < val.length; c++) {newVal += val[c].substring(0,1).toUpperCase() + val[c].substring(1,val[c].length) + ' ';}
field.value = newVal;}
function PrepCodeObj (id,setup_h,setup_m,ready_h,ready_m,eventnotes) {this.id=id;this.setup_h=setup_h;this.setup_m=setup_m;this.ready_h=ready_h;this.ready_m=ready_m;this.eventnotes = eventnotes;}
function prepCodeChangeForRow(prep_code, row){for(var i=0;i 11){var key = prep_code.name.substring(12); // find the key
$("input[name^='setup_" + key + "'][name$='h']:visible").each(function(){$(this).val(prepcodes[i].setup_h);
});
$("input[name^='setup_" + key + "'][name$='m']:visible").each(function(){$(this).val(prepcodes[i].setup_m);
});
$("input[name^='ready_" + key + "'][name$='h']:visible").each(function(){$(this).val(prepcodes[i].ready_h);
});
$("input[name^='ready_" + key + "'][name$='m']:visible").each(function(){$(this).val(prepcodes[i].ready_m);
});
$("textarea[name='eventnotes_" + key +"']").val(prepcodes[i].eventnotes);
}else{setup_h.value=prepcodes[i].setup_h;setup_m.value=prepcodes[i].setup_m;ready_h.value=prepcodes[i].ready_h;ready_m.value=prepcodes[i].ready_m;eventnotes.value=prepcodes[i].eventnotes;}
}
}
}
}
}
function findStreet(address){if(emptyField(address)) {PopupWindow("adminSelect.sdi?oc=Street","StreetPop","500","400","yes");
return;}
var streetnumber="";var streetname="";var address_value="";for(var j=address.value.length-1;j>=0;j--){if(address.value.charAt(j)==' ') continue;address_value=address.value.substring(0,j+1);
break;}
var space_found = false;var has_number = false;for(var i=0;i 0 && key_id < ajax_id.value) {return;}
ajax_id.value = key_id;var enrollment_id = parseInt(req.responseXML.documentElement.getElementsByTagName("enrollment_id")[0].firstChild.data);
for(var i=0;i 0 && el[0].firstChild != null) {var desc = el[0].firstChild.data;fees[i].desc=desc;}
tag = "amt_" + fees[i].id;var amt = req.responseXML.documentElement.getElementsByTagName(tag)[0].firstChild.data;fees[i].current_fee=parseFloat(amt);
tag = "tax_" + fees[i].id;amt = req.responseXML.documentElement.getElementsByTagName(tag)[0].firstChild.data;fees[i].tax = parseFloat(amt);
}
showFeeTotals(document.fees, enrollment_id);
}
}
}
} catch(err) {}
}
function showFeeTotals(form, enrollment_id){if (!enrollment_id || typeof enrollment_id == 'undefined' || isNaN(enrollment_id)) {enrollment_id = 0;}
var enrollment_id_key = enrollment_id > 0 ? enrollment_id : '';with(form){var taxes=0.0;var total=0.0;var has_per_use_fee = false;var per_use_total = 0.0;for(var i=0;i0) {if(typeof eval("sub_activity_fees_total_"+enrollment_id_key) != 'undefined'){eval("sub_activity_fees_total_"+enrollment_id_key).value = formatCurrency(total_val);
}
} else {if(typeof sub_activity_fees_total != 'undefined') {sub_activity_fees_total.value = formatCurrency(total_val);
}
}
} catch (err) {}
try {if(enrollment_id > 0 && typeof eval("grand_total_"+enrollment_id_key) != 'undefined'){eval("grand_total_"+enrollment_id_key).value = formatCurrency(parseFloat(eval("grand_total_"+enrollment_id_key).value) + parseFloat(diff));
}
} catch (err) {}
try {if(typeof all_enroll_total != 'undefined'){all_enroll_total.value=formatCurrency(parseFloat(all_enroll_total.value)+parseFloat(diff));
}
} catch (err) {}
try {if(typeof grand_total != 'undefined'){grand_total.value=formatCurrency(parseFloat(grand_total.value)+parseFloat(diff));
}
} catch (err) {}
try {if(typeof transfer_grand_total != 'undefined' && typeof raw_total_prev_fee != 'undefined') {transfer_grand_total.value=formatCurrency(total_val + parseFloat(raw_total_prev_fee.value));
}
} catch (err) {}
}
}
var postal_to_city=["18929","Jamison","PA","0","91901","Alpine","CA","0","91902","Bonita","CA","0","91903","Alpine","CA","0","91905","Boulevard","CA","0","91906","Campo","CA","0","91908","Bonita","CA","0","91909","Chula Vista","CA","0","91910","Chula Vista","CA","0","91911","Chula Vista","CA","0","91912","Chula Vista","CA","0","91913","Chula Vista","CA","0","91914","Chula Vista","CA","0","91915","Chula Vista","CA","0","91916","Descanso","CA","0","91917","Dulzura","CA","0","91921","Chula Vista","CA","0","91931","Guatay","CA","0","91932","Imperial Beach","CA","0","91933","Imperial Beach","CA","0","91934","Jacumba","CA","0","91935","Jamul","CA","0","91941","La Mesa","CA","0","91942","La Mesa","CA","0","91943","La Mesa","CA","0","91944","La Mesa","CA","0","91945","Lemon Grove","CA","0","91946","Lemon Grove","CA","0","91950","National City","CA","0","91951","National City","CA","0","91962","Pine Valley","CA","0","91963","Potrero","CA","0","91976","Spring Valley","CA","0","91977","Spring Valley","CA","0","91978","Spring Valley","CA","0","91979","Spring Valley","CA","0","91980","Tecate","CA","0","91987","Tecate","CA","0","91990","Potrero","CA","0","92003","Bonsall","CA","0","92004","Borrego Springs","CA","0","92007","Cardiff","CA","0","92008","Carlsbad","CA","0","92009","Carlsbad","CA","0","92013","Carlsbad","CA","0","92014","Del Mar","CA","0","92018","Carlsbad","CA","0","92019","El Cajon","CA","0","92020","El Cajon","CA","0","92021","El Cajon","CA","0","92022","El Cajon","CA","0","92023","Encinitas","CA","0","92024","Encinitas","CA","0","92025","Escondido","CA","0","92026","Escondido","CA","0","92027","Escondido","CA","0","92028","Fallbrook","CA","0","92029","Escondido","CA","0","92030","Escondido","CA","0","92033","Escondido","CA","0","92036","Julian","CA","0","92037","La Jolla","CA","0","92038","La Jolla","CA","0","92039","La Jolla","CA","0","92040","Lakeside","CA","0","92046","Escondido","CA","0","92049","Oceanside","CA","0","92051","Oceanside","CA","0","92052","Oceanside","CA","0","92054","Oceanside","CA","0","92055","Camp Pendleton","CA","0","92056","Oceanside","CA","0","92057","Oceanside","CA","0","92058","Oceanside","CA","0","92064","Poway","CA","1","92065","Ramona","CA","0","92066","Ranchita","CA","0","92068","Rancho Santa Fe","CA","0","92068","San Luis Rey","CA","0","92069","San Marcos","CA","0","92070","Santa Ysabel","CA","0","92071","Santee","CA","0","92072","Santee","CA","0","92075","Solana Beach","CA","0","92078","San Marcos","CA","0","92079","San Marcos","CA","0","92082","Valley Center","CA","0","92083","Vista","CA","0","92084","Vista","CA","0","92085","Vista","CA","0","92086","Warner Springs","CA","0","92088","Fallbrook","CA","0","92090","El Cajon","CA","0","92091","Rancho Santa Fe","CA","0","92092","La Jolla","CA","0","92093","La Jolla","CA","0","92096","San Marcos","CA","0","92101","San Diego","CA","0","92102","San Diego","CA","0","92103","San Diego","CA","0","92104","San Diego","CA","0","92105","San Diego","CA","0","92106","San Diego","CA","0","92107","San Diego","CA","0","92108","San Diego","CA","0","92109","San Diego","CA","0","92110","San Diego","CA","0","92111","San Diego","CA","0","92112","San Diego","CA","0","92113","San Diego","CA","0","92114","San Diego","CA","0","92115","San Diego","CA","0","92116","San Diego","CA","0","92117","San Diego","CA","0","92118","San Diego","CA","0","92119","San Diego","CA","0","92120","San Diego","CA","0","92121","San Diego","CA","0","92122","San Diego","CA","0","92123","San Diego","CA","0","92124","San Diego","CA","0","92125","San Diego","CA","0","92126","San Diego","CA","0","92127","San Diego","CA","0","92128","San Diego","CA","0","92129","San Diego","CA","0","92130","San Diego","CA","0","92131","San Diego","CA","0","92132","San Diego","CA","0","92133","San Diego","CA","0","92134","San Diego","CA","0","92135","San Diego","CA","0","92136","San Diego","CA","0","92137","San Diego","CA","0","92138","San Diego","CA","0","92139","San Diego","CA","0","92140","San Diego","CA","0","92141","San Diego","CA","0","92142","San Diego","CA","0","92143","San Diego","CA","0","92144","San Diego","CA","0","92145","San Diego","CA","0","92146","San Diego","CA","0","92147","San Diego","CA","0","92148","San Diego","CA","0","92149","San Diego","CA","0","92150","San Diego","CA","0","92151","San Diego","CA","0","92152","San Diego","CA","0","92153","San Diego","CA","0","92154","San Diego","CA","0","92155","San Diego","CA","0","92156","San Diego","CA","0","92157","San Diego","CA","0","92158","San Diego","CA","0","92159","San Diego","CA","0","92160","San Diego","CA","0","92161","San Diego","CA","0","92162","San Diego","CA","0","92163","San Diego","CA","0","92164","San Diego","CA","0","92165","San Diego","CA","0","92166","San Diego","CA","0","92167","San Diego","CA","0","92168","San Diego","CA","0","92169","San Diego","CA","0","92170","San Diego","CA","0","92171","San Diego","CA","0","92172","San Diego","CA","0","92173","San Diego","CA","0","92174","San Diego","CA","0","92175","San Diego","CA","0","92176","San Diego","CA","0","92177","San Diego","CA","0","92178","San Diego","CA","0","92179","San Diego","CA","0","92180","San Diego","CA","0","92181","San Diego","CA","0","92182","San Diego","CA","0","92183","San Diego","CA","0","92184","San Diego","CA","0","92185","San Diego","CA","0","92186","San Diego","CA","0","92187","San Diego","CA","0","92188","San Diego","CA","0","92189","San Diego","CA","0","92190","San Diego","CA","0","92191","San Diego","CA","0","92192","San Diego","CA","0","92193","San Diego","CA","0","92194","San Diego","CA","0","92195","San Diego","CA","0","92196","San Diego","CA","0","92197","San Diego","CA","0","92198","San Diego","CA","0","92199","San Diego","CA","0",];
var geo_to_resident=["33","0","23","0","9","0","7","0","40","0","26","0","1","1","15","0","5","0","13","0","2","0","4","0","14","0",];
function setCityState(form,set_resident) {with(form){setCityStateZip(form,zipcode,city,state,set_resident);
}
}
function setCityStateZip(form,zipfield,cityfield,statefield,set_resident) {with(form){var cities = new Array();
var states = new Array();
var residents = new Array();
for(var i=0;i 0) {break;}
}
if (cities.length > 0) {for (var j=0;j 0 && statefield.selectedIndex >= 0 && y == statefield[statefield.selectedIndex].value) {cityfield.value = x; // copy the city name over to fix any lower/upper case mismatch
if(set_resident) setResident(form, (residents[j] == "1" ? true : false));
return;}
}
}
x = cities[0];if (x != "") {cityfield.value = x;}
x = states[0];if (x != "") {for(var k=0;k=0){for(var i=0;i 11){alert("The SSN should not be longer than 11 digits.");
ssn.focus();
return false;}
return true;}
function validEIN (ein) {var number_digits = 0;var new_ein = "";for(var i=0;i 2) country_code = country_code.substring(country_code.length - 2);
if (country_code == "" || country_code == "US" || country_code == "CA") {if (ext) {if (wholeNumber(ext, "ext number")) {if (ext.value.length == 4 && phone.value.length == 3){phone.value += ext.value;ext.value = "";}
} else {return false;}
}
if (area.value.length == 0) {if (phone.value.length == 0) return true;alert(field_name + " is missing the area code.");
area.focus();
return false;}
if (area.value.length != 3) {alert("Area code for " + field_name + " is not 3-digits.");
area.focus();
return false;}
if (!wholeNumber(area, field_name + " area code")) return false;if (phone.value.length == 0) {alert("The " + field_name + " is missing.");
phone.focus();
return false;}
var number_digits = 0;for (var i = 0; i < phone.value.length; i++) {var c = phone.value.charAt(i);
if (c == ' ' || c == "." || c == "-") continue;if (isNaN(parseInt(c, 10))) {alert("The " + field_name + " contains invalid characters.");
phone.focus();
return false;}
number_digits++;}
if (number_digits != 7) {alert("The " + field_name + " must be 7 digits.");
phone.focus();
return false;}
} else if (country_code == "AU") {if (phone.name.indexOf("c") > -1) {if (phone.value.length == 0) return true;var number_digits = 0;for (var i = 0; i < phone.value.length; i++) {var c = phone.value.charAt(i);
if (c == ' ' || c == "." || c == "-") continue;if (isNaN(parseInt(c, 10))) {alert("The " + field_name + " contains invalid characters.");
phone.focus();
return false;}
number_digits++;}
if (number_digits != 10) {alert("The " + field_name + " must be 10 digits.");
phone.focus();
return false;}
} else {if (ext) {if (wholeNumber(ext, "ext number")) {if (ext.value.length == 4 && phone.value.length == 4){phone.value += ext.value;ext.value = "";}
} else {return false;}
}
if (area.value.length == 0) {if (phone.value.length == 0) return true;alert(field_name + " is missing the area code.");
area.focus();
return false;}
if (area.value.length != 2) {alert("Area code for " + field_name + " is not 2-digits.");
area.focus();
return false;}
if (!wholeNumber(area, field_name + " area code")) return false;if (phone.value.length == 0) {alert("The " + field_name + " is missing.");
phone.focus();
return false;}
var number_digits = 0;for (var i = 0; i < phone.value.length; i++) {var c = phone.value.charAt(i);
if (c == ' ' || c == "." || c == "-") continue;if (isNaN(parseInt(c, 10))) {alert("The " + field_name + " contains invalid characters.");
phone.focus();
return false;}
number_digits++;}
if (number_digits != 8) {alert("The " + field_name + " must be 8 digits.");
phone.focus();
return false;}
}
} else if (country_code == "NZ") {if (phone.name.indexOf("c") > -1) {if (phone.value.length == 0) return true;var number_digits = 0;for (var i = 0; i < phone.value.length; i++) {var c = phone.value.charAt(i);
if (c == ' ' || c == "." || c == "-") continue;if (isNaN(parseInt(c, 10))) {alert("The " + field_name + " contains invalid characters.");
phone.focus();
return false;}
number_digits++;}
if (number_digits > 11) {alert("The " + field_name + " must be smaller than 11 digits.");
phone.focus();
return false;}
} else {if (ext) {if (wholeNumber(ext, "ext number")) {if (ext.value.length == 4 && phone.value.length == 4){phone.value += ext.value;ext.value = "";}
} else {return false;}
}
if (area.value.length == 0) {if (phone.value.length == 0) return true;alert(field_name + " is missing the area code.");
area.focus();
return false;}
if (area.value.length != 2) {alert("Area code for " + field_name + " is not 2-digits.");
area.focus();
return false;}
if (!wholeNumber(area, field_name + " area code")) return false;if (phone.value.length == 0) {alert("The " + field_name + " is missing.");
phone.focus();
return false;}
var number_digits = 0;for (var i = 0; i < phone.value.length; i++) {var c = phone.value.charAt(i);
if (c == ' ' || c == "." || c == "-") continue;if (isNaN(parseInt(c, 10))) {alert("The " + field_name + " contains invalid characters.");
phone.focus();
return false;}
number_digits++;}
if (number_digits != 7) {alert("The " + field_name + " must be 7 digits.");
phone.focus();
return false;}
}
} else {if (phone.value.length == 0) return true;var number_digits = 0;for (var i = 0; i < phone.value.length; i++) {var c = phone.value.charAt(i);
if (c == ' ' || c == "." || c == "-") continue;if (isNaN(parseInt(c, 10))) {alert("The " + field_name + " contains invalid characters.");
phone.focus();
return false;}
number_digits++;}
if (number_digits > 20) {alert("The " + field_name + " must be smaller than 20 digits.");
phone.focus();
return false;}
if (ext && !wholeNumber(ext, "ext number")) return false;}
return true;}
var default_country_code;var local_area_code;function iniLocalAreaCode() {try {doXmlHttpRequest("getSiteLocalAreaCode.sdi", setLocalAreaCode, "GET", '');
} catch (err) {}
}
function setLocalAreaCode () {if (req.readyState == 4) {if (req.status == 200) {var temp = req.responseText;if (temp != null) {for (var i = 0; i < temp.length; i++) {if (isNaN(temp.charAt(i))) {default_country_code = temp.substring(0, 2);
local_area_code = temp.substring(2);
break;}
}
}
}
}
}
function enterAreaCode(area_code) {if (area_code.value.length == 0) {if (local_area_code == null) {iniLocalAreaCode();
} else {var $calling_code = $(area_code).parent().parent().find("select");
if ($calling_code.size() == 0 || ($calling_code.size() > 0 && $calling_code.val().substring($calling_code.val().length - 2) == default_country_code)) {var area_code_size = $(area_code).attr("size");
if (area_code_size < local_area_code.length) {area_code.value = local_area_code.substring(0, area_code_size);
} else {area_code.value = local_area_code;}
}
}
}
}
function leavePhone(area_code,phone){if (typeof(area_code) == "undefined") return;if (phone.value.length == 0) {if (local_area_code == null) {iniLocalAreaCode();
} else if (area_code.value == local_area_code) {area_code.value = "";}
}
}
function confirmDelete () {return confirm ("Are you sure you want to delete this record?");
}
function confirmDeleteTransaction(){return confirm("Are you sure you want to delete this transaction?");
}
function tabFirstField () {for(i=0; i < document.forms.length; i++) {resetFormDirty(document.forms[i]);
}
for (var i = 0; i < document.forms.length; i++) {if(tabFirstFieldInForm (document.forms[i])) return;}
}
function tabFirstFieldInForm (form) {for (var j = 0; j1){alert(msg+" can contain only one decimal point.");
field.focus();
return false;}
}
}
return true;}
function isRealNumber (field,msg) {var countDecimals = 0;if (field.value.length > 0) {if (field.value.charAt(0)=="-") {var temp_field;temp_field.value = field.value.substring(1, field.value.length)
return decimalNumber(temp_field, msg);
} else {return decimalNumber(field, msg);
}
}
return true;}
function customerID(field,msg) {if(field.value.length==0)return true;var val = field.value;if(val.length<=3)return wholeNumber(field,msg);
return true;}
function PopupWindow(mypage,myname,w,h,scroll) {var offset = 20;var winl = screen.width-w;if ((parseFloat(w)+parseFloat(offset))0)mypage=mypage+"&popup_window=yes"; else mypage=mypage+"?popup_window=yes";win = window.open(mypage, myname, winprops);
try {if (parseInt(navigator.appVersion,10) >= 4) win.window.focus();
} catch(err) {}
}
function PopupWindowWithMenu(mypage,myname,w,h,scroll) {var offset = 20;var winl = screen.width-w;if ((parseFloat(w)+parseFloat(offset))0)mypage=mypage+"&popup_window=yes"; else mypage=mypage+"?popup_window=yes";win = window.open(mypage, myname, winprops);
try {if (parseInt(navigator.appVersion,10) >= 4) win.window.focus();
} catch(err) {}
}
function NewWindow(mypage) {if(mypage.indexOf('?')>0)mypage=mypage+"&new_window=yes"; else mypage=mypage+"?new_window=yes";win = window.open(mypage, "ReceiptWindow", "menubar=yes,toolbar=yes,scrollbars=yes,resizable");
if (parseInt(navigator.appVersion,10) >= 4) win.window.focus();
}
function formatCurrency(num) {num = num.toString().replace(/\$|\,/g,'');
if(isNaN(parseFloat(num))) num = "0";num=parseFloat(num);
var neg=num<0;if(neg)num=-num;num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num)) num = "0";cents = Math.floor(num*100+0.5)%100;num = Math.floor((num*100+0.5)/100).toString();
if(cents < 10) cents = "0" + cents;num+="." + cents;if(neg)num="-"+num;return num;}
function validCurrency(field,field_name) {if(emptyField(field))return true;for(var i=0;i 1 || isNaN(num)){alert("The " + field_name + " contains an invalid entry");
if (!field.disabled) {field.focus();
}
return false;}
if(num<0){alert(field_name + " cannot be negative");
if (!field.disabled) {field.focus();
}
return false;}
return true;}
function validCurrencyMatchCondition(field, field_name, operater, condition_value) {if(emptyField(field))return true;if(!decimalNumber(field,field_name))return false;var num=parseFloat(field.value);
if(isNaN(num)){alert("The " + field_name + " contains an invalid entry");
field.focus ();
return false;}
if(!eval("num"+operater+condition_value)){var warn_msg = field_name + " must be ";if (operater == ">") {warn_msg += "greater than ";} else if (operater == ">=") {warn_msg += "greater than or equal to ";} else if (operater == "<") {warn_msg += "less than ";} else if (operater == "<=") {warn_msg += "less than or equal to ";} else if (operater == "=") {warn_msg += "equal to ";}
if (condition_value == 0) {warn_msg += "ZERO";} else {warn_msg += condition_value;}
alert(warn_msg);
field.focus ();
return false;}
return true;}
function empty(field,msg) {if(!emptyField(field)) return false;if(field.type=="text"||field.type=="password"||field.type=="textarea") {alert("Please enter "+msg+".");
if(!field.disabled) field.focus();
return true;}
if(field.type=="select-one"||field.type=="select-multiple" || field.type == "file"){alert("Please select "+msg+".");
if(!field.disabled) field.focus();
return true;}
alert(msg + " doesn't exist");
return false;}
function emptyField(field){if(field==null){alert("'emptyField' called with undefined field");
return true;}
if(field.type=="hidden")return false;if(field.type=="text"||field.type=="password"||field.type=="textarea"||field.type=="file") {for(var i=0;i 0) {for (var i=0;i11){month-=12;year++;}
if(init_day_fmonthly) day = init_day_fmonthly;if(day > get_daysofmonth(month, year))
day = get_daysofmonth(month, year);
}
else if(frequency==6){ //every four weeks
day+=28*duration;}
return new Date(year,month,day);
}
function bumpdate(date,frequency,init_day_fmonthly){return bumpdateDuration(date,frequency,init_day_fmonthly,1);
}
function selectAll(box){for (var i=0;i=0; i--) {if(!box.options[i].selected)continue;box.options[i].selected=false;for(var j=i; j=0; i--) {if(box.options[i].value!=value||box.options[i].text!=text)continue;box.options[i].selected=false;for(var j=i; j=0; i--) {if(!fbox.options[i].selected)continue;fbox.options[i].selected=false;if(fbox.options[i].value=="")continue;var moved = false;for (var j=0;jtbox.options[j].text)continue;tbox.options[tbox.length]=new Option();
for (var k=tbox.length-1; k>j; k--) {tbox.options[k].value=tbox.options[k-1].value;tbox.options[k].text=tbox.options[k-1].text;}
tbox.options[j].value = fbox.options[i].value;tbox.options[j].text = fbox.options[i].text;moved = true;break;}
if (!moved) {new_opt = new Option ();
new_opt.value=fbox.options[i].value;new_opt.text=fbox.options[i].text;new_opt.selected = false;tbox.options[tbox.length]=new_opt;}
for(j=i; jmoveto;j--){box.options[j].value=box.options[j-1].value;box.options[j].text=box.options[j-1].text;}
box.options[moveto].value=value;box.options[moveto].text=text;box.options[moveto].selected = true;moveto++;}
}
function moveUp(box){for(var i=0;i=0; i--) {if(!box.options[i].selected)continue;box.options[i].selected=false;var value = box.options[i].value;var text = box.options[i].text;for(var j=i;j=0; i--) {if(!box.options[i].selected)continue;box.options[i].selected=false;if(i==box.length-1)continue;var value = box.options[i+1].value;var text = box.options[i+1].text;box.options[i+1].value=box.options[i].value;box.options[i+1].text=box.options[i].text;box.options[i+1].selected=true;box.options[i].value=value;box.options[i].text=text;}
}
var digits = "0123456789";function isDigit(c) {return digits.indexOf(c)>=0;}
var valid_date_months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];function validMonthDay (field,msg) {return validDate(field,msg,true);
}
function validDate (field,msg,month_day_format) {if(field.value=="")return true;var date_value=parseDateFieldValue(field.value);
var date=new Date (date_value);
if(isNaN (date)) {alert (msg+" date is invalid.");
field.focus();
return false;}
var year = date.getYear();
if (year == 70) { // don't use Date default for year, use current year instead
date.setYear(new Date().getFullYear());
year = date.getYear();
}
year = (year < 1000) ? year + 1900 : year;if (year < 1900) {alert (msg+" date is too old (earlier than 1900).");
field.focus();
return false;}
if (date.getHours() == 23) {date = $.datepicker._daylightSavingAdjust(date);
}
if(month_day_format){date_value=formatMonthDay (date);
} else {date_value=formatDate (date);
if (date.getYear() > new Date ().getYear () + 50) {alert (msg+" date is too far in the future (more than fifty years).");
field.focus();
return false;}
}
field.value=date_value;return true;}
function parseDateFieldValue(field_value) {var parsed_value="";var changed = false;var all_numeric=true;var num_slashes = 0;var date_format_type = 0;var month = 0;var date = 0;var year = 0;var processed = false;for (var i = 0; i < field_value.length; i++) {var ch = field_value.charAt(i);
if(ch=='.'||ch=='-'){ch='/';changed=true;}
if(ch == '/')num_slashes++;if(!isDigit(ch))all_numeric=false;parsed_value+=ch;}
if(!changed){parsed_value=field_value;if(all_numeric){if(parsed_value.length==1) {parsed_value="0" + parsed_value;}
if(parsed_value.length==2) {parsed_value+="01";}
if(parsed_value.length==3) {parsed_value=parsed_value.substring(0,2) + "0" + parsed_value.substring(2);
}
if(parsed_value.length==4) {parsed_value+="1970";}
if(parsed_value.length>4) {var odd_entry = parsed_value.length%2 == 1;switch (date_format_type) {case 1:
if (odd_entry) {date = parsed_value.substring(0,1);
month = parsed_value.substring(1,3);
year = parsed_value.substring(3);
} else {date = parsed_value.substring(0,2);
month = parsed_value.substring(2,4);
year = parsed_value.substring(4);
}
break;case 2:
if (parsed_value.length > 6) {year = parsed_value.substring(0,4);
month = parsed_value.substring(4,6);
date = parsed_value.substring(6);
} else if (odd_entry){year = parsed_value.substring(0,2);
month = parsed_value.substring(2,3);
date = parsed_value.substring(3,5);
} else {year = parsed_value.substring(0,2);
month = parsed_value.substring(2,4);
date = parsed_value.substring(4,6);
}
break;default:
if(odd_entry) {month = parsed_value.substring(0,1);
date = parsed_value.substring(1,3);
year = parsed_value.substring(3);
} else {month = parsed_value.substring(0,2);
date = parsed_value.substring(2,4);
year = parsed_value.substring(4);
}
}
}
num_slashes=2;processed = true;}
}
if(num_slashes>0){if(num_slashes==1) {var first_index = parsed_value.indexOf('/');
if(date_format_type==1) {month = parsed_value.substring(first_index+1);
date = parsed_value.substring(0,first_index);
} else {date = parsed_value.substring(first_index+1);
month = parsed_value.substring(0,first_index);
}
year = 1970;} else if (num_slashes >=2 && !processed) {var tempNum = trimString(parsed_value).split('/');
switch(date_format_type) {case 1:
date = tempNum[0];month = tempNum[1];year = tempNum[2];break;case 2:
year = tempNum[0];month = tempNum[1];date = tempNum[2];break;default:
month = tempNum[0];date = tempNum[1];year = tempNum[2];}
}
if (year>=0) {if(!isNaN(year) && year<100){year=parseInt(year,10);
year += 2000;}
}
parsed_value = month+"/"+date+"/"+year;} else {var tempVal = trimString(parsed_value).split(' ');
if ((tempVal.length <= 2) && (parsed_value.indexOf(',') == -1)) {parsed_value+=", " + new Date().getFullYear();
}
}
return parsed_value;}
function validNonFutureDate(field,msg) {if(validDate(field,msg)){var todayDate=new Date();
var checkDate=new Date(field.value);
if (checkDate > todayDate){alert(msg +" date must not be later than today.");
field.focus();
return false;}
return true;}
return false;}
function formatDate(date){var year = date.getYear();
if (year < 1000) {year += 1900;}
if (0 == 1) {return date.getDate() + " " + valid_date_months[date.getMonth()] + " " + year;} else if(0 == 2) {return year + " " + valid_date_months[date.getMonth()] + " " + date.getDate();
} else {return valid_date_months[date.getMonth()] + " " + date.getDate() + ", " + year;}
}
function formatMonthDay(date){return valid_date_months[date.getMonth()] + " " + date.getDate();
}
function incrMonth(d,incr){var month=d.getMonth();
if(month+incr<12){if(d.getDate() > findLastDayByTheMonth(month+incr,d.getYear())) d.setDate(findLastDayByTheMonth(month+incr,d.getYear()));
d.setMonth(month+incr);
} else {if(d.getDate() > findLastDayByTheMonth((month+incr)%12,d.getYear()+1)) d.setDate(findLastDayByTheMonth((month+incr)%12,d.getYear()+1));
d.setMonth((month+incr)%12);
var year = d.getYear();
if (year < 1000) {year += 1900;}
d.setYear(year+1);
}
}
function checkMinMaxDateRange(minField, maxField){var minDate=new Date (minField.value);
if(isNaN (minDate)) {alert ("Date is invalid.");
minField.focus();
return false;}
var maxDate=new Date (maxField.value);
if(isNaN (maxDate)) {alert ("Date is invalid.");
maxField.focus();
return false;}
if ( minDate < maxDate )
return true;else
return false;}
function checkToFromPercentRange(fromField, toField){if (fromField.value != ""){if (fromField.value < 0 || fromField.value > 100){alert("The From Percent must be between 0 and 100");
fromField.focus();
return false;}
}
if (toField.value != ""){if (toField.value < 0 || toField.value > 100){alert("The To Percent must be between 0 and 100");
toField.focus();
return false;}
}
if (toField.value != "" && fromField.value != ""){if (parseInt(toField.value,10) < parseInt(fromField.value,10)){alert("The To Percent must be greater than the From Percent");
toField.focus();
return false;}
}
return true;}
function checkToFromDateRange(fromDateField, toDateField){var dummyField = "";if (!checkToFromDateTimeRange(fromDateField, toDateField, dummyField, dummyField)) return false;var todayDate=new Date();
var checkDate = new Date();
if (fromDateField.value != ""){checkDate=new Date(fromDateField.value);
if (checkDate > todayDate){alert("From Date must not be later than today.");
if(!fromDateField.disabled) fromDateField.focus();
return false;}
}
if (toDateField.value != ""){checkDate=new Date(toDateField.value);
if (checkDate > todayDate){alert("To Date must not be later than today.");
if(!fromDateField.disabled) toDateField.focus();
return false;}
}
return true;}
function checkToFromDateTimeRange(fromDateField, toDateField, fromTimeField, toTimeField){if(fromDateField.value != "" && toDateField.value != ""){var fromDate=new Date (fromDateField.value);
var toDate=new Date (toDateField.value);
if ( fromDate < toDate ) return true;if ( fromDate > toDate ){alert("From Date must be earlier than the To Date");
if(!fromDateField.disabled) toDateField.focus();
return false;}
else {if (!checkToFromTimeRange(fromTimeField, toTimeField)){return false;}
}
}
return true;}
function checkToFromTimeRange(fromTimeField, toTimeField){if(fromTimeField.value != "" && toTimeField.value != ""){var fromTime=new Date ("January 1, 1999 "+fromTimeField.value);
var toTime=new Date ("January 1, 1999 "+toTimeField.value);
if ( fromTime >= toTime ) {alert("From Time must be earlier than the To Time");
toTimeField.focus();
return false;}
}
return true;}
function findLastDayOfTheMonth(d) {var days = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var lastday = days[d.getMonth()];if (d.getMonth() == 1) {year = d.getYear();
if (year%400==0 || (year%4 == 0 && year%100!=0) )
lastday +=1;}
return lastday;}
function findLastDayByTheMonth(month,year) {if (month<0||month>11) return 0;var days = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var lastday = days[month];if (month == 1) {if (year%400==0 || (year%4 == 0 && year%100!=0) )
lastday +=1;}
return lastday;}
function validBirthDate (field,msg) {if(field.value=="")return true;field.value = parseDateFieldValue(field.value);
if(isNaN (Date.parse(field.value))) {alert (msg+" date is invalid.");
field.focus();
return false;}
var millis=Date.parse (field.value);
var date=new Date();
date.setTime(millis);
if (date > new Date()) {date.setFullYear(date.getFullYear() - 100);
}
var year = date.getFullYear();
if (year < 1900) {field.value = formatDate(date);
alert (msg+" date is too old.");
field.focus();
return false;}
field.value = formatDate(date);
if (date.getTime() > new Date().getTime()) {alert(msg+" date is in the future.");
field.focus();
return false;}
return true;}
function militaryTime(field){}
function validTime(field,msg,ampm_field) {if (field.value=="")return true;var is24hr = 0 > 0;var clean_string = "";var suffix="";var end_digits=false;for (var i = 0; i < field.value.length; i++) {var ch = field.value.charAt(i);
if (ch == " "){end_digits = clean_string.length>0;continue;}
if (!end_digits && (ch==":" || ((ch >= "0") && (ch <= "9")))) {clean_string += ch;continue;}
end_digits=true;suffix+=ch;}
if (suffix.length>0) {suffix=suffix.toLowerCase ();
if ("am".indexOf(suffix)==0) suffix="am";else if ("pm".indexOf(suffix)==0) suffix="pm";else {alert (msg+" time is invalid. The am/pm portion of the time is unrecognizable.");
field.focus();
return false;}
} else if (ampm_field!=null) {if (ampm_field[0].checked)suffix=ampm_field[0].value;else if (ampm_field[1].checked)suffix=ampm_field[1].value;}
var hours = 0;var minutes = 0;var colon_index=clean_string.indexOf (":");
if (colon_index >= 0){if (colon_index>0)hours = parseInt (clean_string.substring (0,colon_index), 10);
minutes = parseInt (clean_string.substring (colon_index+1, clean_string.length), 10);
if (isNaN(hours) || isNaN(minutes)) {alert (msg+" time is invalid. Please use a value of the form 'HH:MM AM/PM'");
field.focus();
return false;}
} else {var x = parseInt (clean_string, 10);
if (isNaN (x)) {alert (msg+" time is invalid. Please use a value of the form 'HH:MM AM/PM'");
field.focus();
return false;}
hours=Math.floor(x/100);
minutes=x-hours*100;if(hours==0&&minutes<24){hours=minutes;minutes=0
}
}
if(hours==0 && !is24hr){hours=12;if(suffix.length==0)suffix="am";}
if(hours==12 && suffix.length==0) {if (!is24hr) {alert(msg+" time is invalid. Please specify am/pm.");
field.focus();
return false;} else {suffix = "pm";}
}
if (hours>12) {if (suffix.length>0){alert(msg+" time is invalid. Military time does not need am/pm");
field.focus();
return false;}
hours -= 12;suffix="pm";}
if (suffix.length==0) suffix="am";/*********
* Using 24hr time format
* No matter which format user input,
* will change it to 24hr format.
* Here treat 12 as 12 pm, 0 as 12 am.
**/
if (is24hr && ampm_field==null) {if (suffix == "pm" && hours < 12)
hours += 12;if (suffix == "am" && hours == 12)
hours = 0;suffix = "";}
var s = hours.toString() + ":";if (minutes < 10)s+="0";s+=minutes.toString();
var d=new Date("January 1, 1999 "+s+" "+suffix);
if(isNaN (d)) {alert (msg+" time is invalid. Please use a value of the form 'HH:MM AM/PM'");
field.focus();
return false;}
if (ampm_field==null) {if (!is24hr) {field.value=s+" "+suffix;} else {field.value=s;}
} else {field.value=s;if (ampm_field[0].value.toLowerCase() == suffix) {if (!ampm_field[0].checked) {ampm_field[1].checked=false;ampm_field[0].checked=true;}
}
else {if (!ampm_field[1].checked) {ampm_field[0].checked=false;ampm_field[1].checked=true;}
}
}
return true;}
function validFinishTime(field,msg) {if (field.value=="")return true;var clean_string = "";var suffix="";var end_digits=false;for (var i = 0; i < field.value.length; i++) {var ch = field.value.charAt(i);
if (ch == " "){end_digits = clean_string.length>0;continue;}
if (!end_digits && (ch==":" || ((ch >= "0") && (ch <= "9")))) {clean_string += ch;continue;}
end_digits=true;suffix+=ch;}
if (suffix.length>0) {alert (msg+" time is invalid. Portions of the time are unrecognizable.");
field.focus();
return false;}
var hours = 0;var minutes = 0;var seconds = 0;var colon_index=clean_string.indexOf (":");
if (colon_index >= 0){if (colon_index>0)hours = parseInt (clean_string.substring (0,colon_index), 10);
var colon_index2=clean_string.indexOf (":",colon_index+1);
if (colon_index2>colon_index) {minutes = parseInt (clean_string.substring (colon_index+1, colon_index2), 10);
seconds = parseInt (clean_string.substring (colon_index2+1, clean_string.length), 10);
} else {minutes = parseInt (clean_string.substring (colon_index+1, clean_string.length), 10);
}
if (isNaN(hours) || isNaN(minutes) || isNaN(seconds)) {alert (msg+" time is invalid. Please use a value of the form 'HH:MM:SS'");
field.focus();
return false;}
if (minutes>59) {alert (msg+" time is invalid. Maximim value for minutes is '59'");
field.focus();
return false;}
if (seconds>59) {alert (msg+" time is invalid. Maximim value for seconds is '59'");
field.focus();
return false;}
}
else {alert (msg+" time is invalid! Please use a value of the form 'HH:MM:SS'");
field.focus();
return false;}
var s = hours.toString() + ":";if (minutes < 10)s+="0";s+=minutes.toString() + ":";if (seconds < 10)s+="0";s+=seconds.toString();
field.value=s;return true;}
function validTimeRange(start_time_field, end_time_field, focus_field, msg, ampm_field) {if (!validTime(start_time_field,msg,ampm_field)) return false;if (!validTime(end_time_field,msg,ampm_field)) return false;if (start_time_field.value=="" || end_time_field.value=="") return true;var t1 = new Date("January 1, 1999 " + start_time_field.value);
var t2 = new Date("January 1, 1999 " + end_time_field.value);
var diff = t2.getTime() - t1.getTime();
if (diff < 0) {alert(msg+" time is invalid. Start time must be before end time.");
focus_field.focus();
return false;}
return true;}
function hoursDiff(start_time, end_time) {var t1 = new Date("January 1, 1999 " + start_time);
var t2 = new Date("January 1, 1999 " + end_time);
var diff = t2.getTime() - t1.getTime();
if (diff == 0) return 0;var daysDifference = Math.floor(diff /1000/60/60/24);
diff -= daysDifference*1000*60*60*24
var hoursDifference = Math.floor(diff/1000/60/60);
diff -= hoursDifference*1000*60*60
var minutesDifference = Math.floor(diff/1000/60);
return hoursDifference;}
function minutesDiff(start_time, end_time) {var t1 = new Date("January 1, 1999 " + start_time);
var t2 = new Date("January 1, 1999 " + end_time);
var diff = t2.getTime() - t1.getTime();
if (diff == 0) return 0;var daysDifference = Math.floor(diff /1000/60/60/24);
diff -= daysDifference*1000*60*60*24
var hoursDifference = Math.floor(diff/1000/60/60);
diff -= hoursDifference*1000*60*60
var minutesDifference = Math.floor(diff/1000/60);
return minutesDifference;}
function minutesOffset(time) {var t1 = new Date("January 1, 1999 00:00 am");
var t2 = new Date("January 1, 1999 " + time);
var diff = t2.getTime() - t1.getTime();
return Math.floor(diff /1000/60);
}
function checkMaxLength(field, maxlimit, msg) {if (field.value.length > maxlimit){ // if too long...trim it & alert
field.value = field.value.substring(0, maxlimit);
alert(msg + " cannot contain more than " + maxlimit + " characters.");
return false;}
return true;}
function trimString(sInString) {return sInString.replace(/\s+$/g,"");
}
function trim(str){for(var i = 0; i < str.length && str.charAt(i) == " "; i++) ;for(var j = str.length; j > 0 && str.charAt(j-1) == " "; j--) ;if(i > j) return "";return str.substring(i,j);
}
function showHeaderDisplayGroup(groupNum, show) {setDisplay("entiregroup_" + groupNum, show);
}
function toggleHeaderDisplayGroup(groupNum) {toggleDisplay("entiregroup_" + groupNum);
}
function getSelectedRadioObj(elem) {if (elem!=null){if (!elem.length) {return elem.checked ? elem : null;}
for (var i=0; i < elem.length; i++) {if (elem[i].checked){return elem[i];}
}
}
return null;}
function getRadioValue(elem){var selected_rb = getSelectedRadioObj(elem);
if (selected_rb!=null){return selected_rb.value;}
return -1;}
function setRadioValueSelected(elem, value) {if (elem!=null){if (!elem.length) {elem.checked = value && elem.value == value;} else {for (var i=0; i < elem.length; i++) {elem[i].checked = value && elem[i].value == value;}
}
}
}
function disabledWhenChecked(checkbox_elem, elem){elem.disabled = checkbox_elem.checked;}
function enabledWhenChecked(checkbox_elem, elem){elem.disabled = !checkbox_elem.checked;}
function setTransactionLevelCheckbox(groupby_combo_elem, summary_chkbx_elem, target_elem){if (groupby_combo_elem.value == 1 || summary_chkbx_elem.checked){target_elem.checked = false;target_elem.disabled = true;} else {target_elem.disabled = false;}
}
function checkTimeHasDatePortion(date_field,time_field) {if(time_field.value=="")return true;if(date_field.value!="")return true;alert ("If a time value is entered, a date value must be entered as well.");
date_field.focus ();
return false;}
function CQ(question_route,parent_question_route,answer_index){this.route=question_route;this.parent_route=parent_question_route;this.answer_index=answer_index;}
/******************************************************************
*
* Refresh sub questions display
*
******************************************************************/
function displayCQ(route, show, session_context_key) {var tr_row = document.getElementById("tr_" + route);
if (tr_row == null) {if (show) getCustomSubQuestionHTML(route, session_context_key);
return;}
if (!show && tr_row.style.display == "none") return;tr_row.style.display = (show ? "" : "none");
var hr_row = document.getElementById("hr_" + route);
if (hr_row != null) hr_row.style.display = (show ? "" : "none");
var answers = document.getElementsByName("ans." + route);
var k;for (var i = 0; i < answers.length; i++) {if (answers[i].options != null) {var offset = 0;if (answers[i].options.length > 0 && answers[i].options[0].value=="") {offset = 1;}
for (var j = 0; j < answers[i].options.length; j++) {var sub_question_route = document.getElementById("subq_" + route + "_" + (j - offset));
if (sub_question_route != null) {displayCQ(sub_question_route.value, answers[i].selectedIndex==j && show, session_context_key);
} else if (answers[i].selectedIndex==j && show && (typeof CQs != 'undefined') && CQs != null) {for(k=0;k= 0) {var info = row_contents.substring(0,routeidx).split(":");
row_contents = row_contents.substring(routeidx+delimiter.length);
route = info[0];session_key = info[1];}
var insert_idx = -1;var table_element = null;for(i=0;i= 0) {var endidx = row_contents.indexOf("")+5;var next_row = row_contents.substring(idx, endidx);
addTableRowAt(table_element, null, next_row, insert_idx++);
row_contents = row_contents.substring(endidx);
}
parentResizeInner();
if (parent_route != null) {displayCQ(parent_route, true, session_key);
}
} else {alert("Error getting sub-question for display:\n" + req.statusText);
}
}
}
/******************************************************************
*
* Display password strength
*
******************************************************************/
var _password_strength_timer=null;function displaySystemUserPasswordStrengthMeter(password) {if(_password_strength_timer)clearTimeout(_password_strength_timer);
_password_strength_timer=setTimeout("requestPasswordStrengthMeter('" + password + "', true)",200);
}
function displayPasswordStrengthMeter(password) {if(_password_strength_timer)clearTimeout(_password_strength_timer);
_password_strength_timer=setTimeout("requestPasswordStrengthMeter('" + password + "', false)",200);
}
function passwordStrengthCallBack(){if (req.readyState == 4) {if (req.status == 200) {var section = document.getElementById("password_strength_section");
if (section == null) return;section.innerHTML = req.responseText;} else {alert("There was a problem retrieving the XML data:\n" + req.statusText);
}
}
}
function pointOfSaleApplet(com_port,pop_drawer_url,rno,keyboard_revision,site_id,user_name,org_name,org_address1,org_address2,org_city,org_state,org_zip,poslayout_id,popcashdrawer,autocut,smallfont,mediumfont,largefont,smallfontcharcount,mediumfontcharcount,largefontcharcount,ejectlines,cash_customer_id,cash_customer_name,cash_customer_tax_state,cash_customer_tax_country,cash_customer_membership_discounts,receiptheader_id,allow_card_type_1,allow_card_type_2,allow_card_type_3,allow_card_type_4,allow_card_type_5,allow_card_type_6,user_options,sitename,address1,address2,city,site_state,zipcode,p1,daily_close_output,pass_scan_output, enable_pole_display, pole_display_com_port, message_for_pole_display, cursor_first_line, cursor_second_line, clear_display, scroll_text_first_line, scroll_text_second_line, display_clock, character_between_hours_and_minutes,allow_payment_with_cash,allow_payment_by_memo,allow_refund_with_cash,tabbed_admin_ui,front_desk_label,topmost_menu_id,target_tab_id,allow_product_sale,allow_equipment_lending,equipment_label,round_cash_type,round_cash_to_type,eq_lend_success_sign_out_sound,eq_lend_success_sign_in_sound,eq_lend_warn_prereq_sound,eq_lend_warn_max_sound,eq_lend_warn_inv_sound,default_cust_scan_type,cc_scan_with_magtek_device) {var use_tabbed_staff_ui = tabbed_admin_ui && tabbed_admin_ui.length > 0;if(use_tabbed_staff_ui) resizeIFrameForApp(target_tab_id);
var width = window.innerWidth ? Math.floor(parseFloat(window.innerWidth) * 0.98) + "px" : "98%";var height = window.innerHeight ? Math.floor(parseFloat(window.innerHeight) * 0.98) + "px" : "98%";if (use_tabbed_staff_ui && navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {width = "98%";height = "98%";}
document.write('');
}
function passProductionAppletPhotoOnly(filedata, customer_id, imagesource, win_os, return_url, width, height, tabbed_admin_ui, target_tab_id) {passProductionApplet(filedata, customer_id, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
imagesource, win_os, return_url, width, height, tabbed_admin_ui, target_tab_id);
}
function passProductionApplet(filedata, customer_id, name,
address1, address2, city, state,
country, zipcode, hphone, age,
pass_id, passnumber, pass_number_length, lastprinted,
passlayoutname, error_message, imagesource, win_os,
return_url, width, height, tabbed_admin_ui, target_tab_id) {var use_tabbed_staff_ui = tabbed_admin_ui && tabbed_admin_ui.length > 0;if(use_tabbed_staff_ui) resizeIFrameForApp(target_tab_id);
if (use_tabbed_staff_ui && navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {width = width > 0 ? width : "98%";height = height > 0 ? height : "98%";} else {width = width > 0 ? width : window.innerWidth ? Math.floor(parseFloat(window.innerWidth) * 0.98) + "px" : "98%";height = height > 0 ? height : window.innerHeight ? Math.floor(parseFloat(window.innerHeight) * 0.98) + "px" : "98%";}
var driver = win_os.length > 0 ? "morena_windows.jar" : "morena_osx.jar";document.write('');
}
function doStartupRecall(form){var elementArray = "";if (document.getElementById('GenerateList') != null){elementArray = form.definition.value.split(String.fromCharCode(255));
} else {if (document.recallDefinition)
elementArray = document.recallDefinition.definition.value.split(String.fromCharCode(255));
else if (form.definition)
elementArray = form.definition.value.split(String.fromCharCode(255));
else
elementArray = "";}
var lastElement = "";var ver = "";if (elementArray.length > 0 && elementArray[0].indexOf("def_format_ver_") != -1) {ver = elementArray[0];}
with (form){for(i=1; i=0; z--){elem.options[z] = null;}
}
if (etext != " " && elem.options){var opt = new Option(etext, evalue);
elem.options[elem.options.length] = opt;lastElement = ename;}
if (ver == 'def_format_ver_2') elem.disabled = edisabled == 'true';break;}
if(etype == "select-one" || etype == "select"){elem.value = evalue;lastElement = ename;if (ver == 'def_format_ver_2') elem.disabled = edisabled == 'true';break;}
if(etype == "text" || etype == "textarea" || etype == "button" ){elem.value = evalue;lastElement = ename;if (ver == 'def_format_ver_2') elem.disabled = edisabled == 'true';break;}
if(etype == "checkbox-group"){if(evalue != elem.value) continue;elem.checked = true;lastElement = ename;if (ver == 'def_format_ver_2') elem.disabled = edisabled == 'true';break;}
if(etype == "checkbox"){elem.checked = evalue == "true" || evalue == "true ";lastElement = ename;if (ver == 'def_format_ver_2') elem.disabled = edisabled == 'true';break;}
if(etype == "radio"){if(ename != elem.name || evalue != elem.value) continue;elem.checked = true;lastElement = ename;if (ver == 'def_format_ver_2') elem.disabled = edisabled == 'true';}
if(ename == "EmailBodyText"){elem.value = evalue;lastElement = ename;enableDesignMode('rte1', evalue, false);
if (ver == 'def_format_ver_2') elem.disabled = edisabled == 'true';break;}
if(ename == "BodyText"){elem.value = evalue;lastElement = ename;enableDesignMode('rte2', evalue, false);
if (ver == 'def_format_ver_2') elem.disabled = edisabled == 'true';break;}
if(ename == "FooterText"){elem.value = evalue;lastElement = ename;enableDesignMode('rte3', evalue, false);
if (ver == 'def_format_ver_2') elem.disabled = edisabled == 'true';break;}
}
}
}
if (document.getElementById('ApplyAdditionalFilters') != null){elem = document.getElementById('ApplyAdditionalFilters');
if (elem != null && elem.type == "checkbox" && !elem.checked){try {setFilterGroupsDisplay(false);
} catch (err) { }
}
}
if(document.getElementById('WeeklyCalendarLayout')!=null){if(document.getElementById('WeeklyCalendarLayout').options[1].selected){if(document.getElementById('CalendarTimeInterval')!=null) document.getElementById('CalendarTimeInterval').disabled=true;if(document.getElementById('IncludeFacilitiesWithoutBookings')!=null)document.getElementById('IncludeFacilitiesWithoutBookings').disabled=true;}else{if(document.getElementById('CalendarTimeInterval')!=null) document.getElementById('CalendarTimeInterval').disabled=false;if(document.getElementById('IncludeFacilitiesWithoutBookings')!=null)document.getElementById('IncludeFacilitiesWithoutBookings').disabled=false;}
}
if(document.getElementById('SummaryReport')!=null&&document.getElementById('SummaryReport').checked){if(document.getElementById('SortByStreetAddress')!=null)document.getElementById('SortByStreetAddress').disabled=true;if(document.getElementById('SortByOddEvenHouse')!=null)document.getElementById('SortByOddEvenHouse').disabled=true;}else{if(document.getElementById('SortByStreetAddress')!=null)document.getElementById('SortByStreetAddress').disabled=false;if(document.getElementById('SortByOddEvenHouse')!=null)document.getElementById('SortByOddEvenHouse').disabled=false;}
if(document.getElementById('SortByStreetAddress')!=null&&!document.getElementById('SortByStreetAddress').checked){if(document.getElementById('SortByOddEvenHouse')!=null)document.getElementById('SortByOddEvenHouse').disabled=true;}
if (document.getElementById('IncludeTeamTotals') != null){document.getElementById('IncludeTeamTotals').disabled=true;}
if(typeof(onClickSortPagesBy)!='undefined') onClickSortPagesBy(document.getElementById("SortPagesBy"));
if(typeof(onChangeCustomerSkillOption)!='undefined') onChangeCustomerSkillOption(document.getElementById("CustomerSkillOption"));
var showCustAdd = document.getElementById("ShowCustomerAddress");
var showCustAddList = document.getElementById("ShowCustomerAddressList");
if (showCustAdd != null && showCustAddList != null){showCustAdd.value = showCustAddList.value;}
}
function elmLoop(form, emailBodyText, bodyText, footerText){var delim = String.fromCharCode(255);
var elementInfo = "def_format_ver_2";if (emailBodyText){updateRTE('rte1');
form.EmailBodyText.value = getRTEValue();
}
if (bodyText){updateRTE('rte2');
form.BodyText.value = getRTE2Value();
}
if (footerText){updateRTE('rte3');
form.FooterText.value = getRTE3Value();
}
with(form) {for(i=0; i 0){if(elem.type == "select-multiple"){if (elem.options.length > 0){for(var x=0;x= 0){elementInfo += thisElementInfo + delim + elem.options[elem.selectedIndex].value + delim + elem.options[elem.selectedIndex].text + delim + (elem.disabled ? "true" : "false");
}
} else if(elem.type == "text" || elem.type == "textarea" || elem.type == "button" ){elementInfo += thisElementInfo + delim + elem.value + delim + " " + delim + (elem.disabled ? "true" : "false");
} else if(elem.type == "checkbox"){if(document.getElementsByName(elem.name).length > 1){if(elem.checked){elementInfo += delim + elem.name + delim + "checkbox-group" + delim + elem.value + delim + " " + delim + (elem.disabled ? "true" : "false");
}
}else{elementInfo += thisElementInfo + delim + elem.checked + delim + " " + delim + (elem.disabled ? "true" : "false");
}
}else if(elem.type == "radio") {if (elem.checked) {elementInfo += thisElementInfo + delim + elem.value + delim + " " + delim + (elem.disabled ? "true" : "false");
}
} else if(elem.type == "hidden") {elementInfo += thisElementInfo + delim + elem.value + delim + " " + delim + "false";}
}
}
}
if (emailBodyText){elementInfo += delim + "EmailBodyText" + delim + form.EmailBodyText.type + delim + form.EmailBodyText.value + delim + " " + delim + (elem.disabled ? "true" : "false");
}
if (bodyText){elementInfo += delim + "BodyText" + delim + form.BodyText.type + delim + form.BodyText.value + delim + " " + delim + (elem.disabled ? "true" : "false");
}
if (footerText){elementInfo += delim + "FooterText" + delim + form.FooterText.type + delim + form.FooterText.value + delim + " " + delim + (elem.disabled ? "true" : "false");
}
if (document.getElementById('GenerateList') != null){form.definition.value = elementInfo;}else {document.recallDefinition.definition.value = elementInfo;}
}
function addPOSFeatureRow(tableName, reno, pos_product_id, unit_fee){var targetTable = document.getElementById(tableName);
var rows_length = targetTable.rows.length;var newRow = targetTable.insertRow(rows_length);
this["count_"+reno] += 1;var targetRow = targetTable.getElementsByTagName('tr')[0];for (var i=0; i < targetRow.cells.length; i++) {var currentCell = targetRow.cells[i];var temp = currentCell.innerHTML.replace(/id=["']([a-zA-Z0-9_]+)_[0-9]+["']/g, "id='$1_"+this["count_"+reno]+"'");
temp = temp.replace(/name=["']?([a-zA-Z0-9_]+)_[0-9]+['"]?/g, "name='$1_"+this["count_"+reno]+"'");
var newCell = document.createElement("TD");
newCell.innerHTML = temp;newRow.appendChild(newCell);
}
updatePOSQuantity(tableName, reno, pos_product_id, unit_fee);
}
function deletePOSFeatureRow(button, tableName, reno, pos_product_id, unit_fee){var row = button.parentNode.parentNode;var parent = button.parentNode.parentNode.parentNode;var row_count = parent.getElementsByTagName('tr').length;if (row_count > 1){parent.removeChild(row);
updatePOSQuantity(tableName, reno, pos_product_id, unit_fee);
} else
alert("You cannot delete the last row");
}
function updatePOSQuantity(tableName, reno, pos_product_id, unit_fee){var targetTable = document.getElementById(tableName);
var arrQty = targetTable.getElementsByTagName("input");
var newQty = 0;for(var i=0; i < arrQty.length; i++){var elem = arrQty[i];if (elem != null && elem.name.indexOf("posproduct_qty_") != -1){newQty = newQty + parseInt(elem.value);
}
}
elem = document.getElementById("posproduct_qty_"+reno+"_"+pos_product_id);
if (elem != null){elem.value = newQty;}
var fee_elem = document.getElementById("posproduct_fee_"+reno+"_"+pos_product_id);
if (fee_elem != null){fee_elem.value = newQty * parseFloat(unit_fee);
var total_elem = document.getElementById("posproduct_total_"+reno+"_"+pos_product_id);
if (total_elem != null)
total_elem.innerHTML = formatCurrency(fee_elem.value);
}
updatePOSTotal("merchandises_"+reno, reno);
}
function changePOSQuantity(elem, reno, pos_product_id, unit_fee){var line_amount = parseFloat(elem.value) * parseFloat(unit_fee);
var net_amount = line_amount;var coupon_amount = 0;var coupon_amount_available_elem = document.getElementById("coupon_amount_available_"+reno+"_"+pos_product_id);
if (coupon_amount_available_elem != null) {coupon_amount = parseFloat(coupon_amount_available_elem.value);
net_amount = net_amount - Math.min(net_amount,coupon_amount);
var total_less_coupon_elem = document.getElementById("posproduct_total_less_coupon_"+reno+"_"+pos_product_id);
if(total_less_coupon_elem != null) {total_less_coupon_elem.innerHTML = formatCurrency(net_amount);
}
}
var fee_elem = document.getElementById("posproduct_fee_"+reno+"_"+pos_product_id);
if (fee_elem != null){var sub_amount =
fee_elem.value = net_amount;var total_elem = document.getElementById("posproduct_total_"+reno+"_"+pos_product_id);
if (total_elem != null)
total_elem.innerHTML = formatCurrency(line_amount);
}
updatePOSTotal("merchandises_"+reno, reno);
}
function updatePOSTotal(tableName, reno){var targetTable = document.getElementById(tableName);
var arrQty = targetTable.getElementsByTagName("input");
var newSubTotal = 0.0;for(var i=0; i < arrQty.length; i++){var elem = arrQty[i];if (elem != null && elem.name.indexOf("posproduct_fee_") != -1){if (isNaN(elem.value)) elem.value = 0;newSubTotal += parseFloat(elem.value);
}
}
var subtotal_elem = document.getElementById("merchandises_subtotal_"+reno);
subtotal_elem.innerHTML = formatCurrency(newSubTotal);
this["merchandise_subtotal_"+reno] = newSubTotal;updateTotal(reno);
}
function updateTotal(reno){var newTotal = parseFloat(eval("primary_tran_enrollee_subtotal_"+reno)) + parseFloat(eval("membership_subtotal_"+reno)) + parseFloat(eval("merchandise_subtotal_"+reno)) + parseFloat(eval("donation_subtotal_"+reno));
var total_elem = document.getElementById("total_"+reno);
total_elem.innerHTML = formatCurrency(newTotal);
try {checkoutTotalChanged(reno);
} catch (err) {}
}
function updateOnlineDonationTotal(tableName, reno){var targetTable = document.getElementById(tableName);
var arrDonations = targetTable.getElementsByTagName("input");
var newSubTotal = 0.0;for(var i=0; i < arrDonations.length; i++){var elem = arrDonations[i];if (elem != null && elem.name.indexOf("linked_campaign_"+reno) != -1){newSubTotal += parseFloat(elem.value);
}
}
var subtotal_elem = document.getElementById("donation_subtotal_"+reno);
subtotal_elem.innerHTML = formatCurrency(newSubTotal);
this["donation_subtotal_"+reno] = newSubTotal;updateTotal(reno);
}
function validateDonationAmount(field, reno_val) {if (field.value=="")field.value=0;if (isNaN(parseFloat(field.value))) {alert ("The value " + field.value + " is not valid in currency field");
field.focus();
return false;}
if (parseFloat(field.value)<0) {alert ("Only positive donation amounts are acceptable.");
field.focus();
return false;}
field.value = formatCurrency(parseFloat(field.value));
return true;}
function validateLinkedDonation(field, reno_val, enrollmentid_val) {with (field.form) {try {var str = "linked_campaign";if (field.name.indexOf(str) < 0) return true;str = field.name.substring(str.length);
var idx = str.indexOf("_amount");
if (idx >= 0) {str = str.substring(0,idx);
}
if(!eval("validateRecurringDonation"+str+"(field.form, field)")) return false;} catch(err) { }
}
return true;}
var PageHelpContextID = "";function attachHotKey(PageID){}
function handleHotKey(evt){evt = (evt) ? evt : ((event) ? event : null);
if (evt){if (evt.keyCode == 112){ //if user press F1 key
RH_ShowHelp(0, '/cityofpowaycsd/RoboHelp/ActiveNetHelp.htm>WithNavPane', HH_HELP_CONTEXT, PageHelpContextID);
preventEventPropoagation();
}
}
}
function preventEventPropagation(event){if (event.preventDefault)
event.preventDefault();
else
event.returnValue = false; // IE
}
var states_array=[["us","CA,PA,CO,NY,AZ,MA,KS,OX,IL"]];function load_states(country, statelist, statetext) {var list = null;var text = null;if (country.name == "country") {list = country.form.state;text = country.form.statetxt;} else if (country.name == "mailing_country") {list = country.form.mailingstate;text = country.form.mailingstatetxt;} else {list = statelist;text = statetext;}
var old_value = list.value;var new_value = "";list.options.length = 0; //clear out the list
var found = false;for (var i = 0; i < states_array.length; i++) {if (states_array[i][0].toLowerCase() == country.value.toLowerCase()) {found = true; //found the country in our array; load the states
list.options[list.length] = new Option();
var states = states_array[i][1].split(",");
for (var j = 0; j < states.length; j++) {list.options[list.length] = new Option();
list.options[list.length-1].text = states[j];list.options[list.length-1].value = states[j];if (states[j] == old_value) { //if the original state is still valid, we want to keep it
new_value = old_value;}
}
break;}
}
if (found) {list.value = new_value;list.style.display = "";text.style.display = "none";text.value = "";} else {text.style.display = "";list.style.display = "none";list.value = "";}
}
function load_states_cmb(country, states_cmb_name, show_blank) {var list = eval("country.form."+states_cmb_name);
if (list != null){list.options.length = 0; //clear out the list
for (var i = 0; i < states_array.length; i++) {if (states_array[i][0].toLowerCase() == country.value.toLowerCase()) {if (show_blank){list.options[list.length] = new Option();
list.options[list.length-1].text = "All States";}
var states = states_array[i][1].split(",");
for (var j = 0; j < states.length; j++) {list.options[list.length] = new Option();
list.options[list.length-1].text = states[j];list.options[list.length-1].value = states[j];}
break;}
}
}
}
function copyStateRawtoStateCmb(form){if (form.state != null && form.state.style.display == "none") {form.state.options.length = 0;form.state.options[form.state.length] = new Option(form.statetxt.value, form.statetxt.value);
form.state.options[form.state.length-1].selected = true;}
if (form.mailingstate != null){if (form.mailingstate.style.display == "none") {form.mailingstate.options.length = 0;form.mailingstate.options[form.mailingstate.length] = new Option(form.mailingstatetxt.value, form.mailingstatetxt.value);
form.mailingstate.options[form.mailingstate.length-1].selected = true;}
}
}
function getAjaxRequest() {try {if (window.XMLHttpRequest) {return new XMLHttpRequest();
}
if (window.ActiveXObject) {return new ActiveXObject("Microsoft.XMLHTTP");
}
} catch (err) {alert("Error in sendXmlHttpRequest: " + err.description);
}
return null;}
function doAjaxRequest(ajax_request, get_url, call_back_function, submit_method, message, is_waited) {if (submit_method == "" || submit_method == undefined) {submit_method = "GET";}
if (message == "" || message == undefined) {message = null;}
if (is_waited == undefined) {is_waited = false;}
if(authtoken && authtoken.length>0) {get_url += (get_url.indexOf('?') < 0 ? "?" : "&") + "sdireqauth=" + authtoken;}
try {ajax_request.onreadystatechange = call_back_function;ajax_request.open(submit_method, get_url, !is_waited);
if (submit_method == "POST") {ajax_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
ajax_request.send(message);
} catch (err) {alert("Error in doAjaxRequest " + (is_waited ? "for waited request" : "") + " (" + get_url + "): " + err.description);
}
}
function doWaitedXmlHttpRequest(get_url, call_back_function, submit_method, message) {sendXmlHttpRequest(get_url, call_back_function, submit_method, message, true);
}
function doXmlHttpRequest(get_url, call_back_function, submit_method, message) {sendXmlHttpRequest(get_url, call_back_function, submit_method, message, false);
}
function sendXmlHttpRequest(get_url, call_back_function, submit_method, message, is_waited) {req = getAjaxRequest();
doAjaxRequest(req, get_url, call_back_function, submit_method, message, is_waited);
}
function buildPOST(theFormName) {theForm = document.forms[theFormName];var qs = ''
for (e=0;e= min_age_child.value || max_age_parent.value == 0))) continue;return false;}
}
}
return true;}
function publishHeight(topFrameName, parentUrl) {if (parentUrl.length == 0) return;var frameId = topFrameName;if (frameId == '') return;var actualHeight = getBodyHeight();
var currentHeight = getViewPortHeight();
if (Math.abs(actualHeight - currentHeight) > 15) {var hostUrl = parentUrl;hostUrl += "#";hostUrl += 'frameId=' + frameId;hostUrl += '&';hostUrl += 'height=' + actualHeight.toString();
window.top.location = hostUrl;}
}
function getFrameId() {var qs = parseQueryString(window.location.href);
var frameId = qs["frameId"];var hashIndex = frameId.indexOf('#');
if (hashIndex > -1) {frameId = frameId.substring(0, hashIndex);
}
return frameId;}
function getBodyHeight() {var height;var scrollHeight;var offsetHeight;if (document.height) {height = document.height;} else if (document.body) {if (document.body.scrollHeight) {height = scrollHeight = document.body.scrollHeight;}
if (document.body.offsetHeight) {height = offsetHeight = document.body.offsetHeight;}
if (scrollHeight && offsetHeight) {height = Math.max(scrollHeight, offsetHeight);
}
}
return height;}
function getBodyWidth() {var width;var scrollWidth;var offsetWidth;if (document.width) {width = document.width;} else if (document.body) {if (document.body.scrollWidth) {width = scrollWidth = document.body.scrollWidth;}
if (document.body.offsetWidth) {width = offsetWidth = document.body.offsetWidth;}
if (scrollWidth && offsetWidth) {width = Math.max(scrollWidth, offsetWidth);
}
}
return width;}
function getElementBodyWidth(el) {var width;if (el.contentWindow && el.contentWindow.document && el.contentWindow.document.documentElement && el.contentWindow.document.documentElement.scrollWidth) {width = el.contentWindow.document.documentElement.scrollWidth;}
if (el.contentDocument && el.contentDocument.body && el.contentDocument.body.offsetWidth) {if (width) {width = Math.max(width, el.contentDocument.body.offsetWidth);
} else {width = el.contentDocument.body.offsetWidth;}
}
if (el.Document && el.Document.body && el.Document.body.scrollWidth){if (width) {width = Math.max(width, el.Document.body.scrollWidth);
} else {width = el.Document.body.scrollWidth;}
}
if (!width && document.width) {width = document.width;}
return width;}
function getViewPortHeight() {var height = 0;if (window.innerHeight) {height = window.innerHeight - 18;} else if (document.documentElement && document.documentElement.clientHeight) {height = document.documentElement.clientHeight;} else if (document.body && document.body.clientHeight) {height = document.body.clientHeight;}
return height;}
function getViewPortWidth() {var width = 0;if (window.innerWidth) {width = window.innerWidth - 18;} else if (document.documentElement && document.documentElement.clientWidth) {width= document.documentElement.clientWidth;} else if (document.body && document.body.clientWidth) {width= document.body.clientWidth;}
return width;}
function parseQueryString(url) {url = new String(url);
var queryStringValues = new Object();
var querystring = url.substring((url.indexOf('?') + 1), url.length);
var querystringSplit = querystring.split('&');
for (i = 0; i < querystringSplit.length; i++) {var pair = querystringSplit[i].split('=');
var name = pair[0];var value = pair[1];queryStringValues[name] = value;}
return queryStringValues;}
function validIntegerRange (myVal, min, max, msg) {if(!isInteger(myVal.value)){alert(msg + " must be a whole number between " + min + " and " + max + " (inclusive)");
myVal.focus();
return false;}
if(myVal.valuemax){alert(msg + " must be a whole number between " + min + " and " + max + " (inclusive)");
myVal.focus();
return false;}
return true;}
function validMask(field,field_name) {if(emptyField(field))return true;for(var i=0;i 95 || code == 45 || code == 59 || code == 61 || code == 63 || code == 94) {field.value = "";field.focus();
alert("Illegal character entered.");
return false;}
}
return true;}
function validForFileName(field){if (empty(field,"a Name"))return false;var code = "";var display_error = false;var i = 0;for(i = 0; i < field.value.length; i++){code = field.value.charCodeAt(i);
if ( code == 92 ){display_error = true;break;} else if ( code == 47 ){display_error = true;break;} else if ( code == 58 ){display_error = true;break;} else if ( code == 42 ){display_error = true;break;} else if ( code == 63 ){display_error = true;break;} else if ( code == 34 ){display_error = true;break;} else if ( code == 60 ){display_error = true;break;} else if ( code == 62 ){display_error = true;break;} else if ( code == 124 ) {display_error = true;break;}
}
if (display_error){field.focus();
alert("Character '" + field.value.charAt(i) + "' is invalid here, please change it.");
return false;}
return true;}
function onChangeActivityType(field) {}
function calculateBalance() {}
/*****************************************
*
* Parent & Child Season Dynamic Combo for Activities
*
***************************************/
function load_child_seasons(parent_season, except_empty_option) {var list = parent_season.form.child_season_id;if (list == null || list.type != "select-one") {return;}
var old_value = list.value;list.options.length = 0; //clear out the list
var put_empty_option = except_empty_option;for (var i = 0; i < child_seasons_array.length; i++) {if (child_seasons_array[i][0] == parent_season.value || child_seasons_array[i][0] == -1) {if (!put_empty_option) {list.options[list.length] = new Option();
list.options[0].value = 0;put_empty_option = true;}
var child_season_names = child_seasons_array[i][1].split("@::@");
var child_season_ids = child_seasons_array[i][2].split(",");
for (var j = 0; j < child_season_names.length; j++) {list.options[list.length] = new Option();
list.options[list.length-1].text = child_season_names[j];list.options[list.length-1].value = child_season_ids[j];if (child_season_ids[j] == old_value) { //if the original child season is still valid, we want to keep it
list.options[list.length-1].selected=true;}
}
if (child_seasons_array[i][0] != -1) {break;}
}
}
if (list.options.length <= 0) {list.options[0] = new Option();
list.options[0].text = "";list.options[0].value = 0;}
}
function init_child_seasons(parent_season) {var list = parent_season.form.child_season_id;if (list == null || list.type != "select-one") {return;}
list.options.length = 0; //clear out the list
list.options[0] = new Option();
list.options[0].text = "";list.options[0].value = 0;list.options[1] = new Option();
list.options[1].text = "None";list.options[1].value = -1;}
/*****************************************
*
* Validate the color number
*
***************************************/
function validateColorNumber(name, owner, param) {var temp = name.value;var pattern = new RegExp("[a-fA-F0-9]{6}");
var flag1 = pattern.test(temp);
var flag2 = pattern.test(temp.substring(1));
if(temp!=""){if(temp.length >=6 && temp.length <= 7) {if(temp.length == 6 && temp.charAt(0) != '#' && flag1 == true) {temp = "#"+temp;if(owner != null) {self.opener.setColor(param, temp);
window.close();
}
else {name.value = temp;return true;}
}
else if(temp.length == 7 && temp.charAt(0) == '#' && flag2 == true) {if(owner != null) {self.opener.setColor(param, temp);
window.close();
}
else {name.value = temp;return true;}
}
else {alert("Invalid color value");
return false;}
}
else {alert("Invalid color value");
return false;}
}
else {alert("Please input a color");
return false;}
return false;}
/*****************************************
*
* Update age category and birthdate fields
*
***************************************/
function ageCategoryAndBirthDateUpdate(field) {with (field.form) {var isstaff=typeof(birthdate)!='undefined';var isonline=typeof(dobyear)!='undefined';if (field == age_category_id) {if (isonline) {if (!emptyField(field)) {dobyear.value='';dobmonth.selectedIndex=0;dobday.selectedIndex=0;}
} else if (isstaff) {if (!emptyField(field)) birthdate.value='';}
return;}
if (isonline) {if (!emptyField(dobyear)||!emptyField(dobmonth)||!emptyField(dobday))
age_category_id.selectedIndex=0;} else if (isstaff) {if (!emptyField(field))
age_category_id.selectedIndex=0;}
}
}
/*****************************************
*
* Adjust refund total
*
*****************************************/
function adjustTotal(checkbox,rescind_discount,new_value,old_value,max_value, allow_retain_refund_amount, fee_id){with (checkbox.form) {var new_amount = parseFloat(new_value.value);
if (isNaN(new_amount)) {alert ("The value " + new_value.value + " is not valid in currency field");
new_value.focus ();
return false;}
if (!new_value.disabled) {if(rescind_discount.value!=0) {if(new_amount > 0) {alert ("A rescinded discount cannot be used to increase the refund.");
new_value.focus();
return false;}
if (new_amount < parseFloat(max_value)) {alert ("You cannot charge back more than the original discount of $" + max_value);
new_value.focus ();
return false;}
} else {if (new_amount<0){alert ("A refund cannot be negative.");
new_value.focus ();
return false;}
if (new_amount > parseFloat(max_value)) {alert ("You cannot credit more than original payment of $" + max_value);
new_value.focus ();
return false;}
}
}
var new_total=parseFloat(hiddenrefund.value);
if (checkbox.checked) {new_total=parseFloat(hiddenrefund.value)-parseFloat(old_value.value)+new_amount;}
hiddenrefund.value=formatCurrency(new_total);
old_value.value=formatCurrency(new_value.value);
totalrefund.value=formatCurrency(new_total);
if (allow_retain_refund_amount != null && allow_retain_refund_amount.toString().length > 0 && retain_refund_amount.checked) {total_retain_refund_amount.value = formatCurrency(new_total);
if (document.getElementById("refund_charge_amount") != null) {total_retain_refund_amount.value = formatCurrency(total_retain_refund_amount.value - document.getElementById("refund_charge_amount").value);
}
document.getElementById("retain_refund_amount_td_"+fee_id).innerHTML = document.getElementById("refund_"+fee_id).value;}
return true;}
}
/*
* onclick event handler for link to return to a flex app
*/
function gotoApp(app_name, app_key, use_use_tabbed_staff_ui) {try{var main_frame = findFrame('sdi_main');
main_frame.showFlexAppIFrame(app_name, app_key);
return true;}catch(err){}
return false;}
/*
* get mark_as_not_attended flag of choosed attendance code
*/
function getMarkasNotAttended(attendance_code) {if (typeof(attendance_code_array)=='undefined' || typeof(attendance_code)=='undefined') return false;for (var i = 0; i < attendance_code_array.length; i++) {if (attendance_code_array[i][0] == attendance_code.value) {if (attendance_code_array[i][1] == 'checked') return true;return false;}
}
return false;}
/*
* Breadcrumb support
*/
function breadcrumb(type,itemname,linkhref,linktarget,linkonclick) {this.type = type;this.name = itemname;this.linkhref = linkhref;this.linktarget = linktarget;this.linkonclick = linkonclick;}
function breadcrumbToString(breadcrumb) {return ("[Type: " + breadcrumb.type + ", Name: " + breadcrumb.name + ", href: "+breadcrumb.linkhref + ", link element: " + (breadcrumb.link ? breadcrumb.link.href : "none") + ", target: "+breadcrumb.linktarget + ", onclick: " + breadcrumb.linkonclick + ", altname: " + (breadcrumb.altname ? breadcrumb.altname : "null") + "]");
}
function setTopLevelBreadcrumbs(stack){updateBreadcrumbDisplay(stack);
}
function setFunctionPageBreadcrumb(function_menu_group, function_title, url){if (!url || url.length==0) url = location.href;if (function_title.length==0) return;var stack = new Array();
stack[0] = new breadcrumb("currentpage", null, null, null, null); // clear the currentpage element
stack[1] = new breadcrumb("fnpage_"+function_menu_group, function_title, url, self.name, null);
updateBreadcrumbDisplay(stack);
}
function addStaticBreadcrumb(type,name) {if (name.length==0) return;updateBreadcrumbDisplay(new breadcrumb(type, name, null, null, null));
}
function setCurrentPageBreadcrumb(page_title){updateBreadcrumbDisplay(new breadcrumb("currentpage", page_title, location.href, self.name, null));
}
function updateBreadcrumbDisplay(breadcrumbs) {try{var breadcrumbFrame = self && self.name && self.name=='sdi_main_nav' ? self : findFrame('sdi_main_nav');
if (breadcrumbFrame && breadcrumbFrame.updateBreadcrumbs) {breadcrumbFrame.updateBreadcrumbs(breadcrumbs, self.name);
return;}
breadcrumbFrame = self && self.name && self.name=='admin_banner' ? self : findFrame('admin_banner');
if (breadcrumbFrame && breadcrumbFrame.updateBreadcrumbs) {breadcrumbFrame.updateBreadcrumbs(breadcrumbs);
return;}
breadcrumbFrame = self && self.name && self.name=='sdi_main' ? self : findFrame('sdi_main');
if (breadcrumbFrame && breadcrumbFrame.updateBreadcrumbs){breadcrumbFrame.updateBreadcrumbs(breadcrumbs);
return;}
if (self && self.name && self.name=='sdi_main' && self.frames[1]) breadcrumbFrame = self.frames[1];if (breadcrumbFrame && breadcrumbFrame.updateBreadcrumbs){breadcrumbFrame.updateBreadcrumbs(breadcrumbs);
return;}
}catch(err){}
}
function breadcrumbsXMLToArray(breadcrumbsXML) {var breadcrumb_array = new Array();
var bc_set = breadcrumbsXML.getElementsByTagName("bc");
for(var i=0;i"
+ breadcrumb.type + ""
+ breadcrumb.name + ""
+ breadcrumb.linkhref + ""
+ breadcrumb.linktarget + ""
+ breadcrumb.linkonclick + "";}
return xml_string + "";}
function ANEncodeURL(url) {return url.replace(/\?/g,"@Q@").replace(/=/g,"@E@").replace(/&/g,"@A@");
}
function ANDecodeURL(url) {var real_part = url;var idx = url.indexOf("&breadcrumbs")
if (idx != -1) {real_part = url.substring(0, idx-1);
}
real_part = real_part.replace(/@Q@/g,"?").replace(/@E@/g,"=").replace(/@A@/g,"&")
if (idx != -1) real_part = real_part + url.substring(idx);
return real_part;}
/*
* Check if there is dirty form data in target frame. If there is dirty form data
* then ask the user if they want to continue.
*/
function userCancelForDirtyForms(oFrame,menu_name){if (!dirtyFormsInFrame(oFrame)) return false;var form_title = "current";if (oFrame.document && oFrame.document.title) {form_title = oFrame.document.title;} else if (oFrame.contentDocument && oFrame.contentDocument.title) {form_title = oFrame.contentDocument.title;}
var confirm_msg = "You have changed one or more fields in the " + form_title + " form. If you continue the form data will NOT be processed or saved. Are you sure you wish to continue";if(menu_name && menu_name.length>0) {confirm_msg += " to '" + menu_name + "'";}
confirm_msg += "?";var answer = confirm (confirm_msg);
if (answer) {return false;} else {return true;}
}
/*
* Check if requested frame contains any dirty forms
*/
function dirtyFormsInFrame(oFrame){try {var child_iframes;try {child_iframes = oFrame.window ? oFrame.window.frames : null;if (!child_iframes || child_iframes.length == 0) {child_iframes = oFrame.contentWindow.document.getElementsByTagName("iframe");
}
} catch (ierr) {}
for (var index = 0; index < child_iframes.length; index++) {var current_iframe = child_iframes[index];var el;el = null;if (oFrame.document) el = oFrame.document.getElementById('chk' + current_iframe.name);
if (el==null && oFrame.contentWindow && oFrame.contentWindow.document) {el = oFrame.contentWindow.document.getElementById('chk' + current_iframe.name);
}
if (el != null) {var original_value = el.value;var current_doc = current_iframe.contentWindow && current_iframe.contentWindow.document ? current_iframe.contentWindow.document : current_iframe.document;var current_value = current_doc.getElementsByTagName('body')[0].innerHTML;doWaitedXmlHttpRequest('checkHTMLfield.sdi', null, "POST", 'get_value=true&check_value1=' + encodeURIComponent(current_value) + '&check_value2=' + encodeURIComponent(original_value));
if (req.responseText == "false") {return true;}
}
}
for (var i=0; i < oFrame.document.forms.length; i++) {if (isFormDirty(oFrame.document.forms[i])) {return true;}
}
} catch (err) {}
try {for (var j=0; j < oFrame.contentDocument.forms.length; j++) {if (isFormDirty(oFrame.contentDocument.forms[j])) {return true;}
}
} catch (err) {}
return false;}
/*
* Check if form is dirty
*/
function isFormDirty(oForm){if (oForm.noNeedCheckForm&&oForm.noNeedCheckForm.value.length>0) return false;if(oForm.formIsDirtyFlag&&oForm.formIsDirtyFlag.value.length>0) return true;var el, opt, hasDefault, i = 0, j;while ((el = oForm.elements[i++])) {if (el.disabled) continue;switch (el.type) {case 'text' :
case 'textarea' :
case 'password' :
if (el.value != el.defaultValue) {return true;}
break;case 'checkbox' :
case 'radio' :
if (el.checked != el.defaultChecked) {return true;}
break;case 'select-one' :
case 'select-multiple' :
j = 0, hasDefault = false;while ((opt = el.options[j++])) {if (opt.defaultSelected) hasDefault = true;}
j = hasDefault ? 0 : 1;while ((opt = el.options[j++])) {if (opt.selected != opt.defaultSelected) {return true;}
}
break;}
}
return false;}
function isElementDirty(el){if (el.disabled) return false;switch (el.type) {case 'text' :
case 'textarea' :
case 'password' :
if (el.value != el.defaultValue) {return true;}
break;case 'checkbox' :
case 'radio' :
if (el.checked != el.defaultChecked) {return true;}
break;case 'select-one' :
case 'select-multiple' :
j = 0, hasDefault = false;while ((opt = el.options[j++])) {if (opt.defaultSelected) hasDefault = true;}
j = hasDefault ? 0 : 1;while ((opt = el.options[j++])) {if (opt.selected != opt.defaultSelected) {return true;}
}
break;}
}
/*
* Clear form "dirty" status
*/
function resetFormDirty(oForm){var el, opt, i = 0;while ((el = oForm.elements[i++])) {if (el.disabled) continue;switch (el.type) {case 'text' :
case 'textarea' :
el.defaultValue = el.value;break;case 'checkbox' :
case 'radio' :
el.defaultChecked = el.checked;break;case 'select-one' :
case 'select-multiple' :
var j = 0;while ((opt = el.options[j++])) {opt.defaultSelected = opt.selected;}
break;}
}
}
sorttable = {init: function() {if (arguments.callee.done) return;arguments.callee.done = true;if (!document.createElement || !document.getElementsByTagName) return;sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;forEach(document.getElementsByTagName('table'), function(table) {if (table.className.search(/\btableList\b/) != -1) {sorttable.makeSortable(table);
}
});
},
makeSortable: function(table) {if (table.getElementsByTagName('thead').length == 0) {the = document.createElement('thead');
the.appendChild(table.rows[0]);
table.insertBefore(the,table.firstChild);
}
if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];if (table.tHead.rows.length != 1) return; // can't cope with two header rows
sortbottomrows = [];for (var i=0; i6' : ' ▾';this.appendChild(sortrevind);
return;}
if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {sorttable.reverse(this.sorttable_tbody);
this.className = this.className.replace('sorttable_sorted_reverse',
'sorttable_sorted');
if (document.getElementById('sorttable_sortrevind') != null) this.removeChild(document.getElementById('sorttable_sortrevind'));
sortfwdind = document.createElement('span');
sortfwdind.id = "sorttable_sortfwdind";sortfwdind.innerHTML = $.browser.msie ? ' 5' : ' ▴';this.appendChild(sortfwdind);
return;}
theadrow = this.parentNode;forEach(theadrow.childNodes, function(cell) {if (cell.nodeType == 1) { // an element
cell.className = cell.className.replace('sorttable_sorted_reverse','');
cell.className = cell.className.replace('sorttable_sorted','');
}
});
sortfwdind = document.getElementById('sorttable_sortfwdind');
if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
sortrevind = document.getElementById('sorttable_sortrevind');
if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
this.className += ' sorttable_sorted';sortfwdind = document.createElement('span');
sortfwdind.id = "sorttable_sortfwdind";sortfwdind.innerHTML = $.browser.msie ? ' 5' : ' ▴';this.appendChild(sortfwdind);
row_array = [];col = this.sorttable_columnindex;rows = this.sorttable_tbody.rows;for (var j=0; j 1) {row_array[row_array.length] = new Array(rows[j].cells[0].rowSpan+1);
row_array[row_array.length-1][0] = sorttable.getInnerText(rows[j].cells[col]);
for (var x=1; x<=rows[j].cells[0].rowSpan; x++) {row_array[row_array.length-1][x] = rows[j+x-1];}
j+=rows[j].cells[0].rowSpan-1;} else {row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]];}
}
/* If you want a stable sort, uncomment the following line */
/* and comment out this one */
row_array.sort(this.sorttable_sortfunction);
tb = this.sorttable_tbody;for (j=0; j 4 && !isNaN(Date.parse(new Date("January 1, 1999 " + text.toString())))) {active_time_count++;continue;}
possdate = text.match(sorttable.DATE_RE)
if (possdate) {first = parseInt(possdate[1]);
second = parseInt(possdate[2]);
if (first > 12) {date_count1++;} else if (second > 12) {date_count2++;} else {date_count1++;}
}
}
}
if (count == num_count) return sorttable.sort_numeric;if (count == date_count1) return sorttable.sort_ddmm;if (count == date_count2) return sorttable.sort_mmdd;if (count == active_date_count) return sorttable.sort_activenet_date;if (count == active_time_count) return sorttable.sort_activenet_time;return sorttable.sort_alpha;},
getInnerText: function(node) {if (!node) return '';switch (node.nodeType) {case 3:
case 4:
return node.nodeValue.replace(/^\s+|\s+$/g, '').toLowerCase();
break;case 1:
case 11:
if (node.nodeName.toLowerCase() == 'select') {return node.options[node.selectedIndex].text.replace(/^\s+|\s+$/g, '').toLowerCase();
}
hasInputs = false;hasInputs = node.getElementsByTagName('input') && node.getElementsByTagName('input').length;hasInputs = hasInputs || (node.getElementsByTagName('select') && node.getElementsByTagName('select').length);
if (node.getAttribute("sorttable_customkey") != null) {return node.getAttribute("sorttable_customkey");
} else if (typeof node.value != 'undefined' && !hasInputs) {if (node.type != 'undefined' && node.type=='hidden') return "";return node.value.replace(/^\s+|\s+$/g, '').toLowerCase();
} else if (typeof node.textContent != 'undefined' && !hasInputs) {return node.textContent.replace(/^\s+|\s+$/g, '').toLowerCase();
} else if (typeof node.innerText != 'undefined' && !hasInputs) {return node.innerText.replace(/^\s+|\s+$/g, '').toLowerCase();
} else if (typeof node.text != 'undefined' && !hasInputs) {return node.text.replace(/^\s+|\s+$/g, '').toLowerCase();
} else {var innerText = '';for (var i = 0; i < node.childNodes.length; i++) {innerText += sorttable.getInnerText(node.childNodes[i]).toLowerCase();
}
return innerText.replace(/^\s+|\s+$/g, '').toLowerCase();
}
break;default:
return '';}
},
reverse: function(tbody) {newrows = [];for (var i=0; i 1) {rowspan_first_rows[rowspan_first_rows.length]=i;}
}
if (rowspan_first_rows.length > 0) {for (i=rowspan_first_rows.length-1; i>=0; i--) {var end = i < rowspan_first_rows.length-1 ? rowspan_first_rows[i+1] : newrows.length;for (var j=rowspan_first_rows[i]; j=0; i--) {tbody.appendChild(newrows[i]);
}
}
delete newrows;},
/* sort functions
each sort function takes two parameters, a and b
you are comparing a[0] and b[0] */
sort_numeric: function(a,b) {aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
if (isNaN(aa)) aa = 0;bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
if (isNaN(bb)) bb = 0;return aa-bb;},
sort_alpha: function(a,b) {if (a[0] == "--" || a[0] == "-") {a[0] = "";}
if (b[0] == "--" || b[0] == "-") {b[0] = "";}
if (a[0]==b[0]) return 0;if (a[0] 0 ) {var q = list[i]; list[i] = list[i+1]; list[i+1] = q;swap = true;}
} // for
t--;if (!swap) break;for(i = t; i > b; --i) {if ( comp_func(list[i], list[i-1]) < 0 ) {q = list[i]; list[i] = list[i-1]; list[i-1] = q;swap = true;}
} // for
b++;} // while(swap)
}
}
/* ******************************************************************
Supporting functions: bundled here to avoid depending on a library
****************************************************************** */
function dean_addEvent(element, type, handler) {if (element.addEventListener) {element.addEventListener(type, handler, false);
} else {if (!handler.$$guid) handler.$$guid = dean_addEvent.guid++;if (!element.events) element.events = {};var handlers = element.events[type];if (!handlers) {handlers = element.events[type] = {};if (element["on" + type]) {handlers[0] = element["on" + type];}
}
handlers[handler.$$guid] = handler;element["on" + type] = handleEvent;}
};dean_addEvent.guid = 1;function removeEvent(element, type, handler) {if (element.removeEventListener) {element.removeEventListener(type, handler, false);
} else {if (element.events && element.events[type]) {delete element.events[type][handler.$$guid];}
}
};function handleEvent(event) {var returnValue = true;event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
var handlers = this.events[event.type];for (var i in handlers) {this.$$handleEvent = handlers[i];if (this.$$handleEvent(event) === false) {returnValue = false;}
}
return returnValue;};function fixEvent(event) {event.preventDefault = fixEvent.preventDefault;event.stopPropagation = fixEvent.stopPropagation;return event;};fixEvent.preventDefault = function() {this.returnValue = false;};fixEvent.stopPropagation = function() {this.cancelBubble = true;}
/*
forEach, version 1.0
Copyright 2006, Dean Edwards
License: http://www.opensource.org/licenses/mit-license.php
*/
if (!Array.forEach) { // mozilla already supports this
Array.forEach = function(array, block, context) {for (var i = 0; i < array.length; i++) {block.call(context, array[i], i, array);
}
};}
Function.prototype.forEach = function(object, block, context) {for (var key in object) {if (typeof this.prototype[key] == "undefined") {block.call(context, object[key], key, object);
}
}
};String.forEach = function(string, block, context) {Array.forEach(string.split(""), function(chr, index) {block.call(context, chr, index, string);
});
};var forEach = function(object, block, context) {if (object) {var resolve = Object; // default
if (object instanceof Function) {resolve = Function;} else if (object.forEach instanceof Function) {object.forEach(block, context);
return;} else if (typeof object == "string") {resolve = String;} else if (typeof object.length == "number") {resolve = Array;}
resolve.forEach(object, block, context);
}
};function addRemoveAllSelected(table_id, add_remove) {var inputs = document.getElementById(table_id).getElementsByTagName("input");
for (var j = 0; j < inputs.length; j++) {var element = inputs[j];if(element.type!="checkbox")continue;if(!element.checked)continue;var s = element.name;if(s.substring(s.indexOf("_"),s.indexOf("_")+8)!="_select_")continue;var cust_id=s.substring(0,s.indexOf("_"));
s=s.substring(s.indexOf("_")+1);
var cust_name=s.substring(s.indexOf("_")+1);
if(add_remove)addItemToParent(cust_id,cust_name);
else removeItemToParent(cust_id,cust_name);
}
}
/*
* Set checkbox selection checked/cleared state of all checkbox fields in requested
* table to match that of the passed checkbox field. The checkbox fields name
* is expected to start with the passed checkbox_name_prefix OR with _select_ .
* Any checkbox in the requested table that does not match that naming format will
* not be selected/deselected.
*/
function selectAndDeSelectAll(table_id, field, checkbox_name_prefix) {var inputs = document.getElementById(table_id).getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {var element = inputs[i];if (element.type != "checkbox") continue;if (element.disabled == true) continue;var s = element.name;if(checkbox_name_prefix && checkbox_name_prefix.length > 0) {if (s.indexOf(checkbox_name_prefix)!=0) continue;} else {if (s.substring(s.indexOf("_"),s.indexOf("_")+8) != "_select_") continue;}
element.checked = field.checked;}
}
function selectAndDeSelectAllByValue(table_id, value, checkbox_name_prefix) {var inputs = document.getElementById(table_id).getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {var element = inputs[i];if (element.type != "checkbox") continue;if (element.disabled == true) continue;var s = element.name;if(checkbox_name_prefix && checkbox_name_prefix.length > 0) {if (s.indexOf(checkbox_name_prefix)!=0) continue;} else {if (s != "select_all" && s.substring(s.indexOf("_"),s.indexOf("_")+8) != "_select_") continue;}
element.checked = value;}
}
function selectAllCheckbox(table_id, value) {var inputs = document.getElementById(table_id).getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {var element = inputs[i];if (element.type != "checkbox") continue;if (element.disabled == true) continue;element.checked = value;}
}
function onSiteChange(site, location, online){if (!document.getElementById(location)) {if (document.listselect) startSubmit('listselect');
} else {$.get('getCenters.sdi',
{site_id: site.value, online: online},
function(data){var sel = $("#"+location);
if (sel.length == 0) return;var all_loc_opt = sel.find('option[value=0]');
var other_spec_opts = sel.find('option[value*=-]');
sel.empty();
sel.append(all_loc_opt);
sel.append(data);
sel.append(other_spec_opts);
sel.get(0).selectedIndex = 0;sel.change();
});
}
if (online && self.updateInstructor) {updateInstructor(site);
}
}
/******************************************************************************************************
* This function used for list page to control show Specific Value Items or NOT (Ex: Show Retired?).
* The default value is "YES", you also can specific the value as need.
* NOTE: master field check box and the list items must be in a same table
******************************************************************************************************/
function showSpecificValueItemsOrNot(masterField, startRowIndex, columnIndex, bottomRowNumber, value) {if (value == null || value == undefined) {value = "YES";} else {value = value.toUpperCase();
}
var table = masterField.parentNode;while(table != null && table != undefined && table.tagName != "TABLE"){table = table.parentNode;}
if (table == null || table == undefined) return;var show_retired = masterField.checked;for (var i=startRowIndex; i 0) {try {var el = parent.document.getElementById(self.name);
if (el) {el.style.overflow = "auto";el.scrolling = "auto";}
if (is_app_load) {resizeIFrameForApp('');
} else {el.style.height='';}
if (el && el.className=='content_iframe') {scrollHome('sdi_main');
}
} catch (err){}
}
}
/*
* Handler for close event on a receipt tab
*/
function handleReceiptTabCloseEvent(rno, is_pending_receipt_empty) {var answer = is_pending_receipt_empty ? true : confirm ("If you continue, receipt #" + rno + " will be cancelled. Do you want to continue and cancel this receipt?");
if (answer) {doXmlHttpRequest("ReceiptVoid.sdi?rno="+rno+"&ajax_id="+rno, function(){});
} else {return false; // User cancelled
}
return true; // Ok to proceed
}
/*
* Add a hidden field to a form
*/
function addHiddenField(form, name, id, value, check_duplicate) {if (check_duplicate) {for (var i=0; i 0) {curr_frame_name = curr_frame_name + '.frames[' + i + ']';y[level] = i + 1;level++;y[level] = 0;var fr = findChildFrame(curr_frame_name, frame_name); // recursive call to check child frames for curr frame
if (fr) {return fr;}
break;}
}
curr_frame_name = level == 0 ? '' : curr_frame_name.substring(0,curr_frame_name.lastIndexOf('.'));
level--;}
return null; // didn't find frame'
}
function clearInputFieldValue(names) {var field_names = names.split(",");
for (var i=0; i (round_cash_to/2)) {rounded_amount = (Math.round(parseFloat(rounded_amount)*100) + Math.round(parseFloat(round_cash_to)*100))/100;}
break;case 2:
if (remaining_amount >= round_cash_to/2) {rounded_amount = (Math.round(parseFloat(rounded_amount)*100) + Math.round(parseFloat(round_cash_to)*100))/100;}
break;case 3:
rounded_amount = (Math.round(parseFloat(rounded_amount)*100) + Math.round(parseFloat(round_cash_to)*100))/100;break;default:
break;}
return rounded_amount;}
/**
* jQuery.fn.sortElements
* --------------
* @param Function comparator:
* Exactly the same behaviour as [1,2,3].sort(comparator)
*
* @param Function getSortable
* A function that should return the element that is
* to be sorted. The comparator will run on the
* current collection, but you may want the actual
* resulting sort to occur on a parent or another
* associated element.
*
* E.g. $('td').sortElements(comparator, function(){* return this.parentNode;* })
*
* The | 's parent ( | ) will be sorted instead
* of the itself.
*/
jQuery.fn.sortElements = (function(){var sort = [].sort;return function(comparator, getSortable) {getSortable = getSortable || function(){return this;};var placements = this.map(function(){var sortElement = getSortable.call(this),
parentNode = sortElement.parentNode,
nextSibling = parentNode.insertBefore(
document.createTextNode(''),
sortElement.nextSibling
);
return function() {if (parentNode === this) {throw new Error(
"You can't sort elements if any one is a descendant of another."
);
}
parentNode.insertBefore(this, nextSibling);
parentNode.removeChild(nextSibling);
};});
return sort.call(this, comparator).each(function(i){placements[i].call(getSortable.call(this));
});
};})();
/***************************************************
*
* Format phone number when changed calling code
*
***************************************************/
function changeCallingCode(field, init) {var $td = $(field).parent();
var name = $(field).attr("name");
var prefix = name.substring(0, name.indexOf("_"));
var country_code = $(field).val().substring($(field).val().length - 2);
var phone_number = "";var area = "";var phone = "";var ext = "";var $phone_span = $td.find(".phoneNumber");
var form_name = "";if ($(field).parents().find("form").size() > 0) {form_name = $(field).parents().find("form").attr("name");
}
if (init) {if ($td.find("input[type=hidden]").size() > 0) {var hidden_phone_number = $td.find("input[type=hidden]").val();
if (hidden_phone_number.charAt(0) == "+") {for (var i = 1; i < hidden_phone_number.length; i++) {if (isNaN(hidden_phone_number.charAt(i))) {phone_number = hidden_phone_number.substring(i + 2);
break;}
}
} else {phone_number = hidden_phone_number;}
}
} else {if ($phone_span.find("input[name$=area]").size() > 0) phone_number += $phone_span.find("input[name$=area]").val();
if ($phone_span.find("input[name$=phone]").size() > 0) phone_number += $phone_span.find("input[name$=phone]").val();
if ($phone_span.find("input[name$=ext]").size() > 0) phone_number += $phone_span.find("input[name$=ext]").val();
}
if (country_code == "" || country_code == "US" || country_code == "CA") {if (phone_number.length > 0) {area = phone_number.substring(0, Math.min(3, phone_number.length));
if (phone_number.length > 3) phone = phone_number.substring(3, Math.min(10, phone_number.length));
if (phone_number.length > 10) ext = phone_number.substring(10, Math.min(16, phone_number.length));
}
$phone_span.html(" ( "
+ " ) 0 ? " onBlur='leavePhone(document." + form_name + "." + prefix + "area,this)'>" : "")
+ " Ext ");
} else if (country_code == "AU") {if (prefix == "c") {if (phone_number.length > 0) {phone = phone_number.substring(0, Math.min(10, phone_number.length));
}
$phone_span.html(" 0 ? " onBlur='leavePhone(document." + form_name + "." + prefix + "area,this)'>" : "")
+ " ");
} else {if (phone_number.length > 0) {area = phone_number.substring(0, Math.min(2, phone_number.length));
if (phone_number.length > 2) phone = phone_number.substring(2, Math.min(10, phone_number.length));
if (phone_number.length > 10) ext = phone_number.substring(10, Math.min(16, phone_number.length));
}
$phone_span.html(" ( "
+ " ) 0 ? " onBlur='leavePhone(document." + form_name + "." + prefix + "area,this)'>" : "")
+ " Ext ");
}
} else if (country_code == "NZ") {if (prefix == "c") {if (phone_number.length > 0) {phone = phone_number;}
$phone_span.html(" 0 ? " onBlur='leavePhone(document." + form_name + "." + prefix + "area,this)'>" : "")
+ " ");
} else {if (phone_number.length > 0) {area = phone_number.substring(0, Math.min(2, phone_number.length));
if (phone_number.length > 2) phone = phone_number.substring(2, Math.min(9, phone_number.length));
if (phone_number.length > 9) ext = phone_number.substring(9, Math.min(15, phone_number.length));
}
$phone_span.html(" ( "
+ " ) 0 ? " onBlur='leavePhone(document." + form_name + "." + prefix + "area,this)'>" : "")
+ " Ext ");
}
} else {if (prefix == "c") {if (phone_number.length > 0) {phone = phone_number;}
$phone_span.html(""
+ " 0 ? " onBlur='leavePhone(document." + form_name + "." + prefix + "area,this)'>" : "")
+ " ");
} else {if (phone_number.length > 0) {var index = phone_number.indexOf("-");
if (index > 0) {phone = phone_number.substring(0, Math.min(20, index));
ext = phone_number.substring(index + 1, Math.min(26, index + 6));
} else {phone = phone_number.substring(0, Math.min(20, phone_number.length));
if (phone_number.length > 20) ext = phone_number.substring(20, Math.min(26, phone_number.length));
}
}
$phone_span.html(""
+ " 0 ? " onBlur='leavePhone(document." + form_name + "." + prefix + "area,this)'>" : "")
+ " Ext ");
}
}
}
/***********************************************************************
*
* set a sortable table to be JQuery sortable (with drag row feature)
* Note class "handle" stand of drag handle for individual row
*
************************************************************************/
function initJQSortableTable(){var $table = $(".jqsortable_table");
$table.find("tbody").sortable({handle : '.handle',
helper: function(e, ui) {ui.children().each(function() {$(this).width($(this).width());
});
return ui;},
stop: function(event, ui) {$table.find("thead").find(".sorttable_sorted, .sorttable_sorted_reverse").removeClass("sorttable_sorted sorttable_sorted_reverse");
$("#sorttable_sortfwdind, #sorttable_sortrevind").remove();
}
});
$table.find("tbody").find(":input").change(function(e){$(this).parents("table.jqsortable_table").find("thead").find(".sorttable_sorted, .sorttable_sorted_reverse").removeClass("sorttable_sorted sorttable_sorted_reverse");
$("#sorttable_sortfwdind, #sorttable_sortrevind").remove();
});
}
/**********************
* tool for preload images if we want
*/
function preloadImages() {for(var i = 0; i < arguments.length; i++) {$(" ").attr('src', arguments[i]);
}
}
/************************
* tool for in processing dialog, may wanna use it for the case form need long time for processing
*/
function initProgress() {preloadImages("/cityofpowaycsd/spinning_busy.gif");
}
function showProgress(position_of) {if (!position_of) {position_of = (parent && $(parent.window).scrollTop() > 0) ? parent.window : window;}
if ($("#process_dialog").length == 0) {$("body").append("Please wait...  ");
$("#process_dialog").css({border: 'none',
padding: '15px',
backgroundColor: '#000',
opacity: .5,
display: "none",
color: '#fff',
position: 'absolute',
width: "180px",
top: 100
});
}
if ($("#process_dialog_overlay").length == 0) {$('').addClass('ui-widget-overlay').appendTo(document.body).css({width: $.ui.dialog.overlay.width(),
height: $.ui.dialog.overlay.height()
});
} else {$("#process_dialog_overlay").show();
}
$(window).bind('resize.process_dialog', function(){$("#process_dialog_overlay").css({width: 0,
height: 0
}).css({width: $.ui.dialog.overlay.width(),
height: $.ui.dialog.overlay.height()
});
});
$("#process_dialog").show().position({my: 'center',
at: 'center',
of: position_of,
collision: 'fit'
});
}
function hideProgress() {$("#process_dialog, #process_dialog_overlay").hide();
}
String.prototype.endWith=function(str){if(str == null || str == ""|| this.length == 0 || str.length > this.length) return false;return this.substring(this.length - str.length) == str;}
String.prototype.startWith=function(str){if(str == null || str == "" || this.length == 0 || str.length > this.length) return false;return this.substring(0,str.length) == str;}
| |