function hide_left_menu(){ hide_all_categories(); $$('.level_1' ).each(function(e) { e.setStyle('cursor: pointer'); if(e.down('ul')) { if(e.hasClassName('current')) e.down('ul').show(); e.observe('click' , function (event) { hide_all_categories(); e.down('ul').toggle(); remove_all_current(); e.addClassName('current'); }); } }); } function hide_all_categories(){ $$('.level_1' ).each(function(e) { if(e.down('ul')) { e.down('ul').hide(); } }); } function hide_left_menu_over(){ hide_all_categories(); $$('.level_1' ).each(function(e) { e.setStyle('cursor: pointer'); if(e.down('ul')) { if(e.hasClassName('current')) e.down('ul').show(); e.observe('click' , function (event) { hide_all_categories(); e.down('ul').toggle(); remove_all_current(); e.addClassName('current'); }); e.observe('mouseover' , function (event) { hide_all_categories(); e.down('ul').toggle(); }); e.observe('mouseout' , function (event) { hide_all_categories(); }); } }); } function hide_left_menu_over2(){ jQuery(document).ready( function(){ jQuery(".level_1").bind("mouseenter", function(){ alert('ciao'); }); } ); }//Some observer to load at the start document.observe('dom:loaded' , function() { //To show the layer with the items $$('.cart-show' ).each(function(e) { e.observe('mouseover' , function (event) { if($('cart-result') && $('demo-element-blind')){ $('cart-result' ).addClassName('cart-extended'); $('demo-element-blind' ).clonePosition($('cart-result' ), { setHeight: false, offsetTop: $('cart-result' ).offsetHeight }); $('demo-element-blind' ).show(); } }); }); $$('.cart-show' ).each(function(e) { e.observe('mouseout' , function (event) { if($('cart-result') && $('demo-element-blind')){ $('cart-result' ).removeClassName('cart-extended'); $('demo-element-blind' ).hide(); } }); }); //To make the search better //TO DO }); function remove_all_current(){ $$('.level_1' ).each(function(e) { /* if(e.down('ul')) { */ e.removeClassName('current'); /* } */ }); } /* from here is jQuery code*/ // JavaScript for product author: Daniele Suppo daniele@suppo.org //Some observer to load at the start document.observe('dom:loaded' , function() { if($('img-big-show') && $('img-big-image') && $('img-big-background')){ $('img-big-show').observe('click' ,function (event) { if($('img-big-show').getStyle('cursor') == 'pointer'){ $('img-big-show').setStyle('cursor: move'); $('img-big-background').setStyle('cursor: move'); $('img-big-navigation').setStyle('cursor: move'); mouse_x = event.pointerX(); mouse_y = event.pointerY(); var left = $('img-big-image').getStyle('left'); var top = $('img-big-image').getStyle('top'); total_x = mouse_x - (left.substring(0,left.length-2)*1); total_y = mouse_y - (top.substring(0,top.length-2)*1); $('img-big-show').observe('mousemove' , move_image.bindAsEventListener(this, total_x, total_y)); $('img-big-background').observe('mousemove' , move_image.bindAsEventListener(this, total_x, total_y)); $('img-big-navigation').observe('mousemove' , move_image.bindAsEventListener(this, total_x, total_y)); } else { $('img-big-show').stopObserving('mousemove'); $('img-big-background').stopObserving('mousemove'); $('img-big-navigation').stopObserving('mousemove'); $('img-big-show').setStyle('cursor: pointer'); $('img-big-background').setStyle('cursor: default'); $('img-big-navigation').setStyle('cursor: default'); } }); //Check only the click to stop observing $('img-big-background').observe('click' ,function (event) { if($('img-big-show').getStyle('cursor') == 'move'){ $('img-big-show').stopObserving('mousemove'); $('img-big-background').stopObserving('mousemove'); $('img-big-navigation').stopObserving('mousemove'); $('img-big-show').setStyle('cursor: pointer'); $('img-big-background').setStyle('cursor: default'); $('img-big-navigation').setStyle('cursor: default'); } }); }}); //set by the open_zoom function var max_ratio = 0; var actual_ratio = 0; var image_width = 0; var image_height = 0; var original_image_width = 0; var original_image_height = 0; var left_margin = 60; var right_margin = 60; var navigation_width = 100; var from_top = 30; var from_bottom = 60; function open_zoom (image_name,passed_image_width,passed_image_height, passed_from_top, passed_from_bottom) { if(image_name && $('img-big-background') && $('img-big-show' )){ if(passed_from_top) from_top = passed_from_top; if(passed_from_bottom) from_bottom = passed_from_bottom; if(passed_image_width) image_width = passed_image_width; else image_width = (document.viewport.getWidth() - (right_margin + left_margin + navigation_width)); if(passed_image_height) image_height = passed_image_height; else image_height = (document.viewport.getHeight() - (from_bottom + from_top)); $('img-big-image' ).down('img').src = image_name; original_image_width = $('img-big-image' ).down('img').getStyle('width'); original_image_width = original_image_width.substring(0,(original_image_width.length-2)*1); original_image_height = $('img-big-image' ).down('img').getStyle('height'); original_image_height = original_image_height.substring(0,(original_image_height.length-2)*1); var x_ratio = original_image_width / image_width; var y_ratio = original_image_height / image_height; max_ratio = Math.max(x_ratio, y_ratio); actual_ratio = max_ratio; var actual_width = parseInt( original_image_width / actual_ratio); var actual_height = parseInt( original_image_height / actual_ratio); $('img-big-image' ).down('img').setStyle('width: ' + actual_width + 'px'); $('img-big-image' ).down('img').setStyle('height: ' + actual_height + 'px'); var to_subtract = 0; if(Prototype.Browser.Gecko) { to_subtract = 17; //try to fix the scriptaculous bug, remove it when upgrade } $('img-big-background' ).setStyle('opacity: 0.95'); $('img-big-background' ).setStyle('top: 0px'); $('img-big-background' ).setStyle('left: 0px'); $('img-big-background' ).setStyle('height: ' + (Math.max($('outer-wrapper').getHeight(),image_height + from_bottom) + from_top ) + 'px'); $('img-big-background' ).setStyle('width: ' + (document.viewport.getWidth() - to_subtract) + 'px'); $('img-big-navigation' ).setStyle('opacity: 1'); $('img-big-navigation' ).setStyle('width: ' + navigation_width + 'px'); $('img-big-navigation' ).setStyle('top: ' + from_top + 'px'); $('img-big-navigation' ).setStyle('left: ' + (left_margin + image_width) + 'px'); $('img-big-navigation' ).setStyle('height: ' + image_height + 'px'); $('img-big-show' ).setStyle('opacity: 1'); $('img-big-show' ).setStyle('left: ' + left_margin + 'px'); $('img-big-show' ).setStyle('top: ' + from_top + 'px'); $('img-big-show' ).setStyle('height: ' + image_height + 'px'); $('img-big-show' ).setStyle('width: ' + image_width +'px'); $('img-big-show' ).makeClipping(); $('img-big-image').setStyle('left: ' + ((image_width - actual_width) / 2) + 'px'); $('img-big-image').setStyle('top: ' + ((image_height - actual_height) / 2) + 'px'); //First hide the product details and classes .to-hide-for-zoom to avoid problems in IE6 if($('product-details')){ $('product-details').hide(); } $$('.to-hide-for-zoom').each(function(e) { e.hide(); }); $('img-big-show').show(); $('img-big-navigation').show(); $('img-big-background').show(); } } function change_zoom(image_name){ if(image_name && $('img-big-image')){ $('img-big-image' ).down('img').src = image_name; } } function close_zoom (){ if($('img-big-background') && $('img-big-show' )){ $('img-big-show' ).hide(); $('img-big-background' ).hide(); $('img-big-navigation' ).hide(); } //Restore product details and classes .to-hide-for-zoom, hidden to avoid problems in IE6 if($('product-details')){ $('product-details').show(); } $$('.to-hide-for-zoom').each(function(e) { e.show(); }); } function move_image(event, total_x, total_y) { x = event.pointerX(); y = event.pointerY(); $('img-big-image').setStyle('left: ' + (x - total_x) + 'px'); $('img-big-image').setStyle('top: ' + (y - total_y) + 'px'); } function slide_image(amount_x, amount_y) { var original_left = $('img-big-image').positionedOffset().left; var original_top = $('img-big-image').positionedOffset().top; //Positive x go to rigth //Positive y go down //$('img-big-image').setStyle('left: ' + (original_left + amount_x) + 'px'); //$('img-big-image').setStyle('top: ' + (original_top + amount_y) + 'px'); //$('img-big-image').visualEffect('move' , (original_left + amount_x), (original_top + amount_y) ); new Effect.Move ($('img-big-image'),{ x: (original_left + amount_x), y: (original_top + amount_y), mode: 'absolute'}); } function zoom_image(zoom_in) { var original_width = parseInt( original_image_width / actual_ratio); var original_height = parseInt( original_image_height / actual_ratio); var original_left = $('img-big-image').positionedOffset().left; var original_top = $('img-big-image').positionedOffset().top; if (zoom_in) zoom_ratio = 120; else zoom_ratio = 80; new Effect.Scale ($('img-big-image' ).down('img'), zoom_ratio, { scaleFromCenter: true } ); new Effect.Scale ($('img-big-image' ), zoom_ratio, { scaleFromCenter: true } ); /* var actual_width = parseInt( original_image_width / actual_ratio); var actual_height = parseInt( original_image_height / actual_ratio); $('img-big-image').setStyle('left: ' + (original_left - ((actual_width - original_width) / 2)) + 'px'); $('img-big-image').setStyle('top: ' + (original_top - ((actual_height - original_height) / 2)) + 'px'); $('img-big-image' ).down('img').setStyle('width: ' + actual_width + 'px'); $('img-big-image' ).down('img').setStyle('height: ' + actual_height + 'px'); */ } function changeOpac(opacity, id) { var object = $(id).style; object.opacity = (opacity / 100); object.MozOpacity = (opacity / 100); object.KhtmlOpacity = (opacity / 100); object.filter = "alpha(opacity=" + opacity + ")"; } function changeOpac_curr(opacity, id) { var object = $(id).style; object.opacity = (opacity / 100); object.MozOpacity = (opacity / 100); object.KhtmlOpacity = (opacity / 100); object.filter = "alpha(opacity=" + opacity + ")"; } function opacity(id, opacStart, opacEnd, millisec ,id_curr) { //speed for each frame var speed = Math.round(millisec / 100); var timer = 0; //determine the direction for the blending, if start and end are the same nothing happens if(opacStart > opacEnd) { for(i = opacStart; i >= opacEnd; i--) { setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); timer++; } } else if(opacStart < opacEnd) { j=101; for(i = opacStart; i <= opacEnd; i++) { setTimeout("changeOpac(" + j + ",'" + id_curr + "')",(timer * speed)); setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); timer++; j--; } } } function shiftOpacity(id, millisec,id_curr) { if($(id)) { $(id).style.zIndex = Number($('hidd').value) + 1; $('hidd').value = $(id).style.zIndex; opacity(id, 0, 100, millisec,id_curr); $('id_curr').value = id; } } //Function to set the right option using the id (used in product and TO DO in the category) function setOptionById(option_id) { //The foreach on all the select menu of options $$('.select-option' ).each(function(element) { for (var k=1; k 0){ var selected_option = 'option-image-' + type_id + option_id; $$('.option-image-selected-' + type_id ).each(function(element) { element.removeClassName('option-image-selected-' + type_id); }); $(selected_option).addClassName('option-image-selected-' + type_id); } } function AJAX_addProduct(){ var check=true; var check=checkPhysical(); if(check){ var pid = $('pid').value; var qta = $('qta').value; var ajaxID = $('buttonbuy'); var img = ''; new Ajax.Request(makeUrl({module: 'eshop', action: 'addToCartNew'}), { method: 'get', parameters:'pid='+pid+'&qta='+qta, onSuccess: function(transport, json) { ajaxID.style.visibility = "hidden"; var test = transport.responseText.evalJSON(); $('cart_items').update(test.total_items); $('load').update(''); $('cart_total').update(test.total); ajaxID.disabled = false; Fwindow(test.total,test.total_items); }, onLoading: function(){ new Insertion.After(ajaxID, '
'+img+'
'); ajaxID.disabled = true; }, onFailure: function(){ ajaxID.disabled = false; $('load').update(''); } }); } } function Fwindow(total,total_items){ var win = new Window({className: "alphacube", width:280, height:100,top: 290,left:550, resizable: false, title: "", destroyOnClose: false, recenterAuto:true}) win.getContent().innerHTML = "

