// JavaScript Document
function addCommas(nStr)
{
	nStr = Math.round(nStr*100)/100;
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ?( ',' + x[1] +  (x[1].length<2?"0":"")): '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '&nbsp;' + '$2');
	}
	return x1 + x2;
}
Element.extend(
{
	hide:function()
	{
		this.style.display = "none";
	},
	show:function()
	{
		this.setStyle("display", "");
	},
	toggle:function()
	{
		this.style.display = this.style.display=="none"?"":"none";
	}
})
function fixBottom()
{
	var left_height = $("layout_left_side").getStyle("height").toInt();
	var main_height = $("layout_main_body").getStyle("height").toInt();
	if($("layout_right_side"))
		var right_height = $("layout_right_side").getStyle("height").toInt();
	else
		var right_height = 0;
	$("layout_main").setStyle("height", Math.max(left_height, Math.max(main_height, right_height)) + 100);
//	$("quick-links").setStyle("position", "absolute");
}

$(window).addEvent('domready', function(){
	Nifty("div.niftybig", "big");
	fixBottom();
	new SmoothScroll();
	var so2 = new SWFObject("img/logo.swf", "flash-login", "163", "51", "5", "#ffffff");
	 so2.addParam("quality", "high");
	 so2.addParam("wmode", "transparent");
	 so2.addParam("scale", "exactfit");
	 so2.write("logo-flash");	
	//document.body.onload = fixBottom();
	
	
	 
	var list = $$('#menu li ');
	list.each(function(element) {
	 
		var fx = new Fx.Styles(element, {duration:50, wait:false});
	 
		element.addEvent('mouseenter', function(){
			fx.start({
				'font-size': 13,
				'color': '#000'
			});
		});
	 
		element.addEvent('mouseleave', function(){
			fx.start({
				'font-size': 11,
				'color': '#0C5195'
			});
		});
	 
	});
});


function initCalculator()
{
	$("calc_cena").addEvent('keyup', calc_przelicz);
	$("calc_lata").addEvent('change', calc_przelicz);
	calc_przelicz();
}

function calc_przelicz()
{
	var cena = parseInt($("calc_cena").getValue());
	var lata = parseInt($("calc_lata").getValue());
	$("calc_wynik").innerHTML = addCommas(cena / (lata*365));
}
