//controllo sul formato del prezzo: accetta . o vorgole e ne esce con punti per mysql
function controllaPrezzo(inValue){
	if ((inValue == "")||(inValue == "0,00")){
	    return "0.00";
   }else{
		var outPrezzo = inValue.replace(",",".");
        if(isNaN(outPrezzo)){
		    outPrezzo = "0.00";
		    //alert("Attenzione! Inserire un valore numerico.");
		    return "KO";
		  }else{
				return outPrezzo;
		  }  
	} 
}

//aprire una finestra centrata nello schermo
function apriFinestra(url, myname, w, h, prop, res) {
 	var winl = (screen.width - w) / 2;
 	var wint = (screen.height - h) / 2;
 	winprops = "scrollbars="+prop+",height="+h+",width="+w+",top="+wint+",left="+winl+",resizable="+res+",status=yes";
	var win;
 	win = window.open(url, myname, winprops);
 if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//apre finestra centrata con la foto grande
function apriZoom(theURL,winName,width,height,features) { //v3.1
    var window_width = width;
    var window_height = height;
    var newfeatures= features;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',features=' + newfeatures + '');
    newWindow.focus();
}

//es onClick= apriFinestra('fotoGrandi.php','".urlencode(DIR_V_DT_IMG)."','".$aDati2[0]['file_4']."','fotoGrande',720,500,1,'yes')


function closeFin(){
	if(confirm("chiudo la finestra?")){
		this.close();
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


function riposiziona(layername, XX,YY){
if (document.layers){ 
document.layers[layername].width = XX; 
document.layers[layername].pageX = (window.innerWidth/2)-(document.layers[layername].width/2); 
document.layers[layername].height = YY; 
document.layers[layername].pageY = (window.innerHeight/2)-(document.layers[layername].height/2); 
} 
else if (document.all){ 
document.all[layername].width = XX; 
document.all[layername].style.posLeft = (document.body.clientWidth/2)-(document.all[layername].width/2); 
document.all[layername].height = YY; 
document.all[layername].style.posTop = (document.body.clientHeight/2)-(document.all[layername].height/2); 
} 
else if(document.getElementById){ 
document.getElementById(layername).width = XX; 
document.getElementById(layername).style.left = (window.innerWidth/2)-(document.getElementById(layername).width/2); 
document.getElementById(layername).height = YY; 
document.getElementById(layername).style.top = (window.innerHeight/2)-(document.getElementById(layername).height/2); 
} 
} 
