/** Generators website javascript functions **/ function refreshComparisons() { var refreshCodes = new Array(); if ( (document.getElementById('compareCombo1') != null) && (document.getElementById('compareCombo1').value != '' ) ) { refreshCodes[0] = document.getElementById('compareCombo1').value; } if ( (document.getElementById('compareCombo2') != null) && (document.getElementById('compareCombo2').value != '' ) ) { refreshCodes[1] = document.getElementById('compareCombo2').value; } if ( (document.getElementById('compareCombo3') != null) && (document.getElementById('compareCombo3').value != '' ) ) { refreshCodes[2] = document.getElementById('compareCombo3').value; } renderComparisons(refreshCodes); } function renderComparisons(codes) { if ( codes.length == 2 ) { $('#compareResultsTable').getTransform('templates/compare.xsl', 'products/products.xml', {params: {'code1': codes[0], 'code2': codes[1]}}); $('#compareSelectTable').getTransform('templates/compare-dd.xsl', 'products/products.xml', {params: {'code1': codes[0], 'code2': codes[1]}}); } else if ( codes.length == 3 ) { $('#compareResultsTable').getTransform('templates/compare.xsl', 'products/products.xml', {params: {'code1': codes[0], 'code2': codes[1], 'code3': codes[2]}}); $('#compareSelectTable').getTransform('templates/compare-dd.xsl', 'products/products.xml', {params: {'code1': codes[0], 'code2': codes[1], 'code3': codes[2]}}); } else { alert('Please select 2 or 3 products to compare'); return; } } /** * Adds the items (with a suffix) to the combo element referenced by id */ function populateCombo(id, items, suffix) { for (i=0; i 3) ) { if ( (ancor.href.split('&').length < 2) ) { alert('Please select a minimum of 2 products to compare'); return false; } if ( (ancor.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; } } /** * Called by each compare checkbox, appends the selected product code * with the appropriate URL parameter name to the href of the actual * hyperlink, so when the user is ready to proceed to compare the URL * will have been composed. */ function appendProductCode(name, checkbox) { var url = 'compare.html?'; $('input[@name=compare]').filter(':checked').each(function() { url += 'code=' + $(this).attr('id') + '&'; }); url = url.substring(0, url.length-1); $('#compareLink').attr('href', url); $('#compareLinkBottom').attr('href', url); } /** * Alerts the user to the redirect to seddons site for purchase */ function redirectConfirm() { var answer = confirm('Please note:\n\nAll online purchases are handled by our Honda Approved Partner.\n\nIf you click OK you will be redirected to their site in order to complete your order.'); return answer; }