function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen)  {
    var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
    var int_windowTop = (screen.height - a_int_windowHeight) / 2;
    var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
    var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties);
	
    if (parseInt(navigator.appVersion) >= 4)
        obj_window.window.focus();
}

/****************************************************************/

/***** funzione che regola la scelta della taglia nelle pagine della categoria e del prodotto***/

function scegliTaglia(questo, dreambox) {
	mioForm = eval("document." + questo);
	if (mioForm.sizes.type == 'select-one') {
		if (mioForm.sizes.selectedIndex == 0) {
			alert('You have to choose a size for this product');
			mioForm.action = 'javascript:void(0);';
		}
		else
			inviaDati(mioForm, dreambox);
	}
	else if (mioForm.sizes.type == 'hidden')
		inviaDati(mioForm, dreambox);
}

function inviaDati(mioForm, dreambox) {
	var itemId = mioForm.itemsId.value;
	if (mioForm.sizes.type == 'select-one')
		var quantityId = mioForm.sizes.options[mioForm.sizes.selectedIndex].value;
	else
		var quantityId = mioForm.sizes.value;
	
	if (dreambox)
		mioForm.action = baseURL + '/mystyledrops/wishlist/add/' + itemId + '/' + quantityId;
	else
		mioForm.action = baseURLHTTPS + '/cart/add/' + itemId + '/' + quantityId;
	
	mioForm.submit();
}

/************* funzioni che si trovavano nel file common.js*******************/

/***** sniffer del browser *****/

function searchNav(where,what) {
    trova = eval("navigator."+where+".toLowerCase().indexOf(\""+what+"\")");
	
    return trova;
}

function checkOs() {
    if (searchNav("userAgent","win") >= 0)
        Os = "win";
    else if (searchNav("userAgent","linux") >= 0)
        Os = "linux";
    else if (searchNav("userAgent","mac") >= 0)
        Os = "mac";
    else
        Os = "other";
}

function checkBr() {
    if (searchNav("userAgent","opera") >= 0)
        Br = "OP";
    else if (searchNav("userAgent","msie") >= 0)
        Br = "IE";
    else if ((document.layers) && (searchNav("appName","netscape") >= 0))
        Br = "NN";
    else if (searchNav("userAgent","gecko") >= 0)
        Br = "MOZ";
    else if (document.getElementById)
        Br = "modern";
    else
        Br = "other";
}

function rileva(param) {
    var num = param.length+1;
    var initString = (searchNav("userAgent",param))+num;
    var sottoStringa = navigator.userAgent.substring(initString,navigator.userAgent.length);
    
    return sottoStringa;
}

function checkVersion() {
    if (Br == "IE")
        version = parseFloat(rileva("msie", "vers"));
    else if (Br == "OP")
        version = parseFloat(rileva("opera", "vers"));
    else if (Br == "MOZ")
        version = parseFloat(rileva("rv", "vers"));
    else
        version = parseFloat(navigator.appVersion.substring(0,navigator.appVersion.length));
}

function getObjModel() {
    if (document.getElementById)
        dom = "modern";
    else if (document.layers)
        dom = "layers";
    else if (document.all)
        dom = "all";
}

function inizializza() {
    checkOs();
    checkBr();
    checkVersion();
    getObjModel();
}

/*x = navigator.appVersion;
if (navigator.appName == 'Microsoft Internet Explorer') 
	ver = x.charAt(22)+x.charAt(23)+x.charAt(24)
else 
	ver = x.charAt(0)+x.charAt(1)+x.charAt(2)
alert(navigator.appName+' '+ver);*/

inizializza();

/****************************************************************/

/***** funzione per il cambio delle immagini *****/

function cambiaImg(dove, cosa) {
    eval("document.images[\"" + dove + "\"].src = " + cosa + ".src;");
}

//altre funzioni per il cambio delle immagini si trovano negli script della home

/***** script per individuare lalarghezza della pagina e aggiustare i livelli *****/

largWin = false;
dimLiv = false;

function rilevaLarghezza() {
    if (Br == "IE")
        largWin = document.body.offsetWidth;
    else
        largWin = window.innerWidth;

    if (largWin <= 800)
        dimLiv = 800-340;
    else if (largWin >= 1006)
        dimLiv = 1024-338;
    else
        dimLiv = largWin-338;
}

/****************************************************************/

/***** funzione per la gestione dei cookie *****/

//la scrittura del cookie in home  gestita nel js della home

function scriviCookie(name, value) {
    var argv = scriviCookie.arguments;
    var argc = scriviCookie.arguments.length;
    var path = (argc>2)?argv[2]:null;
    var domain = (argc>3)?argv[3]:null;
    var expires = (argc>4)?argv[4]:null;
    var secure = (argc>5)?argv[5]:false;

    document.cookie = name+"="+escape(value)
    + ((expires == null) ? "" : ("; expires=" +expires.toGMTString()))
    + ((path == null) ? "" : ("; path=" +path))
    + ((domain == null) ? "" : ("; domain=" +domain()))
    + ((secure == true) ? "; secure" :"");
}



function leggiCookie(name) {
    var arg = name +"=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;

    while (i<clen) {
        var j = i+alen;
        if (document.cookie.substring(i,j) == arg)
            return leggiValCookie(j);
        i = document.cookie.indexOf(" ",i)+1;
        if (i == 0) break;
    }
    return null;
}

function leggiValCookie(offset) {
    var endstr = document.cookie.indexOf(";", offset);

    if (endstr ==- 1)
        endstr = document.cookie.length;

    return unescape (document.cookie.substring(offset, endstr));
}

function cancellaCookie(name) {
    var exp = new Date();

    exp.setTime(exp.getTime()-1);

    var cval = leggiCookie(name);
    
    document.cookie = name+"="+cval+"; expires="+exp.toGMTString();
}

/****************************************************************/

/***** script che scrive gli opgroup in IE 5 *****/


