var Ebuy = new Class({ initialize: function(){ }, showPanel:function(){ $('ecommerce').setStyle('display', 'block'); }, hidePanel:function(){ $('ecommerce').setStyle('display', 'none'); }, buyPanel:function(){ if (($('pro').value == "") && ($('codpro').value == "")) { alert("Please fill in customer code field, thank you"); } else if ($('quantity').value == "") { alert("La quantita' non puo' essere vuota."); } else { var prodotto = $('codpro').value; if (prodotto == "") { prodotto = $('pro').value; } var req = new Request.JSON({ url: '/savecommerce.php', // l'url da contattare async: true, onComplete: function(json) { if (json.result == "singolo") { alert("The product has been added to the basket."); } else if (json.result == "multiplo") { if (confirm("This article is part of a set or has components that must be chosen. Do you want to continue?")) { window.open("/multipli.php?codpro=" + prodotto + "&quantity=" + $('quantity').value,"buywindow","status=no,toolbar=no,width=700,height=700,scrollbars=yes"); } } else { alert(json.message); } } }).get({ 'codpro': prodotto, 'quantity':$('quantity').value }); req.get(); } } }); window.addEvent('domready', function() { var status = { 'true': 'open', 'false': 'close' }; var posizione = 0; //--horizontal var myHorizontalSlide = new Fx.Slide('secondo', {mode: 'horizontal'}); myHorizontalSlide.hide(); $('h_slidein').addEvent('click', function(e){ e.stop(); if (posizione == 0) { myHorizontalSlide.slideIn(); posizione = 1; } else { myHorizontalSlide.slideOut(); posizione = 0; } }); //$('h_slideout').addEvent('click', function(e){ // e.stop(); // myHorizontalSlide.slideOut(); //}); // When Horizontal Slide ends its transition, we check for its status // note that complete will not affect 'hide' and 'show' methods myHorizontalSlide.addEvent('complete', function() { // $('horizontal_status').set('html', status[myHorizontalSlide.open]); }); var ebuy = new Ebuy(); if ($('buybut')) { $('buybut').addEvent('click',function(event){ event.stop(); ebuy.showPanel(); }); } if ($('chiudi')) { $('chiudi').addEvent('click',function(event){ event.stop(); ebuy.hidePanel(); }); } if ($('acquista')) { $('acquista').addEvent('click',function(event){ event.stop(); ebuy.buyPanel(); }); } });