// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
    if (!radioObj) return "";
    var radioLength = radioObj.length;

    if (radioLength == undefined)
        if (radioObj.checked) return radioObj.value;
    else
        return "";
        
    for (var i = 0; i < radioLength; i++) {
        if (radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}

function visPrice(UrlArea)
{

    //Form = document.getElementById("formprodx") / aspnetForm
	//indice1 = Form.Opz0.selectedIndex;
	
	// ID   Prezzo   CartXConf Codice   Img   MsgCartone MsgConfez   MsgQtaMin   Dispo   Consegna   Ordinabile  
	// 0    1        2            3       4     5          6           7           8       9          10		  
	
	// ConfXCart PezziXConf EleQta	(Numerici)
	// 11        12         13
		
	if ( (document.getElementById("AddIdArtBase") != undefined) ||       // Solo un articolo = senza varianti
	     (document.getElementById("AddIdArtDrop") != undefined) ||       // Menu a tendina
	     (document.getElementById("RArt") != undefined)                  // Radio
	   )
	{
		ConfXCart = 1;
		PezziXConf = 1;
		EleQta = 1;
		Opz = "";
		Scelta = 0; // Va ad 1 se c'e' scelta da fare. 
			
		if (document.getElementById("AddIdArtDrop") != undefined) {
		    Drop = document.getElementById("AddIdArtDrop")
		    if (Drop.length == 2) { Drop.options[1].selected = true; }

		    Indice = Drop.selectedIndex;

		    if (Indice > 0) { Opz = Drop.options[Indice].value; }

		    Scelta = 1;
   
		}

		if (document.getElementById("RArt") != undefined) {
		    Rad = document.getElementsByName("RArt")
		    Opz = getCheckedValue(Rad);
		    
		    Scelta = 1;
		}
				
		if (Scelta == 1)
			{ 
			  if (Opz.length > 0)
				{ AddButton = true;	
				  
				  VOpz = Opz.split("$$$")
				  Prezzo = parseFloat(VOpz[1]);				  
				  MsgPrezzoxConfCart = VOpz[2];				  
				  MsgCod = VOpz[3];
				  Img = VOpz[4];
				  MsgCart = VOpz[5];
				  MsgConf = VOpz[6];
				  MsgQtaMin = VOpz[7];
				  MsgDisp = VOpz[8];
				  MsgCons = VOpz[9];
				  VisBask = VOpz[10];
				  ConfXCart = VOpz[11];
				  PezziXConf = VOpz[12];
				  EleQta = VOpz[13];
				  
				  if (Img != 'none')
				  { document.getElementById("imgModello").src=Img; 	
   		  		    document.getElementById("DivImgModello").style.display=''; 	
   		  		    document.getElementById("zoomImgModello").href="javascript:OpenBig('" + UrlArea + "','" + Img.replace('-SMA-','-BIG-') + "')";
   		  		  }
   		  		  else
   		  		  { document.getElementById("DivImgModello").style.display='none'; 	}
   		  		  
   		  		  visProdEle ('Cod', MsgCod);
   		  		  visProdEle ('Cart', MsgCart);   		  		  
   		  		  visProdEle ('Conf', MsgConf);
   		  		  visProdEle ('QtaMin', MsgQtaMin);
   		  		  visProdEle ('Disp', MsgDisp);
   		  		  visProdEle ('Cons', MsgCons);   		  		     		  		  
   		  		  
   		  		  if (VisBask == 'N') 
   		  		  { document.getElementById("AddBasket").style.display='none'; }
   		  		  else
   		  		  { document.getElementById("AddBasket").style.display=''; }
   		  		  
				}  
				else
				{ AddButton = false;	
				  Prezzo = 0;
   		  		  document.getElementById("DivImgModello").style.display='none'; 
   		  		  visProdEle ('Cod', 'none');
   		  		  visProdEle ('Cart', 'none');   		  		  
   		  		  visProdEle ('Conf', 'none');
   		  		  visProdEle ('QtaMin', 'none');
   		  		  visProdEle ('Disp', 'none');
   		  		  visProdEle ('Cons', 'none');
				}
			
				// alert (Indice + " - " + Prezzo);
			}

		if (document.getElementById("AddIdArtBase") != undefined)
			{	Opz = document.getElementById("AddIdArtBase").value;
				VOpz = Opz.split("$$$")
  			    Prezzo = parseFloat(VOpz[1]);		
				AddButton = true;	
			}
		
		k = 1;
		while (document.getElementById("DropOpz" + k) != undefined)
			{ 	Drop = document.getElementById("DropOpz" + k)
				Indice = Drop.selectedIndex;
				Opz = Drop.options[Indice].value
				
				Prezzo = parseFloat(Prezzo) + (parseFloat(GetPrezzoOpz(Opz, ConfXCart, PezziXConf, EleQta)));	// estrarre prezzo !
		
				// alert (Indice + " - " + Prezzo);
		
				k += 1;
			}

		if (Prezzo < 0) { AddButton = false; }

		if (AddButton)	
			{	StrPrezzo = Prezzo.toString();

			    while (StrPrezzo.length < 3)		
			     { StrPrezzo = '0' + StrPrezzo; }

			    StrPrezzo = StrPrezzo.substr(0, StrPrezzo.length - 2) + "," + StrPrezzo.substr(StrPrezzo.length - 2, 2);

			    document.getElementById("TRSelezionaArt").style.display = 'none'; 
                document.getElementById("TRPrezzoOff").style.display = ''; 
				document.getElementById("PriceOff").innerHTML = StrPrezzo + " &euro;";
				document.getElementById("MsgConfCart").innerHTML='&nbsp;' + MsgPrezzoxConfCart; 				
  	  		  	document.getElementById("MsgIvaArt").style.display=''; 
			}
			else {
			    document.getElementById("TRPrezzoOff").style.display = 'none'; 
                document.getElementById("PriceOff").innerHTML = "-";
				document.getElementById("MsgConfCart").innerHTML=''; 						
				document.getElementById("MsgIvaArt").style.display='none'; 			
			}
	}
}


function visProdEle (idObj, value)
{ 
  if ((value == 'none') || (value == ''))
  {  document.getElementById(idObj + "Val").innerHTML = ''; 
     document.getElementById(idObj + "Lab").style.display = 'none'; 
  }
  else
  {  document.getElementById(idObj + "Val").innerHTML = value; 
     document.getElementById(idObj + "Lab").style.display = ''; 
  }   
}


function GetPrezzoOpz(Opz, ConfXCart, PezziXConf, EleQta)
{ 	var OpzVet = Opz.split("$$$")
	
	PrezzoOpz = OpzVet[1];
	ModeCalcOpz = OpzVet[2];
	
	if (ModeCalcOpz == "K") { Prezzo = PrezzoOpz; }
	if (ModeCalcOpz == "C") { Prezzo = PrezzoOpz * ConfXCart; }
	if (ModeCalcOpz == "P") { Prezzo = PrezzoOpz * ConfXCart * PezziXConf; }
	if (ModeCalcOpz == "U") { Prezzo = PrezzoOpz * ConfXCart * PezziXConf * EleQta; }
	
	// alert (PrezzoOpz + " - " + ModeCalcOpz + " * " + ConfXCart + " - " + PezziXConf + " - " + EleQta + " - " + Prezzo);
	
	return Prezzo;
}

/* ------------------------------------------------------------------------------------------------------------------- */
function ProdMenuSel(Item) {
    /* Menu del prodotto. Item 0 = Vedi Tutti */

    /* Se Item = 0 ... Visualizza tutti i riquadri */
    if (Item == 0) {
        for (i = 1; i <= 20; i++) {
            Ele = document.getElementById("ProdBOX" + i);
            if (Ele != undefined) { Ele.style.display = 'block'; }
        }
    }

    /* Se Item > 0 ... Nasconde i riquadri informativi visibili */
    if (Item > 0) {
        for (i = 1; i <= 20; i++) {
            Ele = document.getElementById("ProdBOX" + i);
            if (Ele != undefined) { if (Ele.style.display != 'none') { Ele.style.display = 'none'; } }
        }

        /* Visualizza il riquadro selezionato */
        Ele = document.getElementById("ProdBOX" + Item);
        if (Ele != undefined) { Ele.style.display = 'block'; }
    }
        
    /* Ripristina le classi di tutti gli span dei bottoni del MENU */
    for (i = 0; i <= 20; i++) {
        Ele = document.getElementById("ProdLI" + i);
        if (Ele != undefined) {
            EleS = Ele.childNodes[0];
            if (EleS.className == 'PLHover') { EleS.className = ''; }
        }
    }

    /* Mette in hover lo stile dello span selezionato */
    Ele = document.getElementById("ProdLI" + Item);
    EleS = Ele.childNodes[0];       /* EleS = Ele.getElementsByTagName("span")[0]; */
    if (EleS != undefined) {
        EleS.className = 'PLHover';

        /* Tolgo il focus ... mi fa antipatia .. */
        EleI = EleS.childNodes[0];
        if (EleI != undefined) { EleI.blur(); }
    }

}

function ProdOpenDesArt(IdDiv) {
    ElePreview = document.getElementById("ArtDesPreview-" + IdDiv);
    EleFull = document.getElementById("ArtDes-" + IdDiv);
    if (ElePreview != undefined) { ElePreview.style.display = 'none'; }
    if (EleFull != undefined) { EleFull.style.display = 'block'; }
    return false;
}

function ProdCloseDesArt(IdDiv) {
    ElePreview = document.getElementById("ArtDesPreview-" + IdDiv);
    EleFull = document.getElementById("ArtDes-" + IdDiv);
    if (ElePreview != undefined) { ElePreview.style.display = 'block'; }
    if (EleFull != undefined) { EleFull.style.display = 'none'; }
    return false;
}

/* ------------------------------------------------------------------------------------------------------------------- */

function openPopBasket(page)
{		info = "width=280,height=100,menubar=no,scrollbars=yes,resizable=no";
		window.open(page, "Basket", info);
}

function addArtSPop(TBasket, UrlArea, ZonaC, lang, IdArt)		
// Chiama addArt di prodotto semplice nel pop-up basket.
{
	page = UrlArea + "/PopBasket.aspx?zonac=" + ZonaC + "&lang=" + lang + "&Addidart=" + IdArt;
	info = "width=280,height=100,menubar=no,scrollbars=no,resizable=no"
	window.open(page, "Basket", info);
}

function SubmitCk(TBasket, UrlArea, ZonaC, lang, IdArt) {

    NumCk = 0;
    AddButton = false;

    //alert(document.getElementById("AddIdArtDrop"));
    //alert(document.getElementById("RArt"));
    //alert(document.getElementById("ArtQta-0"));

    // Menu a discesa articoli multipli
    if (document.getElementById("AddIdArtDrop") != undefined) {
        Drop = document.getElementById("AddIdArtDrop")
        Indice = Drop.selectedIndex;
        if (Indice > 0) { AddButton = true; }
        
        return (AddButton);
    }

    // Radio Articoli mutipli
    if (document.getElementById("RArt") != undefined) {      // Qui va messo GetElementById, perche il GetByName restituisce un oggetto anche se non c'è nulla con quel nome ...
        Rad = document.getElementsByName("RArt")             // Con getElementById non funge ... GetElementsByName prende TUTTI i Name(s)
        ValueRad = getCheckedValue(Rad);
        if (ValueRad.length > 0) { AddButton = true; }
        
        return (AddButton);
    }

    // if (document.getElementById("ArtQta-0") != undefined) { AddButton = true; }

    // Prodotto singolo, o prodotto selezionato da elenco ART modo avanzato
    if (!isNaN(IdArt)) {
         if ((IdArt>0) && (document.getElementById("ArtQta-" + IdArt) != undefined)) { AddButton = true;  }
    }

    // Selezione multipla da elenco ART modo avanzato
    if (IdArt == 'Sel') {
        Cks = document.getElementById("aspnetForm");    // Tutti i campi del Form
        for (i = 0; i < Cks.length; i++)
         {
             if (Cks[i].type == 'checkbox') 
              { if ((String(Cks[i].id).substring(0, 6) == 'ArtCk-') && (Cks[i].checked)) NumCk = NumCk + 1; }
         }

         if (NumCk > 0) { AddButton = true;  }
     }

    return (AddButton);
}

function SubmitaddArtPop(TBasket, UrlArea, ZonaC, lang, IdArt)		
// Chiama addArt di prodotto con varianti o opzioni nel pop-up basket.
{   
    AddButton = SubmitCk(TBasket, UrlArea, ZonaC, lang, IdArt);
    
	if (AddButton) 
	{	openPopBasket("");

	    page = UrlArea + "/PopBasket.aspx?zonac=" + ZonaC + "&lang=" + lang + "&PostIdArt=" + IdArt;

		document.getElementById("aspnetForm").action = page;
		document.getElementById("aspnetForm").target = "Basket";
		document.getElementById("aspnetForm").submit();
	}
	else
	{   alert ("E' necessario selezionare l'articolo!"); }	
}

function SubmitaddArt(TBasket, UrlArea, ZonaC, lang, IdArt)
// Chiama addArt di prodotto con varianti o opzioni direttamente sulla windows corrente 
// quando PopBasket è spento !
{
    AddButton = SubmitCk(TBasket, UrlArea, ZonaC, lang, IdArt);

	if (AddButton) {

	    if (TBasket == "BasketA") 
        {
            page = UrlArea + "/Navigation.aspx?mode=Basket&zonac=" + ZonaC + "&lang=" + lang + "&PostIdArt=" + IdArt;
	    }

	    else 
        {
            /* document.getElementById("__EVENTTARGET").value = ""; */
	        /* document.getElementById("__EVENTARGUMENT").value = ""; */
	        /* document.getElementById("__VIEWSTATE").value = ""; */
            page = UrlArea + "/BasketRapido.aspx?mode=Basket&zonac=" + ZonaC + "&lang=" + lang + "&PostIdArt=" + IdArt; 
         }

	    document.getElementById("aspnetForm").action = page;
	    document.getElementById("aspnetForm").submit();

		}
	else {  alert ("E' necessario selezionare l'articolo!"); }	
}

/* ------------------------------------------------------------------------------------------------------------------- */

function imgPreload (urlimg)
{  im = new Image;
   im.src = urlimg;
}  

function setimg (obj, nomeimg)
{ obj.src = nomeimg;  }

function overpreloadAll ()
{ var vimg = document.images;
  for (i=0; i<vimg.length; i++)
   { if (vimg[i].id.indexOf("ov") >= 0) { overpreload (vimg[i].src); }
   }
}

function overpreload (urlimg)
{ imgname = urlimg.substr (0, urlimg.length - 4);
  imgext = urlimg.substr (urlimg.length - 4, 4);
  imgname = imgname + '-HO' + imgext;
  im = new Image;
  im.src = imgname;
}

function overin (obj)
{ imgname = obj.src.substr (0, obj.src.length - 4);
  imgext = obj.src.substr (obj.src.length - 4, 4);
  imgname = imgname + '-HO' + imgext;
  obj.src = imgname;  }
  
function overout (obj)
{ imgname = obj.src.substr (0, obj.src.length - 7);
  imgext = obj.src.substr (obj.src.length - 4, 4);
  imgname = imgname + imgext;
  obj.src = imgname; }
  
function apriProd(UrlArea, id, ZonaC, lang)
{
    // page = UrlArea + "/PopProd.aspx?id=" + id + "&zonac=" + ZonaC + "&lang=" + lang + "&Type=pop";
    page = UrlArea + "/Navigation.aspx?url=nexp&idprod=" + id + "&zonac=" + ZonaC + "&lang=" + lang + "&popmode=Y";
	info = "width=680,height=520,menubar=no,scrollbars=yes,resizable=yes"
	window.open(page, "Prod"+id, info);
}

function ProdCorrelati(UrlArea, id, ZonaC, lang)
{
	page = UrlArea + "/nexp/" + ZonaC + "/" + lang + "/idProd/"+ id + "/navigation.htm#prodcorr";
	window.opener.location.href = page
	window.close()
}

function apriMakePdf(UrlArea, ZonaC, lang, param)
{
	page = UrlArea + "/Catalog/CatalogoPdf.aspx?zonac=" + ZonaC + "&lang=" + lang + param + "&UrlArea=" + UrlArea;
	info = "width=640,height=380,menubar=no,scrollbars=no,resizable=no"
	window.open(page, "Pdf", info);
}

function apriMakeXls(UrlArea, ZonaC, lang, param)
{
	page = UrlArea + "/Catalog/CatalogoXls.aspx?zonac=" + ZonaC + "&lang=" + lang + param + "&UrlArea=" + UrlArea;
	info = "width=640,height=380,menubar=no,scrollbars=no,resizable=no"
	window.open(page, "Pdf", info);
}

function apriSaveBasket(UrlArea, ZonaC, lang)
{
	page = UrlArea + "/PopBasketSave.aspx?zonac=" + ZonaC + "&lang=" + lang;
	info = "width=640,height=440,menubar=no,scrollbars=no,resizable=no"
	window.open(page, "SaveBasket", info);
}

function apriBasketModify(UrlArea, ZonaC, lang) {
    page = UrlArea + "/BasketModify.aspx?zonac=" + ZonaC + "&lang=" + lang;
    info = "width=900,height=700,menubar=no,scrollbars=yes,resizable=yes"
    window.open(page, "BasketModify", info);
}

function apriBasketModifyPdf(UrlArea, ZonaC, lang) {
    UfEmail = "";
    if (document.getElementById("TbUfEmail")) {
        UfEmail = document.getElementById("TbUfEmail").value;
    }
    page = UrlArea + "/BasketModify.aspx?action=pdf&zonac=" + ZonaC + "&lang=" + lang + "&UfEmail=" + UfEmail;
    info = "width=900,height=700,menubar=no,scrollbars=yes,resizable=yes"
    window.open(page, "BasketModifyPdf", info);
}

function apriMList(Mode) {
    page = "/bk/mailing/mail.aspx?mail=" + Mode;
    info = "width=900,height=700,menubar=no,scrollbars=yes,resizable=yes"
    window.open(page, "BasketML", info);
}

function OpenBig(UrlArea, foto)
{
	page = UrlArea + "/PopImgZoom.aspx?foto=" + foto;
	info = "width=640,height=500,menubar=no,scrollbars=yes,resizable=yes";
	window.open(page,"ProdottiBig",info);
}

function OpenBigAuto(obj)
{ imgname = obj.src.substr (0, obj.src.length - 4);
  imgext = obj.src.substr (obj.src.length - 4, 4);
  imgname = imgname + '-big' + imgext;

  page = "/Sito/PopImgZoom.asp?foto=" + imgname;
  info = "width=640,height=500,menubar=no,scrollbars=yes,resizable=yes";
  window.open(page,"ProdottiBig",info);
}


function OpenPay (UrlArea, ZonaC, lang)
{
		page = UrlArea + "/PopPay.aspx?modepay=Start&zonac=" + ZonaC + "&lang=" + lang;
		info = "width=800,height=600,menubar=no,scrollbars=yes,resizable=yes";
		window.open(page,"PopPay",info);
}

function OpenFormCustom(Url, ZonaC, lang) {
    page = Url + "?zonac=" + ZonaC + "&lang=" + lang + "&popmode=Y";
    info = "width=800,height=600,menubar=no,scrollbars=yes,resizable=yes";
    window.open(page, "PopFormCustom", info);
}

function OpenUpload(ZonaC, lang, TypeUser, Folder, SubDir, IdUser, IdProf, IdArea) {
    page = "/Sito/Special/Upload.aspx?TypeUser=" + TypeUser + "&Folder=" + Folder + "&SubDir=" + SubDir + "&iduser=" + IdUser + "&idprof=" + IdProf + "&idarea=" +IdArea + "&zonac=" + ZonaC + "&lang=" + lang;
    info = "width=800,height=600,menubar=no,scrollbars=yes,resizable=yes";
    window.open(page, "PopUpload", info); 
}

function OpenAvvisoZoneC (UrlArea,  ZonaC, lang)
{
    // page = UrlArea + "/PopNavigation.aspx?mode=Msg&tag=MsgZoneC&zonac=" + ZonaC + "&lang=" + lang;
    page = UrlArea + "/Navigation.aspx?popmode=Y&mode=Msg&tag=MsgZoneC&zonac=" + ZonaC + "&lang=" + lang;
    info = "width=648,height=350,menubar=no,scrollbars=yes,resizable=yes";
    window.open(page, "PopMsg", info);
		
}

function OpenDownZoneC (UrlAreaCli, ZonaC, lang)
{
		page = UrlAreaCli + "/" + ZonaC + "/" + lang + "/Static/Zonec.htm";
		window.opener.location = page;
		window.close();
}

function OpenCondVendita (UrlAreaCli, ZonaC, lang)
{
		page = UrlAreaCli + "/" + ZonaC + "/" + lang + "/popmode/Y/Static/CondVendita.htm";
		info = "width=680,height=480,menubar=no,scrollbars=yes,resizable=yes";
		window.open(page,"PopMsg",info);
}

function OpenCondVenditaDB (UrlArea, Pagina, ZonaC, lang)
{
		page = UrlArea + "/nexp/" + ZonaC + "/" + lang + "/popmode/Y/ContName/" + Pagina + "/navigation.htm";
		info = "width=680,height=480,menubar=no,scrollbars=yes,resizable=yes";
		window.open(page,"PopMsg",info);
}

function RedirToUrl(url) {
    alert(url);
        document.location.href=url;
}

function CheckQta(Val)
{
	if (isNaN(Val.value))
	{
		alert("Inserire un numero intero!");
		Val.focus();
	}
	
	if (Val.value.match(/\./) != null)
	{
		alert("Inserire un numero intero!");
		Val.focus();
	}
}

// function check()
// {
	// if (event.keyCode==13) return false;
// } 

/* Questa funzione potrebbe essere rimossa ... */
function check(e) {
    if (window.event)
        keyPressed = window.event.keyCode; // IE
    else
        keyPressed = e.which; // Firefox


    // if (keyPressed == 13) return false;
} 

function Check_Basket()
{
	if (document.getElementById("DropTrasporto") != undefined)
	{
		if (document.getElementById("DropTrasporto").value == 0 || document.getElementById("DropPagamento").value == 0)
		{	
			alert("Specificare metodi di trasporto e pagamento!");
			return false;
		}
	}
	
	return true;
}

function Resize()
{
	altezza = document.images.imma.height + 82;
	larghezza = document.images.imma.width + 30;
	
	if (altezza < 540 && larghezza < 760)
	{
		self.resizeTo(larghezza,altezza);
	}
	else
	{
		if (altezza > 540 && larghezza < 760)
		{
			self.resizeTo(larghezza,540);
		}
		else
		{
			if (altezza < 540 && larghezza < 760)
			{
				self.resizeTo(760,altezza);
			}
		}
	}
}

function CheckSize(MaxSize)		// In genere 1024
{
	larghezza = document.body.clientWidth;
	//alert(larghezza);
	
	if (isNaN(MaxSize)) { MaxSize = 1024; }
	
	if (!isNaN(larghezza)) 
	{
		if (larghezza > MaxSize)
		{
			if (document.getElementById("MainTable") != undefined)
				{ 
				  document.getElementById("MainTable").width = MaxSize; }
				
			if (document.getElementById("FootTable") != undefined)
				{ 
				  document.getElementById("FootTable").width = MaxSize; }
				
			if (document.getElementById("HeadTable") != undefined)
				{ 
				  document.getElementById("HeadTable").width = MaxSize; }
		}
	}
}

function CheckDatiSpedA(ZonaC, lang)
{
	// var df = document.Form1

	/*
	if (df.presso.value != "" || df.indirizzo.value != "" || df.citta.value != "" || df.cap.value != "" || df.provincia.value != "" || df.nazione.value != "")
	{
		if (df.presso.value == "" || df.indirizzo.value == "" || df.citta.value == "" || df.cap.value == "" || df.provincia.value == "" || df.nazione.value == "")
		{
			alert("$trad-datialt*$");
			return false;
		}
	}
	*/
	
	/* FExist = typeof CheckCustom;
	OkCustom = true;
	
	if (FExist != "undefined")
	{   OkCustom = CheckCustom();
	}
	*/
	
	if (document.getElementById("AcceptCV").checked)	// check condizioni di vendita
	{
	    OkCustom = CheckCustomA();
		if (OkCustom == true)
		{ 
			// document.FormBasketConfirmA.action = "Navigation.aspx?zonac=" + ZonaC + "&lang=" + lang + "&mode=BaskSend&TBask=A";
		    // document.FormBasketConfirmA.submit();
		    // document.aspnetForm.action = "Navigation.aspx?zonac=" + ZonaC + "&lang=" + lang + "&mode=BaskSend&TBask=A";
		    document.aspnetForm.action = "Navigation.aspx?zonac=" + ZonaC + "&lang=" + lang + "&mode=BaskSend";
		    document.aspnetForm.submit();		    
		    
		}
	}	
	else
	{	
		if (lang == 'ITA') 
			{ alert ("E' necessario accettare le condizioni di acquisto."); }
			else
			{ alert ("Check terms and conditions."); }
			
	}
}

function CheckDatiSpedI(ZonaC, lang)
{
	
    OkCustom = CheckCustomI();
	if (OkCustom == true)
	{ 
		document.FormBasketConfirmI.action = "Navigation.aspx?zonac=" + ZonaC + "&lang=" + lang + "&mode=BaskSend&TBask=I";
		document.FormBasketConfirmI.submit();
	}
}

function SendSearchSimple(ZonaC, lang)
{
	// document.FSearchSimple.action = "$URLArea$/NavCercaAdv.aspx";

    // if (document.FSearchSimple) {
    // OLD CALL :    document.FSearchSimple.submit();
    // }
    
    // alert(document.aspnetForm.action);
    // alert(document.getElementById("__VIEWSTATE").value);
    
    // findw = document.getElementById("MNtesto").value;
    // document.location = "/Sito/NavCercaAdv.aspx?ns=Y&zonac=" + ZonaC + "&lang=" + lang + "&MNtesto=" + findw;

    
    //document.getElementById("__VIEWSTATE").value = "";  // Azzero la viewstates altrimenti da errore il controllo 
                                                          // di validità passando da una pagina ad un altra direttamente.

    // findw = document.getElementById("MNtesto").value; hidden 10.7.2011
    // document.aspnetForm.action = "/Sito/NavCercaSimple.aspx?zonac=" + ZonaC + "&lang=" + lang + "&q=" + findw;

     if (document.FSearchSimple) {
         // alert(document.FSearchSimple.action);
         document.FSearchSimple.action = "/Sito/NavCercaSimple.aspx?zonac=" + ZonaC + "&lang=" + lang;
         document.FSearchSimple.submit();
      }
      else
      {
         document.aspnetForm.action = "/Sito/NavCercaSimple.aspx?zonac=" + ZonaC + "&lang=" + lang;
         document.aspnetForm.submit();
      }

}

function ClickEnterSearch(e, ZonaC, lang) {

    if (window.event)
        keyPressed = window.event.keyCode; // IE
    else
        keyPressed = e.which; // Firefox

    if (keyPressed == 13) {
        SendSearchSimple(ZonaC, lang);
    }

    

}

function ApriNote(UrlArea, ZonaC, lang, id)
{
	page = UrlArea + "/Catalog/nota.aspx?zonac=" + ZonaC + "&lang=" + lang + "&id=" + id + "&UrlArea=" + UrlArea;
	info = "width=640,height=380,menubar=no,scrollbars=no,resizable=no";
	window.open(page, "nota"+id, info);
}

function ApriDDT(UrlArea, ZonaC, lang, id)
{
	page = UrlArea + "/Catalog/fattura.aspx?zonac=" + ZonaC + "&lang=" + lang + "&id=" + id + "&UrlArea=" + UrlArea;
	info = "width=640,height=380,menubar=no,scrollbars=no,resizable=no";
	window.open(page, "DDT"+id, info);
}

function ApriPop(Url, X, Y)
{
   page = Url;
   info = "width=" + X + ",height=" + Y + ",menubar=no,scrollbars=no,resizable=no";
   window.open(page, "Pop", info);
}

function ApriTechBsaDoc(UrlArea, ZonaC, lang, idord, idut) 
{
    page = UrlArea + "/Catalog/TechBsaDoc.aspx?zonac=" + ZonaC + "&lang=" + lang + "&idord=" + idord + "&idut=" + idut + "&UrlArea=" + UrlArea;
    info = "width=640,height=380,menubar=no,scrollbars=yes,resizable=yes";
    window.open(page, "DOC" + idord + idut, info);
}

function ApriBennatiDoc(UrlArea, ZonaC, lang, idord, idut) {
    page = UrlArea + "/Catalog/BennatiDoc.aspx?zonac=" + ZonaC + "&lang=" + lang + "&idord=" + idord + "&idut=" + idut + "&UrlArea=" + UrlArea;
    info = "width=640,height=380,menubar=no,scrollbars=yes,resizable=yes";
    window.open(page, "DOC" + idord + idut, info);
}

function ApriVettore(UrlArea, ZonaC, lang, id)
{
	page = UrlArea + "/Catalog/vettore.aspx?zonac=" + ZonaC + "&lang=" + lang + "&id=" + id + "&UrlArea=" + UrlArea;
	info = "width=640,height=380,menubar=no,scrollbars=no,resizable=no";
	window.open(page, "Vettore"+id, info);
}



function MostraDescr(nomediv)
{
	document.getElementById(nomediv).className="box";
}

function CancellaDescr(nomediv)
{
	document.getElementById(nomediv).className="nobox";
}

function SelAreaZonaC(obj)
{
 	// alert(obj.value);	
	window.location.href = obj.value;
}

function SelZonaCLingua(curpage)
{
	var selgeogroup = document.getElementById('selgeogroup');
	var sellingua = document.getElementById('sellingua');
	var newurl;
	newurl = selgeogroup.value.replace('$jslingua$', sellingua.value);
	window.location.href = newurl;
}

function logout(UrlArea, ZonaC, lang, msg)
{
    if (window.confirm(msg))  
    {
        location.href=UrlArea + "/navigation.aspx?mode=Logout&zonac=" + ZonaC + "&lang=" + lang;
    }
}

function ConfermaReg()
{ 	if (confirm("Confermi la tua registrazione?"))
	{ return true; }
	return false;
}

// Open + negolo
function OpenInfo() {
    if (document.getElementById("netnegolo").style.display == 'block')
    { document.getElementById("netnegolo").style.display = 'none'; }
    else
    { document.getElementById("netnegolo").style.display = 'block'; }
}

// Open + Cli (se presente)
function OpenInfoCli() {
    if (document.getElementById("infocli").style.display == 'block')
    { document.getElementById("infocli").style.display = 'none'; }
    else
    { document.getElementById("infocli").style.display = 'block'; }
}



// Over Seo Link Prod 

var LockCat = 0;
var TimerSeoCat;

function OpenMenuBox(IdCat) {
    if (document.getElementById("menubox" + IdCat)) {
        /* CloseALLMenuBox(); */
        if (TimerSeoCat) { clearTimeout(TimerSeoCat); }
        /* document.getElementById("menubox" + IdCat).style.display = 'block'; */
        TimerSeoCat = setTimeout("OpenMenuBoxInterna(" + IdCat + ")", 200);
    }
}


function OpenMenuBoxInterna(IdCat) {
        CloseALLMenuBox();
        if (TimerSeoCat) { clearTimeout(TimerSeoCat); }
        document.getElementById("menubox" + IdCat).style.display = 'block'; 
}

function CloseMenuBoxTimer(IdCat) {
    if (document.getElementById("menubox" + IdCat)) {
        if (TimerSeoCat) { clearTimeout(TimerSeoCat); } 
        TimerSeoCat = setTimeout("CloseMenuBox(" + IdCat + ")", 500); }
}

function LockMenuBox(IdCat) {
    if (TimerSeoCat) { clearTimeout(TimerSeoCat); }
}

function CloseMenuBox(IdCat) {
    if (document.getElementById("menubox" + IdCat)) { document.getElementById("menubox" + IdCat).style.display = 'none'; }
}

function CloseALLMenuBox() {
    for (i = 1; i < 1200; i++) {
        CloseMenuBox(i);
    }
}

// -------------------------------------- Xml Req 4 Logintime
function TimerOnPage ()
{ updateTimerOP();
  timerOnPageID = setInterval('updateTimerOP()',300000); // 5 minuti
}

var req;
function updateTimerOP()
{
    var url = "/Ascx/LoginTime.aspx";
    req = false;
        
    // chiamata per XMLHttpRequest native object
    if(window.XMLHttpRequest) 
    {   try { req = new XMLHttpRequest(); } 
        catch(e) { req = false; }
    }    
    // chiamata per versione IE/Windows ActiveX 
    else 
    if(window.ActiveXObject) 
    {   try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch(e) 
          { try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
            catch(e) { req = false; }
          }
    }
    
    if(req) 
    {	req.onreadystatechange = processResponseTimerOP;
        req.open("GET", url, true);
        req.send("");
    }
}

function processResponseTimerOP() 
{   // only if req shows "loaded"
    if (req.readyState == 4) 
    {   // only if "OK"
        if (req.status == 200) 
        {   if (req.responseText == "0")
            {  // document.location.href = "/login.aspx";  
               // Nothing !
            }
            else
            {  if (document.getElementById("TempoTrascorso") != null)
               { document.getElementById("TempoTrascorso").innerHTML = "&nbsp;time on line: " + req.responseText;} 
               else
               { // alert (req.responseText); 
               }
            }
        }
    }

}


// Invece di (document.location.href='#Completa').
// Farlo seguire da un return(false), in un button se non si vuole generare un postback !
function scrollToPosition(Ele) {
    var theElement = document.getElementById(Ele)   
    elemPosX = theElement.offsetLeft
    elemPosY = theElement.offsetTop;
    theElement = theElement.offsetParent;
    while (theElement != null) {
        elemPosX += theElement.offsetLeft
        elemPosY += theElement.offsetTop;
        theElement = theElement.offsetParent;
    }
    window.scrollTo(elemPosX, elemPosY);
}  


/* Usata per la SoundManager */

function fireOnclick(objID) {
    var target = document.getElementById(objID);
    if (document.dispatchEvent) { // W3C
        var oEvent = document.createEvent("MouseEvents");
        oEvent.initMouseEvent("click", true, true, window, 1, 1, 1, 1, 1, false, false, false, false, 0, target);
        target.dispatchEvent(oEvent);
    }
    else if (document.fireEvent) { // IE
        target.fireEvent("onclick");
    }
}