function scriviVoceSelect(voce, classe) {
    if ((Os == "win") && (Br == "IE") && (version < 5.5)) {
        document.writeln("<option class=\""+classe+"\" style=\"font-weight:bold\">"+voce+"</option>");
    }
}

function cambiaSelect(param) {
    if (param.indexOf('.html') >- 1)
        this.location.href = param;
}	

/***** funzione per togliere il tratteggio *****/

function togliTratteggio()
{
    togliTratteggio2("a");
    togliTratteggio2("area");
    togliTratteggio2("button");
}

function togliTratteggio2(tag)
{
    for (var i=0;i<document.getElementsByTagName(tag).length;i++)
    {
        var linkTratt = document.getElementsByTagName(tag).item(i);

        if(Br == "IE")
            linkTratt.onfocus = togliTratt;
        else
            linkTratt.addEventListener("focus", togliTratt, false);
    }
}

function togliTratt()
{	
    this.blur();
}

/****************** fine di common.js*************/

/***************** inizio di home.js *************/

/***** se il browser  IE alcuni stili vengono sovrascritti *****/

if ((Br == "IE") && (Os != "mac")) 
{
    document.writeln("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/home/IE.css\" />");
}

/****************************************************************/

/***** funzione che aggiusta la dimensione dei livelli, al caricamento e al ridimensionamento ***/

dimLiv = false;
//largWin  definito nella funzione rilevaLarghezza

function aggiustaLiv() {
    if (largWin <= 800) {
        document.writeln("<style type=\"text/css\">");
        document.writeln("#container{width:778px}");
        document.writeln("#barraNera{width:778px}");
        document.writeln("#footer{width:778px}");
        document.writeln("</style>");
    }
    else if (largWin >= 1002) {
        document.writeln("<style type=\"text/css\">");
        document.writeln("#container{width:1002px}");
        document.writeln("#barraNera{width:1002px}");
        document.writeln("#footer{width:1002px;}");
        document.writeln("</style>");
    }
    
    document.writeln("<style type=\"text/css\">");
    document.writeln(".shop {width:" + dimLiv + "px;}");
    document.writeln(".sinistra {width:" + dimLiv + "px;}");
    document.writeln("#boxBasso {width:" + dimLiv + "px;}");
    document.writeln("#boxPromoSotto {width:" + (dimLiv + 5) + "px;}");
    document.writeln(".boxIframe {width:" + dimLiv + "px;}");
    document.writeln("</style>");
}

function ridimLiv() {
    if (largWin <= 778) {
        document.getElementById("container").style.width = "778px";
        document.getElementById("barraNera").style.width = "778px";
        document.getElementById("footer").style.width = "778px";
    }
    else if (largWin >= 1002) {
        document.getElementById("container").style.width = "1002px";
        document.getElementById("barraNera").style.width = "1002px";
        document.getElementById("footer").style.width = "1002px";
    }
    else {
        document.getElementById("container").style.width = "100%";
        document.getElementById("barraNera").style.width = "100%";
        document.getElementById("footer").style.width = "100%";
    }

    aggiustaClassi("shop","sinistra","boxIframe");
    document.getElementById("boxBasso").style.width = dimLiv.toString()+"px";
}

function aggiustaClassi(param1, param2, param3) {
    var divs = document.getElementsByTagName("div");
    
    for (var i=0;i<divs.length;i++) {
        if (divs.item(i).className.indexOf(param1)>-1)
            divs.item(i).style.width = dimLiv.toString()+"px";
        else if (divs.item(i).className.indexOf(param2)>-1)
            divs.item(i).style.width = dimLiv.toString()+"px";
        else if (divs.item(i).className.indexOf(param3)>-1)
            divs.item(i).style.width = dimLiv.toString()+"px";
    }
}

/****************************************************************/

/***** funzione che si occupa di cambiare l'immagine del "Toll Free *****/

tollFree800 = new Image();
tollFree800.src = staticURL + "/img/home/tollfree800.gif";
tollFree1024 = new Image();
tollFree1024.src = staticURL + "/img/home/tollfree1024.gif";

function aggiustaToll(alt) {
    if (largWin <= 900) {
        var ris = "800";
        var larg = "170px";
        var margini = "";
    }
    else {
        var ris = "1024";
        var larg = "328px";
        var margini = "margin-top:3px;";
    }
    document.writeln("<a href=\"/interne/designer/index.php\"><img id=\"imgToll\" title=\""+alt+"\" alt=\""+alt+"\" src=\"" + staticURL + "/img/home/tollfree"+ris+".gif\" style=\"width:"+larg+";height:34;"+margini+"\" /></a>");
}

/****************************************************************/

/***** funzione per la lettura del cookie che contiene il nome della tendina in home *****/


/*funzioni specifiche per Styledrops*/
function leggiCookieIframe() {
    if (leggiCookie("homeIframe") != null) {
        //eseguiH3(leggiCookie("homeIframe"));
        cancellaCookie("homeIframe");
    }
}

/****************************************************************/

/***** funzioni che cambiano le immagini - adattate per via degli effetti di transizione *****/

//funzione leggermente adatta perch prenda due immagini globali
function cambiaImg2() {
    eval("document.images[\""+tempImages1+"\"].src="+tempImages2+".src;");
}

//funzioni "adattate" per far funzionare le cose con le promozioni
function cambiaImg3() {
    tempImages3.src = tempImages4.src;
}

//funzioni "adattate" per far funzionare le cose con le promozioni
function cambiaImg4() {
    tempImages5.src = tempImages6.src;
}

/****************************************************************/

/***** funzione che si occupa degli effetti di transizione: carica l'immagine ed effettuta la transizione *****/

tempImages1 = false; 	//variabili globali necessari per passare i parametri alla funzione cambiaImg
tempImages2 = false;  	//c' il richiamo alla funzione cambiaImg che si trova in un altro file
tempImages3 = false;
tempImages4 = false;
tempImages5 = false; 	//variabili globali necessari per passare i parametri alla funzione cambiaImg
tempImages6 = false; 	//c' il richiamo alla funzione cambiaImg che si trova in un altro file

