/*
* Pretty Product Dimmer Using Lightbox Effects
* By Jesse Donat
*/

function product_dims() {

	var anchors = document.getElementsByTagName('a');

	// loop through all anchor tags
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		var theClass = String(anchor.className);
		
		// use the string.match() method to catch 'lightbox' references in the rel attribute
		if (  anchor.getAttribute('href') && ( theClass.toLowerCase().match('product_greyed_image') )  ){
			anchor.onmouseover = function (){ product_hover(this); }
			anchor.onmouseout = function (){ product_leave(this); }
			//new Effect.Appear(anchor.id, { duration: 0.1, from: 1, to: .3 });
		}
	}
}

function product_hover(sender) {
	Effect.Appear(sender.id, { duration: 0.2, from: .6, to: .98 }); //not 1 because casued ie6 to flicker
}

function product_leave(sender) {
	Effect.Appear(sender.id, { duration: 0.2, from: .98, to: .6 });
}

addLoadHandler(function(){ product_dims(); });

function addLoadHandler(handler)
{
	if(window.addEventListener)
	{
		window.addEventListener("load",handler,false);
	}
	else if(window.attachEvent)
	{
		window.attachEvent("onload",handler);
	}
	else if(window.onload)
	{
		var oldHandler = window.onload;
		window.onload = function piggyback()
		{
			oldHandler();
			handler();
		};
	}
	else
	{
		window.onload = handler;
	}
}