var intro = {
	init: function(){
		 
		var kwicks = $$("#intro-links .intro-link");
		var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.linear});
		kwicks.each(function(kwick, i) {
			if(!kwick.hasClass('wide')){
				kwick.setStyle('opacity', '0.3');
			}
			kwick.addEvent("mouseenter", function() {
				var o = {};
				o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
				kwicks.each(function(other, j) {
					if(i != j) {
						var w = other.getStyle("width").toInt();
						$(other.id + '_content').setStyle('display', 'none');
						if(w != szSmall) o[j] = {width: [w, szSmall]};
						other.setStyle('opacity', '0.3');
					}else{
						$(other.id + '_content').setStyle('display', '');
						other.setStyle('opacity', '1');
					}
				});
				fx.start(o);
			});
		});
	}
}

var shop = {
	init: function(){
		
		$$('#shop div.list').each(function(el){
			if(!el.hasClass('current')){
				el.setStyle('display', 'none');
			}
		});
		
		$$('a.shop-menu').each(function(el){
			if(el.hasClass('open')){
				el.open = true;
			}else{
				el.open = false;
			}
			el.addEvent('click', function(e){

				new Event(e).stop();
				
				if(this.open){
					this.open = false;
					$(this.rel).setStyle('display', 'none');
					$(this.rel+'-arrow').setStyle('background-position', '0 2px');
				}else{
					this.open = true;
					$(this.rel).setStyle('display', 'block');
					$(this.rel+'-arrow').setStyle('background-position', '-12px 2px');
				}
			})
		});		
	}
}

var productHover = {
	init: function(){
		$$('.product-info a img').each(function(el){
			if(el){
				el.addEvents({
					'mouseover': function(){
						el.setStyles({
							width: 248,
							height: 248,
							margin: '-26px',
							position: 'relative',
							zIndex: 999999
						});
					},
					'mouseleave': function(){
						el.setStyles({
							width: 196,
							height: 196,
							margin: 0,
							zIndex: 0
						});
					}
				});
			}
		});
	}
}

window.addEvent('domready', function(){
	intro.init();
	//productHover.init();
	if($('shop')){
		shop.init();
	}
		
	if($('checkout-btn')){
	  $('checkout-btn').addEvent('click', function(e){
	
			new Event(e).stop();
	    $('checkout-btn').remove();
	    
	    $('buttons').innerHTML = '<div id="loading">Loading...</div>' + $('buttons').innerHTML;
	    
	    $('checkout_form').submit();
	  });
	}

	if($('size')){
		$('size').addEvent('change', function(e){
			
			window.location = this.value;
			
		});
	}
});