function Pattern(patternID, patternName, showroomOrder,  romanceCopy, thumbImage, hotBuy) {
	this.patternID = patternID;
	this.patternName = patternName;
	this.showroomOrder = showroomOrder;
	this.romanceCopy = romanceCopy;
	this.thumbImage = thumbImage;
	this.hotBuy = hotBuy;
}
var patternOrderList = new Array();
var patternList = new Array();
var patternAlphaList = new Array();

var curIndex = 1;
function showPatterns(){
	var lastImage;
	var image = 1;
	
	try
	{
		for (var i=curIndex;i<curIndex + 8;i++)
		{ 
			if (i < patternOrderList.length)
			{
				eval("patternImage" + image + ".style.backgroundImage = 'url(" + patternOrderList[i].thumbImage + ")'");
				eval("thumbnailPattern" + image + ".innerText = patternOrderList[i].patternName;");
				
				try {
					if (patternOrderList[i].hotBuy == 0)
						eval("hotBuy" + image + ".style.display = 'none';");
					else
					{
						eval("hotBuy" + image + ".style.display = 'inline';");
						if (patternOrderList[i].thumbImage.indexOf("NoImage.gif") > 0)
							eval("hotBuy" + image + ".style.top = '100';");
						else
							eval("hotBuy" + image + ".style.top = '60';");
					}
				}
				catch (e) {}
				lastImage = i;	
			}
			else
			{
				eval("patternImage" + image + ".style.backgroundImage = 'url(/webimgs/ffffff_white.gif)'");
				eval("thumbnailPattern" + image + ".innerText = '';");
			}
			image++;
		}	
		
		if (lastImage < patternOrderList.length - 1)
			document.getElementById("more").src = "/webimgs/ps_more.gif";
		else
			document.getElementById("more").src = "/webimgs/ffffff_white.gif";
				
		if (curIndex > 1)
			document.getElementById("back").src = "/webimgs/ps_back.gif";
		else
			document.getElementById("back").src = "/webimgs/ffffff_white.gif";
	}
	catch (e){}	
}

function prevPage(){
	if ((curIndex - 8) >= 1)
		curIndex -= 8;
	else
		curIndex = 1;
		
	showPatterns();	 	
}
function nextPage(){
	if ((curIndex + 8) <= patternOrderList.length)
	{
		curIndex += 8;
		showPatterns();
	}
}

function displayPattern(idx)
{	
 	var pattern = curIndex + idx;
	
	// 
	if (pattern >= patternOrderList.length)
		return;
		
	window.location = window.location + "&pid=" + patternOrderList[pattern].patternID;
}