/** * This file holds javscript functions that are used by the templates in the Theme * */ // AJAX FUNCTIONS function loadNewPage( el, url ) { var theEl = $(el); var callback = { success : function(responseText) { theEl.innerHTML = responseText; if( Lightbox ) Lightbox.init(); } } var opt = { // Use POST method: 'get', // Handle successful response onComplete: callback.success } new Ajax( url + '&only_page=1', opt ).request(); } function handleGoToCart() { document.location = live_site + '/index.php?option=com_virtuemart&page=shop.cart&product_id=' + formCartAdd.product_id.value ; } function handleAddToCart( formId, parameters ) { formCartAdd = document.getElementById( formId ); var callback = function(responseText) { updateMiniCarts(); // close an existing mooPrompt box first, before attempting to create a new one (thanks wellsie!) if (document.boxB) { document.boxB.close(); clearTimeout(timeoutID); } document.boxB = new MooPrompt(notice_lbl, responseText, { buttons: 2, width:400, height:150, overlay: false, button1: ok_lbl, button2: cart_title, onButton2: handleGoToCart }); setTimeout( 'document.boxB.close()', 3000 ); } var opt = { // Use POST method: 'post', // Send this lovely data data: $(formId), // Handle successful response onComplete: callback, evalScripts: true } new Ajax(formCartAdd.action, opt).request(); } /** * This function searches for all elements with the class name "vmCartModule" and * updates them with the contents of the page "shop.basket_short" after a cart modification event */ function updateMiniCarts() { var callbackCart = function(responseText) { carts = $$( '.vmCartModule' ); if( carts ) { try { for (var i=0; i