var models = [{
series: 'Special',
model: '41',
style: '4469',
price: 2291,
retail: 2787,
weight: 3745,
production: 84182,
description: 'Tourback Sedan',
doors: 4,
passengers: 6,
wheelbase: 122,
horsepower: 188,
picture: 'http://www.55buick.com/pics/colorCar/41.gif'
},
{
series: 'Special',
model: '43',
style: '4439',
price: 2409,
retail: 2915,
weight: 3820,
production: 66409,
description: 'Four-Door Riviera',
doors: 4,
passengers: 6,
wheelbase: 122,
horsepower: 188,
picture: 'http://www.55buick.com/pics/colorCar/43.gif'
},
{
series: 'Special',
model: '49',
style: '4481',
price: 2974,
retail: 3198,
weight: 3940 ,
production: 2952,
description: 'Estate Wagon',
doors: 2,
passengers: 6,
wheelbase: 122,
horsepower: 188,
picture: 'http://www.55buick.com/pics/colorCar/49.gif'
},
{
series: 'Special',
model: '46R',
style: '4437',
price: 2332,
retail: 2834,
weight: 3720 ,
production: 155818,
description: 'Two-Door Riviera',
doors: 2,
passengers: 6,
wheelbase: 122,
horsepower: 188,
picture: 'http://www.55buick.com/pics/colorCar/46R.gif'
},
{
series: 'Special',
model: '46C',
style: '4467',
price: 2590,
retail: 3158,
weight: 3825 ,
production: 10009,
description: 'Convertible coupe',
doors: 2,
passengers: 6,
wheelbase: 122,
horsepower: 188,
picture: 'http://www.55buick.com/pics/colorCar/46C.gif'
},
{
series: 'Special',
model: '48',
style: '4411',
price: 2233,
retail: 2399.95,
weight: 3715 ,
production: 61875,
description: 'Tourback Sedan',
doors: 2,
passengers: 6,
wheelbase: 122,
horsepower: 188,
picture: 'http://www.55buick.com/pics/colorCar/48.gif'
},
{
series: 'Super',
model: '52',
style: '4569',
price: 2876,
retail: 3738,
weight: 4140 ,
production: 43280,
description: 'Four Door Sedan',
doors: 4,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/colorCar/52.gif'
},
{
series: 'Super',
model: '56C',
style: '4567X',
price: 3225,
retail: 4075,
weight: 4280 ,
production: 3527,
description: 'Convertible Coupe',
doors: 2,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/colorCar/56C.gif'
},
{
series: 'Super',
model: '56R',
style: '4537',
price: 2831,
retail: 3686,
weight: 4075 ,
production: 85656,
description: 'Riviera',
doors: 2,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/colorCar/56R.gif'
},
{
series: 'Century',
model: '61',
style: '4669',
price: 2548,
retail: 2990,
weight: 3825 ,
production: 13629,
description: 'Tourback Sedan',
doors: 4,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/colorCar/61.gif'
},
{
series: 'Century',
model: '63',
style: '4639',
price: 2733,
retail: 3478,
weight: 3900 ,
production: 55088,
description: 'Riviera',
doors: 4,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/colorCar/63.gif'
},
{
series: 'Century',
model: '66C',
style: '4667X',
price: 2991,
retail: 3799,
weight: 3950 ,
production: 5558,
description: 'Convertible Coupe',
doors: 2,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/colorCar/66C.gif'
},
{
series: 'Century',
model: '66R',
style: '4637',
price: 2601,
retail: 3407,
weight: 3805 ,
production: 80338,
description: 'Riviera',
doors: 2,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/colorCar/66R.gif'
},
{
series: 'Century',
model: '68',
style: '4611',
price: 0,
retail: 0,
weight: 0 ,
production: 270,
description: 'Tourback Sedan',
doors: 2,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/55BuickModel68.gif'
},
{
series: 'Century',
model: '69',
style: '4681',
price: 3175,
retail: 3742,
weight: 3995 ,
production: 4243,
description: 'Estate Wagon',
doors: 4,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/colorCar/69.gif'
},
{
series: 'Roadmaster',
model: '72',
style: '4769',
price: 3349,
retail: 4019,
weight: 4300 ,
production: 31717,
description: 'Sedan',
doors: 4,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/colorCar/72.gif'
},
{
series: 'Roadmaster',
model: '76C',
style: '4767X',
price: 3552,
retail: 4249,
weight: 4415 ,
production: 4739,
description: 'Convertible Coupe',
doors: 2,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/colorCar/76C.gif'
},
{
series: 'Roadmaster',
model: '76R',
style: '4737',
price: 3453,
retail: 4120,
weight: 4270 ,
production: 28071,
description: 'Riviera',
doors: 2,
passengers: 6,
wheelbase: 127,
horsepower: 236,
picture: 'http://www.55buick.com/pics/colorCar/76R.gif'
}
];

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function showModel(location,pictureLocation,descripLocation,model) {
	var yourModel;
	var description;

	yourModel = getModelInfo(model);

	var html = "";
	description='1955 Buick '+yourModel.series+' '+yourModel.description;
	document.getElementById(descripLocation).innerHTML=description;
	for (var i in yourModel){
		if (i == 'picture') {
		document.getElementById(pictureLocation).innerHTML='<img src="'+yourModel[i]+'"/>';
		}
		else
		if (i == 'price' || i == 'retail')
			html+=i+': '+formatCurrency(yourModel[i])+'<br>';
		else
			html+=i+': '+yourModel[i]+'<br>';
	}
	document.getElementById(location).innerHTML=html;
}

function getModelInfo(model) {
	for(var i=0; i < models.length; i++) {
	    if (models[i].model == model )
		    return models[i];
		}
	return null;
}

function getModelsForSeries(series) {
    var list = new Array();
	for(var i=0; i < models.length; i++) {
	    if (models[i].series == series && models[i].price > 0)
		    list.push(models[i]);
		}
	return list;
}

function modelsPopulateSelect(bmodels,selectName) {
	d=document.getElementById(selectName);
	if(!d){return;}	
	d.options.length=bmodels.length;
	for(var i=0;i<bmodels.length;i++)
	{
		d.options[i].text=bmodels[i].description;
		d.options[i].value=bmodels[i].model;
	}
}