/** * Brilliant AdditionalCatalogView * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * * * Assumes existance of jQuery and instantiation before this script is loaded * * @category   Brilliant * @package    Brilliant_AdditionalCatalogView * @copyright  Copyright (c) 2010 Pod1 (http://www.pod1.com) * @license    ???  */var quickBuyBox = {    currentQBForm: '',    /**     * Copy from send cart of ajax cart and customization in order to have the same behaviour.     */    sendcart: function () {        showLoading();        url = ($('product_addtocart_form').action).replace('checkout', 'j2tajaxcheckout/index/cart');        var myAjax = new Ajax.Request(        url, {            method: 'post',            postBody: $('product_addtocart_form').serialize(),            parameters: Form.serialize("product_addtocart_form"),            onException: function (xhr, e) {                alert('Exception : ' + e);            },            onComplete: function (xhr) {                jQuery('#ajax_cart_holder').html(xhr.responseText).css('display', 'block');                //cufonInitialization();                cart_timeout = setTimeout(fade, 5000);                jQuery('#ajax_cart_holder a, #ajax_cart_holder input, #ajax_cart_holder button').focus(function () {                    clearTimeout(cart_timeout);                });                hideJ2tOverlay();            }        });    },    //spConfig: null,    /**     * quickBuy.displayProduct(this, 'http://...');     */    displayProduct: function (element, productID, baseUrl) {        //http://bukdev.com/magento/pod1/branches/occa/additionalcatalogview/product/quickbuybox/id/4?mode=overlay        //console.log('displaying ' + baseUrl);        var productQuickBuyUrl = baseUrl;        productQuickBuyUrl += 'additionalcatalogview/product/quickbuybox/id/';        productQuickBuyUrl += productID;        //jQuery('.product-quick-buy').hide();        jQuery.ajax({            //type: "GET",            //async: true,            //dataType: "html",            url: productQuickBuyUrl,            //trigger error url to see what's going on            //cache: true,            error: function (data) {                //console.log('error result');                jQuery('#fancybox-wrap').hide();            },            success: function (data) {                				//jQuery('#fancybox-inner').append('<br />');                jQuery('#fancybox-inner').append(data);                                var productAddToCartFormQB = new VarienForm('product_addtocart_form');                // Store last one locally (So that web page can call it):                quickBuyBox.currentQBForm = productAddToCartFormQB;                if (typeof productAddToCartFormQB != 'undefined') {                    if ($('j2t-overlay')) {                        Event.observe($('j2t-overlay'), 'click', hideJ2tOverlay);                    }                    productAddToCartFormQB.submit = function () {                        jQuery('#fancybox-close').click();                        if (this.validator && this.validator.validate()) {                            quickBuyBox.sendcart();                        }                    }                }                                //console.log('baseUrl: ' + baseUrl);                                /**/jQuery.ajax({                    url: baseUrl + 'additionalcatalogview/product/getconfig/id/' + productID,                    dataType: 'json',                    //data: null,					error: function (data) {						console.log('error result');					},                    success: function(data) {                        var spConfig = new Product.Config(data);						console.log(spConfig);                    }                    });                return false;            }        });        return false;    }    /*set_attribute_selected_value: function(attribute_id, val) {            //console.log('call set_attribute_selected_value');                       dropdown = document.getElementById('attribute' + attribute_id);            if (dropdown != null) {                for ( var i = 0; i < dropdown.options.length; i++ ) {                    if ( dropdown.options[i].value == val ) {                        dropdown.selectedIndex = i;                        break;                    }                }            }                        quickBuyBox.spConfig.configureElement($('attribute' + attribute_id));        }*/}
