(function($){
	if(EYE.defaultLanguage != 'cn' && EYE.defaultLanguage != 'bg'){
		Cufon.replace('div#navigation ul li a, a#switchSection, body#shop div#footerContent div#footerContentLeft ul li a, div#homepage div#hompageBoxLeft h3 a, div#homepage div#hompageBoxRight h3 a, div#homepage div#hompageBoxLeft ul li a, div#homepage div#hompageBoxRight ul li a', {hover: "true", autoDetect: true});
		Cufon.replace('form#searchFrom button span, body#shop div#footerContent div#footerContentRight form#subscribeForm h3, body#shop div#footerContent div#footerContentRight form#subscribeForm button span, div.rightSpecialBox h2, div#homepage div#hompageBoxLeft h2, div#homepage div#hompageBoxRight h2, div.contentBox h3, body#presentation div#footerContent p strong, div.labeledList h3, div.filters h3, body#shop div#footerContent div#footerContentLeft ul li', {autoDetect: true});
	}

	EYE.mainMenu = function(){
		var currentItem,
			timer,
			visible = false,
			enter = function(){
				currentItem = this;
				if (visible) {
					clearTimeout(timer);
					show();
				} else {
					timer = setTimeout(show, 120);
				}
			},
			show = function(){
				visible = true;
				$(currentItem)
					.addClass('active')
					.find('>div')
						.show();
			},
			leave = function(){
				clearTimeout(timer);
				timer = setTimeout(clear, 80);
				$(this)
					.removeClass('active')
					.find('>div').hide();
			},
			clear = function(){
				currentItem = null;
				visible = false;
			};
		return {
			init: function(){
				$('#mainMenu li.mainItem')
					.bind('mouseenter', enter)
					.bind('mouseleave', leave);
			}
		};
	}();
	EYE.register(EYE.mainMenu.init, 'init');

	EYE.brands = function() {
		var total, shown = 8, current = 0, width = 106;
		var click  = function() {
			current = Math.max(0, Math.min(total, current + shown * (this.id == 'brandsLeft' ? -1 : 1)));
			$('#brandsImages ul')
				.stop()
				.animate(
					{left: -current * width},
					500
				);
			return false;
		};
		return {
			init: function() {
				total = $('#brands ul a').size();
				if (total > shown) {
					$('#brandsImages ul').css('width', width * total);
					$('#brandsLeft, #brandsRight').bind('click', click);
					total -= shown;
				} else {
					$('#brandsLeft, #brandsRight').hide();
				}
			}
		};
	}();
	EYE.register(EYE.brands.init, 'init');

	EYE.slideshow = function() {
		var total, current = 0, timer, duration = 6000;
		var goTo = function() {
			$('#slideshowContainer a').hide().eq(current).show();
			$('#slideshowNavigation a').removeClass('active').eq(current).addClass('active');
		};
		var click = function(ev) {
			clearTimeout(timer);
			if (ev) {
				var targetEl = $(ev.target).closest('a');
				if (targetEl.size() == 1) {
					current = $('#slideshowNavigation a').index(targetEl);
					targetEl.blur();
				}
			} else {
				current ++;
				if (current >= total) {
					current = 0;
				}
			}
			goTo();
			timer = setTimeout(click, duration);
			return false;
		};
		return {
			init: function() {
				if (document.getElementById('slideshow')) {
					var html = [];
					total = $('#slideshowContainer a').each(function(nr){
						html.push('<li><a href="#">');
						html.push(nr+1);
						html.push('</a></li>');
					}).size();
					$('#slideshowNavigation').append(html.join('')).bind('click', click);
					goTo();
					timer = setTimeout(click, duration);
				}
			}
		};
	}();
	EYE.register(EYE.slideshow.init, 'init');

	EYE.order = function() {
		var enter = function() {
			$('#orderProductsByOptions').show();
		};
		var leave = function() {
			$('#orderProductsByOptions').hide();
		}
		return {
			init: function() {
				if (document.getElementById('orderProductsBy')) {
					$('#orderProductsBy a, #orderProductsByOptions')
						.bind('mouseenter', enter)
						.bind('mouseleave', leave);
				}
			}
		};
	}();
	EYE.register(EYE.order.init, 'init');


	EYE.productCombos = function () {
		var el,
			selectedOptions = {},
			anySelected = 0,
			currentCombo = '',
			//currentImage,
			click = function(ev) {
				var targetEl = $(ev.target).closest('a');
				if (targetEl.is('a')) {
					var dat = targetEl.blur().data('opt');
					var near = targetEl.parent().parent().find('a');
					if (!targetEl.is('.disabled') && near.size()>1) {
						if (dat.disabled != true) {
							var sel = !dat.selected;
						}
						targetEl.parent().parent().find('a').removeClass('selected').each(function(){
							$(this).data('opt').selected = false;
						});
						if ((dat.selected = sel)) {
							targetEl.addClass('selected');
							EYE.product.combos[dat.attr_id].selected = dat.id;
						}
						else {
							EYE.product.combos[dat.attr_id].selected = false;
						}
						highlight();
					} else {
						clear();
						EYE.product.combos[dat.attr_id].selected = dat.id;
						dat.selected = true;
						targetEl.addClass('selected');
						highlight();
					}
					return false;
				}
			},
			highlight = function(){
				$('a', el).addClass('disabled');
				selectedOptions = {};
				anySelected = 0;
				currentCombo = '';
				$.each(EYE.product.combos, function(nr, val){
					if (val.selected) {
						selectedOptions[val.id] = val.selected;
						anySelected ++;
					}
				});
				$.each(EYE.product.combo, function(nr, combo){
					var cnt = 0;
					if (anySelected > 0) {
						$.each(selectedOptions, function(attr, opt){
							if (combo.attributes[attr] && combo.attributes[attr] == opt) {
								cnt++;
							}
						});
						combo.available = (cnt == anySelected && combo.quantity > 0);
					} else {
						combo.available = combo.quantity > 0;
					}
					$.each(combo.attributes, function(attr, opt){
						if (combo.available) {
							$('#A'+attr+'O'+opt).removeClass('disabled');
						}
					});
					if (cnt == combo.size) {
						currentCombo = nr;
					}
				});
				/*$('#productImages a:first')
					.attr('href', imagePath + img)
					.find('img:first')
						.attr('src',thumbPath + img);*/
				if ($('#productCombo option[value='+currentCombo+']').size() != 1) {
					$('#productCombo').val(0);
					$('#productPrice').text(EYE.product.price);
				} else {
					$('#productCombo').val(currentCombo);
					$('#productPrice').text(EYE.product.combo[currentCombo].price);
				}
			},
			setCombo = function(ev){
				if (ev) {
					$('a', el).removeClass('selected').each(function(){
					 $(this).data('opt').selected = false;
					 });
					 $.each(EYE.product.combos, function(nr, combo){
					 combo.selected = false;
					 });
				}
				clear();
				var sel = $('#productCombo')
				var val = sel.val();
				if (val == 0) {
					if (sel.get(0).length == 2) {
						val = sel.find('option:last').attr('value');
						sel.val(val);
					}
				}
				if (EYE.product.combo[val]) {
					$.each(EYE.product.combo[val].attributes, function (attr, opt){
						EYE.product.combos[attr].selected = opt;
						$('#A'+attr+'O'+opt).addClass('selected').data('opt').selected = true;
					});
				}
				highlight();
			},
			submit = function(){
				if (!currentCombo || $('#productCombo option[value='+currentCombo+']').size() != 1) {
					$('#productCombo').parent()
						.find('em').remove().end()
						.append('<em>'+EYE.product.error+'</em>');
					return false;
				}
				return true;
			},
			clear = function (){
				var lnks = $('a', el).removeClass('selected');
				var cnt = 0;
				$.each(EYE.product.combos, function(nr, attr){
					var cnt2 = 0, lastOpt;
					$.each(attr.options, function(nr2, opt){
						lnks.eq(cnt).data('opt', $.extend({
							attr_id: attr.id,
							selected: false,
							disabled: false,
							order: nr
						}, opt));
						cnt++;
						cnt2++;
						lastOpt = opt;
					});
					if (cnt2 == 1) {
						lnks.eq(cnt - 1).addClass('selected').data('opt').selected = true;
						attr.selected = lastOpt.id;
					} else {
						attr.selected = false;
					}
				});
			},
			mouseEnter = function(){
				var attr = $(this).data('opt').attr_id;
				var opt = $(this).data('opt').id;
				if (EYE.product.combos[attr].options[opt].image) {
					var img = EYE.product.combos[attr].options[opt].image.name;
					$('#productImages a:first')
						.attr('href', imagePath + img)
						.find('img:first')
							.attr('src',thumbPath + img);
				}
			},
			mouseLeave = function(){
				$('#productImages a:first')
					.attr('href', imagePath + currentImage)
					.find('img:first')
						.attr('src',thumbPath + currentImage);
			};
		return {
			init: function(){
				if ((el = document.getElementById('productFormCombos'))) {
					$('#productForm').bind('submit', submit);
					currentImage = EYE.product.image;
					setCombo();
					$('#productCombo').bind('change', setCombo);
					$(el).bind('click', click);
					//$('a', el).bind('mouseenter',mouseEnter).bind('mouseleave', mouseLeave);
				}
			}
		};
	}();
	EYE.register(EYE.productCombos.init, 'init');

	EYE.productImages = function() {
		var currentImage,
			thumbPath = '/images/eshop/products/orig/',
			imagePath = '/images/eshop/products/max/',
			total,
			current = 0;
		var enter = function() {
			var img = $(this).attr('rel');
			$('#productImages a:first')
				.attr('href', imagePath + img)
				.find('img:first')
					.attr('src',thumbPath + img);

		};
		var leave = function() {
			$('#productImages a:first')
				.attr('href', imagePath + currentImage)
				.find('img:first')
					.attr('src',thumbPath + currentImage);
		};
		var click = function() {
			current = Math.max(0, Math.min(total, current + (this.id == 'productGalleryUp' ? -4 : 4)));
			$('#productGallery')
				.stop()
				.animate({
					top: - current * 73
				}, 500);
			this.blur();
			return false;
		};
		return {
			init: function() {
				if (document.getElementById('productGallery')) {
					currentImage = EYE.product.image;
					total = $('#productGallery a')
								.bind('mouseenter', enter)
								.bind('mouseleave', leave)
								.size();
					if (total > 4) {
						$('#productGalleryUp, #productGalleryDown')
							.show().bind('click', click);
						total -= 4;
					}
				}
			}
		};
	}();
	EYE.register(EYE.productImages.init, 'init');

	EYE.productTabs = function() {
		var click = function(ev) {
			var targetEl = $(ev.target).closest('a');
			if (targetEl.size() == 1) {
				$('#productTabs')
					.parent()
						.find('div.productTab').hide()
							.eq(
								$('#productTabs a')
									.removeClass('active')
									.index(targetEl.addClass('active').blur())
							).show();
				return false;
			}
		};
		return {
			init: function() {
				if (document.getElementById('productTabs')) {
					$('#productTabs')
						.bind('click', click)
						.find('a:first').addClass('active').end()
						.parent()
							.find('div.productTab:first').show();
				}
			}
		};
	}();
	EYE.register(EYE.productTabs.init, 'init');

	EYE.general = function() {
		var accntForm;
		if ((accntForm = document.getElementById('accountForm'))) {
			var swicthAccount = function(ev){
				var el = $(this);
				el
					.parent()
					.parent()
						.find('input, select')
							.not(el)
							.attr('disabled', el.attr('checked'));
			};
			swicthAccount.apply($('input[name=use_contact_info]', accntForm)
				.bind('click', swicthAccount).get(0));
		}

	};
	EYE.register(EYE.general, 'init');

	EYE.checkout = function(){
		var el,
			asCompany = function(ev){
				if ($(this).attr('checked')) {
					$('p.asCompany', el).show();
					$('p.asPerson', el).hide();
				} else {
					$('p.asCompany', el).hide();
					$('p.asPerson', el).show();
				}
			},
			useBilling = function(){
				$(this).parent().parent().find('input, select').not(this).attr('disabled', $(this).attr('checked'));
			};
		return {
			init: function(){
				if ((el = document.getElementById('checkoutInfo'))) {
					asCompany.apply($('#as_company').bind('click', asCompany).get(0));
					useBilling.apply($('#use_billing').bind('click', useBilling).get(0));
				}
			}
		};
	}();
	EYE.register(EYE.checkout.init, 'init');
	
	EYE.productGallery = function() {
		var images = [], current = false, timer;
		var click = function() {
			current = $.inArray($(this).attr('rel'), images);
			$('#galleryWrapper').css('left', 0);
			$('#gallery')
				.css('top', -2000).show();
			overlay();
			resize();
			scroll();
			$(window).bind('scroll', preScroll).bind('resize', preResize);
			return false;
		},
		galClick = function(ev) {
			var targetEl = $(ev.target).closest('a');
			if (targetEl.size() ==  1 && targetEl.get(0).id != 'galleryClose') {
				targetEl.blur();
				current = Math.max(0, Math.min(images.length - 1, current + (targetEl.get(0).id == 'galleryLeft' ? -1 : 1)));
				place();
			} else {
				close();
			}
			return false;
		},
		overlay = function() {
			$('#overlay').hide().css({
				width: $(document).width(),
				height: $(document).height(),
				display: 'block'
			}).bind('click', close);
			//$('#overlayIframe').hide().bind('click', close);
		},
		close = function(){
			$('#overlay, #gallery').unbind('click', close);
			//$('#overlayIframe').unbind('click', close);
			$(window).unbind('scroll', preScroll).unbind('resize', preResize);
			$('#gallery').stop().animate({top: -2000}, 1000, function() {
				$('#overlay, #gallery').hide();
			});
			return false;
		},
		resize = function(ev){
			var height = $(window).height();
			var width = $(window).width();
			$('#gallery').css({
				'height': height
			});
			$('#overlay').hide().css({
				width: $(document).width(),
				height: $(document).height(),
				display: 'block'
			});
			$('#galleryWrapper')
				.css({
					'width': images.length * width,
					'height': height
				})
				.find('>div').each(function(){
					this.style.width = width + 'px';
				}).end();
			if (ev) {
				place();
			}
		},
		place = function() {
			$('#galleryWrapper').stop().animate({'left': -current * $(window).width()}, 1000);
			$('#galleryLeft').css('display', current == 0 ? 'none' : 'block');
			$('#galleryRight').css('display', current >= images.length -1 ? 'none' : 'block');
		},
		preResize = function() {
			clearTimeout(timer);
			$('#galleryWrapper').stop();
			timer = setTimeout(resize, 100);
		},
		scroll = function() {
			$('#gallery').stop().animate({
				'top': $(document).scrollTop()
			}, 500, place);
		},
		preScroll = function() {
			clearTimeout(timer);
			$('#gallery').stop();
			timer = setTimeout(scroll, 100);
		};
		return {
			init: function() {
				if (document.getElementById('productImages')) {
					images.push($('#productImages a').attr('rel'));
					$('#productGallery a').each(function() {
						if ($.inArray($(this).attr('rel'), images) == -1) {
							images.push($(this).attr('rel'));
						}
					});
					if (EYE.product.combos) {
						$.each(EYE.product.combos, function(nr, attr){
							if (attr.options) {
								$.each(attr.options, function(nr2, opt){
									if (opt.image && $.inArray(opt.image.name, images) == -1) {
										images.push(opt.image.name);
									}
								});
							}
						});
					}
					var html = [];
					$.each(images, function(nr, val) {
						html.push('<div><img src="/images/eshop/products/max/');
						html.push(val);
						html.push('" /></div>');
					});
					$('#galleryWrapper').append(html.join(''))
						.parent().bind('click', galClick);
					$('#productGallery a, #productImages a').bind('click', click);
				}
			}
		};
	}();
	EYE.register(EYE.productGallery.init, 'init');

	EYE.articleGallery = function() {
		var images, current = 0, image, thumb = 0;
		var parseAlbum = function(rest) {
			if (rest && rest.feed && rest.feed.entry) {
				images = rest.feed.entry;
				drawThumbs();
				goTo();
			}
		};
		var goTo = function() {
			$('#articleGalleryWrapper').empty();
			image = new Image();
			$(image).bind('load', showImage);
			image.src = images[current].content.src;
			if (image.complete) {
				$(image).unbind('load');
				showImage();
			} else {
				$('#articleGalleryLoader').show();
			}
		};
		var showImage = function() {
			$('<img src="' + images[current].content.src+'" />')
				//.css('marginTop', (576 - image.height)/2)
				.appendTo('#articleGalleryWrapper');
			$('#articleGalleryLoader').hide();
			$('#articleGallery a').show();
			$('#articleGalleryThumbs a')
				.removeClass('active')
				.filter('[rel='+current+']')
				.addClass('active');
		};
		var click = function(ev) {
			var targetEl = $(ev.target).closest('a');
			if (targetEl.size() == 1) {
				if (targetEl.parent().is('#articleGalleryThumbs')) {
					current = targetEl.attr('rel');
					goTo();
				} else {
					thumb = Math.max(0, Math.min(images.length - 4, thumb  + 4 * (this.id == 'articleGalleryLeft' ? -1 : 1)));
					drawThumbs();
				}
				targetEl.blur();
				return false;
			}
		};
		var drawThumbs = function() {
			var html = [];
			for (var i=thumb, max = thumb + 4; i < max; i++) {
				html.push('<a href="#" rel="');
				html.push(i);
				html.push('"><img src="');
				html.push(images[i].media$group.media$thumbnail[0].url);
				html.push('" width="');
				html.push(images[i].media$group.media$thumbnail[0].width);
				html.push('" height="');
				html.push(images[i].media$group.media$thumbnail[0].height);
				html.push('" style="margin-top:');
				html.push((144 - images[i].media$group.media$thumbnail[0].height)/2);
				html.push('px;" /></a>');
			}
			$('#articleGalleryThumbs').html(html.join(''))
				.find('a[rel='+current+']').addClass('active');
		};
		return {
			init: function() {
				if (EYE.galleryId) {
					$.getJSON('http://picasaweb.google.com/data/feed/api/user/'
						+ EYE.galleryUser + '/albumid/'
						+ EYE.galleryId + '?kind=photo&access=public&alt=json-in-script&thumbsize=144&imgmax=576&callback=?',
						parseAlbum
				   );
					$('#articleGallery a, #articleGalleryThumbs').bind('click', click);
				}
			}
		};
	}();
	EYE.register(EYE.articleGallery.init, 'init');

	EYE.productInfo = function() {
		var click = function() {
			if ($(this).parent().attr('id') == 'productMoreInfo') {
				$('#productForm').addClass('hidden');
				$('#requestInfo').removeClass('hidden');
			} else {
				$('#productForm').removeClass('hidden');
				$('#requestInfo').addClass('hidden');
			}
			return false;
		};
		return {
			init: function() {
				if (document.getElementById('productMoreInfo')) {
					$('#productMoreInfo a, #productBackCart a')
						.bind('click', click);
				}
			}
		};
	}();
	EYE.register(EYE.productInfo.init, 'init');

	EYE.rightCarousel = function() {
		var goTo = function() {
			var targetEl = $(this).parent().find('div.rightSpecialBoxCarousel');
			var data = targetEl.data('carousel');
			if (data.animated == false) {
				data.animated = true;
				var dir = $(this).is('.leftArrow') ? -1 : 1;
				data.current += dir;
				targetEl.animate(
					{
						left: - data.current * data.width
					},
					{
						duration: 700,
						complete: onStop
					}
				)
			}
			return false;
		};
		var onStop = function() {
			var data = $(this).data('carousel');
			if (data.current == 0) {
				data.current = data.total;
			} else if (data.current > data.total) {
				data.current = 1;
			}
			$(this).css('left', - data.current * data.width);
			data.animated = false;
		};
		var setup = function() {
			var data = {
				current: 1,
				animated: false
			};
			var el = $(this);
			var els = el.find('a').prependTo(el);
			el.find('>*').not('a').remove();
			data.total = els.size();
			data.width = els.eq(0).outerWidth();
			els.filter(':last').clone().prependTo(el);
			els.eq(0).clone().appendTo(el);
			el.css('left', -data.width).data('carousel', data);
			el.parent().parent().find('>span').bind('click', goTo);
		};
		return {
			init: function() {
				$('div.rightSpecialBoxCarousel').each(setup);
			}
		};
	}();
	EYE.register(EYE.rightCarousel.init, 'init');

	EYE.galleryCarousel = function() {
		var current = 0, visibleElements = 7, width, total, el, imagePreload, nextImage;
		var fixNavigation = function() {
			el.parent()
				.find('>span')
					.eq(0).css('display', current == 0 ? 'none' : 'block').end()
					.eq(1).css('display', current >= total ? 'none' : 'block');
		};
		var clickEv = function(ev) {
			var targetEl;
			if ((targetEl = $(ev.target).closest('span')).size() == 1) {
				current = Math.min(
					Math.max(
						current + (targetEl.is('.leftArrow') ? -visibleElements : visibleElements),
						0
					),
					total
				);
				el.stop().animate(
					{
						left: -current * width
					},
					{
						duration: 700,
						complete: fixNavigation
					}
				);
			} else if((targetEl = $(ev.target).closest('a')).size() == 1) {
				targetEl.blur();
				$('div.galleryRight a')
					.stop()
					.css('opacity', 1)
					.animate(
						{
							opacity: 0
						},
						{
							duration: 500,
							complete: switchImage
						}
					);
				targetEl
					.parent()
						.parent()
							.find('div.galleryThumbItem').removeClass('current').end()
							.end()
						.addClass('current');
				nextImage = targetEl.attr('href');
			}
			return false;
		};
		var switchImage = function() {;
			$('#galleryLoading').show();
			imagePreload = new Image();
			$(imagePreload).bind('load', showImage);
			imagePreload.src = nextImage;
			if (imagePreload.complete) {
				showImage();
			}
		};
		var showImage = function() {
			$('div.galleryRight a')
				.find('img').attr('src', imagePreload.src).end()
				.animate(
					{
						'opacity': 1
					},
					500
				).attr('href', imagePreload.src);
			$('#galleryLoading').hide();
		};
		return {
			init: function() {
				el = $('div.galleryThumbsWrapper');
				var els = el.find('a');
				width = els.eq(0).parent().outerWidth();
				total = els.size() - visibleElements;
				el.parent().bind('click', clickEv);
				fixNavigation();
			}
		};
	}();
	EYE.register(EYE.galleryCarousel.init, 'init');

	EYE.productCarousel = function() {
		var current = 0, total;
		var fixNavigation = function() {
			$('#carouselUp').css('display', current == 0 ? 'none' : 'block');
			$('#carouselDown').css('display', current == total ? 'none' : 'block');
		};
		var clickEv = function(ev) {
			var targetEl;
			if ((targetEl = $(ev.target).closest('span')).size() == 1) {
				current = Math.min(
					total,
					Math.max(
						0,
						current + (targetEl[0].id == 'carouselUp' ? -3 : 3)
					)
				);
				$('#productThumbsContainer')
					.stop()
					.animate(
						{
							top: - current * 92
						},
						700
					);
				fixNavigation();
			} else if ((targetEl = $(ev.target).closest('a')).size() == 1) {
				var src = targetEl.find('img').attr('src');
				$('#productMainImage')
					.find('a img')
						.attr('src', src.replace("thumbs", "orig"))
						.end()
					.find('a')
						.attr('href', src.replace("thumbs", "max"));
				targetEl.blur();
			}
			return false;
		};
		return {
			init: function() {
				if (document.getElementById('productThumbs')) {
					var el = $('#productThumbsContainer');
					var els = el.find('a');
					total = els.size() - 3;
					$('#productThumbs').bind('click', clickEv);
					fixNavigation();
				}
			}
		};
	}();
	EYE.register(EYE.productCarousel.init, 'init');

	EYE.productZoom = function() {
		var zoomEnter = function() {
			if (!preloading && !inzoom) {
				$('#productZoom').stop().animate({opacity: 0.7}, 400);
			}
		};
		var zoomLeave = function() {
			if (!preloading && !inzoom) {
				$('#productZoom').stop().animate({opacity: 0}, 400);
			}
		};
		var initPage,zoomScale, viewEl, srcPos, viewPort, viewSize, viewMax,
			inzoom, srcImage, preloading;
		var initZoom = function(ev) {
			this.blur();
			if (inzoom == true) {
				return false;
			}
			zoomLeave();
			initPage = {
				left: ev.pageX,
				top: ev.pageY
			}
			srcImage = new Image();
			$(srcImage).bind('load', finishLoadZoom);
			preloading = true;
			srcImage.src = $(this).attr('href');
			if (srcImage.complete && inzoom === false) {
				$(srcImage).unbind('load', finishLoadZoom);
				finishLoadZoom();
			}
			return false;
		};
		var finishLoadZoom = function() {
			inzoom = true;
			preloading = false;
			viewEl = $('#productImageZoom').css({
				//height: Math.max(500, document.getElementById('productInfo').offsetHeight),
				display: 'block',
				opacity: 0
			}).animate({opacity: 1}, 400).append('<img src="'+srcImage.src+'" />');
			zoomScale = $('#productMainImage>a>img')[0].width/srcImage.width;
			srcPos = $('#productMainImage').append('<span id="productZoomView" />').bind('mouseleave', hideZoom).offset();
			viewSize = {
				width: (viewEl.width() * zoomScale),
				height: (viewEl.height() * zoomScale)
			};
			viewPort = $('#productZoomView').css({
				width: viewSize.width,
				height: viewSize.height,
				opacity: 0
			}).animate({opacity: 0.3}, 400);
			viewMax = {
				left: 450 - viewSize.width,
				top: 450 - viewSize.height
			};
			viewSize.width = viewSize.width/2;
			viewSize.height = viewSize.height/2;
			viewEl = viewEl.find('img');
			$(document).bind('mousemove', zoomMove);
			zoomPosition(initPage.left-srcPos.left, initPage.top-srcPos.top);
		};
		var hideZoom = function() {
			inzoom = false;
			$('#productMainImage').unbind('mouseleave', hideZoom);
			$(document).unbind('mousemove', zoomMove);
			viewPort = false;
			$('#productZoomView').add(viewEl).animate(
				{opacity:0},
				400, function(){
					$(this).remove();
					$('#productImageZoom').hide();
				}
			);
			viewEl = false;
			srcImage = false;
		};
		var zoomMove = function(ev) {
			zoomPosition(ev.pageX - srcPos.left, ev.pageY - srcPos.top);
		};
		var zoomPosition = function(left, top) {
			left = Math.max(0, Math.min(left - viewSize.width, viewMax.left));
			top = Math.max(0, Math.min(top - viewSize.height, viewMax.top));
			viewPort[0].style.left = left+'px';
			viewPort[0].style.top = top+'px';
			viewEl[0].style.left = -left/zoomScale+'px';
			viewEl[0].style.top = -top/zoomScale+'px';
		};
		return {
			init: function() {
				$('#productMainImage a')
					.bind('mouseleave', zoomLeave)
					.bind('mouseenter', zoomEnter)
					.bind('click', initZoom);
			}
		}
	}();
	EYE.register(EYE.productZoom.init, 'init');

	EYE.collectionSlideshow = function() {
		var el, current = 0, imgs, timer, duration = 5500;
		var show = function() {
			clearTimeout(timer);
			imgs.eq(current).stop().animate({opacity: 0}, 500);
			current ++;
			if (current >= imgs.size()) {
				current = 0;
			}
			imgs.eq(current).stop().animate({opacity: 1}, 500);
			timer = setTimeout(show, duration);
		};
		return {
			init: function() {
				if ((el = $('#collectionGallery')).size() == 1) {
					imgs = el.find('img')
								.css('opacity', 0)
									.eq(0)
										.css('opacity', 1)
										.end();
					timer = setTimeout(show, duration);
				}
			}
		};
	}();
	EYE.register(EYE.collectionSlideshow.init, 'init');

	EYE.sideMenu = function() {
		var click = function(ev) {
			var targetEl = $(ev.target).closest('a');
			if (targetEl.size() == 1) {
				var subTree = targetEl.parent().find('>ul');
				if (subTree.size() == 1) {
					$('#sideMenu ul').addClass('hiddenEl');
					subTree.toggleClass('hiddenEl');
					targetEl.blur();
					return false;
				}
			}
		};
		return {
			init: function() {
				$('#sideMenu').bind('click', click);
			}
		};
	}();
	EYE.register(EYE.sideMenu.init, 'init');

})(jQuery);

$(document).ready(function() {
	if(typeof($().piroBox) != "undefined"){
		$().piroBox({
				my_speed: 400, //animation speed
				bg_alpha: 0.1, //background opacity
				slideShow : true, // true == slideshow on, false == slideshow off
				slideSpeed : 4, //slideshow duration in seconds(3 to 6 Recommended)
				close_all : '.piro_close,.piro_overlay'// add class .piro_overlay(with comma)if you want overlay click close piroBox
	 
		});
	}
});