function loading(dove,cosa,percorso,numTrans) {
    eval(cosa+"=new Image();");
    eval(cosa+".src=\""+percorso+"\";");
	
    var doveImg = document.images[dove];
	
    tempImages1 = dove;
    tempImages2 = cosa;

    if(Br == "IE") {
        if(version <= 5.5) {
            eval(cosa+".onload=cambiaImg2");
        }
        else {
            doveImg.filters.revealTrans.Transition = Math.floor(numTrans);
            doveImg.filters.revealTrans.apply();
            
            eval ("if ("+cosa+".complete) cambiaImg2();");
            eval(cosa+".onload=cambiaImg2;");
            codice = doveImg.id+".filters.revealTrans.play();";
            j = setTimeout(codice, 2000);
        }
    }
    else
        eval(cosa+".onload=cambiaImg2");
}

/****************************************************************/

/***** funzione che gestisce la colorazione delle scritte all'interno delle tendine *****/

function assegnaH5() {
    var titoli = document.getElementsByTagName("h5");

    for (i=0;i<titoli.length;i++) {
        if (Br == "IE") {
            titoli.item(i).onmouseover = coloraH5;
            titoli.item(i).onclick = coloraH5;
            titoli.item(i).onmouseout = scoloraH5;
        }
        else {
            titoli.item(i).addEventListener("mouseover", coloraH5, false);
            titoli.item(i).addEventListener("click", coloraH5, false);
            titoli.item(i).addEventListener("mouseout", scoloraH5, false);
        }
    }
}

function coloraH5()	{
    this.style.background = "#4486AE";
    this.getElementsByTagName("a").item(0).style.fontWeight = "bold";
    this.getElementsByTagName("u").item(0).style.visibility = "visible";
}

function scoloraH5(evt) {
    this.style.background = "transparent";
    this.getElementsByTagName("a").item(0).style.fontWeight = "normal";
    this.getElementsByTagName("u").item(0).style.visibility = "hidden";
}

/****************************************************************/

/***** funzione che apre/chiude le scritte all'interno delle tendine *****/

function chiudiStilisti() {
    var questiDIV = document.getElementsByTagName("div");

    for (var i=0;i<questiDIV.length;i++) {
        if ((questiDIV.item(i).className == "stilisti") && (questiDIV.item(i).style.display == "block")) {
            questiDIV.item(i).style.display = "none";
        }
    }

    var questiH5 = document.getElementsByTagName("h5");

    for (var i=0;i<questiH5.length;i++) {
        var linkST = questiH5.item(i).getElementsByTagName("a");

        for (var j=0; j<linkST.length;j++) {
            if (linkST.item(j).style.fontWeight == "bold") {
                /* per brevit ripeto qui il contenuto del file assegnaH5 */
                linkST.item(j).style.fontWeight = "normal";
                questiH5.item(i).style.background = "transparent";
                questiH5.item(i).getElementsByTagName("u").item(0).style.visibility = "hidden";

                if (Br == "IE")
                    questiH5.item(i).onmouseout = scoloraH5;
                else
                    questiH5.item(i).addEventListener("mouseout", scoloraH5, false);
            }
        }
    }
}

// il parametro  dato dal this lanciato dal link
function mostraLink(param) { 
    chiudiStilisti();

    var h5 = param.parentNode;
    var divStilisti = param.parentNode.nextSibling;
    
    divStilisti.style.display = "block";
    param.style.fontWeight = "bold";

    if (Br == "IE")
        h5.onmouseout = annulla;
    else
        h5.removeEventListener("mouseout", scoloraH5, false);
}

/****************************************************************/

/***** funzione per il movimento delle tendine *****/

lockMove = false;
lockMove2 = false;
lockMove2Rid = false; // il lock per la funzione ridotta

//da impostare a seconda del browser

if (Br == "OP") {
    velInterv = 8; 	//velocit intervallo
    pixPerc = 15;	//pixel percorsi
}
else 	//in tutti gli altri casi, soprattutto per IE
{	
    velInterv = 8; 	//velocit intervallo
    pixPerc = 5;	//pixel percorsi
}

function muovi(livello, partenza, arrivo) {
    if (lockMove == true) 	//nel caso in cui ci sia gi un movimento in corso lo cancella
        clearInterval(w);

    lockMove = true;
    raggiungi = arrivo;
    posAttuale = partenza;
	
    var inviaDati = "vai(\""+livello+"\")";
    w = setInterval(inviaDati,velInterv);
}

function vai(livello) {
    if ((lockMove2 == false) && (posAttuale < raggiungi)) {
        lockMove2 = true;
        posAttuale += pixPerc;
        document.getElementById(livello).style.top = posAttuale+"px";
        lockMove2 = false;
    }
    else {
        clearInterval(w);
        lockMove = false;
    }
}

/* per evitare i conflitti tra i vari setInterval la funzione di 
 * movimento stata in pratica ricopiata qui sotto, togliendo la parte non necessari: 
 * la funzione viene richiamata una sola volta, qui necessita di un solo lock */

function muoviRidotto(livello, partenza, arrivo) {
    raggiungiRid = arrivo;
    posAttualeRid = partenza;
	
    var inviaDati = "vaiRidotto(\""+livello+"\")";
	
    v = setInterval(inviaDati, velInterv);
}

function vaiRidotto(livello) {
    if ((lockMove2Rid == false) && (posAttualeRid < raggiungiRid)) {
        lockMove2Rid = true;
        posAttualeRid += pixPerc;
        document.getElementById(livello).style.top = posAttualeRid+"px";
        lockMove2Rid = false;
    }
    else
        clearInterval(v);
}

/****************************************************************/

/***** da qui la parte che regola il comportamento di tutta l'home page *****/

