// Javascript for all pages
$(document).ready(function() {

    // Prepare links to activate overlays
    $("a[rel]").overlay({

        // Specify the z-index
        zIndex: '800',

        // Apple effect
        effect: 'apple',

        // custom expose settings
        expose: {
            color: '#000000',
            opacity: 0.7,
            closeSpeed: 500,
            zIndex:'799'
        }
    });

    // Event listener for Q&A drop-down menus (to jump to question upon selecting an item from the drop-down)
    $('#question_list').change(function(){
        selectedQuestion = $(this).val();
//        alert('changed to :'+selectedQuestion);
        // Jump to selected question
        $.scrollTo($("#"+selectedQuestion), 'normal' );
//        window.location = location.href+"#"+selectedQuestion
    });

});

// Adds product(s) to the magento cart via AJAX
function add_to_cart(arrProductIDs) {
    // Set the cursor to 'waiting'
    $('body').css('cursor', 'wait');
    // Assemble the query string containing the product IDs
    var queryString = '';
    $(arrProductIDs).each(function(index, value){
        if (queryString){
            queryString += '&product[]='+value;
        } else {
            queryString += '?product[]='+value;
        }
    });
    // Add the product to the magento cart and redirect to cart page
    window.location = magento_url+'checkout/cart/add'+queryString;
//    $.get(base_url+'cart/checkout/cart/add', { product: productID, qty: 1 }, function(){
//        window.location = base_url+'cart/checkout/cart/';
        // window.location.replace(base_url+'cart/checkout/cart/');
//    });
}
