$(document).ready(function(){initializeNewSelectAlls();initializePage()});var ajaxData="";function initializePage(){var a="";initializeForms(a);initializeInstitutionType();initializeStateProvince();initializeSelectAlls();initializeExtraFormSubmits();initializeTextareaMaxlength(a);initializePrintLink();initializePopupLinks();initializeCreateNewForm();initializeCommentField();initializeEditReminderForm();initializeAccessIReward();initializeQuickOrder();currentSCMSID();iRewardsSubmitButton();iRewardRedeemForm();initializeICard();resetErrors();showErrors();initializeDatePicker()}function initializeModal(){var a=".modal ";initializeForms(a);initializeTextareaMaxlength(a);initializeCopyItemModal()}function initializeForms(a){$(".quickAddFields form").submit(function(){return checkQuickAddAndSubmit()});if($(a+"div.renameCartForm").length>0){initializeRenameCartForm()}if($(a+"div.cart").length>0){initializeUpdateBeforeCheckout()}if($(a+"div.cartItems").length>0){initializeUpdateBeforeCheckout()}if($(a+"div.registration").length>0){initializeRegistration()}if($(a+"table.shippingAccounts").length>0){initializeShippingAccounts()}if($(a+"div.paymentInformation").length>0){initializePaymentInformation()}if($(a+"div.paymentInfo").length>0){initializeUserProfilePaymentInfo()}if(("div.addApproverNew").length>0){initializeApprover()}}function initializeRenameCartForm(){$(".renameCartLink a").click(function(){showCartRenameForm();return false});$(".renameCartForm form").submit(function(){return validateCartRename()})}function showCartRenameForm(){var b=$(".cartName");var a=$(".renameCartForm input[type='text']");a[0].value=b.text();$(".cartName").hide();$(".renameCartLink").hide();$(".renameCartForm").show()}function validateCartRename(){var b=$(".cartName");var a=$(".renameCartForm input[type='text']");if((a[0].value!="")&&(a[0].value!=b.text())){return true}else{$(".renameCartForm").hide();$(".renameCartLink").show();$(".cartName").show();return false}}function initializeUpdateBeforeCheckout(){$(".cartItems table input[type='text']").keyup(function(){if(this.value!=this.defaultValue){changeCheckoutButtonToUpdateCart()}})}function changeCheckoutButtonToUpdateCart(){$("form#cartForm").removeAttr("onsubmit");$("form#cartForm").unbind("submit");$("form#cartForm").submit(function(){validateAndSubmitCartForm("updateCart");return false});$(".cartSubheader a.blueButton span").each(function(){if(document.URL.match("cmd=TemplateDataDisplay")!=null){$(this).text("Update Favorite")}else{$(this).text("Update Cart")}});$(".cartFooter a.blueButton span").each(function(){if(document.URL.match("cmd=TemplateDataDisplay")!=null){$(this).text("Update Favorite")}else{$(this).text("Update Cart")}});$(".cartSubheader a.disabledButton span").each(function(){if(document.URL.match("cmd=TemplateDataDisplay")!=null){$(this).text("Update Favorite")}else{$(this).text("Update Cart")}$(".cartSubheader a.disabledButton").addClass("blueButton");$(".cartSubheader a.disabledButton").removeClass("disabledButton")});$(".cartFooter a.disabledButton span").each(function(){if(document.URL.match("cmd=TemplateDataDisplay")!=null){$(this).text("Update Favorite")}else{$(this).text("Update Cart")}$(".cartFooter a.disabledButton").addClass("blueButton");$(".cartFooter a.disabledButton").removeClass("disabledButton")});$(".cartFooter a.blueButton").removeAttr("onclick");$(".cartSubheader a.blueButton").removeAttr("onclick");$(".cartFooter a.blueButton").unbind("click");$(".cartSubheader a.blueButton").unbind("click");$(".cartFooter a.blueButton").click(function(){validateAndSubmitCartForm("updateCart");return false});$(".cartSubheader a.blueButton").click(function(){validateAndSubmitCartForm("updateCart");return false})}function changeUpdateCartButtonToCheckout(){$("form#cartForm").submit(function(){validateAndSubmitCartForm("updateCart");return false});$(".cartSubheader a.blueButton span").each(function(){$(this).text("Checkout")});$(".cartFooter a.blueButton span").each(function(){$(this).text("Checkout")})}function initializeRegistration(){$("input.iAccept").click(function(){$(".submitButton .enabled").show();$(".submitButton .disabled").hide()});$("input.iDoNotAccept").click(function(){$(".submitButton .disabled").show();$(".submitButton .enabled").hide()});$(".submitButton .disabled").click(function(){return false});$("#sameAsShipping").click(function(){if(this.checked){copyShippingToBilling()}else{removeShippingToBilling()}})}function initializeUserProfilePaymentInfo(){if($("input.newCard").length>0){togglePaymentInfo(true)}$("select.creditCardType").change(function(){togglePaymentInfo();return false});$("input.ccSelect").click(function(){togglePaymentInfo(true)});$("a.addCreditCard").click(function(){$("select#CardType").addClass("validateRequired requiredFieldsForCreditCard");$("input#CreditCardNo").addClass("validateRequired validateCreditCard requiredFieldsForCreditCard creditCardNumber");$("input#CardHolderName").addClass("validateRequired requiredFieldsForCreditCard");$("select#month").addClass("validateRequired requiredFieldsForCreditCard");$("select#year").addClass("requiredFieldsForCreditCard validateRequired validateExpirationDate");validateAndAddNewCard($(this).parent("td").parent("tr"))})}function togglePaymentInfo(a){validate=true;if(a){if($("input.ccSelect:checked").hasClass("newCard")){validate=true}else{validate=false}}else{if($("select.creditCardType")[0]){$("select.creditCardType")[0].value==""?validate=false:validate=true}}if(!validate){$(".validateRequired").each(function(){$(this)[0].value=""});$("select.month")[0].value="";$("select.year")[0].value="";$(".validateRequired").addClass("doNotValidateRequired").removeClass("validateRequired");$(".validateCreditCard").addClass("doNotValidateCreditCard").removeClass("validateCreditCard");$(".validateExpirationDate").addClass("doNotValidateExpirationDate").removeClass("validateExpirationDate")}else{$(".doNotValidateRequired").addClass("validateRequired").removeClass("doNotValidateRequired");$(".doNotValidateCreditCard").addClass("validateCreditCard").removeClass("doNotValidateCreditCard");$(".doNotValidateExpirationDate").addClass("validateExpirationDate").removeClass("doNotValidateExpirationDate")}}function initializePaymentInformation(){$("ul.paymentRadios").find("input").click(function(){togglePaymentInformation();togglePaymentInformation_MGH()});togglePaymentInformation_MGH();togglePaymentInformation();$("input#SaveCard").click(function(){$(this).attr("checked")?$("input#SetAsDefaultCard").removeAttr("disabled").next("span").removeClass("disabled"):$("input#SetAsDefaultCard").removeAttr("checked").attr("disabled","disabled").next("span").addClass("disabled")});$("a.addCreditCard").click(function(){validateAndAddNewCard($(this).parent("td").parent("tr"))})}function validateAndAddNewCard(a){if(formValidation($(".CCTable"))){document.CCForm.operation.value="Add";document.CCForm.submit()}else{$("select#CardType").removeClass("validateRequired requiredFieldsForCreditCard");$("input#CreditCardNo").removeClass("validateRequired validateCreditCard requiredFieldsForCreditCard creditCardNumber");$("input#CardHolderName").removeClass("validateRequired requiredFieldsForCreditCard");$("select#month").removeClass("validateRequired requiredFieldsForCreditCard");$("select#year").removeClass("requiredFieldsForCreditCard validateRequired validateExpirationDate")}return false}function togglePaymentInformation_MGH(){if($(".PaymentTypeChartofAccount input:radio:checked").length>0){$("#MGH_ChartofAccount").show();$("#porefdiv").hide();$("#applyDuringRoutingPanel").hide();$("#addApprover").hide();$("#display_or").show();$("#addNewApprover").show();$(".isApprovalRouting").hide();$("#approverList").removeClass("validateRequired")}else{if($(".paymentTypeApplyRouting input:radio:checked").length>0){$("#MGH_ChartofAccount").hide();$("#porefdiv").hide();$("#applyDuringRoutingPanel").show();$("#addApprover").hide();$("#display_or").show();$(".paymentTypeApplyRouting").show();$("#addNewApprover").show();$(".isApprovalRouting").show();$("#isExpanded").val("false");$("#GrantValue").removeClass("validateRequired");$("#CostCenterAccount").removeClass("validateRequired");$("#CostCenterAccount ").removeClass("validateAlphanumeric");$("#approverLastName").val("");$("#approverFirstName").val("");$("#approverEmailAddress").val("");$("#approverPhoneNumber").val("")}}}function togglePaymentInformation(){if($(".paymentTypePO input:radio:checked").length>0){$(".purchaseOrder").show();$("#otherPONumber").show();$(".isApprovalRouting").hide();$("#porefdiv").show();$("#applyDuringRoutingPanel").hide();$("#addApprover").hide();$("#display_or").show();$("#addNewApprover").show();$("#tableerror").html("");$("#tableerror").hide();$("#approverLastName").removeClass("text validateRequired error");$("#approverFirstName").removeClass("text validateRequired error");$("#approverEmailAddress").removeClass("text validateRequired validateEmail error");$("#approverPhoneNumber").removeClass("text validateRequired validatePhone error");$("#ApproverID").removeClass("validateApprover error");$("#isExpanded").val("true");$(".creditCard").hide();$(".storedCard").hide();$(".iCard").hide();$(".iCard input[type='text']").attr("value","");$(".refNoContract").show();$(".isApprovalRouting").hide();$(".poNumber").addClass("validateRequired");$(".requiredFieldsForCreditCard").removeClass("validateRequired");$(".creditCardNumber").removeClass("validateCreditCard");$(".creditCard .year").removeClass("validateExpirationDate");$(".iCard .iCardValidate").removeClass("validateRequired");$(".iCard .iCardAccessCode").removeClass("validateRequired");$(".iCard .iCardNumber").removeClass("validateRequired");$("#approverList").removeClass("validateRequired");selectIcardRadioOption("none",false)}else{if($(".paymentTypeStored input:radio:checked").length>0){$(".purchaseOrder").hide();$("#porefdiv").show();$("#applyDuringRoutingPanel").hide();$("#addApprover").hide();$("#display_or").show();$("#addNewApprover").show();$("#tableerror").html("");$("#tableerror").hide();$("#approverLastName").removeClass("text validateRequired error");$("#approverFirstName").removeClass("text validateRequired error");$("#approverEmailAddress").removeClass("text validateRequired validateEmail error");$("#approverPhoneNumber").removeClass("text validateRequired validatePhone error");$("#ApproverID").removeClass("validateApprover error");$("#isExpanded").val("true");$(".creditCard").hide();$(".storedCard").show();$(".iCard").hide();$(".iCard input[type='text']").attr("value","");$(".refNoContract").show();$(".isApprovalRouting").hide();$(".poNumber").removeClass("validateRequired");$(".requiredFieldsForCreditCard").removeClass("validateRequired");$(".creditCardNumber").removeClass("validateCreditCard");$(".creditCard .year").removeClass("validateExpirationDate");$(".iCard .iCardAccessCode").removeClass("validateRequired");$(".iCard .iCardValidate").removeClass("validateRequired");$(".iCard .iCardNumber").removeClass("validateRequired");$("#approverList").removeClass("validateRequired");selectIcardRadioOption("none",false)}else{if($(".paymentTypeCC input:radio:checked").length>0){$(".purchaseOrder").hide();$("#porefdiv").show();$("#applyDuringRoutingPanel").hide();$("#addApprover").hide();$("#display_or").show();$(".creditCard").show();$(".storedCard").hide();$(".iCard").hide();$(".iCard input[type='text']").attr("value","");$(".refNoContract").show();$(".isApprovalRouting").hide();$(".poNumber").removeClass("validateRequired");$(".requiredFieldsForCreditCard").addClass("validateRequired");$(".creditCardNumber").addClass("validateCreditCard");$(".creditCard .year").addClass("validateExpirationDate");$(".iCard .iCardAccessCode").removeClass("validateRequired");$(".iCard .iCardValidate").removeClass("validateRequired");$(".iCard .iCardNumber").removeClass("validateRequired");$("#approverList").removeClass("validateRequired");$("#addNewApprover").show();$("#tableerror").html("");$("#tableerror").hide();$("#approverLastName").removeClass("text validateRequired error");$("#approverFirstName").removeClass("text validateRequired error");$("#approverEmailAddress").removeClass("text validateRequired validateEmail error");$("#approverPhoneNumber").removeClass("text validateRequired validatePhone error");$("#ApproverID").removeClass("validateApprover error");$("#isExpanded").val("true");selectIcardRadioOption("none",false)}else{if($(".paymentTypeICard input:radio:checked").length>0){$(".purchaseOrder").hide();$("#porefdiv").hide();$("#applyDuringRoutingPanel").hide();$("#addApprover").hide();$("#display_or").show();$("#addNewApprover").show();$("#tableerror").html("");$("#tableerror").hide();$("#approverLastName").removeClass("text validateRequired error");$("#approverFirstName").removeClass("text validateRequired error");$("#approverEmailAddress").removeClass("text validateRequired validateEmail error");$("#approverPhoneNumber").removeClass("text validateRequired validatePhone error");$("#ApproverID").removeClass("validateApprover error");$("#isExpanded").val("true");$(".creditCard").hide();$(".storedCard").hide();$(".iCard").show();$(".validatedRecords").hide();$(".refNoContract").hide();$(".isApprovalRouting").hide();$(".poNumber").removeClass("validateRequired");$(".requiredFieldsForCreditCard").removeClass("validateRequired");$(".creditCardNumber").removeClass("validateCreditCard");$(".creditCard .year").removeClass("validateExpirationDate");$("#approverList").removeClass("validateRequired")}else{if($(".paymentTypeApplyRouting input:radio:checked").length>0){$(".purchaseOrder").hide();$("#otherPONumber").hide();$(".creditCard").hide();$(".storedCard").hide();$("#porefdiv").hide();$("#applyDuringRoutingPanel").show();$("#addApprover").hide();$("#display_or").show();$("#iCardPanel").hide();$(".paymentTypeApplyRouting").show();$("#addNewApprover").show();$(".isApprovalRouting").show();$(".poNumber").removeClass("validateRequired");$(".requiredFieldsForCreditCard").removeClass("validateRequired");$(".creditCardNumber").removeClass("validateCreditCard");$(".creditCard .year").removeClass("validateExpirationDate");$("#isExpanded").val("false");$("#approverLastName").val("");$("#approverFirstName").val("");$("#approverEmailAddress").val("");$("#approverPhoneNumber").val("");$(".iCard .iCardValidate").removeClass("validateRequired");selectIcardRadioOption("none",false)}}}}}if($("#ICardException").attr("checked")){$(".paymentTypeApplyRouting").hide()}$("#ICardException").click(function(){if($("#ICardException").attr("checked")){$(".paymentTypeApplyRouting").hide()}else{$(".paymentTypeApplyRouting").show()}})}function initializeCommentField(){$(".paymentInformation .commentField").toggle();$("a.toggleAddComment").click(function(){if(jQuery.browser.msie){$(".commentField").toggle();forceIE6Redraw()}else{$(".commentField").slideToggle()}return false})}function initializeApprover(){$("#addNewApprover").click(function(){$("#MyApproverSearchResults").hide();$("#MyApproverSearchResults input:radio").attr("checked",false);$("#MyApproverSearchResults").empty();$("#ApproverID").val("");$("#ApproverID").attr("disabled","diabled");$("#isExpanded").val("true");$("#addApprover").show();$("#display_or").hide();$("#addNewApprover").hide();$(".innerSpace").hide();$("#approverLastName").addClass("text validateRequired");$("#approverFirstName").addClass("text validateRequired");$("#approverEmailAddress").addClass("text validateRequired validateEmail");$("#approverPhoneNumber").addClass("text validateRequired validatePhone");$("#ApproverID").removeClass("validateApprover");return false});$("#approverCancel").click(function(){$("#ApproverID").removeAttr("disabled");$("#tableerror").hide();$("#addApprover").hide();$("#display_or").show();$("#addNewApprover").show();$(".innerSpace").show();$("#MyApproverSearchResults").show();$("#isExpanded").val("false");$("#approverLastName").val("");$("#approverFirstName").val("");$("#approverEmailAddress").val("");$("#approverPhoneNumber").val("");$("#approverLastName").removeClass("text validateRequired");$("#approverFirstName").removeClass("text validateRequired");$("#approverEmailAddress").removeClass("text validateRequired validateEmail");$("#approverPhoneNumber").removeClass("text validateRequired validatePhone");$("#ApproverID").addClass("validateApprover");return false})}function validatePaymentInfo_PreExistingApprover(b){var a=true;if($("input[@id='approver']:checked").val()==undefined){$("#ApproverID").addClass("validateApprover");addError("validateApprover",$("#ApproverID"));$("#ApproverID").prev().find(".inline-alert").append("<p>"+errors.validateApprover+"</p>");a=false}else{removeError("validateApprover",$("#ApproverID"));$("#ApproverID").prev().find(".inline-alert").html("");$("#ApproverID").prev().find(".inline-alert").hide();a=true}return a}function validateApplyDuringRoutingOptions(b){var a=false;if($("#isExpanded").val()=="false"){a=validatePaymentInfo_PreExistingApprover(b)}else{b.find("input#approverLastName").each(function(){if(isEmpty($(this)[0].value)){addError("validateApprover",$(this));a=false}else{removeError("validateApprover",$(this));a=true}});b.find("input#approverFirstName").each(function(){if(isEmpty($(this)[0].value)){addError("validateApprover",$(this));a=false}else{removeError("validateApprover",$(this));a=true}});b.find("input#approverEmailAddress").each(function(){if(!isValidEmail($(this)[0].value)){addError("email",$(this));a=false}else{removeError("email",$(this));a=true}});b.find("input#approverPhoneNumber").each(function(){$(this)[0].value=stripNonNumericCharacters($(this)[0].value);if(isEmpty($(this)[0].value)){addError("required",$(this));a=false}else{removeError("required",$(this));a=true}if(isValidPhone($(this)[0].value)){removeError("phone",$(this));a=true}else{addError("phone",$(this));a=false}})}return a}function validateAndSubmitPaymentInformationForm(c,a){if(formValidation($("#checkoutForm"))){if(c=="checkout"){if(isEuropeanUser()&&isVatExempt()){showVatExemptConfirmation()}else{if(a=="true"){setTimeout("showProgressBar();",500)}try{checkoutOmniture($("#checkoutForm"))}catch(b){}setTimeout("showProgressBar();",2000);document.checkoutForm.submit()}}else{if(c=="vatExemptConfirmation"){showProgressBar();document.checkoutForm.submit()}}}return false}function isEuropeanUser(){if($("div.europeanUser").length>0){return true}else{return false}}function isVatExempt(){if($(".vatExempt input:checkbox:checked").length>0){return true}else{return false}}function validateAndSubmitApplyPaymentToOrder(b,a){if(formValidation($("#invoiceForm"))){if(b=="approve"){if(isEuropeanUser()&&isVatExempt()){showVatExemptConfirmation()}else{if(a=="true"){setTimeout("showValidatingOrderModal();",500)}$(".blueButton span").text("Please wait");$(".blueButton").attr("disabled","true").css("cursor","wait");return true}}}return false}function validateAndSubmitRejection(b,a){if(formValidation($("#confirmDisable"))){return true}return false}function copyShippingToBilling(){$("input.billingName")[0].value=$("input.shippingName")[0].value;$("input.billingAddress")[0].value=$("input.shippingAddress")[0].value;$("input.billingOfficeSuite")[0].value=$("input.shippingBuilding")[0].value;$("input.billingCity")[0].value=$("input.shippingCity")[0].value;$("select.billingCountry")[0].value=$("select.shippingCountry")[0].value;updateStateProvinceFields($("select.billingCountry"));updateZipCode($("select.billingCountry"));if($("input.shippingProvince")&&$("input.billingProvince")){$("input.billingProvince")[0].value=$("input.shippingProvince")[0].value}if($("select.shippingState")[0]&&$("select.billingState")[0]){$("select.billingState")[0].value=$("select.shippingState")[0].value}if($("select.shippingCAState")[0]&&$("select.billingCAState")[0]){$("select.billingCAState")[0].value=$("select.shippingCAState")[0].value}if($("input.shippingPostalCode")[0]&&$("input.billingPostalCode")[0]){$("input.billingPostalCode")[0].value=$("input.shippingPostalCode")[0].value}if($("input.ShipToZip")[0]&&$("input.BillToZip")[0]){$("input.BillToZip")[0].value=$("input.ShipToZip")[0].value}if($("input.hkShipToZip")[0]&&$("input.hkBillToZip")[0]){$("input.hkBillToZip")[0].value=$("input.hkShipToZip")[0].value}}function removeShippingToBilling(){$("input.billingName")[0].value="";$("input.billingAddress")[0].value="";$("input.billingOfficeSuite")[0].value="";$("input.billingCity")[0].value="";$("select.billingCountry")[0].value="";updateStateProvinceFields($("select.billingCountry"));if($("input.billingProvince")){$("input.billingProvince")[0].value=""}if($("select.billingState")[0]){$("select.billingState")[0].value=""}if($("select.billingCAState")[0]){$("select.billingCAState")[0].value=""}if($("input.billingPostalCode")[0]){$("input.billingPostalCode")[0].value=""}if($("input.BillToZip")[0]){$("input.BillToZip")[0].value=""}if($("input.hkBillToZip")[0]){$("input.hkBillToZip")[0].value=""}}function initializeShippingAccounts(){$(".shippingAddress").hide();$(".defaultShippingAddress").show();$("table.shippingAccounts").find("label").click(function(){$theLabel=$(this);var a=$theLabel.find("span").text();var b="#accountNumber"+a.replace(" ","");toggleShippingAddresses(b)})}function toggleShippingAddresses(a){forceIE6Redraw();$(".shippingAddress").hide();$(a).show()}function initializeExtraFormSubmits(){$("a.submitForm").click(function(){var g=$(this).attr("class");var a=g.match(/submitForm_[a-zA-Z]{1,}/)[0];var e=a.indexOf("_");a=a.substring(e+1);var b="#"+a;var d=$(b);var f=false;if(d.hasClass("validateForm")){if(formValidation(d)){document[a].submit();return false}else{return false}}else{document[a].submit();return false}})}function initializeTextareaMaxlength(a){$(a+"textarea.maxlength").keyup(function(){var f=$(this).attr("class");var b=parseInt(f.match(/maxlength_[0-9]{1,}_/)[0].match(/[0-9]{1,}/)[0]);var e=$(this)[0].value;var d=e.length;if(d>b){$(this)[0].value=e.substr(0,b);return false}})}function initializePrintLink(){$("#printLink").click(function(){window.print();return false})}function initializePopupLinks(){$("a[rel='popup']").click(function(){window.open(this.href);return false})}function initializeSelectAlls(){$("table").each(function(){var a=$(this);a.find("thead :checkbox").click(function(){var b=this.checked;a.find("tbody :checkbox").each(function(){this.checked=b})});a.find(".selectedCheckboxesAction").click(function(){var b=true;resetErrors();var c=$(this);a.find("tbody :checkbox").each(function(){if(this.checked){b=false}});if(b){addError("checkboxes",c)}else{removeError("checkboxes",c)}showErrors()})})}function initializeCopyItemModal(){$("table.copyItems td.select").find("input").click(function(){toggleTextFieldRequiredOnCopyItemModal($(this))});$("table.copyItems td.select input:radio:checked").each(function(){toggleTextFieldRequiredOnCopyItemModal($(this))})}function toggleTextFieldRequiredOnCopyItemModal(b){$("table.copyItems input[type='text']").removeClass("validateRequired");$("table.copyItems input[type='text']").removeClass("requiredError");$("table.copyItems input[type='text']").removeClass("error");var a=b.parent().parent();if(a.hasClass("newItem")){a.find("input[type='text']").addClass("validateRequired")}}function initializeStateProvince(){$("select.countrySelect").each(function(){updateStateProvinceFields($(this));updateZipCode($(this))});$("select.countrySelect").change(function(){updateStateProvinceFields($(this));updateZipCode($(this))})}function updateZipCode(b){var a=b;showHideZip(a,a[0].value)}function showHideZip(c,a){var e=c.parent().parent().next();var d=e.next().next().next();var b=d.next();if(a=="hk"){d.hide();d.find("input").removeClass("validateRequired");b.show()}else{b.hide();d.show();d.find("input").addClass("validateRequired")}}function updateStateProvinceFields(b){var e=b;var c=e.parent().parent().next();var a=c.next();var d=c.next().next();forceIE6Redraw();if(e[0].value=="us"){a.show();d.hide();c.hide();a.find("select").addClass("validateRequired");d.find("select").removeClass("validateRequired");c.find("input").removeClass("validateRequired")}else{if(e[0].value=="ca"){d.show();a.hide();c.hide();d.find("select").addClass("validateRequired");a.find("select").removeClass("validateRequired");c.find("input").removeClass("validateRequired")}else{a.hide();d.hide();c.show();a.find("select").removeClass("validateRequired");d.find("select").removeClass("validateRequired");c.find("input").addClass("validateRequired")}}return false}function initializeDatePicker(){Date.firstDayOfWeek=7;Date.format="mm/dd/yyyy";$(function(){$(".date-pick").datePicker({clickInput:true,startDate:"01/01/1975"})})}function initializeInstitutionType(){if($("select.institutionType").length>0){updatePrincipalInvestigatorFields();var a=$("select.institutionType")[0].value;if(a==""){forceIE6Redraw();$(".principalInvestigator").hide()}$("select.institutionType").change(function(){updatePrincipalInvestigatorFields();forceIE6Redraw();return false})}}function updatePrincipalInvestigatorFields(){var a=$("select.institutionType")[0].value;var b=$("h4.principalInvestigator");forceIE6Redraw();$(".principalInvestigator").show();switch(a){case"10":b.text("Principal Investigator");break;case"20":b.text("Principal Investigator or Team Leader");break;case"30":b.text("Principal Investigator or Chief");break;default:b.text("Principal Investigator")}}function initializeCreateNewForm(){$(".createNewForm").toggle();$("a.toggleCreateNew").click(function(){if($(".createNewForm").is(":visible")){resetErrors()}$(".createNewForm").toggle();return false});ensureAtLeastOneCheckboxesIsChecked()}function ensureAtLeastOneCheckboxesIsChecked(){$(".listAction").click(function(){resetErrors();$theAction=$(this);if($(".tablePanel tbody input:checkbox:checked").length<1){addError("checkboxes",$theAction)}else{removeError("checkboxes",$theAction);if($(this).hasClass("noModal")){return true}else{tb_show(null,$theAction[0].href,false)}}showErrors();$theAction.blur();return false})}function oneCheckboxIsChecked(a){resetErrors();if($("tbody input:checkbox:checked").length<1){addError("checkboxes",a);showErrors();return false}else{removeError("checkboxes",a);return true}}function twoOrMoreCheckboxesAreChecked(a){resetErrors();if($("tbody input:checkbox:checked").length<2){addError("twoOrMorecheckboxes",a);showErrors();return false}else{removeError("twoOrMorecheckboxes",a);return true}}function initializeEditReminderForm(){$(".toggleEditReminder").click(function(){$(".editReminder").slideToggle("1000");return false})}function initializePopupWindow(){$(".popupwindow").popupwindow()}function initializeQuickOrder(){$("a.addRows").click(function(){addRowsToManualEntry(10);return false});$("a.clearManualEntry").click(function(){$("table#manualEntry input[type=text]").each(function(){$(this).hasClass("quantity")?$(this).val("1"):$(this).val("")});resetErrors();return false});$("input#selectAll").click(function(){if($(this).attr("checked")==true){$("table#manualEntry input[type=checkbox]").each(function(){$(this).attr("checked",true)})}else{$("table#manualEntry input[type=checkbox]").each(function(){$(this).attr("checked",false)})}});$("div.deleteChecked a").click(function(){$("table#manualEntry input[type=checkbox][checked]").parents("tr").remove();$("table#manualEntry input.checkbox").length>0?$("div.deleteChecked").show():$("div.deleteChecked").hide();return false});$("dl.quickOrderFAQList dt").click(function(){$(this).hasClass("expanded")?$(this).removeClass("expanded").next().slideUp(100):$(this).addClass("expanded").next().slideDown(100)});$("div.questionsPod ul li a").click(function(){$("dl.quickOrderFAQList dt.expanded").removeClass("expanded").next().hide();$($("dl.quickOrderFAQList dt")[$(this).parent().prevAll().length]).addClass("expanded").next().show()})}function addRowsToManualEntry(a){if(!a){a=10}for(i=0;i<a;i++){$("table#manualEntry tbody:first").append(createManualEntryRow())}$("table#manualEntry input.checkbox").length>0?$("div.deleteChecked").show():$("div.deleteChecked").hide()}function createManualEntryRow(){if($("table#manualEntry tbody tr:last").attr("id")!=undefined){rowNumber=$("table#manualEntry tbody tr:last").attr("id").replace("row","")}else{rowNumber=0}rowNumber++;tr=$(document.createElement("tr"));tdCatNumber=$(document.createElement("td"));tdQuantity=$(document.createElement("td"));tdReserveNumber=$(document.createElement("td"));tdCatNumber.html('<input type="text" class="afterCheckbox" id="sku@'+rowNumber+'" name="sku@'+rowNumber+'" />');tdQuantity.html('<input class="quantity validateQuantity" type="text" value="1" id="qty'+rowNumber+'" name="qty'+rowNumber+'" maxlength="3"/>');tdReserveNumber.html('<input type="text" id="reserveNo'+rowNumber+'" name="reserveNo'+rowNumber+'" />');if(document.getElementById("JPDealer")){tdDealerUserInput=$(document.createElement("td"));tdDealerPOInput=$(document.createElement("td"));tdRemarks=$(document.createElement("td"));tdDealerUserInput.html('<input type="text" class="userinput" id="DealerUserInput'+rowNumber+'" name="DealerUserInput'+rowNumber+'" />');tdDealerPOInput.html('<input type="text" class="poinput" id="DealerPOInput'+rowNumber+'" name="DealerPOInput'+rowNumber+'" />');tdRemarks.html('<input type="text" class="remarks" id="Remarks'+rowNumber+'" name="Remarks'+rowNumber+'" />');tr.append(tdCatNumber).append(tdQuantity).append(tdReserveNumber).append(tdDealerUserInput).append(tdDealerPOInput).append(tdRemarks).attr("id","row"+rowNumber)}else{tr.append(tdCatNumber).append(tdQuantity).append(tdReserveNumber).attr("id","row"+rowNumber)}return tr}function checkQuickAddAndSubmit(){resetErrors();var b=$(".quickAddFields input.catalogNumber");var a=$(".quickAddFields input.quantity");b[0].value=sanitizeSkuNumber(b[0].value);if(isValidQuantity(a[0].value)){removeError("quantity",a)}else{addError("quantity",a)}if(isEmpty(a[0].value)){addError("quantity",a)}else{removeError("quantity",a)}if(isEmpty(b[0].value)){addError("required",b)}else{removeError("required",b)}if(thereAreValidationErrors()){showErrors();return false}else{return true}}function sanitizeSkuNumber(b){var a=new String(b);a=a.replace(/[^a-zA-Z0-9]/g,"");a=a.toUpperCase();return a}function iRewardsSubmitButton(){$(".submitButton .disabled").click(function(){return false});$("a.termsAndConditions").click(function(){window.open(this.href);return false});$("input.enroll").click(function(){if($("input.enroll:checked").length>0){$(".submitButton .enabled").show();$(".submitButton .disabled").hide()}else{$(".submitButton .enabled").hide();$(".submitButton .disabled").show()}})}function iRewardRedeemForm(){$("p.pointNotification").toggle();$("p.promoNotification").toggle();$("input.cashIn").click(function(){if($("input.cashIn:checked").length>0){$("#promoCode").attr("disabled",true);$("#promoCode")[0].value="";forceIE6Redraw();$("p.promoNotification").show()}else{$("#promoCode").removeAttr("disabled");forceIE6Redraw();$("p.promoNotification").hide()}});$("#promoCode").change(function(){if($(this)[0].value==""){$("input.cashIn").removeAttr("disabled");$("select.pointsToCash").removeAttr("disabled");forceIE6Redraw();$("p.pointNotification").hide()}else{$("input.cashIn").attr("disabled",true);$("select.pointsToCash").attr("disabled",true);forceIE6Redraw();$("p.pointNotification").show()}})}function initializeAccessIReward(){$(".viewAccount a").click(function(){window.open(this.href,"","width=800,height=600,scrollbars=yes");return false})}function initializeLoginWidget(){$(".loginWidget .toggleButton").click(function(){$(this).parent().find(".loginWidgetContent").slideToggle("slow",a($(this)));return false});function a(b){b.toggleClass("contracted");if(b.hasClass("contracted")){if(b.find("img").hasClass("buttonLogin")){b.find("img").attr("src","/shared-static/images/buttons/loginWidgetExpand.gif")}if(b.find("img").hasClass("buttonMyAccount")){b.find("img").attr("src","/shared-static/images/buttons/loginWidgetMyAccountExpand.gif")}}else{if(b.find("img").hasClass("buttonLogin")){b.find("img").attr("src","/shared-static/images/buttons/loginWidgetContract.gif")}if(b.find("img").hasClass("buttonMyAccount")){b.find("img").attr("src","/shared-static/images/buttons/loginWidgetMyAccountContract.gif")}}}}function initializeICard(){$("a.validateAndCheckICard").click(function(){setAjaxResponse("");var h=$(this).parents("tr");h.find("input[type=text]").addClass("validateRequired");if(validateICard(h,null)){var g=h.find("input#iCardNumber").val();var f=h.find("input#iCardAccess").val();if(g==undefined){g=h.find("span").attr("id")}if(g==undefined){g=h.find("input[type=radio]").val();f=h.find("input.text").val()}var e=h.attr("id");var b=h.attr("class");setValuesToICardForm(g,f);validateWebMethod(h);var d=$("input[name=subTotalAfterPriceCall]").val();iCardErrors={noResponse:"We are sorry, we are unable to accept SimpleSci&trade; as the only mode of payment at this time. Please select a different mode of payment or combine the selected SimpleSci&trade; with a second mode of payment.",insufficientBalance:"Insufficient funds on your SimpleSci&trade; Card. Your order total is "+d+". <br />Please select a different mode of payment or combine the selected SimpleSci&trade; card with a second mode of payment.",invalidCardIDCodeCombination:"We're sorry, but we were not able to validate your information. Please check your SimpleSci&trade; Card ID and access code, and try again. If you continue to have problems, please contact customer service."};forceIE6Redraw();$.extend(window.errors,iCardErrors);var j=0;if(h.find("input.iCardNumber").length>0){var c=h.find("input.iCardNumber").val().replace(/\D/g,"");j=c.substring(0,c.length-4).replace(/\d/g,"X")+c.substring(c.length-4);$("div.useThisICard td.iCardNumber").text(j)}else{j=h.find("td.iCardNumber span").text();$("div.useThisICard td.iCardNumber").text(h.find("td.iCardNumber span").text())}$("div.useThisICard td.accessCode span").text(h.find("input.iCardAccessCode").val().replace(/\d|\w/g,"*"));var a=500;$("div.useThisICard td.cardBalance").text(a);if(ajaxData!=undefined&&trim(ajaxData)!=""){setErrorInICard(ajaxData,h)}}h.find("input[type=text]").removeClass("validateRequired");return false});$("a.addICard").click(function(){$(this).prev("input").addClass("validateRequired").addClass("validateICardNumber");validateICard($(this).parents("tr"),null);$(this).prev("input").removeClass("validateRequired").removeClass("validateICardNumber");if(thereAreValidationErrors()){return false}else{setICardNumber();return true}});$("form#addProductsForm button").click(function(){var b=$("form#addProductsForm");var a=$("input#iCardSKU").val();$.extend(window.errors,{iCardQuantity:"We're sorry, but you can only add one SimpleSci&trade; at a time. You can add another SimpleSci&trade; to your cart through the Quick Order link at the top of this page."});if(b.find("input.catalogNumber").val()==a&&b.find("input.quantity").val()>1){b.find("input.quantity").val(1);addError("iCardQuantity",b);showErrors();return false}});$(".iCard input.radio").click(function(){$(this).parents("table").find("input.validateRequired").removeClass("validateRequired");$(this).parents("table").find("input[type=radio]:checked").parents("tr").find("input[type=text]").addClass("validateRequired")});if($("input#iCardInCart").val()=="true"){$(".iCardTermsAndConditions").show()}if($("input#isValidICardCountry").val()=="true"){$("div.savedICards").show()}}function forceIE6Redraw(){if(jQuery.browser.msie){$("body, .panelButton, fieldset.panel, .submitButton").each(function(){$(this).css("display","none")});$("body, .panelButton, fieldset.panel, .submitButton").each(function(){$(this).css("display","block")})}}function setAjaxResponse(a){ajaxData=a;return true}function setErrorInICard(a,b){switch(a){case"noResponse":addError("noResponse",b);showErrors();$("div.useThisICard").fadeIn();$(".iCard").add($("li.paymentTypeICard")).remove();$(".purchaseOrder").show();$(".poNumber").addClass("validateRequired");$(".paymentTypePO input[type=radio]").attr("checked",true);$(".refNoContract").show();break;case"unrecognizedCard":b.find("input[type=text]").addClass("error");addError("invalidCardIDCodeCombination",b);showErrors();break;case"insufficientBalance":addError("insufficientBalance",b);showErrors();$(".iCard").fadeOut(10,function(){$(".purchaseOrder").show()});$("div.useThisICard").fadeIn();$(".poNumber").addClass("validateRequired");$(".paymentTypePO input[type=radio]").attr("checked",true);$(".refNoContract").show();break;case"sufficientBalance":b.find("input.iCardNumber").parent("span").text(numX);b.find("input.iCardAccessCode").parents("td").addClass("validICard").children("span").text(b.find("input.iCardAccessCode").val().replace(/\d|\w/g,"*"));$(this).parent("td").text(cardBalance);b.find("input[type=radio]").attr("checked",true);break}return false}function currentSCMSID(){$("select#CostCenterSelected").change(function(){$(".scidCC").hide();var b=$(this).val();var a=".eachSCID_"+b;$(a).show();generateSCIDAndCCMap()})}function initializeNewSelectAlls(){$("#selectAllCartItems").click(function(){var a=this.checked;$("#cartItems input:checkbox").each(function(){this.checked=a})})}function initializeNewUpdateBeforeCheckout(){$("#cartItems input:text").keyup(function(){console.log("Vis here");if(this.value!=this.defaultValue){console.log("Vis changing to update Cart");changeNewCheckoutButtonToUpdateCart()}})}function changeNewCheckoutButtonToUpdateCart(){$("form#cartForm").removeAttr("onsubmit");$("form#cartForm").unbind("submit");$("form#cartForm").submit(function(){validateAndSubmitCartForm("updateCart");return false});$("#updateCartBtn").removeClass("secondary-button");$("#updateCartBtn").addClass("primary-button");$("#checkOutCartBtn").removeClass("primary-button");$("#checkOutCartBtn").addClass("secondary-button");$("#updateCartBtn").click(function(){validateAndSubmitCartForm("updateCart");return false});$("#checkOutCartBtn").unbind("click")}function checkPaymentType(){var a=0;for(var b=0;b<paymentTypes.length;b++){var c=document.getElementById("payment_"+paymentTypes[b]);if(c&&c.checked){a++}}if(!a){alert("Invalid payment options selected. Partner payment information must allow either credit card or purchase order");return false}return true}function linkDisabler(){$("a.linkDisabler").each(function(){$(this).click(function(){var a=$(this).attr("href");$(this).parent().next().show();$(this).parent().hide();document.location.href=a})})};
