/*
	content.js - Content Loader for JavaScript-based Catalogs.
	Author - Eric L .Truitte
	Conception Date - 01-13-2008
	Caveats -
		This script should not need editing.  To add more categories to
		the catalog, follow format in ./products.js and add them where needed.
*/

function Category(cat, category, content) {
	this.cat = cat;
	this.category = category;
  this.content = content;
	return this;
};

function contentfinder (category) {
	$('#content').html('');
	for (var c = 0; c < categories.length; c++) {
		if (categories[c].cat == category) {
			return categories[c].content;
		};
	};
  return "";
};

function contentloader (keyword) {
	$('#content').html(contentfinder(keyword));
};

function hashload () {
	/*
		grabs the hash from reload or load if linked.  Very useful client-side
		mechanism to change the content by, but only works when mechanically
		clicked on something.  For some reason the internet people NEVER put
		changes to the hash into the re-load or created a event for the changing
		of the hash.  Bastards.  -etruitte 01-14-08
	*/
  //windowRatio();
	if (location.hash.length > 1) {
		var hashstring = location.hash.substr(1,location.hash.length).toLowerCase();
		contentloader(hashstring);
	} else {
     contentloader('home');
  };
};

function initmenu () {
	var c = 0;
	var html = "";
	for (c = 0; c < categories.length; c++) {
    $('<div></div>').attr('id', categories[c].cat)
      .addClass(categories[c].content != false ? 'category': 'categoryheader')
      .html(categories[c].category)
      .click(function () { contentloader(this.id); })
      .appendTo($('#menu'));
	};
};
