/* preload SWF for IE7 */
function equalize_thumbs() {
	var thumb_max_height=0;
	var div=document.getElementsByTagName('div');
	for(var z=0; z<div.length; z++) {
		if(div[z].className=='product_list') {
			var thumb=div[z].getElementsByTagName('a');
			var thumb_width = thumb[0].offsetWidth;
			var thumb_inline = 9;
			var thumb_rows = Math.ceil(thumb.length/thumb_inline);
			for (i=0; i<thumb_rows; i++) {
										
				for (n=0; n<thumb_inline; n++) {
					var id = (i*thumb_inline)+n;
					var e = thumb[id];
					if (e && e.className=='title') {				
						if (thumb_max_height < e.offsetHeight ) {								
							thumb_max_height = e.offsetHeight-20;							
						}
					}
				}
				for (n=0; n<thumb_inline; n++) {
					var id = (i*thumb_inline)+n;
					var e = thumb[id];
					if (e && e.className=='title') {
						e.style.height = thumb_max_height+"px";
					}
				}
				thumb_max_height = 0;
			}
		}
	}
}
function load_swf($ID, $filename, $width, $height){
	document.getElementById($ID).innerHTML = '<object type="application/x-shockwave-flash" data="' + $filename + '" width="' + $width + '" height="' + $height + '"><param name="menu" value="false" /><param name="movie"	value="' + $filename + '" /><param name="wmode" value="transparent" /></object>';
}
function show_object($object) {
	document.getElementById($object).style.display = "block";
}
function hide_object($object) {
	document.getElementById($object).style.display = "none";
}
function calc(){
	$sum = parseInt(document.getElementById('sum').value);
	$base = parseInt(document.getElementById('base').value);
	$months = document.getElementById('months').value;
	if(!$sum && !$base || ($base > $sum)) {
		alert('Viga summade sisestamisel!');
		return;
	}
	$loan_sum = $sum - $base;
	if($loan_sum < 2000){
		$percent = 0.25;
	} else if($loan_sum < 10000){
		$percent = 0.22;
	} else {
		$percent = 0.20;
	}

	$total = parseInt( $loan_sum * (1 + $percent * $months / 12) / $months ) + 1 ;
	//while($total%25 != 0)$total++;	
	document.getElementById('total').innerHTML = $months + " x " + $total + " EEK";
	show_object('total');	
}