var contsArray = new Array();
var revisedContsArray = new Array();

function pagingItem(id, bsize, bstyle, bbrand, bcolor, bproblem, code, name, img, listimg, price, saleprice, options, abstr, orderable, brand, mappricing, linktype, link) {
	if (!window.items) window.items = new Array();
	this.id=id.toLowerCase();
	this.bsize=bsize;
	this.bstyle=bstyle;
	this.bbrand=bbrand;
	this.bcolor=bcolor;
	this.bproblem=bproblem;
	this.code=code;
	this.name=name;
	this.img=img;
	this.listimg=listimg;
	this.price=price;
	this.saleprice=saleprice;
	this.options=options;
	this.abstr=abstr;
	this.orderable=orderable;
	this.brand=brand;
	this.mappricing=mappricing;
	this.linktype=linktype;
	this.link=link;
	this.sortby="name";
	this.defaultsort=window.items.length;
	contsArray[window.items.length] = this;
	revisedContsArray[window.items.length] = this;
	window.items[window.items.length] = this;
	
}

function getSeltVal(val, obj){
	var ctr = 0;
	
	for(var x=0; x<contsArray.length; x++){
		if((contsArray[x].bsize == val) || (contsArray[x].bstyle == val) || (contsArray[x].bbrand == val) || (contsArray[x].bcolor == val) || (contsArray[x].bproblem == val)){
			revisedContsArray[ctr] = contsArray[x];
			ctr++;
		}
	}
	assembleContents(revisedContsArray, ctr, obj);
}

function assembleContents(arr, ctr, elem){
	var theContentSpace = document.getElementById("contents-container");
	var localContent = "";	
	
	if(ctr != 0){
		theContentSpace.innerHTML = "";
		
		for(var x=0; x<ctr; x++){
			localContent += "<div class=\"each-item\">";
			localContent += "<a href=" + arr[x].id + ".html>" + arr[x].img + "</a><br />";
			localContent += "<a href=" + arr[x].id + ".html>" + arr[x].code + "</a><br />";
			localContent += "<div class=name>" + arr[x].name + "</div>";
			if(arr[x].saleprice){
				localContent += "<s><span class=price>Price: $" + arr[x].price.toFixed(2) + "</span></s>";
				localContent += "&nbsp;&nbsp;";
				localContent += "<span class=saleprice>Sale: $" + arr[x].saleprice.toFixed(2) + "</span><br />";
			}else{
				localContent += "<span class=pricebold>Price: $" + arr[x].price.toFixed(2) + "</span><br />";	
			}
			
			localContent += "<a href=" + arr[x].id + ".html><img src=\"http://lib.store.yahoo.net/lib/yhst-20906297561931/go-to-item-btn.jpg\" border=0 /></a><br />";
			localContent += "</div>";
		}
		
		theContentSpace.innerHTML = localContent;
	}
	resetSelts(elem);
}

function resetSelts(elem){
	var theDiv = document.getElementById("paging-select-container");
	var theSelts = theDiv.getElementsByTagName("select");
	
	for(var x=0; x<theSelts.length; x++){
		if(theSelts[x] != elem){
			theSelts[x].selectedIndex = 0;
		}
	}
}



