function dgebi(_sId){
	return document.getElementById(_sId) || false;
}

var curr_names = new Array('UAH','USD','EUR','RUB');

if (typeof Array.prototype.indexOf == "undefined") 
{
	  Array.prototype.indexOf = function(value) {
	    for (var i = 0; i < this.length; i++)
	      if (this[i] == value)
	        return i;

	    return -1;
	  }
}


function calculate_curr(){
	var selected_curr_name = dgebi('curr').options[dgebi('curr').selectedIndex].value;
	var amount = dgebi('summ').value;
	var currs_to_show = new Array();
	var selected_curr_index = curr_names.indexOf(selected_curr_name);

	if(!amount || typeof parseInt(amount) != "number" || isNaN(parseInt(amount))){
		dgebi('curr_table').style.display = 'none';
		return;
	}	
	
	switch(selected_curr_name){
		case 'UAH':
			currs_to_show = new Array(1, 2, 3);
			break;
		case 'USD':
			currs_to_show = new Array(0, 2, 3);
			break;
		case 'EUR':
			currs_to_show = new Array(0, 1, 3);
			break;
		case 'RUB':
			currs_to_show = new Array(0, 1, 2);
			break;			
	}
		
	dgebi('curr_cell1').innerHTML = Math.round((amount * curr[selected_curr_index] / curr[currs_to_show[0]]) * 100) / 100;
	dgebi('curr_cell2').innerHTML = Math.round((amount * curr[selected_curr_index] / curr[currs_to_show[1]]) * 100) / 100;
	dgebi('curr_cell3').innerHTML = Math.round((amount * curr[selected_curr_index] / curr[currs_to_show[2]]) * 100) / 100;
	dgebi('curr_hcell1').innerHTML = curr_names[currs_to_show[0]];
	dgebi('curr_hcell2').innerHTML = curr_names[currs_to_show[1]];
	dgebi('curr_hcell3').innerHTML = curr_names[currs_to_show[2]];
	
	dgebi('curr_table').style.display = 'block';	
}

/*function updateTime() {
var time = new Date();
var hours = time.getHours();
if(hours < 10)
	hours = '0' + hours;
var minutes = time.getMinutes();
if(minutes < 10)
	minutes = '0' + minutes;
var seconds = time.getSeconds();
if(seconds % 2)
	document.getElementById("time").innerHTML = hours + ':' + minutes;
else
	document.getElementById("time").innerHTML = hours + '&nbsp;' + minutes;
}
window.onload = function() {
updateTime();
window.setInterval('updateTime()', 1000);
}*/
