

sIFR.replace(clarendon, {
	selector: '#category-image .hero-tooltip .hero-info .price',
	wmode: 'transparent',
	tuneWidth: 5,
	forceSingleLine: true,
	css: {
		'.sIFR-root': { 'color': '#2f2f2f', 'font-weight': 'bold', 'font-size': '17px', 'text-decoration': 'none' }
	}
});

/*
sIFR.replace(futura, {
	selector: '.products-grid .product-name',
	wmode: 'transparent',
	css: {
		'.sIFR-root': {'text-transform': 'uppercase'},
		'a:link': {'color': '#2f2f2f', 'font-weight': 'bold', 'text-decoration': 'none'},
		'a:hover': {'color': '#CF1632'}
	}
});
*/

sIFR.replace(futura, {
	selector: '.hero-info h3',
	wmode: 'transparent'
});

/*
sIFR.replace(knockout_jr_ltw, {
	selector: '.filter-content .dropdown .trigger em',
	wmode: 'transparent',
	tuneWidth: 5,
	forceSingleLine: false,
	css: {
		'.sIFR-root': {'color': '#808080', 'font-weight': 'normal', 'font-size': '20px', 'text-decoration': 'none'}
	}
});
*/

/*--------------------------------------------------------------------------*/

var ProductPromo = function (container) {
	this.promo = $j(container).find('.promo-overlay');
	this.trigger = $j(container).find('.product-info');
	this.setup();
};
ProductPromo.prototype = {
	setup: function () {
		var self = this;
		var default_pos = this.promo.css("top").split("px")[0];
		self.promo.css("height", self.promo.height() + 10);
		
		this.trigger.hoverIntent({
			sensitivity: 1,
			interval: 200,
			over: function () {
				self.promo.animate(
					{ top: (default_pos - self.promo.height()) },
					{ duration: 300 }
				);
			},
			out: function () {
				self.promo.animate(
					{ top: default_pos },
					{ duration: 300 }
				);
			}
		});
	}
};

/*--------------------------------------------------------------------------*/

var ProductColors = function (container, colors) {
	this.container = $j(container);
	this.list = colors.find('ul');
	this.triggers = colors.find('li');
	this.loader = colors.find('.loader');
	this.setup();
};
ProductColors.prototype = {
	setup: function () {
		var self = this;
		var width = 0;
		
		this.triggers.each(function () {
			width += $j(this).width();
			$j(this).bind('click', function (ev) {
				ev.preventDefault();
				self.toggleon($j(this));
			});
		});
		
		this.list.css("width", width);
		this.list.addClass('active');
	},
	toggleon: function (box) {	
		var self = this;
		var dur = 400;
		if ($j.browser.msie) { dur = 0; }
		
		this.container.find('img.cat-prod-img').each(function () {
			if ($j(this).attr('longdesc') != box.find('a').attr('class')) {
				$j(this).fadeOut(dur);
			}
			else {
				var thumb = $j(this);
				if (!thumb.hasClass('loaded')) {
					self.loader.show();
					$j.get('/ajaxproductimage/url/getImageUrl?product_id=' + $j(this).attr('rel') + '&size=small_image&x=240&y=137', function(data){
						self.loader.hide();
						thumb.attr('src', data);
						thumb.addClass('loaded');
						thumb.fadeIn(dur);
					});
					self.loader.ajaxError(function () { $j(this).hide(); });
				}
				else {
					self.loader.hide();
					thumb.fadeIn(dur);
				}
			}
		});
	}
};

var UsPrice = function (triggers) {
	this.triggers = $j(triggers);
	this.setup();
};
UsPrice.prototype = {
	setup: function(){
		/*var self = this;
		$j.get('/ajaxprice/url/getShowPrice/', function(data){
				if(data == '1'){
					self.triggers.show();
				}
		});*/		
	}
};

/*--------------------------------------------------------------------------*/

/* DOM Ready */
$j(document).ready(function () {
	$j('#filter .dropdown').each(function () {
		new DropDown($j(this));
	});
	
	//new ProductGrid($j('.category-products'));
	
	//Clear comparisons popup
	$j('.actions .left').click(function() {
		 $j("#lightbox_clear").center().fadeIn();
		 return false;
	});
	
	$j("#lightbox_clear .cancel").click(function() {
		$j(this).parents(".lightbox").fadeOut();
		return false;
	});
	
	/* badge kickout */
	$j('.product-image-container').hoverIntent({
		sensitivity: 1,
		interval: 10,
		over: function () {
			$j(this).addClass('active');
			$j(this).find('.badge-kickout:first').show();
		},
		out: function () {
			$j(this).removeClass('active');
			$j(this).find('.badge-kickout:first').hide();
		}
	});
	$j("#aside li.trigger .subcat a").click(function(ev){
		ev.stopPropagation();
		
	});
	/* promo overlays */
	$j('#featured.products-grid .item').each(function () {
		new ProductPromo($j(this));
	});
	
	$j('.products-grid .item').each(function () {
		if ($j(this).find('.color-selector li').length) {
			new ProductColors($j(this), $j(this).find('.color-selector'));
		}
	});
	
	$j("#lightbox_compare .ok").click(function() {
		$j(this).parents(".lightbox").fadeOut();
	});
	
	new UsPrice($j('.usprice'));
});

