var mapsCount = 89;
var textCount = 90;
var pathToImg = "images/ox/";
var pathToText = "text/";
var pathToMaps = "maps/";
var textExt = ".jpg";
var mapsExt = ".jpg";

$(
	function()
	{
		$("div#res").mousemove
		(
			function()
			{
				$(this).css("cursor", "pointer");
			}
		);
		$("div#res").mouseout
		(
			function()
			{
				$(this).css("cursor", "default");
			}
		);
		$("div#res").click
		(
			function()
			{
				$("div#cards_text").css("background-image", "none");
				$("div#cards_card").css("background-image", "none");
				$("div#cards").css("background-image", "url(" + pathToImg + "cards_clear.jpg)");
			}
		);
		
		$("div#maps_cards").mousemove
		(
			function()
			{
				$(this).css("cursor", "pointer");
			}
		);
		$("div#maps_cards").mouseout
		(
			function()
			{
				$(this).css("cursor", "default");
			}
		);
		$("div#maps_cards").click
		(
			function()
			{
				var img = getRand(mapsCount);
				$("div#cards").css("background-image", "url(" + pathToImg + "cards_clear2.jpg)");
				$("div#cards_card").css("background-image", "url(" + pathToImg + pathToMaps + img + mapsExt + ")");
			}
		);
		
		$("div#text_cards").mousemove
		(
			function()
			{
				$(this).css("cursor", "pointer");
			}
		);
		$("div#text_cards").mouseout
		(
			function()
			{
				$(this).css("cursor", "default");
			}
		);
		$("div#text_cards").click
		(
			function()
			{
				if($("div#cards_card").css("background-image") != "none")
				{
					var img = getRand(textCount);
					$("div#cards_text").css("background-image", "url(" + pathToImg + pathToText + img + textExt + ")");
				}
			}
		);
	}
);

function getRand(cnt)
{
	var rnd;
	while(true)
	{
		rnd = Math.floor(Math.random(cnt) * 100);
		if (rnd > 0 && rnd <= cnt)
		{
			break;
		}
	}
	return rnd;
}