var blueOver = "#1F5B82";
var lockH3 = false; 		// il lock introdotto per evitare che i vari eventi vadano in conflitto
var catAttiva = false; 		// la categoria attiva. All'inizio non ce ne sono
var oldIframe = new Array(false, false); // variabile per memorizzare l'iframe precedente
var shopAttivo = false; 	// lo shop attivo. All'inizio non ce ne sono
var shop1Status = false; 	// indica se lo Shop ha gi effettuato il cambiamento di colore dopo il primo click
var shop2Status = false;
var shop3Status = false;
var shopTemp = false; 		// variabile di servizio per memorizzare il click sui pulsanti in basso
var posizioniShop = new Array("shop1", "shop2", "shop3");	// array che memorizza la posizione delle categorie

var pos = new Array();
pos[0] = 123; //coordinate verticali dello shop1
pos[1] = 177; //coordinate verticali dello shop2 (e dell'iframe)
pos[2] = 231; //coordinate verticali dello shop3
pos[3] = 397; //coordinate verticali della barra con i link in basso (si chiama "boxPulsantiShop)"
pos[4] =- 68; //cordinate a cui va posizionato l'iframe per il movimento. Si ricava da pos[1]-l'altezza del box dell'iframe -l'altezza di boxPulsantiShop
pos[5] = 152; //cordinate a cui va posizionato il boxPulsantiShop. Si ricava da pos[1] - l'altezza del box

function assegnaShop() {
    if (dom == "modern") 	//questa parte viene eseguita solo se il dom ha document.getElementById
    {
        for (i=1;i<=3;i++) {
            var shop = "shop" + i;
            var shop = document.getElementById(shop);
			
            if(Br == "IE") {
                shop.onmouseover = coloraShop;
                shop.onmouseout = scoloraShop;
            }
            else {
                shop.addEventListener("mouseover", coloraShop, false);
                shop.addEventListener("mouseout", scoloraShop, false);
            }
        }
    }

    var titoli = document.getElementsByTagName("h3");

    for (i=0;i<titoli.length;i++) {
        if (Br == "IE") {
            if (dom == "modern") {
                titoli.item(i).onmouseover = coloraH3;
                titoli.item(i).onmouseout = scoloraH3;
            }
        }
        else {
            if (dom == "modern") {
                titoli.item(i).addEventListener("mouseover", coloraH3, true);
                titoli.item(i).addEventListener("mouseout", scoloraH3, true);
            }
        }
    }
}

function coloraShop() {
    this.style.background = blueOver;
    //colora la categoria "uomo", donna o style. BlueOver  definito nelle variabili globali
    //non  assegnata una classe perch il livello si ridimensiona attravero js
    //negli altri casi  assegnata una classe
					
    this.getElementsByTagName("div").item(0).className = "menuCategoriesHover"; //scurisce la striscia con i tasti

    var titoli = this.getElementsByTagName("h3");
    
    for (i=0;i<titoli.length;i++) {
        //blocca il cambio di colore sui tasti, nel caso del mouse over sui tasti stessi
        if(lockH3 == false)
            titoli.item(i).className = "h3Scuro"; //scurisce i tasti
    }
	
    cambiaImgTitoli(this, "Over"); //richiamo la funzione che cambia le imgs nei tre blocchi
}

function scoloraShop() {
    this.style.background = "#347297";
    this.getElementsByTagName("div").item(0).className = "menuCategories";

    var titoli = this.getElementsByTagName("h3");

    for (i=0;i<titoli.length;i++) {
        if (lockH3 == false)
            titoli.item(i).className = "";
    }
	
    cambiaImgTitoli(this, "Out");
}

function cambiaImgTitoli(param1, param2) {
    //param1 corrisponde a this che in questo caso  l'elemento "shop1" o "shop2" o "shop3"
    if (param2 == "Out")
        param2 = "";
    if (param1.id == "shop1")
        menuCat = "Wom";
    if (param1.id == "shop2")
        menuCat = "Men";
    if (param1.id == "shop3")
        menuCat = "Style";

    var temp1 = "imgShop_"+menuCat.toLowerCase();
    var temp2 = "shop"+menuCat+param2;

    cambiaImg(temp1, temp2);
    // la funcione cambiaImg si trova nella libreria di base
    //il nome delle immagini si trova in un file di preload

    var temp1 = "imgFreccia_"+menuCat.toLowerCase();
    var temp2 = "frecciaShop"+param2;
	
    cambiaImg(temp1, temp2);
}

function coloraH3() {
    lockH3 = true; //blocca la colorazione dei tasti ad opera della funzione coloraShop

    for (i=0;i<this.parentNode.childNodes.length;i++) {
        var tastoH3 = this.parentNode.childNodes.item(i);
        //colora i tasti di scuro
        tastoH3.className = "h3Scuro";
    }

    this.className = "h3Hover";	//mouse over sul tasto interessato
}

function scoloraH3() {
    this.className = "h3Scuro"; //mouseOut
    lockH3 = false;				//sblocca la funzione coloraShop che pu agire sui tasti h3
}

/**** da qui la parte che regola il comportamento al click*/

