var SName = new Array();
var SRecord = new Array();
var SPrice = new Array();
var SImage = new Array();
var SHref = new Array();
var count = 0;
var FullList = new Array();

function addPageSlideItem (list){
	FullList[list[1]] = list;
}
function showPageSlideshow () {
	clearSlideshow();
	for (var i in FullList) {
		addSlideItem(FullList[i]);
	}
	firstSlide();
}
function clearSlideshow() {
		SName = Array();
		SRecord = Array();
		SPrice = Array();
		SImage = Array();
		SHref = Array();
		document.getElementById(['slideshow']).style.visibility="hidden";
}

function setSlideshow(list) {

		SName.unshift(list[0]);
		SRecord.unshift(list[1]);
		SPrice.unshift(list[2]);
		SImage.unshift(list[3]);
		SHref.unshift(list[4]);
		firstSlide();
}

function addSlideItem(list) {
		SName.push(list[0]);
		SRecord.push(list[1]);
		SPrice.push(list[2]);
		SImage.push(list[3]);
		SHref.push(list[4]);
}

function firstSlide() {
	count = 0;
	showSlide();
}


function previousSlide() {
	if (count == 0)
		count = SName.length -1
	else
		count = count-1;
	showSlide();
}

function nextSlide() {
	if (count== SName.length -1)
		count= 0;
	else
		count = count+1;
	showSlide ();
}

function showSlide () {
	if (document.getElementById(['slideshow']).style.visibility != 'visible') {
			document.getElementById(['slideshow']).style.top = (document.documentElement.scrollTop + 50) + 'px';
			document.getElementById(['slideshow']).style.visibility="visible";
		if (SName.length == 1) {
			document.getElementById(['prev']).style.visibility="hidden";
			document.getElementById(['next']).style.visibility="hidden";
		} else {
			document.getElementById(['prev']).style.visibility="";
			document.getElementById(['next']).style.visibility="";
		}	
	}
	
	document.getElementById(['slidename']).innerHTML = SName[count];
	document.getElementById(['sliderecord']).href = "http://www.soabsolutelyfabulous.com/shop-bin/sc/order.cgi?storeid=*1a4417417055c67c028169ef181b3a&dbname=products&itemnum=" + SRecord[count] + "&function=add";
	document.getElementById(['slideprice']).innerHTML = SPrice[count];
	if (SImage[count])
		document.getElementById(['slideimage']).src = "media/" + SImage[count];
	else
		document.getElementById(['slideimage']).src = "media/place-holder.gif";
	document.getElementById(['slideimage']).alt = SName[count];

	if (SHref[count]) {
		document.getElementById(['slidehref']).setAttribute("href",SHref[count]);
	}
	else {
		document.getElementById(['slidehref']).removeAttribute("href");
	}
}
