/* * * * * * GRID Framework * * * * * copyright 2008 by Webfarmer (www.webfarmer.ch) * */ function sendToCart(articleid, amount) { if($('simplecart')) { //we've got a displayed cart, we'll update this one... new Ajax.Updater('simplecart','../api/shop/cart.snippet.html',{ method:'post', parameters: { remotecall_shop: 'addToCart', id: articleid, amount: amount }, onSuccess: function(transport){ //lets highlight the thingy $('simplecart').style.color = "#F00"; setTimeout("$('simplecart').style.color = '#000';",250); setTimeout("$('simplecart').style.color = '#F00';",500); setTimeout("$('simplecart').style.color = '#000';",750); }, onFailure: function(transport){ alert('Could not update your cart.'); } }); }else{ //we just send the information to the cart... alert('no cart found on this page...'); } } /************************************************** * selects a selectbox option with a given value **************************************************/ function selecta(selectboxid, val) { if($(selectboxid)) { var selectbox = $(selectboxid); for (var i = 0; i < selectbox.options.length; i++) { if(selectbox.options[i].value == val) { selectbox.options[i].selected = true; } } } } /************************************************** * checks radioboxes with the given value **************************************************/ function radiochecker(radioboxname, boxvalues, uncheck, defaultvalue) { if(typeof boxvalues == 'string' && boxvalues != '') { var x = new Array(); x.push(boxvalues); boxvalues = x; } else if (boxvalues == '') { boxvalues = new Array(); boxvalues.push(defaultvalue); } $$('input[name="'+radioboxname+'"]').each(function(elem) { if(boxvalues.in_array(elem.value)) { elem.checked = 'checked'; } else { if(typeof uncheck != undefined) { elem.checked = ''; } } }); } Array.prototype.in_array = function(p_val) { for(var i = 0, l = this.length; i < l; i++) { if(this[i] == p_val) { return true; } } return false; }