function FAQ(q, a) {
	this.parent = null;
	this.q = q;
	this.a = a;
	this.link;
	this.parent;  	// the product object, assigned in addFAQ()
}

function Price(list_price, our_price) {
	this.parent = null;
	this.list_price = "$" + list_price;
	this.our_price = "$" + our_price;
}

function Popular(name, price, link) {
	this.name = name;
	this.price = price
	this.link = link;
}

function Color(code, name) {
	this.code = code;
	this.parent;  // the size object
	this.name = name=="Original"?"Matte Silver":name;
	this.img = getImageTag(name, name, "");
	this.price;  // the price object
}

Color.prototype.setPrice = function(price, addToPopulars) {
	this.price = price;  // adding a price to a color object
	price.parent = this;
	if (addToPopulars && price.list_price > price.our_price) {
		var color = price.parent;
		var size = color.parent;
		var product = size.parent;
		var catalog = product.parent;
		catalog.populars[catalog.populars.length] = new Popular(product.name + " " + size.name + 
			" <span style=\"color:"+color.name+"\">" + color.name + "</span> w/ " + size.caption, 
			price.our_price, size.link);
	}
}


function Size(code, model_prefix, w, h, d, vw, vh, weight, power, add_desc, img_size, caption) {

	this.code = code;
	this.parent = null;  // the product object

	this.model = model_prefix + "-" + code;
	this.name = w + "\"" + "x" + h + "\"";
	this.long_name = this.name + " (" + Math.round(w/12*10)/10 + "'" + "x" + Math.round(h/12*10)/10 + "')";
	this.dimension = this.name + "x" + d + "\"";
	this.area = Math.ceil(w * h / 144); // area in square inches
	this.link; 

	this.w = w;
	this.h = h;
	this.d = d;
	this.vw = vw;
	this.vh = vh;
	this.weight = weight + " lb";
	this.power = power + " W";
	this.add_desc = add_desc;
	this.img_size = img_size;
	this.image;
	this.img_src;
	this.caption = caption;
	
	this.colors = new Array();
}

Size.prototype.addColor = function(color) {
	this.colors[color.code] = color;
	color.parent = this;
}

// use 'code' for lightbox type:  lightbox_1sided.JPG
// use 'name' for color type: lightbox_Black.JPG
function getImageTag(code, name, img_size) {
	var str = "";
	if (name.indexOf('croll') != -1) { // 392 x 487
		str = "\
		<object	type='application/x-shockwave-flash' data='prosperb.swf' " + img_size + ">\
			<param name='movie' value='prosperb.swf' />\
			<img src='Images/lightbox_scroll.JPG' " + img_size + " alt='scrolling lightbox - please install Macromedia Flash for an animated experience.' />\
		</object>\
			";
	} else {
		str = "<img src=\"Images/lightbox_" + code +".JPG\" border=\"0\"" + img_size + " alt=\"" + name+"\" />";
	}	
	return str;
}

function Product(code, name, long_name, description, caption, img_src, img_w, img_h, long_description) {
	this.code = code;
	this.parent = null;
	
	this.name = name;
	this.long_name = long_name;
	this.description = description;
	if (img_src) {
		this.img_src = img_src;
	} else {
		this.img_src = "Images/lightbox_" + code +".JPG";
	}
	this.img_w = img_w;
	this.img_h = img_h;
	this.img_ratio = img_w / img_h;
	this.image = getImageTag(code, name, "");
	this.caption = caption;
	this.add_desc = "";
	this.long_description = long_description;
	
	this.sizes = new Array();
	this.faqs = new Array();	

	this.link = "index.html?content=product&type=" + code;
}

Product.prototype.print = function() {
	var str = this.code + ": ";
	for (i in this.sizes) {
		str += "Size:" + this.sizes[i].code + " ";
	}
	alert(str);
}

Product.prototype.addSize = function(size) {
	this.sizes[size.code] = size;
	size.parent = this;
	size.link = "index.html?content=product&type=" + this.code + "&size=" + size.code ;
	size.image = getImageTag(this.code, this.name, size.img_size);
}

Product.prototype.addFAQ = function(faq) {
	this.faqs[faq.q] = faq;
	faq.parent = this;
	faq.link = "?content=faq#" + this.code;
}


function Catalog() {
	this.products = new Array();
	this.populars = new Array();
}

Catalog.prototype.addProduct = function(product) {
	this.products[product.code] = product;
	product.parent = this;
}

Catalog.prototype.print = function() {
	var str = '';
	
	for (i in this.products) {
		str += this.products[i].code + " ";
	}
	alert(str);
}

var cat = new Catalog();