Item has been successfully added to cart!

"; win.show(); } function closeCart(){ var ajaxID = $("buttonbuy"); var container = $("container"); ajaxID.style.visibility = "visible"; $('container').replace('
'); } function AJAX_checkQuantity(id,id_ph,id_pr){ var a = $("view"); var button = $("buttonbuy"); var disp = $("disp"); a.style.visibility = "hidden"; button.disabled = false; if(disp!= null){ $('disp').remove(); } new Ajax.Request(makeUrl({module: 'eshop', action: 'checkQuantity'}), { method: 'get', parameters:'id_pr='+id_pr+'&id_ph='+id_ph, onSuccess: function(transport) { if(transport.responseText!='-1'){ new Insertion.After(a, transport.responseText); a.style.visibility = "visible"; } } }); new Ajax.Request(makeUrl({module: 'eshop', action: 'countQuantity'}), { method: 'get', parameters:'id_pr='+id_pr+'&id_ph='+id_ph, onSuccess: function(transport) { if(transport.responseText=='0'){ a.style.visibility = "visible"; button.disabled = true; } } }); } (function($) { $.fn.jqueryzoom = function(options) { var settings = {xzoom:200,yzoom:200,offset:10,position:"right",lens:1,preload:1,theme:'default_theme'}; if(options) { $.extend(settings,options) } var noalt=''; $(this).hover(function() { var imageLeft = $(this).offset().left; var imageTop = $(this).offset().top; var imageWidth = $(this).children('img').get(0).offsetWidth; var imageHeight = $(this).children('img').get(0).offsetHeight; noalt = $(this).children("img").attr("alt"); var bigimage = $(this).children("img").attr("jqimg"); $(this).children("img").attr("alt",''); if($("div.zoomdiv").get().length==0) { $(this).after("
"); $(this).append("
 
