function img_rollover(path) {
    document.getElementById("big-image").src = "/tcnImg/" + path; return true;
}

function ToogleZoomer() {
    var zoomer = document.getElementById("zoomer-flash");

    if (zoomer.className == "zoomer-nascosto")
        zoomer.className = "zoomer-visibile";
    else
        zoomer.className = "zoomer-nascosto";
        
    //if (zoomer.className == "zoomer-visibile")
        //zoomer.className = "zoomer-nascosto";
}

//* ------------ Scelta DISCOUNT
function evidenzia(totDisc, scelta) {

    var idRiga;
    var idCella;

    for (var i = 1; i < (totDisc + 1); i++) {
        idRiga = document.getElementById("row_discount" + i);
        idCella = document.getElementById("tdrow_discount" + i);

        idRiga.className = "rowDiscount";
        idCella.className = "normal";
    }
    if (scelta.id != "testSelezionato") {
        document.getElementById("row_" + scelta.id).className = "rowDiscountSelected";
        document.getElementById("tdrow_" + scelta.id).className = "selected";
    }
}

function apriScegliDiscount() {
    if (document.getElementById("sceltaDiscountDiv").className == "nascostoDiscount") {
        document.getElementById("sceltaDiscountDiv").className = "visibileDiscount";
    } else {
        document.getElementById("sceltaDiscountDiv").className = "nascostoDiscount";
    }
}

function chiudiScelta(totDisc) {
    document.getElementById("sceltaDiscountDiv").className = "nascostoDiscount";
    evidenzia(totDisc, document.getElementById("discount1"));
    document.forms['indirizzo'].elements['privilegioScelto'][0].checked = true;
}
//* ------------

function closeAllElementes(elementPadre, prefisso) {

    var divModelli = document.getElementById(elementPadre);
    var divCollection = divModelli.getElementsByTagName("div");

    for (var i = 0; i < divCollection.length; i++) {
        if (divCollection[i].getAttribute("id") != null) {
            var FindedId = divCollection[i].getAttribute("id");

            if (FindedId.indexOf(prefisso) >= 0) {
                document.getElementById(divCollection[i].getAttribute("id")).className = "nascosto";
            }
        }
    }   
}

//
// Versione custom di closeAllElementes
// 
function switchFreccina(elementPadre, prefisso) {

    var divModelli = document.getElementById(elementPadre);
    var imgCollection = divModelli.getElementsByTagName("img");

    for (var i = 0; i < imgCollection.length; i++) {
        if (imgCollection[i].getAttribute("id") != null) {
            var FindedId = imgCollection[i].getAttribute("id");

            if (FindedId.indexOf("freccina_") >= 0) {
                document.getElementById(imgCollection[i].getAttribute("id")).src = '/Style/Images/freccia_vuota.png';
            }
        }
    }
}

function toogleBloccoModelli(idElement, prefisso) {

    closeAllElementes("lista-modelli", "block_");
    switchFreccina("lista-modelli", "block_");
    document.getElementById("block_" + idElement).className = "prodotto-visibile";
    document.getElementById("freccina_" + idElement).src = '/Style/Images/freccia_piena-down.png';
}

var head = "display:''"
function doit(header) {

    var head = header.style
    if (head.display == "none")
        head.display = ""
    else
        head.display = "none"
}

///
/// Rollover sulle immagini 
///
function rollOver(img, img_src) {
    img.src = img_src;
}

///
/// 
///
function WinOpen(url, name, features) {
    popWin = window.open(url, name, features);
}

///
/// 
///
function Othervideohelp() {
    var numLista = document.all.others[document.all.others.selectedIndex].value;
    WinOpen('http://www.menestrello.com/kappacomstore/kappacomstore.asp?Id=' + numLista, 'videohelp', 'scrollbars=no,resizable=no,width=380,height=470,left=120,top=120');
}

///
/// Input di ricerca veloce
///
function controllo_ricerca() {
    if (document.Table4FORM.cerca.value.length < 3) {
        alert('Min 3 char')
        return false;
    }
    else
        return true;
}


///
/// Funzione per il pop-up
///
function popUpWin(url, width, height, scroll) {
    parString = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + scroll + ",resizable=0,width=" + width + ",height=" + height + ",screenX=200,screenY=100,left=200,top=100"
    window.open(url, "popUpWin", parString);
}

function ControlloFinale(totelem) {
	for (var numelem=0 ; numelem <= totelem ; numelem++ ) {
		var qtot = 0;
		qtot = parseInt(this.document.myForm.elements[numelem].value);

		// Se la quantit&agrave; non &egrave; un numero
		if ( (isNaN(qtot)) || (qtot < 0)) {
			document.myForm.elements[numelem].value = 0;
		}
	}
}

function openWindow(l, t, w, h,URL, nome, scroll, redim) {
   var windowprops = "location=no,scrollbars=" + scroll + ",menubars=no,toolbars=no,resizable=" + redim +  ",left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;
	 popUpWin = window.open(URL,nome,windowprops);
}
function openWindowMarginalita(l, t, w, h, URL, nome, scroll, redim) {
    var windowprops = "location=no,scrollbars=" + scroll + ",menubars=no,toolbars=no,resizable=" + redim + ",left=" + l + ",top=" + t + ",width=" + w + ",height=" + h;
    popUpWin = window.open(URL, nome, windowprops);
}
///
/// Funzione per inizializzare il menu
///
var startList = function() {
    if (document.all && document.getElementById) {
        navRoot = document.getElementById('menu_a_2livelli');
        for (i = 0; i < navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName == 'LI') {
                node.onmouseover = function() {
                    this.className += 'over';
                }
                node.onmouseout = function() {
                    this.className = this.className.replace('over', '');
                }
                for (x = 0; x < node.childNodes.length; x++) {
                    nodeInternalUl = node.childNodes[x];
                    if (nodeInternalUl.nodeName == 'UL') {
                        for (y = 0; y < nodeInternalUl.childNodes.length; y++) {
                            nodeInternalLi = nodeInternalUl.childNodes[y];
                            if (nodeInternalLi.nodeName == 'LI') {
                                nodeInternalLi.onmouseover = function() {
                                    this.className += 'overInternal';
                                }
                                nodeInternalLi.onmouseout = function() {
                                    this.className = this.className.replace('overInternal', '');
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

window.onload = startList;
