var imageNumbers = Array();

function DeleteImage(index, maxNumber, DisplayMode)
{
	if ( ! imageNumbers[index] )
	{
		imageNumbers[index] = maxNumber;
	}
	
	xajax_DeleteImage(index, imageNumbers[index], DisplayMode);
	
	imageNumbers[index] = false;
}

function lightStars ( EditableID, Rating )
{
	for ( i = 1; i <= 5; i++ )
	{
		Star = document.getElementById('RateStar'+EditableID+'-'+i);
		
		if ( Rating > ( i - 1 ) && Rating < i )
		{
			starType = 'Half';
		}
		else if ( Rating < i )
		{
			starType = 'None';
		}
		else if ( Rating >= i )
		{
			starType = 'Full';
		}
		
		Star.src = '/icons/star'+starType+'.png';
		
	}
}

function rand ( n )
{
  return ( Math.floor ( Math.random ( ) * n + 1 ) );
}

function move(index, maxNumber, up)
{
	if( ! imageNumbers[index] )
	{
		imageNumbers[index] = maxNumber;
	}
	
	if ( up )
	{
		imageNumbers[index]++;
	}
	else
	{
		imageNumbers[index]--;
	}
	
	if ( imageNumbers[index] > maxNumber )
	{
		imageNumbers[index] = 1;
	}
	else if ( imageNumbers[index] < 1 )
	{
		imageNumbers[index] = maxNumber;
	}
	
	// The rand(100) prevents cacheing
	fullHref = '/images/'+index+'/'+imageNumbers[index]+'.png?rand='+rand(1000);
	thumbSrc = '/images/'+index+'/'+imageNumbers[index]+'.th.png?rand='+rand(1000);
	
	ImageLink = document.getElementById('ImageLink'+index);
	ImageThumb = document.getElementById('ImageThumb'+index);
	
	ImageLink.href = fullHref;
	ImageThumb.src = thumbSrc;
}