function eseguiH3(param) {
    param = document.getElementById(param);

    var primoClick;

    (catAttiva == false) ? (primoClick = true) : (primoClick = false);
	
    //ri-assegno le variabili globali
    //memorizzo i nomi dei due iframe che si sono mossi prima dell'iframe corrente

    if (oldIframe[0] != false)
        oldIframe[1] = oldIframe[0];
    if (catAttiva != false)
        oldIframe[0] = catAttiva.replace("shop", "iframe");
	
    //imposto la categoria attiva
	
    catAttiva = param.id;

    if (catAttiva.indexOf("wom") >- 1)
        shopAttivo = "shop1";
    else if (catAttiva.indexOf("men") >- 1)
        shopAttivo = "shop2";
    else if (catAttiva.indexOf("style") >- 1)
        shopAttivo = "shop3";

    disabilita(param, primoClick);
    assegnaComportamentiClick(param);

    var iframeAttivo = cambiaPosizioni(primoClick); //cambia le posizione degli shop e cambia la promozione
    
    if(Os == 'mac') {
        document.getElementById(iframeAttivo).style.zIndex = 90;
        document.getElementById(iframeAttivo).style.visibility = 'visible';
        document.getElementById(iframeAttivo).style.marginTop = '240px';
    }

    cambiaPulsanti(shopAttivo);		//cambia i pulsanti in basso
    chiudiStilisti(iframeAttivo); 	//chiude i menu dei link se sono aperti. Si trova in mostraStilisti.js
    muoviIframe(iframeAttivo);

    if (primoClick)
        muoviPulsanti();

    cambiaImgsIframe(iframeAttivo);
    scriviCookie("homeIframe", iframeAttivo);
}

function annulla() {
    return false;
}

function disabilita(param, primoClick) {
    if (primoClick == true) 	//viene eseguito solo al primo click
    {
        //diasbilita tutti gli eventi esistenti

        for (i=1;i<=3;i++) 	//disabilita gli eventi sui div "shop"
        {
            var shop = "shop"+i;
            var shop = document.getElementById(shop);

            if(Br == "IE") {
                shop.onmouseover = annulla;
                shop.onmouseout = annulla;
            }
            else {
                shop.removeEventListener("mouseover", coloraShop, false);
                shop.removeEventListener("mouseout", scoloraShop, false);
            }

            var h3 = shop.getElementsByTagName("h3");

            for (j=0;j<h3.length;j++) 	//disabilita gli venti su tutti gli h3
            {
                if(Br == "IE") {
                    h3.item(j).onmouseover = annulla;
                    h3.item(j).onmouseout = annulla;
                }
                else {
                    h3.item(j).removeEventListener("mouseover", coloraH3, true);
                    h3.item(j).removeEventListener("mouseout", scoloraH3, true);
                }
            }
        }
    }
}

function assegnaComportamentiClick(param) {
    var questoShop = document.getElementById(shopAttivo);
    var titoli = questoShop.getElementsByTagName("h3");

    /*questa parte viene eseguita solo nel caso in cui la categoria non sia mai stat cliccata*/

    if (eval(shopAttivo+"Status==false")) {
        questoShop.style.background = blueOver;
        questoShop.getElementsByTagName("div").item(0).className = "menuCategoriesHover";
        cambiaImgTitoli(questoShop, "Over");
        eval(shopAttivo+"Status=true");
    }

    /*questa parte viene eseguita a ogni click*/

    for (i=0;i<titoli.length;i++) {
        titoli.item(i).className = "h3Scuro"; //scurisce i tasti
		
        if (titoli.item(i).id != param.id) {
            if (Br == "IE") {
                titoli.item(i).onmouseover = over2;
                titoli.item(i).onmouseout = out2;
            }
            else {
                titoli.item(i).addEventListener("mouseover", over2, true);
                titoli.item(i).addEventListener("mouseout", out2, true);
            }
        }
        else {
            param.className = "h3Hover";
            param.style.cursor = "default";
			
            if (Br == "IE") {
                param.onmouseover = annulla;
                param.onmouseout = annulla;
            }
            else {
                param.removeEventListener("mouseover", over2, true);
                param.removeEventListener("mouseout", out2, true);
            }
        }
    }
}

function over2() {
    this.className = "h3Hover";

    (Br == "IE") ? (cursoreLink = "hand") : (cursoreLink = "pointer");
    
    this.style.cursor = cursoreLink;
}

function out2() {
    this.className = "h3Scuro";
}

/*** regola comparsa, la scomparsa e il movimento dei livelli*/

function cambiaPosizioni(primoClick) 
{
    /* parte che si occupa del cambio di categoria*/

    if ((primoClick == true) && (shopAttivo == 'shop1')) 	//lo esegue solo nel caso in cui
        cambiaPromo();
		
    //non sia mai stato cliccato e ci sia shop1 in prima posizione

    if (shopAttivo != posizioniShop[0]) 	//se la categoria non  in prima posizione, inverto le cose
    {
        cambiaPromo();
		
        document.getElementById(shopAttivo).style.visibility = "visible"; //lo rendo visibile, se non lo  gi
        document.getElementById(shopAttivo).style.top =+ pos[0]+"px";

        for (i=0;i<posizioniShop.length;i++) {
            if (shopAttivo == posizioniShop[i]) {
                document.getElementById(posizioniShop[0]).style.top = pos[i]+"px";
                var m = i;
            }
            else {
                //nascondo gli altri Shop
                document.getElementById(posizioniShop[i]).style.visibility = "hidden";
            }
        }

        posizioniShop[m] = posizioniShop[0]; //vario le posizioni nell'array
        posizioniShop[0] = shopAttivo;
    }

    return iframeAttivo = catAttiva.replace("shop", "iframe");
}

