var icon_close = "http://www.esperticasa.it//Images/icon_close.gif"
var icon_open = "http://www.esperticasa.it//Images/icon_open.gif"

function ShowHideID(id, id2){
	var myid = document.getElementById(id);
	var myid2 = document.getElementById(id2);
	
	if (myid.style.display=="none")  {
		myid.style.display="" 
		if (id2!="") myid2.src=icon_close
	}
	else {
		myid.style.display="none"
		if (id2!="") myid2.src=icon_open
	}

return false;
}


function formatFileSize(value){
  if (value<1024){
    return value + " b";
  }
  else if (value<1048576){
    return Math.round(value / 1024) + " kb";
  }
  else{
    return Math.round(value / 10485.76) / 100 + " mb";
  }
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10) 
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + cents);
}

function getSelectedRadio(buttonGroup) {
   if (buttonGroup[0]) { 
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; }
   }
   return -1;
}