function status_over(w){
	window.status=w;
	return true;
}

function status_out(){
	window.status='';
}

function controllo_frame(URL){
	if (window.top.document.title == window.document.title ) {
		location.replace(URL)
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function popup(name,fin,width,height) 
{ 
var w=width; 
var h=height; 
var x=(screen.availWidth-w)/2; 
var y=(screen.availHeight-h)/2; 
var finestra=window.open(name,fin,'scrollbars=yes,resizable=yes,width='+w+',height='+h+',left='+x+',top='+y); 
} 

function popup_full(name,fin) 
{ 
var w=(screen.availWidth)-10; 
var h=(screen.availHeight)-35; 
var finestra=window.open(name,fin,'scrollbars=yes,resizable=yes,width='+w+',height='+h+',left=0,top=0'); 
} 

function popup_no(name,fin,width,height) 
{ 
var w=width; 
var h=height; 
var x=(screen.availWidth-w)/2; 
var y=(screen.availHeight-h)/2; 
var finestra=window.open(name,fin,',width='+w+',height='+h+',left='+x+',top='+y); 
} 

function controllaData(strData){
	re=/^\d{1,2}\/\d{1,2}\/\d{4}$/
	if(re.test(strData)){
		aData = strData.split('/')
		aData[0]=parseInt(aData[0],10)
		aData[1]=parseInt(aData[1],10)
		aData[2]=parseInt(aData[2],10)
		data = new Date(aData[2],aData[1]-1,aData[0])
		return (data.getDate()==aData[0] && data.getMonth()==(aData[1]-1) && data.getFullYear()==aData[2])
	}
	else return false
}

function ritorna_id(theForm,check){
  cont=0;
  cc=document.forms[theForm].elements[check];
  if(cc.length){
		for (var i=0;i<cc.length;i++){ 
			  var e = cc[i];
			  if(e.checked){
					ID=e.value;
					return ID;
					cont++;
			  }
		}
  } else {
	  if(cc.checked){
			ID=cc.value;
			return ID;
			cont++;
	  }
  }
  if(cont==0) {
		return ID=0;
   }
}


function popupFoto(fin,sezione, foto, titolo) { 
	var URL = sezione +"/"+ foto;
	searchWin=window.open(URL,fin,""+
	"width=700"+
	",height=500"+
	",top=0"+
	",left=0"+
	",scrollbar=no"+
	",status=no"+
	",menubar=no"+
	",toolbar=no"+
	",directories=no"+
	",location=no"+
	",resizable=no"+
	""); 
	searchWin.blur();
	pag = ""+
	"<title>"+titolo+"</title>\n"+
	"<META HTTP-EQUIV=\"imagetoolbar\" CONTENT=\"no\">\n"+
	"<scr"+"ipt>\n"+
	"function adatta(w,h) {\n"+
	"window.resizeTo(w,h);\n"+
	"window.moveTo(Math.round((screen.width-w)/2), Math.round((screen.height-h)/2));\n"+
	"window.focus();\n"+
	"}\n"+
	"</scr"+"ipt>\n"+
	"<body style=\"margin:0px;padding:0px;border:none 0px;\" scroll=\"no\">\n"+
	"<img src=\""+URL+"\" onload=\"adatta(this.width+6,this.height+47);\">\n"+
	"</body>\n"+
	""; 
	searchWin.document.open();
	searchWin.document.write(pag); 
	searchWin.document.close();
}

function number_format(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);
}
