Cufon.replace('.custom');
Cufon.replace('.page-head h3');
Cufon.replace('.product-options dl dt label');


function preload() {
	var d = document;
	if (d.images) {
		if(!d.p) d.p = new Array();
		var i, j = d.p.length, a = preload.arguments;
		for(i = 0; i < a.length; i++) {
			if (a[i].indexOf("#") != 0) {
				d.p[j] = new Image;
				d.p[j++].src = a[i];
			}
		}
	}
}


preload(
	'/skin/frontend/default/peachseason/images/go_hover.png',
	'/skin/frontend/default/peachseason/images/join_hover.png',
	'/skin/frontend/default/peachseason/images/button_pink_big_hover.gif',
	'/skin/frontend/default/peachseason/images/button_pink_big_hover.png',
	'/skin/frontend/default/peachseason/images/left_browse_li.png'
)




var MorphList = Class.create({
	initialize: function(menu, options) {
		this.menu = $(menu);
		this.current = this.menu.select('li.active').first();
		this.menu.select('li').each(function(item) {
			Event.observe(item, 'mouseenter', function() { this.morph(item); }.bind(this));
			Event.observe(this.menu, 'mouseleave', function() { this.morph(this.current); }.bind(this));
			Event.observe(item, 'click', function() { this.click(item); }.bind(this));
		}.bind(this));
		
		new Element.insert(this.menu, '<li class="background"><div class="left"></div></li>');
		new Element.insert(this.menu, '<li class="background2"><div class="left"></div></li>');
		this.bg = this.menu.select('li.background').first();
		this.bg2 = this.menu.select('li.background2').first();
		this.bg.setOpacity(0.5);
		this.bg2.setOpacity(0.5);
		this.setCurrent(this.current);
	},
	
	click: function(item) {
		this.setCurrent(item);
	},
	
	setCurrent: function(item) {
		if (!this.current) return;
		this.bg.setStyle({left: (item.offsetLeft)+'px', width: (item.offsetWidth)+'px'});
		this.bg2.setStyle({left: (item.offsetLeft)+'px', width: (item.offsetWidth)+'px'});
		if (this.current) this.current.removeClassName('active');
		if (item) this.current = item.addClassName('active');
	},
	
	morph: function(to) {
		if (!this.current) return;
		new Effect.Parallel([
			new Effect.Move(this.bg, {sync: true, x: to.offsetLeft, y: 0, mode: 'absolute', transition: Effect.Transitions.sinoidal}), 
			new Effect.Morph(this.bg, {sync: true, style: {width: to.getWidth()+'px'}})
		], { duration: 0.3 });
	}
});


Event.observe(window, 'load', function() {
	if($('nav')) new MorphList('nav');
	
	
	$$('.homepage_content_col a.abs').each(function(item) {
		item.setStyle({display: 'inline'});
	});
});
