
/* Note - anims must be populated with all the fields from the image to generate the thumbnails etc. */
var anims = new Array();
/* set curImage to be whichever image from the list should come first */
var curImage = 0;

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function writeLinkDiv(imNum, whichId) {

	str = '<a href="#" onClick="setMediaIds(' + anims[imNum].artist_id + ', ' + anims[imNum].image_id + ');showNamedMedia(\'' + anims[imNum].swf + '\',';
	str += '\'' + anims[imNum].image + '\',\'' + escape(anims[imNum].name) + '\',\'' + escape(anims[imNum].text2) + '\', \'' + anims[imNum].width + '\', \'' + anims[imNum].height + '\');return false;">';
	str +='<img src="/scaler/image.jpg?src=fi&sz=160&ht=120&crop=y&name=' + anims[imNum].location;
	str += '" width="160" height="120" border="0"></a>';
	str += '<a href="home.asp?artist_id=' + anims[imNum].artist_id + '&image_id=' + anims[imNum].image_id + '"><img ';
	str += 'src="/scaler/textpic.png?text2=' + escape(anims[imNum].text2) + '&w=160&h=16&font=Whitney-Semibold&text=' + escape(anims[imNum].name) + '&fs=10&color=2F2F2F&bgcolor=E7E7E7" ';
	str += ' width="160" height="16" border="0" style="margin-top:3px;"></a>';
	var mdiv = findObj(whichId);
	mdiv.innerHTML = str;
}

function writeLinkDivNoArtistName(imNum, whichId) {

	str = '<a href="#" onClick="setMediaIds(' + anims[imNum].artist_id + ', ' + anims[imNum].image_id + ');showNamedMedia(\'' + anims[imNum].swf + '\',';
	str += '\'' + anims[imNum].image + '\',\'' + anims[imNum].name + '\',\'' + anims[imNum].text2 + '\', \'' + anims[imNum].width + '\', \'' + anims[imNum].height + '\');return false;">';
	str +='<img src="/scaler/image.jpg?src=fi&sz=160&ht=120&crop=y&name=' + anims[imNum].location;
	str += '" width="160" height="120" border="0"></a>';
	str += '<img src="/scaler/textpic.png?text=' + escape(anims[imNum].text2) + '&w=160&h=16&font=Whitney-Semibold&fs=10&color=2F2F2F&bgcolor=E7E7E7" ';
	str += ' width="160" height="16" border="0" style="margin-top:3px;">';
	var mdiv = findObj(whichId);
	mdiv.innerHTML = str;
}



function moveUp() {
	getNextValue();
	getNextValue();
	getNextValue();
	var oldVal = curImage;
	for(var i = 1; i < 4; i++) {
		writeLinkDiv(curImage, "m" + i);
		getNextValue();
	}
	curImage = oldVal;
}

function moveDown() {
	var oldVal = curImage;
	getPrevValue();
	getPrevValue();
	getPrevValue();
	for(var i = 1; i < 4; i++) {
		writeLinkDiv(curImage, "m" + i);
		getNextValue();
	}
	curImage = oldVal;
	getPrevValue();
	getPrevValue();
	getPrevValue();
}

function getNextValue() {
	curImage++;
	if(curImage >= anims.length) curImage = 0;
	return curImage;
}

function getPrevValue() {
	curImage--;
	if(curImage < 0) curImage = anims.length-1;
	return curImage;
}