/**
 * rokShowcaseVariation - Simple showcase varation chooser
 * 
 * @version		0.1
 * 
 * @license		MIT-style license
 * @author		Djamil Legato <djamil [at] djamil.it>
 * @client		Andy Miller @ Rockettheme
 * @copyright	Author
 */

var rokShowcaseVariation=new Class(
	{
	initialize:function()
		{
		this.styles=$$('.styleslist div');
		this.current=$$('.styleslist div.'+window.currentStyle)[0]||false;
		if(this.current)this.current.addClass('active');
		this.firsttime=true;
		if(panel)panel.addEvent('open',this.loadImages.bind(this));
		else this.loadImages()
	}
	,loadImages:function()
		{
		this.styles.each(function(style)
			{
			var cls=style.className.split(" "),l=window.location;
			var location=l.protocol+'//'+l.host+l.pathname;
			location=(window.uri)?window.uri:location;
			var imgPath=location+'/images/stories/demo/styles/ss_'+cls[0]+'.jpg';
			new Asset.image(imgPath,
				{
				onload:function()
					{
					style.setStyle('background','url('+imgPath+') no-repeat')
				}
			}
			);
			if(this.firsttime)style.setStyle('cursor','pointer').addEvent('click',function()
				{
				window.location=location+'?tstyle='+cls[0]
			}
			)
		}
		,this);
		this.firsttime=false
	}
}
);
rokShowcaseVariation.implement(new Options);
window.addEvent('domready',function()
	{
	new rokShowcaseVariation()
}
);
