$(document).ready(function() {
	var imgObj= [];
	var imgLoad = [];
	var t=0;

	
	$.each(images, function(i, val){
		imgLoad[t] = val.url;
		t++;
	});
	
	for(var p=0;p<imgLoad.length;p++){
		imgObj[p] = new Image();
		imgObj[p].src = imgLoad[p];
	}
	
	$('li.grid').hover(function(){
		$('div#prod-info').hide();
		$the = $(this).attr("rel");
		
		if(images[$the]){
			$('img#prod-image').attr("src", images[$the].url);
			
			// If the item is not a product.
			var ltd = images[$the].ltd;
			var price = images[$the].price;
			var make = images[$the].make;
			
			$("span#ltd").html('');
			$("span#price").html('');
			$("span#desc").html('');
			
			if(ltd.length > 0) { 
			    $('#ltdlabel').show();
			    $('span#ltd').html(images[$the].ltd);
			}
			else {
			    $("#ltdlabel").hide();
			}
			
			if(price.length > 0) { 
			    $('#pricelabel').show();
			    $('span#price').html(images[$the].price);
			}
			else {
			    $('#pricelabel').hide();
			}
			
			if(make.length > 0) { 
			    $('span#make').show();
			    $('span#make').html(images[$the].make);
			}
			else {
			    $('span#make').hide();
			}
			
			//$('span#price').html(images[$the].price);
			//$('span#make').html(images[$the].make);
			
			$('span#desc').html(images[$the].desc);
			
			$('a#morelink').attr('href', '/product/' + images[$the].slug);
		} else {
			if($(this).prev(".grid").attr("rel")){
				$the = $(this).prev(".grid").attr("rel");
			} else {
				$the = $(this).next(".grid").attr("rel");
			}
			$('img#prod-image').attr("src", images[$the].url);
			$('span#make').html(images[$the].make);
			$('span#desc').html(images[$the].desc);
			$('span#ltd').html(images[$the].ltd);
			$('span#price').html(images[$the].price);
			$('a#morelink').attr('href', '/product/' + images[$the].slug);
		}
		
		$('div#prod-info').fadeIn(600);
	});
});








