thisPic = 0;
imgCt = arrSlideshow.length;

function slide(path, description, name, page, price, quantity) {
	this.path = path;
	this.description = description;
	this.name = name;
	this.page = page; 
//	this.price = price;
//	this.quantity = quantity;
	}

function basketItem(quantity, price) {
	this.quantity = quantity;
	this.price = price;
	}

function basketValue() {
	numValue = 0;
	for (i in arrBasket) {
		numValue = numValue + (arrBasket[j]["price"] * arrBasket[j]["quantity"]);
		}
	return numValue;
	}
	
function changeQuantity(basket, itemId, newQuantity) {
	strIndex = "pid" + itemId;
	fieldname = "quantity_"+itemId;
	basket[strIndex]["quantity"] = newQuantity;
	}
	
function chgSlide(direction) {
// remove this line once complete as it will be redundant
re = /\//
imgCt = arrSlideshow.length;

	if (document.images) {
		thisPic = thisPic + direction;
		
		if (thisPic>=imgCt) {
			thisPic = 0;
			}
		if (thisPic<0) {
			thisPic=imgCt-1;
			}
		document.productImage.src=arrSlideshow[thisPic].path.replace(re,"/thumb");
		//change picture link to large version of the picture
		//chglink("link2image",slideshowImg[thisPic]);
		chglink("link2image",arrSlideshow[thisPic].page);
		deleteItem("productDescription","productDescText");
		addItem("productDescription",arrSlideshow[thisPic].description, "productDescText", "span");
		deleteItem("productname","productTitle");
		addItem("productname",arrSlideshow[thisPic].name, "productTitle", "span");
		}
	}
	
function clickimg(fromImg,toImg) {
	toimgName="br-images/"+toImg;
	fromimgName="br-images/"+fromImg;
	if (document.images) {
		document.buyme.src = toimgName;
		setTimeout("document.buyme.src = fromimgName",100);
		}
	}
	
function chglink(linkId, newLink) {
	if (document.getElementById) {
		link2Change = document.getElementById(linkId);
		link2Change.href = newLink;
		}
	}

function findItem(parentElement, findItemId) {
	//loop through the items in the tearget element to find the required element
	for (i=0; i<parentElement.childNodes.length; i++) {
		
		// Check item id to verify if it is the item required
		if (parentElement.childNodes[i].id == findItemId) {
			
			// if item is the one required return its index number and exit the function
			return i;
			}
		}
	// if the element is not found then return -1
	return -1;
	}

function addItem(changeId, itemText, addItemId, elementType) {
	// Check for correct version of JavaScript
	if (document.getElementById) {
		//set targetElement to the required element
		targetElement = document.getElementById(changeId);
		
		//check that the item to be added does not already exist
//		if (findItem(targetElement, addItemId)<0) {
			
			// if the item does not exist create a new node
			newItem = document.createElement(elementType);
			newItem.id = addItemId;
			
			// create a text node with the required text and append it to the new node
			newText = document.createTextNode(itemText);
			newItem.appendChild(newText);
			
			// append the new node to the target element
			targetElement.appendChild(newItem);
//			}
		}
	}
	
function changeItem(changeId, itemName, addItemId) {
	// Check for correct version of JavaScript
	if (document.getElementById) {
		//set targetElement to the required element
		targetElement = document.getElementById(changeId);
		
		//check that the item to be added does not already exist
		if (findItem(targetElement, addItemId)<0) {
			
			// if the item does not exist create a new node
			newItem = document.createElement("p");
			newItem.id = addItemId;
			
			// create a text node with the required text and append it to the new node
			newText = document.createTextNode(itemName);
			newItem.appendChild(newText);
			
			// append the new node to the target element
			//targetElement.replaceChild(targetElement, newItem);
			docBody = document.getElementById("productText");
			docBody.replaceChild(targetElement, newItem);
			}
		}
	}
	
function deleteItem(parentId, itemId) {
	// Check for correct version of JavaScript
	if (document.getElementById) {
		//set targetElement to the required element
		targetElement = document.getElementById(parentId);
		
		// assign the index of the item to a variable
		itempos = findItem(targetElement, itemId);
		
		// if the item exists then remove it from the cart
		if (itempos>=0) {
			targetElement.removeChild(targetElement.childNodes[itempos]);
			return
			}
		}
	}