function aggiungiArt(nomeform){
	alert("L'articolo e' stato aggiunto al carrello");
	var F=eval("document."+nomeform);
	F.submit();
}



//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 passaValue(nomeForm, valCampo1,valCampo2,valGiacenza){ //valCampo1 ,valCampo2
	//alert(nomeForm+", "+valCampo1+", "+valCampo2);
	var F=eval("document."+nomeForm);
	F.IDvar.value=valCampo1;
	F.tg.value=valCampo2;
	F.giacVar.value=valGiacenza;
}

function controllaAcq(nomeForm, inAvvisoQnt, inAvvisoCol,inAvvisoGiac){//campo qnt non 0 e almeno un check
	var F=eval("document."+nomeForm);
	var ok=true;
	if(ok){
	 	if(isNaN(F.qnt.value)||(parseInt(F.qnt.value)==0)){
			alert(inAvvisoQnt);
			ok=false;
			F.qnt.value=0;
	   		F.qnt.focus();}}	
	if(ok){
		var numElement=F.elements.length;
		var countR=0;
		for(i=0; i < (numElement - 1);i++){ 
			if((F.elements[i].type=="radio")&&(F.elements[i].checked==true)){
				countR++;
			} //end if text
		}  	//end for
		if(countR==0){
			alert(inAvvisoCol);
			ok=false;
		}	
	}
	if(ok){
	 	if(parseInt(F.qnt.value) > parseInt(F.giacVar.value)){
			alert(inAvvisoGiac);
			//ok=false;
			F.qnt.value=F.giacVar.value;
	   		F.qnt.focus();}}	
	
	if(ok){
		F.submit();
	}	
}
