function drawStarsThumbs(starName, thumbArray, imagesPerRow, pageType) {
	var td = d.getElementById('imageList');
	var thumbTable = d.createElement("table");
	thumbTable.setAttribute("cellSpacing", 5);
	thumbTable.setAttribute("cellPadding", 5);
	
	//safari hack
	if (navigator.userAgent.toLowerCase().indexOf("safari") >= 0) thumbRow = thumbTable.insertRow(0);
	
	var rowCount = 0;
	for (i = 0; i < thumbArray.length; i++) {
		var thumbRow;
		
		if ((imagesPerRow == 1) || (i == 0 || ((i % imagesPerRow) == 0))) {
			thumbRow = thumbTable.insertRow(rowCount);
			rowCount++;
		}
 
		var thumbCell = thumbRow.insertCell(thumbRow.cells.length);
		var aTag = d.createElement("a");

		var imgHref;
		if (pageType == "stars") {
			imgHref = "javascript: pop('/stars/" + starName + "/";
			if (thumbs[i].indexOf("video") >= 0) {
				imgHref += "video.html?id=" + thumbArray[i].substring(0, thumbArray[i].indexOf("_thumb")) + "');";
			} else {
				imgHref += "popup.html?id=" + i + "');";
			}
		} else if (pageType == "popup") {
			imgHref = "javascript: swapImg('" + i + "');";
		} else if (pageType == "video") {
			imgHref = "video.html?id=" + thumbArray[i].substring(0, thumbArray[i].indexOf("_thumb"));
		}

		aTag.setAttribute("href", imgHref);
		var thumb = d.createElement("img");
		thumb.setAttribute("src", "/stars/" + starName + "/img/" + thumbArray[i] + ".gif");
		thumb.setAttribute("border", 0);
		aTag.appendChild(thumb);
		thumbCell.appendChild(aTag);
	}
	
	td.appendChild(thumbTable);
}

function videoNextBack(thumbsArray, dir) {
	var id = sm.getParam('id');
	var nextIndex;
	for (i = 0; i < thumbsArray.length; i++) {
		if (thumbsArray[i].indexOf(id) >= 0) {
			if ((i + 1) == thumbsArray.length && dir > 0) {
				nextIndex = 0;
				break;
			} else if (dir > 0) {
				nextIndex = i + 1;
				break;
			} else if (dir < 0 && i == 0) {
				nextIndex = thumbsArray.length - 1;
				break;
			} else {
				nextIndex = i - 1;
				break;
			}
		}
	}
	location.href = location.pathname + "?id=" + thumbsArray[nextIndex].substring(0, thumbsArray[nextIndex].indexOf('_thumb'));
} 