
var supplierListing = new function supplierListingClass()
{
	var _this = this;
	this.divs = [["#bg1", true], ["#bg2", false]];
	this.suppliers = [
		{name:"- Select a Category -",imgURL:"parts_brands_default.jpg",w:500,h:300},
		{name:"Brakes (Air)",imgURL:"parts_brands_brake-air.jpg",w:500,h:300},
		{name:"Brakes (Hydraulic)",imgURL:"parts_brands_brake-hydro.jpg",w:500,h:300},
		{name:"Cab &amp; Hood; Frame/Attachments",imgURL:"parts_brands_cab-hood.jpg",w:500,h:300},
		{name:"Engine",imgURL:"parts_brands_engine.jpg",w:500,h:300},
		{name:"Maintenance",imgURL:"parts_brands_maintenance.jpg",w:500,h:300},
		{name:"Steering",imgURL:"parts_brands_steering.jpg",w:500,h:300},
		{name:"Suspension Parts",imgURL:"parts_brands_suspension.jpg",w:500,h:300},
		{name:"Trailer Parts",imgURL:"parts_brands_trailor.jpg",w:500,h:300},
		{name:"Transmission/Axle/Driveline/PTO",imgURL:"parts_brands_transmission.jpg",w:500,h:300}
	];
	this.changed = function()
	{
		var idx = $(this).val();
		$(_this.divs).each(function()
		{
			if(this[1])
			{
				$(this[0]).fadeOut(500);
				this[1] = false;
			}
			else
			{
				$(this[0]).css({backgroundImage:"url('" + _this.suppliers[idx].img.src + "')", width:_this.suppliers[idx].w + "px", height:_this.suppliers[idx].h + "px"});		
				$(this[0]).fadeIn(500);
				this[1] = true;
			}
		});
	};
	this.init = function()
	{
		if($("#suppliersDropDown").length > 0)
		{
			$(_this.suppliers).each(function(idx, item)
			{
				item.img = new Image(item.w, item.h);
				item.img.src = "/images/suppliers/" + item.imgURL;
				$("#suppliersDropDown").append('<option value="' + idx + '">' + item.name + '</option>');
			});
			$("#suppliersDropDown").change(_this.changed);			
			$("#bg1").css({backgroundImage:"url('" + _this.suppliers[0].img.src + "')", width:_this.suppliers[0].w + "px", height:_this.suppliers[0].h + "px"});		
			$("#bg1").fadeIn(1, function() { $("#suppliersDropDown").fadeIn(250); });
		}
	};
}
$(supplierListing.init);