") } if(settings.position=="right") { if(imageLeft+imageWidth+settings.offset+settings.xzoom>screen.width){ leftpos = imageLeft-settings.offset-settings.xzoom } else { leftpos = imageLeft+imageWidth+settings.offset } } else { leftpos = imageLeft-settings.xzoom-settings.offset; if(leftpos<0) { leftpos=imageLeft+imageWidth+settings.offset } } $("div.zoomdiv").css({top:imageTop,left:leftpos}); $("div.zoomdiv").width(settings.xzoom); $("div.zoomdiv").height(settings.yzoom); $("div.zoomdiv").show(); if(!settings.lens){ $(this).css('cursor','crosshair') } $(document.body).mousemove(function(e){ mouse = new MouseEvent(e); var bigwidth = $(".bigimg").get(0).offsetWidth; var bigheight = $(".bigimg").get(0).offsetHeight; var scaley='x'; var scalex='y'; if(isNaN(scalex)|isNaN(scaley)){ var scalex = (bigwidth/imageWidth); var scaley = (bigheight/imageHeight); $("div.jqZoomPup").width((settings.xzoom)/scalex); $("div.jqZoomPup").height((settings.yzoom)/scaley); $("img.jqZoomBackground").width($("div.jqZoomPup").width()*5); $("img.jqZoomBackground").height($("div.jqZoomPup").height()*5); $("div.jqZoomBackground").width($("img.jqZoomBackground").width()); $("div.jqZoomBackground").height($("img.jqZoomBackground").height()); if(settings.lens){ /* $("div.jqZoomPup").css('visibility','visible');*/ $("div.jqZoomBackground").css('visibility','visible'); } } xpos = mouse.x-$("div.jqZoomPup").width()/2-imageLeft; ypos = mouse.y-$("div.jqZoomPup").height()/2-imageTop; xposBackground = mouse.x-$("div.jqZoomBackground").width()/2-imageLeft; yposBackground = mouse.y-$("div.jqZoomBackground").height()/2-imageTop; if(settings.lens){ xpos = (mouse.x-$("div.jqZoomPup").width()/2imageWidth+imageLeft)?(imageWidth-$("div.jqZoomPup").width()-2):xpos; ypos = (mouse.y-$("div.jqZoomPup").height()/2imageHeight+imageTop)?(imageHeight-$("div.jqZoomPup").height()-2):ypos; /* alert(mouse.x); to_alert = ($("img.jqZoomBackground").width()/5)*2; alert(to_alert); alert(imageLeft); */ xposBackground = (mouse.x-$("div.jqZoomBackground").width()/10 < imageLeft) ? -$("div.jqZoomBackground").width()/2.5 : (mouse.x+$("div.jqZoomBackground").width()/10>imageWidth+imageLeft) ? (imageWidth - ($("div.jqZoomBackground").width() /5)*3) : xposBackground; yposBackground = (mouse.y-$("div.jqZoomBackground").height()/10 < imageTop) ? -$("div.jqZoomBackground").height()/2.5 : (mouse.y+$("div.jqZoomBackground").height()/10>imageHeight+imageTop) ? (imageHeight- ($("div.jqZoomBackground").height()/5)*3) : yposBackground; } if(settings.lens){ $("div.jqZoomPup").css({top:ypos,left:xpos}); $("div.jqZoomBackground").css({top:yposBackground,left:xposBackground}); } scrolly = ypos; $("div.zoomdiv").get(0).scrollTop=scrolly*scaley; scrollx=xpos; $("div.zoomdiv").get(0).scrollLeft=(scrollx)*scalex }) },function(){ $(this).children("img").attr("alt",noalt); $(document.body).unbind("mousemove"); if(settings.lens){ $("div.jqZoomPup").remove(); $("div.jqZoomBackground").remove() } $("div.zoomdiv").remove() } ); count=0; if(settings.preload){ $('body').append(""); $(this).each(function(){ var imagetopreload=$(this).children("img").attr("jqimg"); var content=jQuery('div.jqPreload'+count+'').html(); jQuery('div.jqPreload'+count+'').html(content+'') } )} }})(jQuery); function MouseEvent(e){ this.x=e.pageX; this.y=e.pageY }