var sHeaderInfoDisplayState = ""; var preLoadedContent = "" var nFullHeight = 50; $(document).ready(function(){ $.validator.setDefaults({ // submitHandler: function() { return true; } }); $.validator.addMethod("dateAU", function(value, element){ if (this.optional(element)) return true; var objRegEx = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/; var re_match = objRegEx.exec(value) if (re_match) { switch (re_match[2]) { case "04": case "06": case "09": case "11": { // Sep, Apr, Jun, Nov return Number(re_match[1]) <= 30; break; } case "02": // Feb if (isLeapYear(Number(re_match[3]))) return Number(re_match[1]) <= 29; else return Number(re_match[1]) <= 28; break; default: // all other months return true; } return false; } return false; }, "Please select a valid date"); $.validator.addMethod("phoneNo", function(value, element){ if (this.optional(element)) return true; var sAllowableChars = value.replace(/[^\d\(\) \-\+]/g, ""); var sNumbersOnly = value.replace(/[^\d]/g, ""); // if (element.value != sAllowableChars) element.value = sAllowableChars; return sNumbersOnly.length >= 7; }, "Please enter a valid phone number"); $("#advSearch").click(function(){ if ($("#advSearchOptions:visible").length == 0) { showSearchOptions(120); } else { hideSearchOptions(); } return false; }); $("#advSearchOptions .closeWin").click(function(){ hideSearchOptions(); }); $("#advSearchOptions input[type=radio]").click(function(){ hideSearchOptions(); if ($("input[name=rbAdvSearchOption]:checked").val() != "search-all") $("#advSearch").text("Advanced Search [active]"); else $("#advSearch").text("Advanced Search"); }); $("#hdrTab1").click( function(){ // CAN WE HELP tab setDynamicRegion(100, function(){loadCanWeHelpForm();}, "CANWEHELP"); return false; }); $("#hdrTab2").click( function(){ // COMM FINDER tab setDynamicRegion(140, function(){loadFinderForm();}, "COMMFINDER"); return false; } ); function showSearchOptions(nBoxHeight) { // $("#advSearchOptions").toggle(); // $("#advSearchOptions .closeWin").show(); $("#advSearchOptions").show(); $("#advSearchOptions .inner").css({height:'0px'}); // for ie6 $("#advSearchOptions .inner").show(); // for ie6 $("#advSearchOptions .inner").animate( { height: String(nBoxHeight+10) + 'px' }, 500).animate( { height: String(nBoxHeight) + 'px' }, 200, null, function(){$("#advSearchOptions .closeWin").show();}); } function hideSearchOptions() { $("#advSearchOptions .closeWin").hide(); $("#advSearchOptions .inner").animate( { height: '0px' }, 600, null, function(){ $("#advSearchOptions").hide(); }); } preLoadedContent = "
"; $("#hdrDynamicRegion .closeWin").click(function(){ closeDynamicRegion(); }); function setDynamicRegion(nFullHeight, objFunc, sHeaderInfoDisplayState_In) { if ($("#hdrDynamicRegion:visible").length == 0) { $("#hdrDynamicRegion .inner").html(preLoadedContent); $("#hdrDynamicRegion").show(); $("#hdrDynamicRegion .inner").css({height:'0px'}); // for ie6 $("#hdrDynamicRegion .inner").show(); // for ie6 $("#hdrDynamicRegion .inner").animate( { height: String(nFullHeight+10) + 'px' }, 1200).animate( { height: String(nFullHeight) + 'px' }, 500, null, objFunc); sHeaderInfoDisplayState = sHeaderInfoDisplayState_In; setExpandStateSignsOnTabs(sHeaderInfoDisplayState); } else { if ((sHeaderInfoDisplayState.length) && (sHeaderInfoDisplayState != sHeaderInfoDisplayState_In)) { // dynamic region is already visible with other content $("#hdrDynamicRegion .inner").html(preLoadedContent); var nFirstTweenPointHeight = ((sHeaderInfoDisplayState=="CANWEHELP") ? nFullHeight+10 : nFullHeight-10); $("#hdrDynamicRegion .inner").animate( { height: String(nFirstTweenPointHeight) + 'px' }, 1200).animate( { height: String(nFullHeight) + 'px' }, 500, null, objFunc); sHeaderInfoDisplayState = sHeaderInfoDisplayState_In; setExpandStateSignsOnTabs(sHeaderInfoDisplayState); } else { closeDynamicRegion(); sHeaderInfoDisplayState = ""; } } } }); function closeDynamicRegion() { $("#hdrDynamicRegion a.closeWin").hide(); $("#hdrDynamicRegion .inner").html(preLoadedContent); $("#hdrDynamicRegion .inner").animate( { height: '0px' }, 600, null, function(){$("#hdrDynamicRegion").hide()}); $("#hdrTab1").removeClass("icon-collapse"); $("#hdrTab2").removeClass("icon-collapse"); } function loadFinderForm() { $("#hdrDynamicRegion a.closeWin").show(); $.ajax({ url: "commfinder-basic.htm", cache: false, success: function(htmlResponse){ $("#hdrDynamicRegion .inner").html(htmlResponse); } }); } function loadCanWeHelpForm() { $("#hdrDynamicRegion a.closeWin").show(); $.ajax({ url: "service_request_search_form.htm", cache: false, success: function(htmlResponse){ $("#hdrDynamicRegion .inner").html($(htmlResponse).find('#CanWeHelpForm')); } }); } function setExpandStateSignsOnTabs(sHeaderInfoDisplayState_In) { if (sHeaderInfoDisplayState_In == "CANWEHELP") { $("#hdrTab1").addClass("icon-collapse"); // active $("#hdrTab2").removeClass("icon-collapse"); } else { $("#hdrTab1").removeClass("icon-collapse"); $("#hdrTab2").addClass("icon-collapse"); // active } } function init_MultiSelectCheckBoxes(){ $(".multiCheckboxSet ul.body input[type=checkbox]").click(function(e){ $(e.target).parent().parent().find("input").attr("checked", $(e.target).attr("checked")); // check all checkboxes that are children of the current checkbox if(!$(e.target).attr("checked")) { // uncheck the ancestors of the current item turnOffParentCheckboxes(e.target, 0); } }); $(".multiCheckboxSet ul.body a").click(function(e){ if ($(e.target).attr("class") != "closed") { // expand the item $(e.target).html(" - "); $(e.target).attr("class", "closed"); $(e.target).parent().find("ul").css("display", "block"); $(e.target).parent().find("ul ul").css("display", "none"); // expand down one level only } else { // close the item $(e.target).html(" + "); $(e.target).attr("class", "open"); $(e.target).parent().find("ul").css("display", "none"); } }); } function turnOffParentCheckboxes(e_target) { var parentListItems = $(e_target).parent().parent().parents("li"); // start looking for parents above the current
  • (the
  • that contained the checkbox that was clicked) parentListItems.find("> label input[type=checkbox]").attr("checked", false); // turn off the checkbox nested in the label immediately underneath the
  • } function disableChildCheckboxes() { // disable all child checkboxes of a checked checkbox $(".multiCheckboxSet ul.body").find("label > input[type=checkbox]:checked").parent().parent().find("li label input[type=checkbox]:checked").attr("disabled", "disabled"); // debug(); } function isLeapYear(nYear) { if (nYear%400 == 0) { return true; } else if (nYear%100 == 0) { return false; } else if (nYear%4 == 0) { return true; } else return false }