var itemCount = 0;		// DO NOT change
var pageCount = 0;		// DO NOT change
var currentPage = 0;	// The currently displayed page
var sets = new Array();	// Set of pages

// Modification by Ashley for Value
// Product Data Structure
function HMProduct(id, name, value, price, img, desc1, desc2){
	this.id = id;
	this.name = name;
	this.value = value;
	this.desc1 = desc1;
	this.desc2 = desc2;
	this.img = new Image();
	this.img.src = img;
	this.price=price;
}

// action for left arrow
function leftArrow(){
	if(currentPage == 0){
		currentPage = (pageCount - 1);
	}
	else{
		currentPage--;
	}
	paintSet();
}

function rightArrow(){
	if(currentPage == (pageCount - 1)){
		currentPage = 0;
	}
	else{
		currentPage++;
	}
	paintSet();
}

// set the currentPage to num and paint to screen
function setCurrent(num){
	currentPage = num;
	paintSet();
}

// adds a new page to the set
function addPage(){
	sets.push(new Array());
	pageCount++;
}

// adds a product to the set in the next available page
function addProduct(nextProd){
	if(pageCount == (itemCount / pageSize)){  // if this page is full
		addPage();
	}
	//alert("adding: " + nextProd.name + " to set: " + (pageCount -1));		
	sets[pageCount-1].push(nextProd);
	itemCount++;
}

// pads the remaining slots in a page
function padPage(){
	while(pageCount > (itemCount / pageSize)){
		addProduct(new HMProduct(-1, "None", "None", "None",0));
	}
}
