// JavaScript Document $(document).ready(function(){ // Use this example, or... $('a[@rel*=lightbox]').lightBox({imageLoading: '/images/lightbox/lightbox-ico-loading.gif', imageBtnClose: '/images/lightbox/lightbox-btn-close.gif', imageBtnPrev: '/images/lightbox/lightbox-btn-prev.gif', imageBtnNext: '/images/lightbox/lightbox-btn-next.gif', containerResizeSpeed: 350 }); // Select all links that contains lightbox in the attribute rel $("#products > li > a").click(function(e) { current = $(this).parent().find("ul.sub"); $("#products > li > ul.sub").each(function(e){ if ($(this).css("display") != 'none'){ if ($(this).html() != current.html()){ $(this).hide('slow'); } } }); if ($(this).parent().find("ul").css("display") != 'none'){ $(this).parent().find("ul").hide('slow'); }else{ $(this).parent().find("ul").show('slow'); } e.preventDefault(); }); $("a.cart_view").click(function(e) { $("#cart_view_dialogue").fadeIn('slow'); $(this).fadeOut('fast'); e.preventDefault(); }); $("a.more,a.less,a.delete").click(function(e){ infostring = this.href.split(".php"); args = infostring[1].split("/"); $.post("/resources/helpers/cart/update_product.php", { item_id: args[args.length-3], key: args[args.length-2], value: args[args.length-1] }, function(data){ $.post("/resources/helpers/cart/update_cart_view.php",function(data){if (data== ''){$("#cart_view_dialogue").fadeOut("slow");}else{$("#cart_view_dialogue").html(data)}}); $.post("/resources/helpers/cart/update_cart_shortlist.php",function(data){if (data== ''){$("ul.shortlist").parent().fadeOut("slow")}else{$("ul.shortlist").html(data)}}); } ); e.preventDefault(); }); $(".validate").blur(function() { $(this).validate.init(this); }); $(".validate").focus(function() { $(this).validate.init(this); }); duplicate_originals = new Array(); $(this).find(".no_duplicate").each(function() {duplicate_originals[this.id] = this.value;}); $('.date_picker').each(function() {$(this).calendar(this);}); /* force validation on submit */ $("form#orders,form#contact").submit(function(e){ var approve = true; $(this).find(".validate").each(function() { $(this).validate.init(this); //approve = false; }); $(this).find(".error").each(function() {approve = false}); if (!approve){ e.preventDefault(); } }); }); function register(obj){ $(obj).click(function(e){ infostring = this.href.split(".php"); args = infostring[1].split("/"); $.post("/resources/helpers/cart/update_product.php", { item_id: args[args.length-3], key: args[args.length-2], value: args[args.length-1] }, function(data){ $.post("/resources/helpers/cart/update_cart_view.php",function(data){$("#cart_view_dialogue").html(data)}); $.post("/resources/helpers/cart/update_cart_shortlist.php",function(data){$("ul.shortlist").html(data)}); } ); e.preventDefault(); }); } function less(obj){ infostring = obj.split(".php/products/"); args = infostring[1].split("/"); $.post("/resources/helpers/cart/update_product.php", { item_id: args[3], key: args[4], value: args[5] }, function(data){ $.post("/resources/helpers/cart/update_cart_view.php",function(data){$("#cart_view_dialogue").html(data)}); e.preventDefault(); } ); } function cancel_add(){ $("#cart_add_dialogue").fadeOut('slow'); } function cancel_view(){ $("#cart_view_dialogue").fadeOut('slow'); $("a.cart_view").fadeIn('fast'); }