// set this to false for production use var products = null; /** * jQuery: this is always called when the page DOM is * ready for manipulation */ $(document).ready(function() { // pre-load products from xml file products = jQuery.load("products/products.xml"); // show all products $('#resultsWrapper').slideDown(1500); // fill the first combo with list of searchable categories $("#masterCombo").fillFromArray(SEARCHABLES, 0); if( $('#masterCombo').children().size() > 2 ) { $("#criteriaTable").show(); } // ensure all other combos are hidden $('.childrenCombo').hide(); // declare event handle to action apon clicking on // either compare buttons $(".compareButton a").click( function(event) { return validateCompareSelection($(this)); } ); // if the first combo is changed then execute this $("#masterCombo").change(function(event, data) { //ANIMATE HIDE $("#childComboWrapper").hide(); $("#resultsWrapper").hide(); $(products).find('product').each(function() { $('#resultsInner').createProductRow($(this)); }); var value = ""; if (data != undefined) { value = data; } else { value = $(this).find(':selected').val(); } $('.childCombo').remove(); $('#childComboWrapper br.clear').remove(); // only populate remaining combos if the user has actually selected something if (value != "Please Select") { var childCombos = SEARCHABLES[value].slice(2, SEARCHABLES[value].length); // render empty child combos for (i=0; i 3) ) { if ( ($(ancor).attr("href").split('&').length < 2) ) { alert('Please select a minimum of 2 products to compare'); return false; } if ( ($(ancor).attr("href").split('&').length > 3) ) { alert('Please select a maximum of 3 products to compare'); return false; } alert('Please select 2 or 3 products to compare'); return false; } // check to ensure that chosen products belong to the same category var codes = $(ancor).attr("href").split('?')[1].split('&'); var categories = new Array(); var error = false; $(products).find("product").filter(function() { for (i=0; i'; html += '
'; html += 'Image of ' + code + ''; html += '
'; html += '

' + code + '
' + prodID + '

'; html += '
'; $(productXML).find("specgroup").each(function() { html += '
'; var specs = $(this).find('spec').filter('spec[@display]').sort('display'); html += '
    '; $(specs).each(function() { html += '
  • ' + $(this).attr('name') + '' + $(this).text() + '
  • '; }); html += '
'; html += '
'; }); html += '
'; html += ''; html += '
'; html += ''; $(this).append(html); } /** * Reads in all the criteria values chosen by the user * and applies them to the filter procedure to arrive at * a properly filtered list of products which are then * appended to the specified element. * @parent : the element to attach the results to * @param products : full list of products in XML format */ jQuery.fn.filterResultsjQuery = function(products) { var id = $(this); $(id).empty(); var gardenProduct = $("#masterCombo").find(":selected").val(); var filterCriteria = new Array(); if ( $(".childCombo").is(':visible') ) { $(".childCombo").each(function() { var selectedOption = $(this).find("select").find(":selected").text(); var selectedLabel = $(this).find("label").text(); filterCriteria[filterCriteria.length] = new Array(selectedLabel,selectedOption); }); } $(products).find("product").filter(function() { var product = $(this); var show = new Array(); if ( (gardenProduct == undefined) || (gardenProduct == 'Please Select') || (gardenProduct == '') ) { show[show.length] = "true"; } else if ( SEARCHABLES[gardenProduct][1] != $(this).find("category").attr("id") ) { return false; } for (i=0; i