formatPrice=function(price,salesPrice){if(salesPrice!=undefined&&parseInt(salesPrice)>0&&parseInt(salesPrice)<parseInt(price)){return'<span class="original-price">'+price+' Ft</span> <span class="sales-price">'+salesPrice+' Ft </span>';}else{return price+' Ft';}};checkCombinationPictures=function(){var selectedParts={};$('.customize-parts a.part-selected, .customize-parts select').each(function(){var partId,partSelected;if($(this).get(0).nodeName=='A'){partId=$(this).parent().find('input').attr('id').split('-')[1];partSelected=$(this).attr('id').split('-')[1];}
else{partId=$(this).attr('id').split('-')[1];partSelected=$(this).val();}
selectedParts[partId]=partSelected;});var imageId=false;var matchCountMax=false;if(typeof combinations!='undefined'){$.each(combinations,function(indexCombination){var matched=true;var matchCount=0;$.each(this,function(indexPart){if(selectedParts[indexPart]==this)matchCount++;else matched=false;});if(matched)
if(!matchCountMax||matchCount>matchCountMax){imageId=indexCombination;matchCountMax=matchCount;}});if(imageId!==false)
if($('.prd-main-image img:visible').attr('id')!='prd-main-image-'+imageId){$('.prd-main-image img:visible').fadeOut();$('#prd-main-image-'+imageId).fadeIn();}}};jQuery(document).ready(function($){$('#webshop-cart .update').live('click',function(event){$('#webshop-cart-action').val('update');$('#webshop-cart-id').val($(event.target).closest('tr').attr('id').split('-')[1]);$('#webshop-cart-quantity').val($(event.target).closest('td').prev().find('input[type=text]').val());});$('#webshop-cart .moveaside').click(function(event){cartId=$(event.target).closest('tr').attr('id').split('-')[1];document.location='/webshopwishlist/add/?cartId='+cartId;event.preventDefault();});$('#webshop-cart .product input[type=text]').live('keypress',function(event){if(event.keyCode=='13'){$('#webshop-cart-action').val('update');$('#webshop-cart-id').val($(this).closest('tr').attr('id').split('-')[1]);$('#webshop-cart-quantity').val($(this).val());$(event.target).closest('.product').find('input[type=submit].update').click();}});$('#webshop-cart .remove').live('click',function(event){$('#webshop-cart-action').val('remove');$('#webshop-cart-id').val($(event.target).closest('tr').attr('id').split('-')[1]);});$('#differentInvoiceAddress').change(function(){if($(this).attr('checked')){$('#invoice-details').show();}else{$('#invoice-details').hide();}});$('.prd_ilist').css('position','relative');$('.prd_ilist div').css({'position':'absolute','white-space':'nowrap'}).data('position',0);$('.prd_iright').click(function(event){var div=$('.prd_ilist div');var position=div.data('position');var width=div.width();if(position-200+width>$('.prd_ilist').width()){div.data('position',position-200);div.animate({'left':'-=200'});}
event.preventDefault();});$('.prd_ileft').click(function(event){var div=$('.prd_ilist div');var position=div.data('position');if(position<0){div.data('position',position+200);div.animate({'left':'+=200'});}
event.preventDefault();});$('.prd_ilist a').click(function(event){var split=$(this).attr('id').split('-');if($('.prd-main-image img:visible').attr('id')!='prd-main-image-'+split[1]){$('.prd-main-image img:visible').fadeOut();$('#prd-main-image-'+split[1]).fadeIn();$('#magnify').data('picture',$('#prd-main-image-'+split[1]));}
event.preventDefault();});$('.productlist-scroller .plist > div').each(function(){$(this).css({'position':'absolute','width':$(this).find('.pbox-tiny').length*160+'px'}).data('position',0);});$('.rightbtn').click(function(event){var div=$(this).prev().children('div');var position=div.data('position');var width=div.width();if(position-480>-1*width){div.data('position',position-160);div.animate({'left':'-=160'});}
event.preventDefault();});$('.leftbtn').click(function(event){var div=$(this).next().children('div');var position=div.data('position');if(position<0){div.data('position',position+160);div.animate({'left':'+=160'});}
event.preventDefault();});$('#magnify').css('opacity',0.4).data('picture',$('.prd-main-image img:first'));$('.prd-main-image').mouseenter(function(){$('#magnify').show();$('#zoom').html('<img src="'+$('#magnify').data('picture').attr('src')+'?zoom" />').show();});$('.prd-main-image').mouseleave(function(){$('#magnify').hide();$('#zoom').hide();});$('.prd-main-image').mousemove(function(event){var magnify=$('#magnify');var zoom=$('#zoom');var zoomPicture=zoom.find('img');var pictureWidth=magnify.data('picture').width();var pictureHeight=magnify.data('picture').height();var zoomPictureWidth=zoomPicture.width();var zoomPictureHeight=zoomPicture.height();var magnifyWidth=parseInt(pictureWidth*(zoom.width()/zoomPictureWidth));var magnifyHeight=parseInt(pictureHeight*(zoom.height()/zoomPictureHeight));if(event.layerX!=undefined){var x=event.layerX;var y=event.layerY;}
else{var x=event.offsetX;var y=event.offsetY;}
x=parseInt(x-magnifyWidth/2);y=parseInt(y-magnifyHeight/2);if(x<0)x=0;if(y<0)y=0;if(x+magnifyWidth>pictureWidth)x=pictureWidth-magnifyWidth;if(y+magnifyHeight>pictureHeight)y=pictureHeight-magnifyHeight;magnify.css({'left':x+'px','top':y+'px','width':magnifyWidth+'px','height':magnifyHeight+'px'});zoomPicture.css({'left':parseInt(-1*x*(zoomPictureWidth/pictureWidth))+'px','top':parseInt(-1*y*(zoomPictureHeight/pictureHeight))+'px'});});});
