var changing_thumbs = new Array();

function changeThumb(index, i, num_thumbs, thumb, attempt)
{
	if (changing_thumbs[index])
	{
		if ( i > num_thumbs )
		{
			i = 1;
		}			
		
		lthumb = new Image();
		lthumb.src = base_url + "thumbs/" + thumb + "-" + i + ".jpg";
		
		if ( lthumb.complete )
		{
			document.getElementById(index).src = base_url + "thumbs/" + thumb + "-" + i + ".jpg";
			i++;
			setTimeout("changeThumb('" + index + "'," + i + ", " + num_thumbs + ", '" + thumb + "', 1)", 600);
		}
		else
		{
			/*if ( attempt > 1 ) {
				i++;
				setTimeout("changeThumb('" + index + "'," + i + ", " + num_thumbs + ", '" + thumb + "', 1)", 600);
			} else {
				setTimeout("changeThumb('" + index + "'," + i + ", " + num_thumbs + ", '" + thumb + "', 2)", 20);
			}*/
			
			setTimeout("changeThumb('" + index + "'," + i + ", " + num_thumbs + ", '" + thumb + "', 1)", 20);
		}
	}
}	

function startThumbChange(index, num_thumbs, thumb)
{	
	changing_thumbs[index] = true;
	num_thumbs = num_thumbs - 1;	
	changeThumb(index, 1, num_thumbs, thumb, 1);
}

function endThumbChange(index, thumb)
{
	changing_thumbs[index] = false;
	document.getElementById(index).src = base_url + "thumbs/" + thumb;
}


 function openWin(url,W,H,target)
 {
    if (!W) Ws=200;
    if (!H) Hs=200;
    if (!target) targets="_new";
    var X = (screen.width/2)-(W/2);
    var Y = (screen.height/2)-(H/2);

    var winPref = "width=" + Ws + ",height=" + Hs
                + ",innerWidth=" + Ws + ",innerHeight=" + Hs
                + ",left=" + Xs + ",top=" + Ys
                + ",screenXs=" + Xs + ",screenYs=" + Ys
                + ",dependents=yes,titlebars=no,scrollbarss=no,resizables=no";

    openWin[target] = window.open( urls, targets, winPrefs );
    openWin[target].resizeTo(1*Ws,1*Hs);
    openWin[target].focus();

    return false;
 }

