function font_set_onchange(base_path, path_to_theme){ $("#edit-attributes-3").change(function(){font_image(base_path, path_to_theme)}); font_image(base_path, path_to_theme); quantity_set_onkeyup(); colour_set_onchange(); } function font_image(base_path, path_to_theme){ var font_value = $("#edit-attributes-3 option:selected").val(); $('#fontimage').remove(); var path = base_path+path_to_theme+'/images/font_images/'+font_value+'.gif' $("#edit-attributes-3").after("   "); $("#edit-attributes-3").parent().attr("width","250px"); } function colour_set_onchange(){ $("#edit-attributes-2").change(function(){quantity_update()}); } var search_timeout = undefined; function quantity_set_onkeyup(){ $("#edit-qty").keyup(function(){quantity_onkeyup()}); } function quantity_onkeyup(){ if(search_timeout != undefined) { clearTimeout(search_timeout); } var $this = this; // save reference to 'this' so we can use it in timeout function search_timeout = setTimeout(function() { search_timeout = undefined; quantity_update(); }, 1000); } function quantity_update(){ var qty_value = $("#edit-qty").val(); var colour = $("#edit-attributes-2").val(); var price = '$3.50'; if(qty_value <= 50 && colour == 2){ price = '$3.50'; } else if(qty_value <= 50 && colour == 1){ price = '$3.00'; } else if(qty_value <= 100 && colour == 2){ price = '$2.50'; } else if(qty_value <= 100 && colour == 1){ price = '$2.20'; } else if(qty_value <= 200 && colour == 2){ price = '$2.40'; } else if(qty_value <= 200 && colour == 1){ price = '$2.10'; } else if(qty_value <= 300 && colour == 2){ price = '$2.30'; } else if(qty_value <= 300 && colour == 1){ price = '$2.00'; } else if(qty_value <= 400 && colour == 2){ price = '$2.20'; } else if(qty_value <= 400 && colour == 1){ price = '$1.80'; } else if(qty_value <= 500 && colour == 2){ price = '$2.00'; } else if(qty_value <= 500 && colour == 1){ price = '$1.50'; } else if(qty_value <= 1000 && colour == 2){ price = '$1.75'; } else if(qty_value <= 1000 && colour == 1){ price = '$1.30'; } else if(qty_value <= 2000 && colour == 2){ price = '$1.50'; } else if(qty_value <= 2000 && colour == 1){ price = '$1.20'; } else if(qty_value <= 3000 && colour == 2){ price = '$1.25'; } else if(qty_value <= 3000 && colour == 1){ price = '$1.10'; } else if(qty_value <= 5000 && colour == 2){ price = '$1.00'; } else if(qty_value <= 5000 && colour == 1){ price = '$1.00'; } else { price = 'N/A'; } $('div.sell_price').empty(); $('div.sell_price').append('Price: ' + price); $('div.display_price').empty(); $('div.display_price').append(price); }