function MM_jumpMenu(targ, selObj, restore) { //v3.0 eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'"); if (restore) selObj.selectedIndex = 0; } function openWin(fileName, windowName, wwidth, wheight) { window.open(fileName, windowName, 'width=' + wwidth + ',height=' + wheight + ',directories=no,location=no,menubar=no, scrollbars=yes,status=no,toolbar=no,resizable=no'); } function urlredirect(myurl) { location.href = myurl; } function checklogin(activationcode) { if (activationcode == "1234") { location.href = '1_4_ActivationCodeLandingPage.html'; } else { location.href = 'membership/13_0_MembershipSiteHomePage.html'; } } function confirmit(yesurl, nourl) { var yesno = confirm("You have not yet saved your changes. Do you wish to save your changes now?"); if (yesno == true) { window.location = yesurl; } else { window.location = nourl; } } function getpic() { total = 6 path = "images/headers/" width = 891 height = 189 num = Math.random() picnum = Math.round(num * (total - 1)); pic = "HomeAgain"; } getpic() maxlimit = 200; function checkMaxInput(field) { if (field.value.length > maxlimit) // if too long...trim it! field.value = field.value.substring(0, maxlimit); } maxMessage = 256 function checkMessageInput(textarea) { if (textarea.value.length > maxMessage) textarea.value = textarea.value.substring(0, maxMessage); } var other_breed_length = 75; // db value 100 var other_characteristics_length = 75; // db value 200 var location_last_seen_length = 100; // db value 100 var poster_comments_length = 225; // db value 2000 function checkOtherBreedLength(textarea) { return checkMessageInput(textarea, other_breed_length); } function checkOtherCharacteristicsLength(textarea) { return checkMessageInput(textarea, other_characteristics_length); } function checkLocationLastSeenLength(textarea) { checkMessageInput(textarea, location_last_seen_length); var label = document.getElementById("charactersLeft100"); if (label != null) label.innerHTML = location_last_seen_length - textarea.value.length; return; } function checkPosterCommentsLength(textarea) { checkMessageInput(textarea, poster_comments_length); var label = document.getElementById("charactersLeft225"); if (label != null) label.innerHTML = poster_comments_length - textarea.value.length; return; } function checkMessageInput(textarea, length) { if (textarea.value.length > length) { textarea.value = textarea.value.substring(0, length); } } /** * Function resubmits the petId form and disabling all the buttons while form is submitting */ function resubmitPetIdForm(button, hidden) { hidden.value = button.value; var postForm = document.forms[0]; for (var i = 0; i < postForm.length; i++) { var tempobj = postForm.elements[i] if (tempobj.type && (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset" || tempobj.type.toLowerCase() == "button")) tempobj.disabled = true } document.forms[0].submit(); return false; } function displayConfirm(message) { var pageName = document.getElementById('page').value; if (pageName == "managePetProfile") return true; var select = document.all['microchipId']; var n = select.selectedIndex; var selectMicrochipId = select.options[n].value; var selectStatus = document.getElementById(selectMicrochipId).value; if (selectStatus == 'L') { var res = window.confirm(message); if (res) { return true; } else { return false; } } } /** * copied from validation-rules.xml */ function checkEmail(emailStr) { if (emailStr.length == 0) { return true; } var emailPat = /^(.+)@(.+)$/; var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"; var validChars = "\[^\\s" + specialChars + "\]"; var quotedUser = "(\"[^\"]*\")"; var ipDomainPat = /^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/; var atom = validChars + '+'; var word = "(" + atom + "|" + quotedUser + ")"; var userPat = new RegExp("^" + word + "(\\." + word + ")*$"); var domainPat = new RegExp("^" + atom + "(\\." + atom + ")*$"); var matchArray = emailStr.match(emailPat); if (matchArray == null) { return false; } var user = matchArray[1]; var domain = matchArray[2]; if (user.match(userPat) == null) { return false; } var IPArray = domain.match(ipDomainPat); if (IPArray != null) { for (var i = 1; i <= 4; i++) { if (IPArray[i] > 255) { return false; } } return true; } var domainArray = domain.match(domainPat); if (domainArray == null) { return false; } var atomPat = new RegExp(atom, "g"); var domArr = domain.match(atomPat); var len = domArr.length; if ((domArr[domArr.length - 1].length < 2) || (domArr[domArr.length - 1].length > 3)) { return false; } if (len < 2) { return false; } return true; } function popAdd(isSearching, redirectTo) { var search = "true"; if (isSearching == false) search = ""; var pageURL = "addAPet.do?search_pet=" + search + "&redirectTo=" + redirectTo; newwin = window.open(pageURL, "addAPetPopup", "width=550,height=310,menubar=no,resizable,scrollbars=yes,status=yes,toolbar=no,location=no"); newwin.focus(); } function popConfirm() { var pageURL = "addAPet.do?searchFor=true"; newwin = window.open(pageURL, "confirmationPopup", "width=550,height=310,menubar=no,resizable,scrollbars=yes,status=yes,toolbar=no,location=no"); if (newwin != null) newwin.focus(); } function addContextParamAndSubmitForm(form, paramName, paramValue) { var input = document.createElement('INPUT'); input.setAttribute('type', 'HIDDEN'); input.setAttribute('name', paramName); input.setAttribute('value', paramValue); form.appendChild(input); form.submit(); } function disableFaxOptIn(elementId, notifyByEmail, notifyByFax) { var check = document.getElementById(elementId); if (check.checked) { document.getElementById(notifyByEmail).disabled = false; document.getElementById(notifyByFax).disabled = false; } else { document.getElementById(notifyByEmail).disabled = true; document.getElementById(notifyByFax).disabled = true; } } function disableForm() { var count = document.forms[0].elements.length; for (var i = 0; i < count; i++) { var element = document.forms[0].elements[i]; element.disabled = true; } } //----------------------------------------------------------------------Primary Vet Clinic Info Task (Track7.Project103) function openWindow2(url, width, height) { window.open(url, 'HomeAgain', 'width=' + width + ',height=' + height + ',directories=no,location=no,menubar=no, scrollbars=yes,status=yes,toolbar=no,resizable=yes'); } function opener$(elementId) { return opener.document.getElementById(elementId); } function drawExistingClinicInfo(json) { opener$('accountName').innerHTML = '' + json.accountName + ''; opener$('primaryClinicAddress').innerHTML = json.primaryClinicAddress; opener$('primaryClinicPhone').innerHTML = json.primaryClinicPhone; var outsideHoursECPhone = json.outsideHoursECPhone; // !!! set style.display = "" instead of "block" to make it work both in IE and FF !!! opener$('ecPhone').style.display = (outsideHoursECPhone == null || outsideHoursECPhone == '') ? "none" : ""; opener$('outsideHoursECPhone').innerHTML = outsideHoursECPhone; } function drawNewClinicInfo() { opener$('accountName').innerHTML = '' + $('newAccountName').value + ''; opener$('primaryClinicAddress').innerHTML = buildAddressLine($('address1').value, $('city').value, $('newState').value, $('newZip').value); opener$('primaryClinicPhone').innerHTML = formatPhone($('phone').value); opener$('ecPhone').style.display = "none"; opener$('outsideHoursECPhone').innerHTML = ''; } function buildAddressLine(address, city, state, zip) { return address + '
' + city + (city != null && city != '' ? ', ' : '') + state + ' ' + zip; } function formatPhone(phone) { if (phone == null || phone == '' || phone.length != 10) { return phone; } else { return phone.substring(0, 3) + '-' + phone.substring(3, 6) + '-' + phone.substring(6, 10); } } function updateClinicInfo(clinicId) { new Ajax.Request('updateClinic.do', { parameters: {submitClinic: true, clinicId: clinicId}, method: 'post', requestHeaders: {Accept: 'application/x-json'}, onSuccess: function (transport) { var json = transport.responseText.evalJSON(true); drawExistingClinicInfo(json); if (json.closeWindow == 'Y') { window.close(); } } }); } function submitClinic() { var radioButtons = document.getElementsByName("clinics"); if (radioButtons != null && radioButtons.length != 0) { for (var i = 0; i < radioButtons.length; i++) { if (radioButtons[i].checked) { disableForm(); updateClinicInfo(radioButtons[i].value); return; } } } alert("Select a clinic!"); } function doOnLoadUpdateClinic(checked, newClinic, closeWindow) { newClinicCheck(checked); if (newClinic == 'Y') { drawNewClinicInfo(); } if (closeWindow == 'Y') { window.close(); } } function newClinicCheck(checked) { $('notInListClinic').style.display = (checked || checked == "on") ? "block" : "none"; } function disableFreeTextFields(indicator) { if (indicator == "Y") { $('newAccountName').disabled = true; $('address1').disabled = true; $('address2').disabled = true; $('city').disabled = true; $('newState').disabled = true; $('phone').disabled = true; $('newZip').disabled = true; } } //--------------------------------------------------------------------------------------------------------------------- // ============= Unpastable text field support (begin) ============= // Unpastable text field is a text or textarea type input field which prohibit user // to make paste action over a field i.e. to change more then one symbol at the moment // use this to enable/disable all functionality var unpastableFunctionalityEnabled = true; // all unpastable text fields will be stored here var unpastableTextFields = new Array(); // curent (focused) unpatable text field var unpastableTextField; // searches for a unpastable text field in unpastableTextFields array, // uses it if found or creates a new one if not // initialization is required before any changes are made over a field function unpastableInit(sourceObject) { if (typeof(sourceObject) == "object" && "type" in sourceObject && (sourceObject.type == "text" || sourceObject.type == "textarea")) { for (var i = 0; i < unpastableTextFields.length; i++) { if (unpastableTextFields[i].sourceObject == sourceObject) { break; } } if (i == unpastableTextFields.length) { unpastableTextFields[i] = new UnpastableTextField(sourceObject); } unpastableTextField = unpastableTextFields[i]; return true; } return false; } // saves current text field state function unpastableSave(sourceObject) { if (typeof(sourceObject) == "object" && "type" in sourceObject && (sourceObject.type == "text" || sourceObject.type == "textarea")) { return unpastableTextField.save(sourceObject); } return false; } // processes the operation function unpastable(sourceObject) { if (typeof(sourceObject) == "object" && "type" in sourceObject && (sourceObject.type == "text" || sourceObject.type == "textarea")) { return unpastableTextField.process(sourceObject); } return false; } // unpastable text field model function UnpastableTextField(sourceObject) { if (typeof(sourceObject) == "object" && "type" in sourceObject && (sourceObject.type == "text" || sourceObject.type == "textarea")) { // a link to text field associated with this unpastable text field object this.sourceObject = sourceObject; // previous value of text field var previous = sourceObject.value; // shall we display debug information on web page var isDebugModeOn = false; // debug anchors var debugContainer = document.getElementById("unpastable_debug_container"); var debugPrevious = document.getElementById("unpastable_debug_previous"); var debugCurrent = document.getElementById("unpastable_debug_current"); var debugDelta = document.getElementById("unpastable_debug_delta"); var debugOffset = document.getElementById("unpastable_debug_offset"); var debugStartOffset = document.getElementById("unpastable_debug_soffset"); var debugEndOffset = document.getElementById("unpastable_debug_eoffset"); // two public methods declaration goes here: // process - disables paste functionality // save - saves current text field state if (unpastableFunctionalityEnabled) { if (navigator.userAgent.indexOf("MSIE") != -1) { // if we use Internet Explorer methods are simple this.process = function process(sourceObject) { if (sourceObject == this.sourceObject) { event.returnValue = false; } return false; } this.save = function save(sourceObject) { return false; } } else { // if not they are not so simple if (isDebugModeOn) { debugContainer.style.position = "relative"; debugContainer.style.visibility = "visible"; } this.process = function process(sourceObject) { if (sourceObject == this.sourceObject) { if (isDebugModeOn) { debugPrevious.innerHTML = "previous = " + previous; debugCurrent.innerHTML = "current = " + this.sourceObject.value; } var delta = getDelta(previous, this.sourceObject.value); if (isDebugModeOn) { debugDelta.innerHTML = "delta = " + delta; } if (delta > 1) { this.sourceObject.value = previous; } else { previous = this.sourceObject.value; } return delta > 1; } return false; } this.save = function save(sourceObject) { if (sourceObject == this.sourceObject) { previous = sourceObject.value; return true; } return false; } } } else { this.process = function process() { return false; } this.save = function save() { return false; } } // the rest of private methods goes here function getDelta(s1, s2) { var offset = getOffset(s1, s2); if (isDebugModeOn) { debugOffset.innerHTML = "offset = " + offset; } return s2.length - offset; } function getOffset(s1, s2) { var startOffset = getStartOffset(s1, s2, 0); if (isDebugModeOn) { debugStartOffset.innerHTML = "startOffset = " + startOffset; } var endOffset = getEndOffset(s1, s2, startOffset); if (isDebugModeOn) { debugEndOffset.innerHTML = "endOffset = " + endOffset; } return startOffset + endOffset; } function getStartOffset(s1, s2, endOffset) { var offset = 0; while (offset + endOffset < s1.length && offset + endOffset < s2.length && s1.charAt(offset) == s2.charAt(offset)) { offset++; } return offset; } function getEndOffset(s1, s2, startOffset) { var offset = 0; while (offset + startOffset < s1.length && offset + startOffset < s2.length && s1.charAt(s1.length - 1 - offset) == s2.charAt(s2.length - 1 - offset)) { offset++; } return offset; } } } // ============= Unpastable text field support (end) =============== // ============= Limited text field support (begin) ============= // Limited text field is text or textarea type input field which prohibit user to enter // more then some predefined number of characters into a field // use this to enable/disable all functionality var limitedFunctionalityEnabled = true; // all limited text fields will be stored here var limitedTextFields = new Array(); // curent (focused) limited text field var limitedTextField; // searches for a limited text field in limitedTextFields array, // uses it if found or creates a new one if not // initialization is required before any changes are made over a field function limitedInit(sourceObject, maxlen) { if (typeof(sourceObject) == "object" && "type" in sourceObject && (sourceObject.type == "text" || sourceObject.type == "textarea")) { for (var i = 0; i < limitedTextFields.length; i++) { if (limitedTextFields[i].sourceObject == sourceObject) { break; } } if (i == limitedTextFields.length) { limitedTextFields[i] = new LimitedTextField(sourceObject, maxlen); } limitedTextField = limitedTextFields[i]; return true; } return false; } // saves current text field state function limitedSave(sourceObject) { if (typeof(sourceObject) == "object" && "type" in sourceObject && (sourceObject.type == "text" || sourceObject.type == "textarea")) { return limitedTextField.save(sourceObject); } return false; } // processes the operation function limitedProcess(sourceObject) { if (typeof(sourceObject) == "object" && "type" in sourceObject && (sourceObject.type == "text" || sourceObject.type == "textarea")) { return limitedTextField.process(sourceObject); } return false; } // limited text field model function LimitedTextField(sourceObject, maxlen) { if (typeof(sourceObject) == "object" && "type" in sourceObject && (sourceObject.type == "text" || sourceObject.type == "textarea")) { // a link to text field associated with this limited text field object this.sourceObject = sourceObject; // previous value of text field var previous = sourceObject.value; // two public methods declaration goes here: // process - limits number of characters // save - saves current text field state if (limitedFunctionalityEnabled) { this.process = function process(sourceObject) { if (sourceObject == this.sourceObject) { if (this.sourceObject.value.length > maxlen) { this.sourceObject.value = previous; } else { previous = this.sourceObject.value; } } return false; } this.save = function save(sourceObject) { if (sourceObject == this.sourceObject) { previous = sourceObject.value; return true; } return false; } } else { this.process = function process() { return false; } this.save = function save() { return false; } } } } // ============= Limited text field support (end) ============= function display(id) { var el = document.getElementById(id); if (el != null) { el.style.display = "block"; } } function hide(id) { var el = document.getElementById(id); if (el != null) { el.style.display = "none"; } } // Enables all elements of html form (sets 'disabled' property of all elements to false) function enableAll(form) { if (typeof(form) == "object" && "elements" in form && "length" in form) { var elements = form.elements; for (var i = 0; i < form.length; i++) { if ("disabled" in elements[i]) { elements[i].disabled = false; } } } } // Disables all elements of html form (sets 'disabled' property of all elements to true) function disableAll(form) { if (typeof(form) == "object" && "elements" in form && "length" in form) { var elements = form.elements; for (var i = 0; i < form.length; i++) { if ("disabled" in elements[i]) { elements[i].disabled = true; } } } } function disableButtons(element, form) { if (element != null) element.value = 'true'; for (var i = 0; form.btn != null && i < form.btn.length; i++) { form.btn[i].disabled = true; } form.submit(); } //======================================================= renewals javascript function popPrinterFriendly(url) { var popup = window.open(url, "popup", "width=670, height=510, menubar=yes, resizable=yes, scrollbars=yes, status=no, toolbar=no, location=no"); if(popup == null) { return "The operation was successful but the pop-up blocker blocked appropriate information popup." } popup.focus(); return ""; } function sendRenewalEmail(actionName) { return sendEmailRE("renewalForm", actionName, "errorsId", "/homeagain/renewalConfirmEmail.do"); } function sendEnhancedEmail(actionName) { return sendEmailEN("enrollmentFormEnhanced", actionName, "errorsId", "/homeagain/enhancedConfirmEmail.do"); } function sendEmailAR(actionName, errorsAnchor, successPopupURL) { new Ajax.Request(actionName, { parameters: {sendConfirmAutorenewalEmailBtn: true}, method: 'post', requestHeaders: {Accept: 'application/x-json'}, onSuccess: function (transport) { try { var json = transport.responseText.evalJSON(true); if (json.error != "") { $(errorsAnchor).innerHTML = json.error; } else { $(errorsAnchor).innerHTML = popPrinterFriendly(successPopupURL); } } catch(ex) { $(errorsAnchor).innerHTML = ex; } } }); } function sendEmailRE(formName, actionName, errorsAnchor, successPopupURL) { var form = $(formName); form['disable'](); new Ajax.Request(actionName, { parameters: {sendRenewalEmailButton: true}, method: 'post', requestHeaders: {Accept: 'application/x-json'}, onSuccess: function (transport) { form['enable'](); try { var json = transport.responseText.evalJSON(true); if (json.error != "") { $(errorsAnchor).innerHTML = json.error; } else { $(errorsAnchor).innerHTML = popPrinterFriendly(successPopupURL); } } catch(ex) { $(errorsAnchor).innerHTML = ex; } } }); } function sendEmailEN(formName, actionName, errorsAnchor, successPopupURL) { var form = $(formName); form['disable'](); new Ajax.Request(actionName, { parameters: {sendEnhancedEmailButton: true}, method: 'post', requestHeaders: {Accept: 'application/x-json'}, onSuccess: function (transport) { form['enable'](); try { var json = transport.responseText.evalJSON(true); if (json.error != "") { $(errorsAnchor).innerHTML = json.error; } else { $(errorsAnchor).innerHTML = popPrinterFriendly(successPopupURL); } } catch(ex) { $(errorsAnchor).innerHTML = ex; } } }); } function goToManageUserProfile(userId) { document.location.href = 'manageUserProfile.do?userId=' + userId; } function goToManagePetProfile(userId, microchipId) { document.location.href = 'managePetProfile.do?userId=' + userId + 'µchipId=' + microchipId; } function goToAddPet(microchipId) { document.location.href = 'enhancedAddPetInfo.do?microchipId=' + microchipId; } function goToRenewal(microchipId) { document.location.href = 'renewalVerifyOwnerInfo.do?microchipId=' + microchipId; } function goToRenewalCSR(microchipId, userId) { document.location.href = 'renewalVerifyOwnerInfo.do?microchipId=' + microchipId + "&userId=" + userId; } function goToAddPetCSR(microchipId, userId) { document.location.href = 'enhancedAddPetInfo.do?microchipId=' + microchipId + "&userId=" + userId; } function allowNumbersOnly(obj) { var val = obj.value; var pattern = new RegExp('[^0-9]+', 'g'); obj.value = val.replace(pattern, ''); }