/* (c) Motoki, 2005-2006
 * www: http://hotspot.narod.ru/
 * e-mail: hotspot@narod.ru
 */

function randomNumber(min, max)
{
	return Math.floor(Math.random() * (max - min)) + min;
}

function replaceToken(text, token, newtext)
{
	return text.replace(token, newtext);
}

function embedImage(url, width, height, cssclass, alt)
{
	var sequence = '<img src="' + url + '"';
	if (width != null) sequence += ' width="' + width + '"';
	if (height != null) sequence += ' height="' + height + '"';
	if (cssclass != null) sequence += ' class="' + cssclass + '"';
	if (alt != null) sequence += ' alt="' + alt + '"';
	sequence += '>';
	document.write(sequence);
}

function getImageCode(url, width, height, cssclass, alt)
{
	code = '<img src="' + url + '"';
	if (width != null) code += ' width="' + width + '"';
	if (height != null) code += ' height="' + height + '"';
	if (cssclass != null) code += ' class="' + cssclass + '"';
	if (alt != null) code += ' alt="' + alt + '"';
	code += '>';
	return code;
}

function embedSimpleVerticalGallery(count, total, root)
{
	var size = Math.floor(total / count);
	for (var i = 0; i < count; i++)
	{
		document.write('<div class="screencap">');
		document.write(getImageCode(replaceToken(root + "images/screencaps/%n.jpg", "%n", randomNumber(i * size, (i + 1) * size)), 150, 100, "framed"));
		document.write('</div>');
	}
}