/** * 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 -1 || navigator.appVersion.indexOf("msie 6") > -1) ) { document.writeln(''); window.attachEvent("onload", fnLoadPngs); } function fnLoadPngs() { var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, ''); var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5); for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) { if (itsAllGood && img.src.match(/(.*)\/com_virtuemart\/(.*)\.png$/i) != null) { fnFixPng(img); img.attachEvent("onpropertychange", fnPropertyChanged); } img.style.visibility = "visible"; } var nl = document.getElementsByTagName("INPUT"); for (var i = nl.length - 1, e = null; (e = nl[i]); i--) { if (e.className && e.className.match(/\bimage\b/i) != null) { if (e.src.match(/\.png$/i) != null) { fnFixPng(e); e.attachEvent("onpropertychange", fnPropertyChanged); } e.style.visibility = "visible"; } } } function fnPropertyChanged() { if (window.event.propertyName == "src") { var el = window.event.srcElement; if (!el.src.match(/x\.gif$/i)) { el.filters.item(0).src = el.src; el.src = "x.gif"; } } } function dbg(o) { var s = ""; var i = 0; for (var p in o) { s += p + ": " + o[p] + "\n"; if (++i % 10 == 0) { alert(s); s = ""; } } alert(s); } function fnFixPng(img) { var src = img.src; img.style.width = img.width + "px"; img.style.height = img.height + "px"; img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"; img.src = "components/com_virtuemart/shop_image/blank.gif"; }