(function($)
{	
	// event manager
	$.extend({
		details:function(obj)
		{
			var o	= typeof(obj) == "string" ? eval(obj) : $(obj);
			o.bind("mouseover mouseleave",function(e){e.type == "mouseover" ? $(this).find(".details").animate({bottom:0},"fast") : $(this).find(".details").animate({bottom:-95},"fast");});
		},
		
		scale:function(obj, zoom)
		{
			var fix = zoom == false ? 217 : 458;
			obj.each(
				function()
				{
					if($(this).width() > fix)
					{
						var ratio = $(this).width()/$(this).height(); 
						$(this).width(fix);
						$(this).height(Math.round(fix / ratio));
						
						// vertical
						var top = (fix - $(this).height())/2;
						$(this).css({"margin-top":top})
					}
					
					if($(this).height() > fix)
					{
						var ratio = $(this).height()/$(this).width(); 
						$(this).height(fix);
						$(this).width(Math.round(fix / ratio));
						
						// vertical
						var left = -(fix - $(this).width())/2;
						$(this).css({"margin-left":left})
					}					
				}
			)
		},
		
		/*
			google code
		*/
		google:{
			// var
			tracker:false,

			// page load
			page:function()
			{
				this.tracker._trackPageview();
			},

			log:function(category, action, label)
			{
				if(this.tracker)
				{
					this.tracker._trackEvent(category, action, label)
				}
			}			
		}
	})
})(jQuery)

// run it and pass it in!
$(document).ready(
	function()
	{
		/*
		setTimeout(function(){
			try
			{
				$.google.tracker = _gat._getTracker("UA-1812163-26");
				$.google.page();
			}
			catch(err){}			
		}, 1000);
		*/
		if($("ul.products li")){/*$.details($("ul.products li"));*/$.scale($("ul.products li .image img"));}
		if($("ul.products li")){/*$.details($("ul.products li"));*/$.scale($("#Details .image img"), true);}
		if($("#Details .alternate img")){$("#Details .alternate img").bind('click',function(){$("#Details .image img").attr({src:$(this).attr("src")})})}
	}
)