/*
	SITE PLATFORM v1.3
	built by AntalMedia (www.antalmedia.com)
	built on Mootools v1.11 (http://www.mootools.net)
	
	copyright 2007. all rights reserved.
		
*/
var PopSwatch = {
	
	init: function(options){
		this.options = Object.extend({
			width: 480,
			height: 370,
			container: document.body,
			speedin: 100,
					speedout: 10

		}, options || {});
		
		this.swatch = new Element('div').setProperty('id', 'pop_swatch').setStyles({width: this.options.initialWidth+'px', height: this.options.initialHeight+'px', position: 'absolute', cursor: 'pointer'}).injectInside(this.options.container);
		this.image = new Element('img').injectInside(this.swatch);
		this.image.addEvent('mouseenter', function() {PopSwatch.show();});
		this.image.addEvent('mouseleave', function() {PopSwatch.hide();});
		this.fx = {
			swatchfadein: this.swatch.effect('opacity', {duration: this.options.speedin, wait: false}).hide(),
			swatchfadeout: this.swatch.effect('opacity', {duration: this.options.speedout, wait: false}).hide()

}
		$$("#swatches li a.pop_up").each(function(input) {
			PopSwatch.preloadImages(input.href);
			input.addEvents({
				mouseenter : function(){ PopSwatch.show(this.href, this.getCoordinates()); return false; },
				mouseleave : function(){ PopSwatch.hide(); } 
			});
		});
	},
	preloadImages: function () {
		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=this.preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	},
	loadImage: function(value){
		this.image.src = value;
	},
	position: function(value) {
		this.swatch.setStyles({top: (value.top-this.options.height-25)+'px', left: (value.left-this.options.width+75)+'px'});
	},
	show: function(value, position) {
		if ( value && position ) {
			this.position(position);
			this.loadImage(value);
		}
		this.fx.swatchfadein.start(1.0);
	},
	hide: function(value) {
		this.fx.swatchfadeout.start(0.0);
	}
}
window.addEvent('domready', function() { PopSwatch.init() } );