$(document).ready(function(){
 			showBoxFirstLead();
	 		evenBoxes();
	});

// leiab esilehe kastide esimesed sissejuhatused ning toob need n2htavale 
function showBoxFirstLead()
{
	$("#promos > table .m").each(function(){
		$(".lead:first", $(this)).each(function(){
			$(this).css("display", "inline");
		});
	});
	/*
	for (i=0;i<o.length;i++)
	{
		first_if_ok = true;
		second_if_ok =true;
		
		// pyyame lead'i yles leida
		o[i].childNodes[1].style.border = "1px solid red;"
		try
		{
			o[i].childNodes[2].style.display = "inline";
		}
		catch(err)
		{
			first_if_ok = false;
			try
			{
				o[i].childNodes[1].style.display = "inline";
			}
			catch(err2)
			{
				second_if_ok = false;
				try
				{
					o[i].childNodes[3].style.display = "inline";
				}
				catch(err3)
				{
					// kurb, aga ei leidnud.
				}
			}
		}
	
		if (first_if_ok && $.browser.msie)
		{
			o[i].childNodes[2].style.display = "inline";
		}
		else if (second_if_ok && $.browser.msie) // kui pealkirja link on tyhi, on sisu teise indeksiga
		{
			o[i].childNodes[1].style.display = "inline";
		}
		else if (o[i].childNodes[3])
			o[i].childNodes[3].style.display = "inline";
	}
	*/
}

// muudab esilehe kastide k6rgused yhepikkuseks kahe kaupa
function evenBoxes()
{
	o = $("#promos > table");
	
	quantifier = 0;
	if ($.browser.mozilla)
		quantifier = 10;
	
	oLeft = $("#promos table .w");
	for(i=0;i<o.length;i++)
	{
		if ((i+1)%2 && o[i+1])
		{
			if (o[i].offsetHeight<o[i+1].offsetHeight)
			{
				oLeft[i].style.height = o[i+1].offsetHeight-12-quantifier+"px";
				oLeft[i+1].style.height = o[i+1].offsetHeight-12-quantifier+"px";
			}
			else
			{
				oLeft[i+1].style.height = o[i].offsetHeight-12-quantifier+"px";
				oLeft[i].style.height = o[i].offsetHeight-12-quantifier+"px";
			}
		}
	}
}
