var ProductCategories = new function() { this.data = [{"product_category_id":"7","parent_product_category_id":"4","name":"12x12","description":null,"active":"t","img":null,"recursive_product_count":"20"},{"product_category_id":"9","parent_product_category_id":"8","name":"12x12","description":null,"active":"t","img":null,"recursive_product_count":"2"},{"product_category_id":"13","parent_product_category_id":"10","name":"12x12","description":null,"active":"t","img":null,"recursive_product_count":"1"},{"product_category_id":"19","parent_product_category_id":"4","name":"8.5x11","description":"8.5x11","active":"t","img":null,"recursive_product_count":"5"},{"product_category_id":"5","parent_product_category_id":"4","name":"8x8","description":null,"active":"t","img":null,"recursive_product_count":"14"},{"product_category_id":"11","parent_product_category_id":"10","name":"8x8","description":null,"active":"t","img":null,"recursive_product_count":"1"},{"product_category_id":"12","parent_product_category_id":"8","name":"8x8","description":null,"active":"t","img":null,"recursive_product_count":"1"},{"product_category_id":"4","parent_product_category_id":"1","name":"Albums","description":null,"active":"t","img":"cat-8x8_albums_1.png","recursive_product_count":"39"},{"product_category_id":"18","parent_product_category_id":"15","name":"Brad Buddies\u2122","description":null,"active":"t","img":null,"recursive_product_count":"29"},{"product_category_id":"16","parent_product_category_id":"15","name":"Creative Kits","description":null,"active":"t","img":null,"recursive_product_count":"7"},{"product_category_id":"17","parent_product_category_id":"15","name":"Embellish-abilities\u2122","description":null,"active":"t","img":null,"recursive_product_count":"6"},{"product_category_id":"8","parent_product_category_id":"1","name":"Frames","description":null,"active":"t","img":"cat-shadowboxes.gif","recursive_product_count":"3"},{"product_category_id":"15","parent_product_category_id":"1","name":"Page Embellishments","description":null,"active":"t","img":"cat-page_embellishments_1.png","recursive_product_count":"42"},{"product_category_id":"10","parent_product_category_id":"1","name":"Sheet Protectors","description":null,"active":"t","img":"cat-sheet-protectors.gif","recursive_product_count":"2"}]; this.no_empty = true; this.no_inactive = true; function path(join) { var buf = new Array(this.data.product_category_id); return buf; } this.id = function(id) { for (var i in this.data) { if (this.data[i].product_category_id == id) { var buf = new Object; buf.data = this.data[i]; buf.children = this.with_parent(buf.data.product_category_id); document.buf = buf; return buf; } } return false; } this.with_parent = function(id, parent, root) { var buf = []; for (var i in this.data) { if (this.no_empty && this.data[i].recursive_product_count<1) continue; if (this.no_inactive && !(this.data[i].active)) continue; if (this.data[i].parent_product_category_id == id) { var cat = {}; cat.path = path; cat.data = clone(this.data[i]); cat.parent = parent ? parent : {}; cat.root = root ? root : {}; cat.children = this.with_parent(this.data[i].product_category_id, cat, (root ? root : cat)); buf.push(cat); } } return buf; } }