//*******************************************************
// Prodottto : WSC PRINTER PRO		   																							                                                                         
// Versione : 2.1                                       																						                                                                        
// Release : 03/2009                                   																					                                                                          
// Autore : Dynamicsoft di Luca Michele Ingenito                      
// Web Site : www.dynamicsoft.it                    
// Email : info@dynamicsoft.it                      																							                                                                          
//#######################################################################################à
//RICERCA FASCE PREZZO PRODOTTO
//#######################################################################################à
  var ricerca_fasce;
  function SelPriceProduct(IdProdotto)
  {
	ValIdProdotto=IdProdotto;
	Valorefascia =document.modulo.elements["FasceProdotto-"+ValIdProdotto].value;
	
	if (Valorefascia=="") 
		{
		alert("Selezionare una quantità corretta! ");
		document.modulo.elements["FasceProdotto-"+ValIdProdotto].focus();
		return false;
		}
	
	QueryString="?PagePart=SelFasciaProdotto&idprodotto="+ValIdProdotto+"&valorefascia="+Valorefascia;
	
	if (window.XMLHttpRequest) 
		{
	    document.getElementById('PageProductsCategory-Container-b-List-Box-Cont-3-' + ValIdProdotto).innerHTML = 'Caricamento in corso...';
		document.getElementById('PageProductsCategory-Container-b-List-Box-Cont-4-' + ValIdProdotto).innerHTML = 'Caricamento in corso...';
		ricerca_fasce = new XMLHttpRequest();
		ricerca_fasce.onreadystatechange = ricevivalore;
		ricerca_fasce.open("GET", QueryString,true);
		ricerca_fasce.send(null);
		
		// per IE 
		} 
	else if (window.ActiveXObject)
	{
	    document.getElementById('PageProductsCategory-Container-b-List-Box-Cont-3-' + ValIdProdotto).innerHTML = 'Caricamento in corso...';
		document.getElementById('PageProductsCategory-Container-b-List-Box-Cont-4-' + ValIdProdotto).innerHTML = 'Caricamento in corso...';
		ricerca_fasce = new ActiveXObject("Microsoft.XMLHTTP");
			if (ricerca_fasce) 
			{
			ricerca_fasce.onreadystatechange = ricevivalore;
		    ricerca_fasce.open("GET",QueryString,true);
			ricerca_fasce.send();
			}
	}
}
  function ricevivalore() {   
	var strRes;       
	var arrValori;      
	  if (ricerca_fasce.readyState == 4 && ricerca_fasce.status == 200) {	    
		  strRes=ricerca_fasce.responseText;
		  var SplitValoreStringa = strRes.split("&");
		  Qty=SplitValoreStringa[0];
		  stage=SplitValoreStringa[1];
		  sezione=SplitValoreStringa[2];	
		  CarPr=SplitValoreStringa[3];
		  LavAggPr=SplitValoreStringa[4];
		  ListCosti=SplitValoreStringa[5];
		  IdProdotto=SplitValoreStringa[6];
		  SchedaTecnicaInterno=SplitValoreStringa[7];
		  SchedaTecnicaCopertina = SplitValoreStringa[8];
		  SidPreventivo = SplitValoreStringa[9];
		  // LISTA COSTI RICAVATI
		  var SplitListaCostiRicavati = ListCosti.split("|");
		  imponibile = SplitListaCostiRicavati[0];
		  totale = SplitListaCostiRicavati[4];
		  StringaValoriPreventivo = "Qty=1&stage=add&sezione=" + sezione + "&CarPr=" + CarPr + "&LavAggPr=" + LavAggPr + "&ListCosti=" + ListCosti + "&SchedaTecnicaInterno=" + SchedaTecnicaInterno + "&SchedaTecnicaCopertina=" + SchedaTecnicaCopertina + "&sidprev=" + SidPreventivo
		  StampaImponibile = "<b>" + imponibile + "</b> &euro;";
		  Stampatotale="<b>" + totale + "</b> &euro;";
		 // alert(StringaValoriPreventivo)
		        //document.modulo.elements["hidimponibile-"+IdProdotto].value=imponibile;
				//document.modulo.elements["hidtotale-"+IdProdotto].value=totale;
				document.getElementById('PageProductsCategory-Container-b-List-Box-Cont-3-' + ValIdProdotto).innerHTML =  StampaImponibile;
				document.getElementById('PageProductsCategory-Container-b-List-Box-Cont-4-' + ValIdProdotto).innerHTML = Stampatotale;
				//document.getElementById('PageProductsCategory-Container-b-List-Box-ContDebung-' + ValIdProdotto).innerHTML = StringaValoriPreventivo;
				document.modulo.elements["ValoriPreventivo-"+IdProdotto].value=StringaValoriPreventivo;
		 } 
	}
	
	
//#######################################################################################à
//AGGIUNGI PRODOTTO  AL CARRELLO
//#######################################################################################à
var dlg0; 
function init(e) {
	dlg0 = dojo.widget.byId("dialog0");	
}
dojo.addOnLoad(init);
function closeDialog0() {
		dojo.widget.byId('dialog0').hide();
	}

var AddToShoppingCart;

function AddCart(IdProdotto)
{
	ValIdProdotto=IdProdotto;
	Valorefascia =document.modulo.elements["FasceProdotto-"+ValIdProdotto].value;
	if (Valorefascia=="") 
		{
		alert("Selezionare una quantità corretta! ");
		document.modulo.elements["FasceProdotto-"+ValIdProdotto].focus();
		return false;
		}
	
	StringaValori =document.modulo.elements["ValoriPreventivo-"+ValIdProdotto].value;
	var QueryString = "default.asp?PagePart=prev.addcart&" + StringaValori ;
	if (window.XMLHttpRequest) 
		{
		AddToShoppingCart = new XMLHttpRequest();
		AddToShoppingCart.onreadystatechange = RequestValue_AddToShoppingCart;
		AddToShoppingCart.open("GET", QueryString,true);
		AddToShoppingCart.send(null);
		} 
	else if (window.ActiveXObject)
	{
		AddToShoppingCart = new ActiveXObject("Microsoft.XMLHTTP");
			if (AddToShoppingCart) 
			{
			AddToShoppingCart.onreadystatechange = RequestValue_AddToShoppingCart;
			AddToShoppingCart.open("GET", QueryString,true);
			AddToShoppingCart.send();
			}
	}
}
function RequestValue_AddToShoppingCart() {   
var strRisultatoCart;       
var arrValoriCart;      
  if (AddToShoppingCart.readyState == 4 && AddToShoppingCart.status == 200) {	    
	    strRisultatoCart=AddToShoppingCart.responseText;
	    var SplitstrRisultatoCart = strRisultatoCart.split("[###]");	
		dlg0.show();
		document.getElementById("dialog0").innerHTML = SplitstrRisultatoCart[0] //Dialog;
		document.getElementById("HeaderCart-b-1").innerHTML = SplitstrRisultatoCart[1];//Carrello
	 } 
}
	
//#######################################################################################à
//ZOOM IMMAGINE PRODOTTO
//#######################################################################################à
function Foto(img){
  foto1= new Image ;
  foto1.src=(img);
  Controlla(img);
}
function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewFoto(img){
  largh=foto1.width+20;
  altez=foto1.height+20;
  stringa="width="+largh+",height="+altez;
  finestra=window.open(img,"",stringa);
}

