/* Product object definition
   DL object
   Does object
   Cost object
   Gallery object
   FAQ object
   
   Index
	==========
	[Product object] Product (XmlElement pxml)
		Constructs data object which holds Product information. Based on named XML 
		document structure. NOTE: Closes XML document when constructed. Inefficient 
		for use with multiple Products.
		
   Bugfix
	===========
	Specifications don't print correctly

   */
   
var IMG_SHOP = "_sn";
var IMG_GALT = "_thumb";

// [Product object] Product (XmlElement pxml)
 function Product (pxml) {
	this.$pxml = pxml; 
	// Defaults
	this.$imgbig = "";
	this.$DEFIMGBIG = "images/lg-little-guy.png";
 	this.name = "Product";
 	this.Name = "Product";
 	this.id = "00";
 	this.img = this.$DEFIMGBIG;
 	this.does = null;
 	this.features = null;
 	this.have = null;
 	this.costs = null;
 	this.description = "Description";
 	this.gallery = null;
 	this.downloads = null;
 	this.category = null;
 	// Add FAQs
 	this.faqs = null;
 	// Verify XML data
 	if (this.$pxml != null) {
 		// Set properties of this [Product object]
 	 	this.name = this.$pxml.getAttribute("name");
 	 	if (this.$pxml.getAttribute("short")) {
 	 		this.Name = this.$pxml.getAttribute("short");
 	 	} else { this.Name = this.name; }
	 	this.id = this.$pxml.getAttribute("id");
	 	this.$imgbig = this.name.replace (/[ .,']/gi, "_")
		this.$imgbig = this.$imgbig.toLowerCase ();
		// construct <this.img>.src
		this.img = "images/" + this.$imgbig + "/";
		this.img += this.$imgbig;
		// Select <gallery> element
	 	var thisGallery = this.$pxml.getElementsByTagName ("gallery");
	 	// Move to <images> elements
		thisGallery = thisGallery[0].getElementsByTagName ("image");
		this.gallery = new Array (thisGallery.length);
	 	// Iterate <gallery><images elements> into [Product object].gallery
	 	for (var i = 0; i < this.gallery.length; i++) {
	 		this.gallery[i] = thisGallery[i].firstChild.data;
	 	}
	 	// Select <downloads> element
	 	var thisDls = this.$pxml.getElementsByTagName ("downloads");
	 	// Move to <item>s elements
	 	thisDls = thisDls[0].getElementsByTagName ("item");
	 	this.downloads = new Array (thisDls.length);
	 	// Iterate DLs into this.downloads
	 	for (var i = 0; i < this.downloads.length; i++) {
	 		this.downloads[i] = new DL (thisDls[i]);
	 	}
		// Iterate <have elements> into [Product object].supports
		var thisHave = this.$pxml.getElementsByTagName("have");
		this.have = new Array(thisHave.length);
		// Iterate supports
		for (var i = 0; i < this.have.length; i++) {
			this.have[i] = thisHave[i].firstChild.data;
		}
		// Iterate <does elements> into [Product object].does
		var thisDoes = this.$pxml.getElementsByTagName("does");
		this.does = new Array(thisDoes.length); // Make enough room
		for (var i = 0; i < this.does.length; i++) {
			this.does[i] = new Does (thisDoes[i]);
		}
		// Iterate <feature elements> into [Product object].features
		var thisFeatures = this.$pxml.getElementsByTagName ("features");
		this.features = new Array (thisFeatures.length); // Make enough room
		for (f in this.features) {
			if (thisFeatures[f].nodeType == 1) {
				this.features[f] = thisFeatures[f].getAttribute("id");
			}
		}
		// Iterate <option elements> in <cost element> into [Product object].costs
		var thisCosts = this.$pxml.getElementsByTagName("option");
		this.costs = new Array(thisCosts.length); // Make room
		for (var i = 0; i < thisCosts.length; i++) {
			this.costs[i] = new Cost(thisCosts[i]);
		}		
		this.description = this.$pxml.getAttribute("desc");
		var thisSpecs = this.$pxml.getElementsByTagName ("specifications")[0];
		this.specifications = null;
//		if (thisSpecs.length > 0) {
			this.specifications = new ProductSpecs (thisSpecs);
//		}
		this.category = this.$pxml.getAttribute("category");
		// fetch <faq>
		var faq_list = this.$pxml.getElementsByTagName("faq");
		if (faq_list.length > 0) {
			var m_faq = FAQ_XML.getElementsByTagName("category");
			var c_faq = null;
			var turt = null;
			// Add FAQs
			this.faqs = new Array(faq_list.length);
//			this.faqs = new Array();
			for (var faq = 0; faq < faq_list.length; faq++) {
				// Double the pleasure
				this.faqs[faq] = new Array(2);
				// We have a node!
				if (faq_list[faq].nodeType==1) {
					// attribute:category
					var faq_cat = faq_list[faq].getAttribute("category");
					for (var f = 0; f < m_faq.length; f++) {
						if (m_faq[f].getAttribute("name")==faq_cat) {
							c_faq = m_faq[f].getElementsByTagName("ask");
							break;
						}
					}
					// if attribute:index
					var faq_ind = faq_list[faq].getAttribute("index");
					// look up
					if (faq_ind) { // load the specific FAQ
						for (var f = 0; f < c_faq.length; f++) {
							if (c_faq[f].getAttribute("id")==faq_ind) {
								this.faqs[faq][0] = c_faq[f].getElementsByTagName("question")[0].firstChild.data;
								this.faqs[faq][1] = c_faq[f].getElementsByTagName("answer")[0].firstChild.data;
								break;
							}
						}
					} else { // load the general category
						turt = c_faq;
						/*
						for (var f = 0; f < c_faq.length; f++) {
							this.faqs[faq][0] = c_faq[f].getElementsByTagName("question")[0].firstChild.data;
							this.faqs[faq][1] = c_faq[f].getElementsByTagName("answer")[0].firstChild.data;
						}
						*/
					}
				}
			}
			if (turt) {
				for (t=0;t<5&&t<c_faq.length;t++) {
				this.faqs[t] = new Array(2);
				this.faqs[t][0] = c_faq[t].getElementsByTagName("question")[0].firstChild.data;
				this.faqs[t][1] = c_faq[t].getElementsByTagName("answer")[0].firstChild.data;
				}
			}
		}
		// Attach product to cookie
		/*
		var thisCookie = new Cookie (document, "quickertek_cookie", 240);
		thisCookie.product = this.name;
		thisCookie.family = this.family;
		thisCookie.store ();
		*/	
 	} else {
  		window.alert ("Why were we not kicked out of the loop?");
 	}
 }
 /*		var allFeatures = openXml(XML_URI).getElementsByTagName("feature");
		for (var i = 0; i < this.features.length; i++) {
			var fid = thisFeatures[i].getAttribute("id");
			for (f in allFeatures) {
				if (allFeatures[f].nodeType == 1) {
					if (fid == allFeatures[f].getAttribute("id")) {
						this.features[i] = new Feature(allFeatures[f]);
//						alert(this.features[i].name);
					}
				}
			}
		}
		*/
 
// [Product object].makePillbox (string cur)
 Product.prototype.makePillbox = function (cur) {
 	// Make contain for pillbox
 	var boxEl = document.createElement('div');
 	boxEl.id = "roundnav";
 	boxEl.style.cssFloat = "right";
 	// List elements, or "pills"
 	var pillsEl = document.createElement('ul');
 	var pills = new Array("Overview", "Specifications", "FAQs", "Support");
 	for (var p = 0; p < pills.length; p++) {
// 	for (p in pills) { // Iterates from hardcoded array
 		var pEl = document.createElement('li');
 		// Note first and last
 		if (p == 0) { pEl.className = "first"; }
 		else if (p == (pills.length)-1) { pEl.className = "last"; }
 		// Compile internal data
 		pDiv = document.createElement('div');
 		if (pills[p] == cur) { // Note currently selected
 			pDiv.className = "current";
 		}
 		// Set onclick event
/*
 		var strOnclick = "new Product('PARSE').writeTo('";
 		strOnclick += PRODUCT_DIV;
 		strOnclick += "','";
 		strOnclick += pills[p];
 		strOnclick += "')";
 		*/
 		var strOnclick = "pbOnClick('";
 		strOnclick += pills[p];
 		strOnclick += "')";
 		pDiv.setAttribute("onclick", strOnclick);
 		pDiv.innerHTML = pills[p];
 		// Append list element
 		pEl.appendChild(pDiv);
 		pillsEl.appendChild(pEl);
 	}
 	boxEl.appendChild(pillsEl);
 	return boxEl;
 }
 
// pbOnClick
 function pbOnClick (which) {
 	// Get elements
 	var pillEls = document.getElementById("roundnav").childNodes[0].childNodes;
 	var tabEls = document.getElementById(PRODUCT_DIV).childNodes;
 	// Hide elements
 	for (var tab = 0; tab < tabEls.length; tab++) {
// 	for (tab in tabEls) {
 		if (tabEls[tab].nodeType == 1 && tabEls[tab].className == "boxContentBody") {
 			if (tabEls[tab].id == which) {
 				// Show element
 				tabEls[tab].style.display = "block";
 			} else {
 				// Hide element
 				tabEls[tab].style.display = "none";
 			}
	 	}
 	}
 	// Switch pills
 	for (var p = 0; p < pillEls.length; p++) {
// 	for (p in pillEls) {
 		if (pillEls[p].nodeType == 1) {
 			if (pillEls[p].firstChild.innerHTML == which) {
 				// Switch pill on
 				pillEls[p].firstChild.className = "current";
 			} else {
 				// Switch pill off
 				pillEls[p].firstChild.className = "";
 			}
 		}
 	}
 }
 
 // [Product object].mkGalleryCtl()
 Product.prototype.mkGalleryCtl = function() {
	// Create Div placement
 	var galDiv = document.createElement('div');
 	galDiv.className = "gallery";
// 	galDiv.style.cssFloat = "left";
 	// Create fade out and rounded element
 	var tGalDiv = document.createElement('div');
 	tGalDiv.className = "top";
 	galDiv.appendChild(tGalDiv);
 	// Create element to hold current image
 	var mGalDiv = document.createElement('div');
 	mGalDiv.className = "mdl";
 	// Present Image
 	var mGalImg = document.createElement('img');
 	mGalImg.id = "gallery_display";
 	mGalImg.src = this.img + "_1.png";
 	var strOnerror = "this.src='" + this.$DEFIMGBIG + "'";
 	mGalImg.setAttribute('onerror', strOnerror);
 	mGalDiv.appendChild(mGalImg);
 	// Caption
 	var mGalCpDiv = document.createElement('div');
 	mGalCpDiv.style.textAlign = "center";
 	mGalCpDiv.innerHTML = this.gallery[0];
 	mGalDiv.appendChild(mGalCpDiv);
 	galDiv.appendChild(mGalDiv);
 	// Fade out for box
 	var bGalDiv = document.createElement('div');
 	bGalDiv.className = "btm";
 	galDiv.appendChild(bGalDiv);
 	// Selector controls
	if (this.gallery.length > 1) {
	 	var sGalDiv = document.createElement('ul');
	 	sGalDiv.id = "gallery_selector";
	 	sGalDiv.className = "noBullet";
	 	for (var g = 0; g < this.gallery.length; g++) {
//	 	for (g in this.gallery) {
	 		var sliDiv = document.createElement('li');
	 		sliDiv.id = g;
	 		// Add Tooltip
//	 		sliDiv.innerHTML = this.gallery[g];
			// Add thumbnail
			var strImg = this.img;
			strImg += "_";
			strImg += (parseInt(g) + 1);
			/*
			strImg += IMG_GALT
			strImg += ".png";
			*/
			var gthumb = document.createElement('img');
			gthumb.src = strImg + IMG_GALT + ".png";
			// Hook up OnClick
			var strOnclick = "document.getElementById('";
			strOnclick += "gallery_display";
			strOnclick += "').src = '";
			strOnclick += strImg + ".png";
			strOnclick += "'";
			gthumb.setAttribute("onclick", strOnclick);
			// Append thumb
			sliDiv.appendChild(gthumb);
	 		// Append li
	 		sGalDiv.appendChild(sliDiv);
	 	}
	 	galDiv.appendChild(sGalDiv);
	 }
	 
	 // Floating Buy Options
	 
	 // Buy Tile
	 var bBox	= document.createElement ('div');
	 bBox.id	= "buy_box";
	 bBox.style.overflow = "hidden";
	 bBox.style.marginTop = "20px";
	 // Override styles
	 bBox.style.width = "340px";
	 bBox.style.height = "97px";
	 //bBox.style.background = "url(images/bg-product-select.png) no-repeat";
	 //bBox.style.color = "white";
	 bBox.style.color = "black";
	 // Initial position
	 /*
	 bBox.style.position = "absolute";
	 bBox.style.left = "0px";
	 bBox.style.top = "0px";
	 bBox.style.zIndex = "20";
	 */
	 // Fade in
	 bBox.style.opacity = '1';
	 bBox.style.filter = 'alpha(opacity = 100)';
	 bBox.FadeState = -2;
	 
	 // Add a title to the Buy Tile
	 var bBoxTitle = document.createElement ('strong');
	 bBoxTitle.style.paddingLeft = "5px";
	 bBoxTitle.innerHTML = "Buy " + this.Name;
	 bBox.appendChild (bBoxTitle);
	 
	 // Add Price List
	 var bBoxPricelist = document.createElement ('ul');
	 bBoxPricelist.className = "noBullet";
	 // 		priceList.style.cssFloat = "left";
	 // Iterate price points into list
	 for (var cost = 0; cost < this.costs.length; cost++) {
	 // 		for (cost in this.SelectedProduct.costs) {
	 	var pricePoint = document.createElement ('li');
	 	pricePoint.style.color = "black";
	 	pricePoint.style.paddingLeft = "5px";
	 	if (this.costs.length > 1) {
	 		// Attach onClick event
	 		var strOnclick	= "onCostClick ('";
	 		strOnclick		+= this.costs[cost].id;
	 		strOnclick		+= "','";
	 		strOnclick		+= this.costs[cost].name;
	 		strOnclick		+= "','";
	 		strOnclick		+= this.costs[cost].value;
	 		strOnclick		+= "')";
	 		pricePoint.setAttribute ("onclick", strOnclick);
	 		// enable rollover effect
	 		pricePoint.className = "roll";
	 	}
	 	pricePoint.innerHTML = this.costs[cost].name;
	 	// Add price point to list
	 	bBoxPricelist.appendChild (pricePoint);
	 }
	 // Add list to Buy Element
	 bBox.appendChild (bBoxPricelist);
	 // Add Price Element
	 var priceDiv = document.createElement ('div');
	 priceDiv.style.paddingLeft = "5px";
	 priceDiv.style.cssFloat = "left";
	 priceDiv.id = "price";
	 // Append price
	 bBox.appendChild(priceDiv);
	 // Add Buy Button
	 var buyButton = document.createElement ('div');
	 buyButton.id = "buy";	// Imperative for shopping cart hook up
	 // Stupid Windows
	 buyButton.style.background = "url(images/buy_green.png) no-repeat";
	 buyButton.style.height = "21px";
	 buyButton.style.width = "68px";
	 buyButton.style.cssFloat = "right";
	 buyButton.style.marginRight = "10px";
	 buyButton.style.cursor = "pointer";
	 // Append Buy Button to price element
	 bBox.appendChild(buyButton);
	 // Actual shopping cart hook up
	 /*
	 var sCartForm = document.createElement ('form');
	 sCartForm.id = "cart";
	 sCartForm.action = "https://intuitivesecure.com/uCart/uCart.php";
	 sCartForm.method = "POST";
	 sCartForm.target = "_blank";
	 // Append shopping cart hook up
	 bBox.appendChild(sCartForm);*/
	 // Fade In
	 galDiv.appendChild(bBox);
	 
	 // End float
	 
 	return galDiv;
 }

 
/* [Product object].writeTo (HtmlDocument document, string whereOnPage)

	Loads up an HTML formatted version of the [Product object] and then
	sends it to be printed to a specified location on the page.

	Arguments:
		:: see printToPage()

	TODO: */
 Product.prototype.writeTo = function (whereOnPage, what) {
 	// Set default
 	if (what == null) {
 		what = "Overview";
 	}
 	// for reuse
 	var clearDiv = document.createElement('div');
 	clearDiv.className = "clear";
 	// Print to page
 	var wEl = document.getElementById(whereOnPage); // Gets write location
	while (wEl.hasChildNodes()) { wEl.removeChild (wEl.childNodes[0]); }
 	wEl.appendChild(this.makePillbox(what));
 	// Header
 	var headDiv = document.createElement('div');
// 	headDiv.style.cssFloat = "left";
 	var sHeadDiv = document.createElement('h3');
 	sHeadDiv.className = "sectionHeader";
 	sHeadDiv.innerHTML = this.name;
 	headDiv.appendChild(sHeadDiv);
 	wEl.appendChild(headDiv); // Insert in final output
// 	wEl.appendChild(this.mkGalleryCtl()); // Add gallery
 	/*
 	var boxBody = document.createElement('div');
 	boxBody.id = "boxContentBody";
 	boxBody.style.cssFloat = "left";
 	*/
 	// Main body content: Overview
 	var oBoxBody = document.createElement('div');
 	oBoxBody.id = "Overview";
 	oBoxBody.className = "boxContentBody";
 	oBoxBody.appendChild(this.mkGalleryCtl());
// 	oBoxBody.style.display = "inline";
 	for (var d = 0; d < this.does.length; d++) {
// 	for (d in this.does) { // Iterate body
 		var dDiv = document.createElement('div');
 		dDiv.className = "column";
 		if (this.does[d].short != "") {
 			var sDiv = document.createElement('div');
 			var sSDiv = document.createElement('strong');
 			sSDiv.innerHTML = this.does[d].short;
 			sDiv.appendChild(sSDiv);
 			dDiv.appendChild(sDiv);
 		}
 		// Append content
 		dDiv.innerHTML += this.does[d].long;
 		oBoxBody.appendChild(dDiv);
 	}
 	// Product features
	// HACK:fix clearDiv
	var clr_div_1 = document.createElement("div");
	clr_div_1.className = "clear";
	oBoxBody.appendChild(clr_div_1);
	var featBody = document.createElement('div');
 	featBody.className = "boxContentBody";
 	featBody.style.border = "none";
// 	featBody.style.cssFloat = "none";
// 	featBody.style.display = "block";
// 	featBody.innerHTML = "TEST";
//	alert(this.category);
	// Get category
	var cels = INVENTORY_XML.getElementsByTagName("category");
	/*
	if (cels) {
		for (var c = 0; c < cels.length; c++) {
			// Find this category and take its features
			if (this.category==cels[c].getAttribute("name")) {
				if (cels[c].nodeType==1) {
					// Enter <feature> nodes
					var feats = cels[c].getElementsByTagName("features")[0];
					if (feats) {
						feats = feats.getElementsByTagName("feature");
						// Iterate to page
						for (var f = 0; f < feats.length; f++) {
							if (feats[f].nodeType==1) {
								var featEl = document.createElement("div");
								featEl.className = "feature";
								featEl.id = (f+1==feats.length) ? "last" : "none";
	//							featEl.style.cssFloat = "left";
	//							featEl.style.width = "185px";
	//							featEl.style.margin = "10px";
								var topEl = document.createElement("div");
								// feats[f].getElementsByTagName("image")[0];
								var imgFEl = document.createElement("div");
								var simg = "url(images/features/";
								simg += feats[f].getElementsByTagName("image")[0].firstChild.data;
								simg += ") no-repeat";
								imgFEl.style.background = simg;
								imgFEl.style.width = "52px";
								imgFEl.style.height = "47px";
								imgFEl.style.cssFloat = "right";
								topEl.appendChild(imgFEl);
								// feats[f].getElementsByTagName("title")[0];
								var titleFEl = document.createElement("div");
								titleFEl.style.color = "green";
								titleFEl.innerHTML = feats[f].getElementsByTagName("title")[0].firstChild.data;
								topEl.appendChild(titleFEl);
								// feats[f].getElementsByTagName("bold")[0];
								var boldFEl = document.createElement("div");
								boldFEl.style.fontWeight = "bold";
								boldFEl.innerHTML = feats[f].getElementsByTagName("bold")[0].firstChild.data;
								topEl.appendChild(boldFEl);
								// Add to top
								featEl.appendChild(topEl);
								// feats[f].getElementsByTagName("body")[0];
								var bodyFEl = document.createElement("div");
								bodyFEl.innerHTML = feats[f].getElementsByTagName("body")[0].firstChild.data;
								featEl.appendChild(bodyFEl);
								// Now append to bigger document
								featBody.appendChild(featEl);
							}
						}
					}
				}
				break;
			}
		}
	}*/
 	oBoxBody.appendChild(featBody);

 	// Main body content: Specifications
 	var sBoxBody = document.createElement('div');
 	sBoxBody.id = "Specifications";
 	sBoxBody.className = "boxContentBody";
 	sBoxBody.appendChild(this.mkGalleryCtl());
 	sBoxBody.style.display = "none";
 	if (this.specifications) {
 		var ssBoxBody = document.createElement('div');
	 	// For TechInfo
	 	if (this.specifications.TechInfo != null) {
	 		ssBoxBody.appendChild(this.makeSpecs(this.specifications.TechInfo, "Technical"));
	 	}
		// For Ease
	 	if (this.specifications.Ease != "") {
	 		ssBoxBody.appendChild(this.makeSpecs(this.specifications.Ease, "Installation"))
	 	}
		// For Dimensions
	 	if (this.specifications.Dimensions != "") {
	 		ssBoxBody.appendChild(this.makeSpecs(this.specifications.Dimensions, "Dimensions"));
	 	}
		// For OS
	 	if (this.specifications.OS != "") {
	 		ssBoxBody.appendChild(this.makeSpecs(this.specifications.OS, "Mac OS Support"));
	 	}
		// For Compatibility
	 	if (this.specifications.Compatibility != "") {
	 		ssBoxBody.appendChild(this.makeSpecs(this.specifications.Compatibility, "Compatibility"));
	 	}
	 	// For Includes
	 	if (this.specifications.Includes != null) {
	 		ssBoxBody.appendChild(this.makeSpecs(this.specifications.Includes, "Includes"));
	 	}
	 	else {
		 	mySTit.innerHTML = "Specifications Coming Soon...";
		 	mySDiv.appendChild(mySTit);
		 	myCDiv.appendChild(mySDiv);
		 	ssBoxBody.appendChild(myCDiv);
		 }
		sBoxBody.appendChild(ssBoxBody);
 	} else { sBoxBody.innerHTML += "Specifications Not Available"; }
 	// Main body content: FAQs
// 	var faq_max = 10;
 	var fBoxBody = document.createElement('div');
 	fBoxBody.id = "FAQs";
 	fBoxBody.className = "boxContentBody";
 	fBoxBody.appendChild(this.mkGalleryCtl());
 	fBoxBody.style.display = "none";
/*
 	// Title
 	var fBodyStrong = document.createElement('h3');
 	var faBodyStrong = document.createElement('a');
 	faBodyStrong.href = "faq.html";
 	faBodyStrong.innerHTML = "Click for all FAQs...";
 	fBodyStrong.appendChild(faBodyStrong);
 	fBoxBody.appendChild(fBodyStrong);
	*/
 	// FAQs
 	if (this.faqs) { //alert(this.faqs.length);
	 	for (var f=0; f<this.faqs.length; f++) {
//	 		if (f<faq_max) {
	 		var fDiv = document.createElement('div');
	 		fDiv.className = "column";
	 		var sFDiv = document.createElement("div");
	 		var ssFDiv = document.createElement('strong');
	 		ssFDiv.innerHTML = this.faqs[f][0];
	 		sFDiv.appendChild(ssFDiv);
	 		fDiv.appendChild(sFDiv);
	 		fDiv.innerHTML += this.faqs[f][1];
	 		fBoxBody.appendChild(fDiv);
//		 	} else { alert(f); }
	 	}
 	} else {
	 	var fDiv = document.createElement('div');
	 	fDiv.className = "column";
	 	var sFDiv = document.createElement('strong');
//	 	sFDiv.innerHTML = "FAQs Available Shortly...";
	 	fDiv.appendChild(sFDiv);
 		fBoxBody.appendChild(fDiv);
 	}
	// Title
 	var fBodyStrong = document.createElement('h3');
 	var faBodyStrong = document.createElement('a');
 	faBodyStrong.href = "faq.html";
 	faBodyStrong.innerHTML = "Click for all FAQs...";
 	fBodyStrong.appendChild(faBodyStrong);
 	fBoxBody.appendChild(fBodyStrong);
 	// Main body content: Support
 	//TODO: don't accomodate support
 	var dBoxBody = document.createElement('div');
// 	dBoxBody.className = "boxContentBody";
// 	dBoxBody.name = "boxContentBody";
 	dBoxBody.id = "Support";
 	dBoxBody.className = "boxContentBody";
 	dBoxBody.appendChild(this.mkGalleryCtl());
 	dBoxBody.style.display = "none";
 	var dBody = document.createElement('div');
 	dBody.id = "boxContentBody";
 	// Title
/*
 	var dBodyStrong = document.createElement('h3');
 	dBodyStrong.innerHTML = "Support";
 	dBody.appendChild(dBodyStrong);
 	*/
 	// Add Text
 	dBody.innerHTML += "Whether you're having trouble installing a product or are concerned about a product's compatibility with your Mac, we're here to help. Simply contact us and our professional support staff will assist you. Be sure to have information about your computer on hand when you contact us, including your Mac OS version, computer model number, specifications and QuickerTek product model. The more information you give us, the quicker we can get you back to doing what you do best!";
 	dBoxBody.appendChild(dBody);
 	// Contacts
 	var dCon1 = document.createElement('div');
 	dCon1.className = "column";
 	dCon1.innerHTML = "support@quickertek.com";
 	dBoxBody.appendChild(dCon1);
 	var dCon2 = document.createElement('div');
 	dCon2.className = "column";
	dCon2.innerHTML = "Tech Support: 1-316-691-1585";
 	dBoxBody.appendChild(dCon2);
 	var dCon3 = document.createElement('div');
 	dCon3.className = "column";
	dCon3.innerHTML = "Sales Line: 1-866-691-1585";
 	dBoxBody.appendChild(dCon3);
 	var dCon4 = document.createElement('div');
 	dCon4.className = "column";
	dCon4.innerHTML = "Fax: 1-316-691-1585";
 	dBoxBody.appendChild(dCon4);
 	// Downloads
	if (this.downloads.length > 0) {
		var dlDiv = document.createElement('div');
		dlDiv.id = "boxContentBody";
		// Title
		var dlDivTitle = document.createElement('h3');
		dlDivTitle.innerHTML = "Downloads";
		dlDiv.appendChild(dlDivTitle);
		// Icon
		var dlDivIcon = document.createElement('img');
		dlDivIcon.style.cssFloat = "left";
		dlDivIcon.src = "http://www.quickertek.com/images/disk-arrow.gif";
		dlDiv.appendChild(dlDivIcon);
		// Description
		var dlDivDesc = document.createElement('div');
		dlDivDesc.innerHTML = "This section contains a list of Manuals and Downloads to help you install the products we design and make full use of them.";
		dlDiv.appendChild(dlDivDesc);
		for (var dl = 0; dl < this.downloads.length; dl++) {
//		for (dl in this.downloads) {
			// Download link container
			var lnk = document.createElement('div');
			lnk.id = "dl";
			// link
//			var strOnclick = "location.href='";
			var strOnclick	 = "window.open('";
			strOnclick		+= this.downloads[dl].link;
			strOnclick		+= "')";
			lnk.setAttribute("onclick", strOnclick);
			// Add image
			lnkImg = document.createElement('div');
			lnkImg.style.height = "48px";
			lnkImg.style.width = "48px";
			var strImg = "url(images/dls/";
			strImg += this.downloads[dl].type;
			strImg += ".png) no-repeat";
			lnkImg.style.background = strImg;
			lnk.appendChild(lnkImg);
			lnk.innerHTML += this.downloads[dl].name;
			// Append to greater instance
			dlDiv.appendChild(lnk);
		}
		// Incorporate downloads
		dBoxBody.appendChild(dlDiv);
		dBoxBody.appendChild(clearDiv);
	}
	// Returns: Policy
	var dret = document.createElement('div');
	dret.id = "boxContentBody";
//	dret.style.display = "inline";
//	dret.style.width = "100%";
	// Title
	var dretTt = document.createElement('h3');
	dretTt.innerHTML = "Return Policy&nbsp;";
	var dretSt = document.createElement('div'); // subtitle
	dretSt.style.color = "#939393";
	dretSt.style.fontWeight = "normal";
	dretSt.style.display = "inline";
	dretSt.innerHTML = "(Not that you'll need it)";
	dret.appendChild(dretTt);
	dret.appendChild(dretSt);
	// Body
	var dretP1 = document.createElement('div');
	dretP1.className = "column";
	dretP1.innerHTML = "Only Store Credit or Merchandise Exchange is available on Returns. Merchandise that has not been opened may be sent back in the original unopened package within 30 days of receipt of purchase to be eligible for in store credit or merchandise exchange, less shipping costs.  Store credit must be used within 30 days. Custom Orders are subject to special restrictions and may not be returned. Please consult a QuickerTek representative with questions on custom orders prior to purchase.";
	var dretP2 = document.createElement('div');
	dretP2.className = "column";
	dretP2.innerHTML = "Products you have used and returned within 30 days of receipt of purchase in the original packaging qualify for in store credit or merchandise exchange for 10% of the then current price of the product, less shipping charges.  Shipping charges are the responsible of the customer.  Merchandise you have tried must be sent back with all the original materials that were included.  Any substituted product that we sent out to you will generate another shipping charge that the customer is responsible for.  * Prices change often and without prior notice.";
	var dretP3 = document.createElement('div');
	dretP3.className = "column";
	dretP3.innerHTML = "Merchandise that is defective upon receipt will be replaced or repaired free of charge within 30 days of receipt of goods.";
	var dretP4 = document.createElement('div');
	dretP4.className = "column";
	dretP4.style.fontWeight = "bold";
	dretP4.innerHTML = "No refunds or exchanges will be made on QuickerTek products that were not purchased directly from QuickerTek";
	// Append Bodies
	dret.appendChild(dretP1);
	dret.appendChild(dretP2);
	dret.appendChild(dretP3);
	dret.appendChild(dretP4);
//	dBoxBody.appendChild(document.createElement("br")); //HACK
	dBoxBody.appendChild(dret);
	// Returns: Procedure
	var drp = document.createElement('div');
	drp.id = "boxContentBody";
	drp.style.width = "100%";
	// Title
	var drpT = document.createElement('h3');
	drpT.innerHTML = "Return Procedure";
	drp.appendChild(drpT);
	drp.innerHTML += "You must return the equipment including all manuals, accessories and packing materials, etc., in the original packaging to get credit for any QuickerTek products purchase.  If there are any damages QuickerTek will NOT issue credit for incomplete returns. The customer is responsible for costs to ship products back to QuickerTek.  Returned items must have a traceable number in case of damage or loss of product.";
	dBoxBody.appendChild(drp);
	// Returns: Refused Orders
	var dref = document.createElement('div');
	dref.id = "boxContentBody";
	dref.style.width = "100%";
	// Title
	var drefT = document.createElement('h3');
	drefT.innerHTML = "Refused Orders/Special Orders/Custom Orders";
	dref.appendChild(drefT);
	dref.innerHTML += "Shipping charges are not refundable, refused orders may result in additional shipping charges to cover the cost of returning the products.  All refused orders will also be subject to a 5% restocking fee. All special or custom orders including the Marine Systems are not eligible for returns or refunds.  QuickerTek at its discretion has the option to repair or replace products based on each individual case.";
	
	// No Float
	
 	// Concatenate content
 	wEl.appendChild(oBoxBody);
 	wEl.appendChild(sBoxBody);
 	wEl.appendChild(fBoxBody);
 	wEl.appendChild(dBoxBody);
 	
 	Fade("buy_box");
 	
 	// Wine for me
 	//setInterval("SetStatic()",1);
 	//position();
 	
 	// For my Guinevere
 	onCostClick (this.costs[0].id, this.costs[0].name, this.costs[0].value, this.costs[0].weight);
 }
 
// HtmlElement [Product object].makeSpecs (obj[] which, str title, str type)
 Product.prototype.makeSpecs = function (which, title, type) {
 	var cDiv = document.createElement('div');
 	cDiv.className = "column";
 	cDiv.style.width = "220px";
	cDiv.style.cssFloat = "left";
 	var sDiv = document.createElement('div');
 	sDiv.style.marginBottom = "10px";
 	var sTit = document.createElement('strong');
	// Append Title
	sTit.innerHTML = title;
	sDiv.appendChild(sTit);
	// Append Data
	if (which.constructor == Array) {
		for (var w = 0; w < which.length; w++) {
//		for (w in which) {
			var wDiv = document.createElement('div');
			wDiv.innerHTML = which[w];
			sDiv.appendChild(wDiv);
		}
	} else {
		var wDiv = document.createElement('div');
		wDiv.innerHTML = which;
		sDiv.appendChild(wDiv); }
	cDiv.appendChild(sDiv);
	// Append Element
	return cDiv;
 }
 
/* string onCostClick (string which)
	hooks into shopping cart solution */
function onCostClick (id, name, value, weight) {
	// Expected values
	var strPrice = "price";
	var strButton = "buy";
	// Get elements
	var divs = document.getElementsByTagName("div");
	var prices = new Array();
	var buttons = new Array();
	for (var d = 0; d < divs.length; d ++) {
		if (divs[d].id == strPrice) prices.push(divs[d]);
		else if (divs[d].id == strButton) buttons.push(divs[d]);
		else { continue; }
		}
	// Create Form
	var m_form = document.getElementById(strCartFormId);
	if (m_form) {
		// clear for
		while (m_form.hasChildNodes()) {
			m_form.removeChild(m_form.childNodes[0]);
			}
		// name <input>
		var name_in		= document.createElement("input");
		name_in.type	= "hidden";
		name_in.name	= "Item";
		name_in.value	= name;
		m_form.appendChild(name_in);
		// value <input>
		var value_in	= document.createElement("input");
		value_in.type	= "hidden";
		value_in.name	= "Price";
		value_in.value	= value;
		m_form.appendChild(value_in);
		// weight <input>
		var weight_in	= document.createElement("input");
		weight_in.type	= "hidden";
		weight_in.name	= "ShippingWeight";
		weight_in.value = weight;
		m_form.appendChild(weight_in);
		// id <input>
		var id_in	= document.createElement("input");
		id_in.type	= "hidden";
		id_in.name	= "SKU";
		id_in.value	= id;
		m_form.appendChild(id_in);
		// qty <input>
		var qty_in		= document.createElement("input");
		qty_in.type		= "hidden";
		qty_in.name		= "Qty";
		qty_in.value	= "1";
		m_form.appendChild(qty_in);
		// merch <input>
		var merch_in	= document.createElement("input");
		merch_in.type	= "hidden";
		merch_in.name	= "merchant";
		merch_in.value	= "quickertek";
		m_form.appendChild(merch_in);
		// url <input>
		var url_in		= document.createElement("input");
		url_in.type		= "hidden";
		url_in.name		= "ShopMoreURL";
		url_in.value	= "http://www.quickertek.com";
		m_form.appendChild(url_in);
		}
	// Iterate prices
	for (var p = 0; p < prices.length; p ++) {
		// Set price as HTML
		prices[p].innerHTML = "$" + value;
		}
	// Iterate buttons
	for (var b = 0; b < buttons.length; b ++) {
		// Event hook up
		var strOnclick = "document.getElementById('";
		strOnclick += strCartFormId;
		strOnclick += "').submit()";
		buttons[b].setAttribute("onclick", strOnclick);
		}
}

function onBuyClick(id) {
	// Hook up and submit form
	var m_form = document.getElementById(id);
	if (m_form != null) {
		m_form.submit();
		// Reset form
		//m_form.reset();
		//alert(m_form.innerHTML);
	// Debug
	} else { alert("Fix it!"); }
	
}

var strCartFormId = "cart";
function ResetForm(submit) {
	if (!strCartFormId) strCartFormId = "cart";
	// Make dynamic cart id
	var newCartId = "cart";
	newCartId += Math.floor(Math.random() * 1024);
	// Get existing cart form
	var oldCart = document.getElementById(strCartFormId);
	// Create replacement cart
	var newCart = document.createElement("form");
//	newCart.id = newCartId;
	newCart.id = strCartFormId;
	newCart.action = "https://intuitivesecure.com/uCart/uCart.php";
	newCart.method = "POST";
	newCart.target = "_blank";
	// Reset cart
	if (oldCart) {
		oldCart.parentNode.replaceChild(newCart, oldCart);
		//strCartFormId = newCartId;
		}
// Hide form data
//var elForm = document.getElementById (strFormId);
// If submit
/*
if (submit) elForm.submit();
	var strFHtml = "<input type=\"hidden\" name=\"Item\" value=\"" + name + "\">";
	strFHtml += "<input type=\"hidden\" name=\"Price\" value=\"" + value + "\">";
	strFHtml += "<input type=\"hidden\" name=\"ShippingWeight\" value=\"\">";
	strFHtml += "<input type=\"hidden\" name=\"SKU\" value=\"" + id + "\">";
	strFHtml += "<input type=\"hidden\" name=\"Qty\" value=\"1\">";
	strFHtml += "<input type=\"hidden\" name=\"merchant\" value=\"quickertek\">";
	strFHtml += "<input type=\"hidden\" name=\"ShopMoreURL\" value=\"http://www.quickertek.com/\">";
	sCartForm.innerHTML = strFHtml;
*/
}