ie5 = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
ns4 = (document.layers);

cpicture=0;
cinum=0;

function previous()
{
if(simage.length<4)
	return;
if(cpicture>0)
	cpicture--;
else
	cpicture=0;
showswatches(cpicture);
}

function next()
{
if(simage.length<4)
	return;
if(cpicture<(simage.length)-3)
	cpicture++;
else
	cpicture=simage.length-3;
showswatches(cpicture);
}


//-----------------------------------------------------------------
//  Function: IMAGEDATA
//
//
//
//-----------------------------------------------------------------
function IMAGEDATA(description,url, width, height) {
this.description = description;
this.url = url;
this.width=width;
this.height=height;
}

mimage = new Array();
simage = new Array();

function selectimage(inum)
{
cinum = inum;
}



//-----------------------------------------------------------------
//  Function: DisplaySampleImage
//
//
//
//-----------------------------------------------------------------
function showimage(inum)
{
var iinum=parseInt(inum);
//if(SelectedColor!=-1 && iinum==-1)
//	iinum=parseInt(SelectedColor);
//tbuff = '<img src="' + mimage[iinum].url + '" width="' + mimage[iinum].width + '" height="' + mimage[iinum].height + '" ' +
//		'border="0">' 
tbuff = '<img src="' + mimage[iinum].url + '" ' +
		'border="0" class="photoborder">'


cbuff = mimage[iinum].description;
if(document.all)
	{
	document.all("vimage").innerHTML = tbuff;
//	document.all("vimage").style.height=mimage[iinum].height+"px";
	document.all("caption").innerHTML = cbuff;
	}

if(document.layers)
	{
	x = document.layers["vimage"];
	x.open();
	x.document.write(tbuff);
	x.document.close();
	x = document.layers["caption"];
	x.open();
	x.document.write(cbuff);
	x.document.close();
//	x.style.height=mimage[iinum].height;
	}
if(document.getElementById)
	{
	document.getElementById("vimage").innerHTML=tbuff;
	document.getElementById("caption").innerHTML=cbuff;
	
//	document.getElementById("vimage").style.height=mimage[iinum].height+"px";
	}
}





function showswatches(inum)
{
var iinum=parseInt(inum);
var i;
//if(SelectedColor!=-1 && iinum==-1)
//	iinum=parseInt(SelectedColor);

var iheight=(simage[0].height/2)-8;
var swatches;

//tbuff='<div class="SWATCHES">';
tbuff='';
for(i=iinum;i<(iinum+3) && i<((simage.length));i++)
	{
	tbuff = tbuff + '<div class="SWATCH">' + 
					'<img src="' + simage[i].url + '" width=' + simage[i].width + ' height=' + simage[i].height + ' ' +
	//	    		'alt="' + pgtitle + '" ' +
					'onmouseover="showimage(' + i + ');" ' +
					'onmouseout="showimage(cinum);" ' +
					'onclick="selectimage(' + i + ');" ' +
					'class="photoborder">' +
					'</div>';
	}
//tbuff = tbuff + "</div>";
if(document.all)
	{
	swatches = document.getElementById('SWATCHES');
	debugtext = document.getElementById('debugtext');
	swatches.innerHTML = tbuff;
//	if(typeof(debugtext.textContent) != "undefined")
//		{
//		debugtext.textContent = tbuff;
//		}
//	else
//		{
//		debugtext.innerText = tbuff;
//		}
	}

if(document.layers)
	{
	x = document.layers["Swatches"];
	x.open();
	x.document.write(tbuff);
	x.document.close();
	}
if(document.getElementById)
	{
	swatches = document.getElementById('SWATCHES');
	debugtext = document.getElementById('debugtext');
	swatches.innerHTML=tbuff;
//	if(typeof(debugtext.textContent) != "undefined")
//		{
//		debugtext.textContent = tbuff;
//		}
//	else
//		{
//		debugtext.innerText = tbuff;
//		}
	}


}