function muoviIframe(param) {
    var iframeAttivo = param;

    /*parte che si occupa del movimento degli Iframe*/
    /*assegnando le varie visibilit mi assicuro che gli iframe siano visualizzati nell'ordine giusto*/
    /*visibilit degli altri i-frame*/

    var subStrIframe = iframeAttivo.substring(0,iframeAttivo.lastIndexOf("_")); //estraggo una sottostringa del nome dell'iframe

    for (i=0;i<document.getElementsByTagName("div").length;i++) {
        var divIframe = document.getElementsByTagName("div").item(i);

        if ((divIframe.id != oldIframe[0])
        &&(divIframe.id != oldIframe[1])
        &&(divIframe.id != iframeAttivo)
        &&(divIframe.id.indexOf(subStrIframe) >- 1))
        {
            divIframe.style.zIndex = 1;
        }
    }

    /*visibilit dell'iframe che si  mosso per terz'ultimo*/
    
    if (oldIframe[1] != false) {
        document.getElementById(oldIframe[1]).style.zIndex = 2;
        document.getElementById(oldIframe[1]).style.visibility = "visible";
    }

    /*visibilit dell'iframe che si  mosso in precedenza*/

    if (oldIframe[0] != false) {
        document.getElementById(oldIframe[0]).style.zIndex = 3;
        document.getElementById(oldIframe[0]).style.visibility = "visible";
    }

    /*visibilit dell'iframe che si muove*/

    macPx = (Os == "mac") ? ("px") : (""); //Mac vuole per forza l'indicazione px (nella riga sotto)

    document.getElementById(iframeAttivo).style.top = pos[4]+macPx; //porto in alto il livello
    document.getElementById(iframeAttivo).style.visibility = "visible";
    document.getElementById(iframeAttivo).style.zIndex = 4;

    //movimento

    if (Br != "MOZ" && Os != "mac")
        muovi(iframeAttivo, pos[4], pos[1]);
}

/**viene eseguita una sola volta*/

function muoviPulsanti() {
    if (Br != "MOZ" && Os != "mac") {
        document.getElementById("boxPulsantiShop").style.top = pos[3]+macPx;
        document.getElementById("boxPulsantiShop").style.visibility = "visible";
        muoviRidotto("boxPulsantiShop", pos[5], pos[3]);
    }
    else {
        document.getElementById("boxPulsantiShop").style.top = pos[5];
        document.getElementById("boxPulsantiShop").style.visibility = "visible";
    }

    document.getElementById(posizioniShop[1]).style.visibility = "hidden";
    document.getElementById(posizioniShop[2]).style.visibility = "hidden";
    document.getElementById("filettoBasso").style.visibility = "hidden";
    document.getElementById("boxBasso").style.visibility = "hidden";

    var ricarica;

    (Br == "IE")?(ricarica="javascript:self.location.replace(location.href);"):(ricarica="javascript:self.location.reload();");

    document.getElementById("linkLogo").href = ricarica;
}

/*parte che gestisce il click sui pulsanti*/
	
function cambiaPulsanti(param) 		//param  lo shopAttivo
{ 
    //cambio le immagini
    cambiaImg("imgPulsante1", "pulsante"+posizioniShop[1]);
    cambiaImg("imgPulsante2", "pulsante"+posizioniShop[2]);

    //cambio alt e title
    for (i=1;i<=2;i++)
    {
        if (posizioniShop[i] == "shop1")
        {
            var titolo = "Shop for Women";
            var linkURL = "iframe_wom_shoes";
        }
        else if (posizioniShop[i] == "shop2")
        {
            var titolo = "Shop for Men";
            var linkURL = "iframe_men_shoes";
        }
        else if (posizioniShop[i] == "shop3")
        {
            var titolo = "Shop by Style";
            var linkURL = "iframe_style_prada";
        }

        var link = "linkPulsante"+i;
        var immagine = "imgPulsante"+i;

        document.getElementById(link).title = titolo;
        document.getElementById(immagine).alt = titolo;

        //cambio i link
		
        document.getElementById(link).href = "javascript:eseguiH3('"+linkURL+"')";
    }
}

function cambiaPromo() 
{
    //il percorso dell'immagine  impostato come variabile globale nella home

    loading('imgPromo', 'imgPromoClick', immaginiPromo[shopAttivo][0], 12, "promoGrande");
    document.getElementById("promo").getElementsByTagName("a").item(0).href = immaginiPromo[shopAttivo][1];
    document.getElementById("promo").getElementsByTagName("a").item(0).title = immaginiPromo[shopAttivo][2];
    document.getElementById("imgPromo").alt = immaginiPromo[shopAttivo][2];
}

function cambiaImgsIframe(param)	//param il nome dell'Iframe attivo
{	
    //i nomi delle immagini da caricare sono inseriti in vari array javascript nella pagina
    var stringaPromo = param.replace("iframe", "imgIframe"); //ricavo il nome dell'array relativo a quest'immagine
    var divs = document.getElementById(param).getElementsByTagName("div");
    var elementi = new Array();
    var m = 0;

    for(i=0;i<divs.length;i++)
    {
        if (divs.item(i).className.indexOf("promoEspanso") != -1)
        {
            elementi[m] = divs.item(i);	//non uso array.push perch a IE 5.0 non piace...
            m++;
        }
    }
	
    var promo = new Array();

    promo[0] = elementi[0].getElementsByTagName("a").item(0).getElementsByTagName("img").item(0);	//in
    promo[1] = elementi[1].getElementsByTagName("a").item(0).getElementsByTagName("img").item(0);
    promo[0].id = param+"temp0";	//assegno dei nomi qualsiasi alle immagini
    promo[1].id = param+"temp1";

    eval("imgsOver=new Array("+stringaPromo+"[0],"+stringaPromo+"[1]);");

    /* questa parte  solo il riadattamente della funzione loading, in modo che possa essere applicat in3 parti diverse della pagina, senza che vada in conflitto*/

    //prima immagine promozionale

    promoOver0 = new Image();
    promoOver0.src = imgsOver[0];
    tempImages3 = promo[0];
    tempImages4 = promoOver0;

    if (Br == "IE")
    {
        if(version <= 5.5)
        {
            promoOver0.onload = cambiaImg3;
        }
        else
        {
            promo[0].filters.revealTrans.Transition = Math.floor(12);
            promo[0].filters.revealTrans.apply();

            if (promoOver0.complete) 	//questo controllo  necessario perch le immagini sono talmente piccole
                cambiaImg3();		//da non eseguire l'onload
            else
                promoOver0.onload = cambiaImg3;

            var codice1 = promo[0].id+".filters.revealTrans.play();";
            xx = setTimeout(codice1,2000);
        }
    }
    else
        promoOver0.onload = cambiaImg3;
		
    //seconda immagine promozionale

    promoOver1 = new Image();
    promoOver1.src = imgsOver[1];
    tempImages5 = promo[1];
    tempImages6 = promoOver1;

    if (Br == "IE")
    {
        if(version <= 5.5)
        {
            promoOver1.onload = cambiaImg4;
        }
        else
        {
            promo[1].filters.revealTrans.Transition = Math.floor(12);
            promo[1].filters.revealTrans.apply();

            if (promoOver1.complete)
                cambiaImg4();
            else
                promoOver1.onload = cambiaImg4;
			
            var codice2 = promo[1].id+".filters.revealTrans.play();";

            yy = setTimeout(codice2,2000);
        }
    }
    else
        promoOver1.onload = cambiaImg4;
}

/****************************************************************/

/***** precaricamento di tutte le immagini necessarie agli script *****/

function preloadImgs() {
    frecciaShop = new Image();
    frecciaShop.src = staticURL + "/img/home/menuShop/azzurro/freccia.gif";
	
    frecciaShopOver = new Image();
    frecciaShopOver.src = staticURL + "/img/home/menuShop/blu/fecciablu.gif";

    shopMen = new Image();
    shopMen.src = staticURL + "/img/home/menuShop/azzurro/shopforman.gif";

    shopMenOver = new Image();
    shopMenOver.src = staticURL + "/img/home/menuShop/blu/shopformenblu.gif";

    shopWom = new Image();
    shopWom.src = staticURL + "/img/home/menuShop/azzurro/shopforwoman.gif";

    shopWomOver = new Image();
    shopWomOver.src = staticURL + "/img/home/menuShop/blu/shopforwomenblu.gif";

    shopStyle = new Image();
    shopStyle.src = staticURL + "/img/home/menuShop/azzurro/shopbystyle.gif";

    shopStyleOver = new Image();
    shopStyleOver.src = staticURL + "/img/home/menuShop/blu/shopbystyleblu.gif";

    pulsanteshop1 = new Image();
    pulsanteshop1.src = staticURL + "/img/home/shopforwomen.gif";

    pulsanteshop2 = new Image();
    pulsanteshop2.src = staticURL + "/img/home/shopformen.gif";

    pulsanteshop3 = new Image();
    pulsanteshop3.src = staticURL + "/img/home/shopby.gif";
}

/****************************************************************/
/****************************************************************/

/***** funzione per il random dell'immagine in home page *****/

function randomNumber(min,max) {
    var m = min;
    var n = max;
    var r = m+Math.round(Math.random()*n);
    return(r);
}

function randomImgHome() {
    var imgsHome = new Array();
    imgsHome[0] = new Array(baseURL + '/prada-handbags.html', staticURL + '/img/home/donna45.jpg');
    imgsHome[1] = new Array(baseURL + '/fendi-handbags-62.html', staticURL + '/img/home/donna61.jpg');
    imgsHome[2] = new Array(baseURL + '/celine-handbags-274.html', staticURL + '/img/home/celinehandbags.jpg');
    /*imgsHome[0] = new Array(baseURL + "/prada-shoes.html", "donna45.jpg");
    imgsHome[1] = new Array(baseURL + "/viewAll-66.html", "donna40.jpg");
    imgsHome[2] = new Array(baseURL + "/shoes-44.html", "donna51.jpg");
    imgsHome[3] = new Array(baseURL + "/shoes-82.html", "donna48.jpg");
    imgsHome[4] = new Array(baseURL + "/shoes-82.html", "donna62.jpg");
    imgsHome[5] = new Array(baseURL + "/shoes-28.html", "donna1.jpg");
    imgsHome[6] = new Array(baseURL + "/prada-shoes.html", "donna45.jpg");
    imgsHome[7] = new Array(baseURL + "/shoes-84.html", "donna48.jpg");
    imgsHome[8] = new Array(baseURL + "/shoes-62.html", "donna61.jpg");
    imgsHome[9] = new Array(baseURL + "/shoes-33.html", "donna45.jpg");
    imgsHome[10] = new Array(baseURL + "/shoes-84.html", "donna48.jpg");
    imgsHome[11] = new Array(baseURL + "/shoes-78.html", "donna63.jpg");
    imgsHome[12] = new Array(baseURL + "/shoes-33.html", "donna45.jpg");
    imgsHome[13] = new Array(baseURL + "/viewAll-86.html", "donna40.jpg");
    imgsHome[14] = new Array(baseURL + "/shoes-82.html", "donna62.jpg");
    imgsHome[15] = new Array(baseURL + "/viewAll-86.html", "donna40.jpg");*/
    
    var r = randomNumber(0, 2);
    
    document.writeln("<a href=\"" + imgsHome[r][0] + "\"><img src=\"" + imgsHome[r][1] + "\" alt=\"\" border=\"0\" id=\"imgPromo\" /></a>");
}

/***************************************************************/

/***** immagini per le promozioni *****/

function assegnaImgsPromo() {
    var ImgsDonna = new Array();
    ImgsDonna[0] = new Array(staticURL + '/img/home/donna45.jpg', 'prada-handbags.html', '');
    ImgsDonna[1] = new Array(staticURL + '/img/home/donna61.jpg', 'fendi-handbags-62.html', '');
    ImgsDonna[2] = new Array(staticURL + '/img/home/celinehandbags.jpg', 'celine-handbags-274.html', '');
    
    var ImgsUomo = new Array();
    ImgsUomo[0] = new Array(staticURL + '/img/home/donna43.jpg', 'gucci-men-s-shoes-48.html', '');
    
    var ImgsStyle = new Array();
    ImgsStyle[0] = new Array(staticURL + '/img/home/donna48.jpg', 'interne/designer/index.php', '');
    ImgsStyle[1] = new Array(staticURL + '/img/home/womengenerica.jpg', 'interne/designer/index.php', '');
    
    immaginiPromo = new Array();
    immaginiPromo['shop1'] = ImgsDonna[randomNumber(0, 2)];
    immaginiPromo['shop2'] = ImgsUomo[randomNumber(0, 0)];
    immaginiPromo['shop3'] = ImgsStyle[randomNumber(0, 1)];
}

function avviso() {
    if (leggiCookie("divPopUp") == null) {
        setTimeout("document.getElementById('divPopUp').style.display='block'", 2000);
        scriviCookie("divPopUp","true");
        setTimeout("chiudi()", 15000);
    }
}

function avvisoIndex() {
    if (leggiCookie("divPopUpToll") == null) {
        setTimeout("document.getElementById('divPopUpToll').style.display='block'", 2000);
        scriviCookie("divPopUpToll","true");
        setTimeout("chiudiToll()", 30000);
    }
}

function avvisoIndex1() {
    if (leggiCookie("divPopUpToll") == null) {
        setTimeout("document.getElementById('divPopUpToll').style.display = 'block'", 2000);
        scriviCookie("divPopUpToll", "true");
        //setTimeout("chiudiToll()", 15000);
    }
}

function chiudi() {
    document.getElementById('iframePopUp').style.display = 'none';
    document.getElementById('divPopUp').style.display = 'none';
}

function chiudiToll() {
    document.getElementById('iframePopUp').style.display = 'none';
    document.getElementById('divPopUpToll').style.display = 'none';
}

/****************************************************************/

/***** immagine che scende *****/

lockMove3Rid = false;

function muoviRidotto3(livello, partenza, arrivo, act, vel) {
    raggiungiRid2 = arrivo;
    posAttualeRid2 = partenza;
    var inviaDati = "vaiRidotto2(\""+livello+"\",\""+act+"\","+vel+")";
    qv = setInterval(inviaDati,4);
}

function vaiRidotto2(livello, act, vel) {
    if ((lockMove3Rid==false) && (posAttualeRid2<raggiungiRid2)) {
        lockMove3Rid = true;
        posAttualeRid2 += vel;
        eval("document.getElementById(livello).style."+act+"='"+posAttualeRid2+"px';");
        lockMove3Rid = false;
    }
    else {
        clearInterval(qv);
        if (act == "left") {
            scriviCookie("popupHome", "true");
            document.getElementById('promoSh').style.visibility = 'hidden';
        }
    }
}

function promoShipping() {
    if (leggiCookie("popupHome") == null) {
        muoviRidotto3("promoSh", -300, 300, "top", 15);
        setTimeout("viaBici()", 5000);
    }
}

function viaBici() {
    //document.getElementById('promoSh').style.visibility='hidden';
    //muoviRidotto3("promoSh",300,-300,"top",15);
    var arrivo = largWin-370;
    muoviRidotto3("promoSh", 316, arrivo, "left", 8);
}

/***************************** funzione che precarica tutte le imgs   *****************/

(function(){

    /*Use Object Detection to detect IE6*/
    var  m = document.uniqueID /*IE*/
    && document.compatMode  /*>=IE6*/
    && !window.XMLHttpRequest /*<=IE6*/
    && document.execCommand ;

    try{
        if(!!m){
            m("BackgroundImageCache", false, true) /* = IE6 only */
        }

    }catch(oh){};
})();


function preloadingImgs(args) 
{
    for(var n=0;n<arguments.length;n++)
    {
        preloadImg(arguments[n]);
    }
	
    //funzione che precarica un immagine
    function preloadImg(percorso)
    {
        var temp = new Image();
        temp.src = percorso;
    }
}


function redirectLang(value)
{
    var nomePath = location.pathname;
    var nomeHost = location.hostname;
    var get = location.search;
	
    if(value != 'en')
    {
        if(nomePath.indexOf('/interne/cart/') < 0)
        {
            if(nomePath.indexOf('lang-') < 0)
                var redUrl = '/lang-' + value + nomePath + get;
            else
            {
                url = nomePath.split('/');
                lang = url[1].split('-');
                var redUrl = nomePath.replace('/lang-' + lang[1] + '/', '/lang-' + value + '/');
                redUrl = redUrl + get;
            }
        }
        else
            var redUrl = nomePath + get;
    }
    else
    {
        if(nomePath.indexOf('/interne/cart/') < 0)
        {
            url = nomePath.split('/');
            lang = url[1].split('-');
            var redUrl = nomePath.replace('/lang-' + lang[1] + '/', '/');
            redUrl = redUrl + get;
        }
        else
            var redUrl = nomePath + get;
    }
		
    cancellaCookie('language');
    scriviCookie('language', value);
	
    document.frmLanguage.lang.value = value;
    document.frmLanguage.action = redUrl;
    document.frmLanguage.submit();
}

function redirectParam()
{
    var red = document.frmParam.redirect.value;
	
    if(red)
    {
        var nomePath = window.location.pathname;
        var get = window.location.search;
		
        var lang = document.frmParam.lang.value;
        var cur = document.frmParam.cur.value;
        var cou = document.frmParam.cou.value;
	
        var redUrl = '';
        var url = nomePath.split('/');
		
        if(nomePath.indexOf('lang-') > 0)
        {
            var lang_old = url[1].split('-');
            nomePath = nomePath.replace('/lang-' + lang_old[1], '');
            var cur_old = url[2].split('-');
            nomePath = nomePath.replace('/cur-' + cur_old[1], '');
            var cou_old = url[3].split('-');
            nomePath = nomePath.replace('/cou-' + cou_old[1], '');
        }
		
        if(lang == 'en' && cur == 'usd' && cou == 'us')
            redUrl += nomePath + get;
        else
        {
            if(nomePath.indexOf('/interne/cart/') < 0)
                redUrl += '/lang-' + lang + '/cur-' + cur + '/cou-' + cou + nomePath + get;
            else
                redUrl += nomePath + get;
        }
	
        document.frmParam.redirect.value = false;
        document.frmParam.action = redUrl;
        document.frmParam.submit();
    }
}

