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();
}

/************* 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\">");

	/*parte che riguarda i box dei prezzi*/

	/*
	if (largWin<=930) 
	{
		document.writeln("#TP_imgCentro1{display:none}");
		document.writeln("#TP_imgCentro2{display:none}");
		document.writeln('.TP_30{width:40%}');
	}
	else
	{
		document.writeln("#TP_imgCentro1{display:block}");
		document.writeln("#TP_imgCentro2{display:block}");
		document.writeln('.TP_30{width:23%}');
	}
	*/

	/*fine parte che riguarda i box dei prezzi*/

	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";

	// box dei prezzi
	//document.getElementById("boxPromoSotto").style.width=(dimLiv+5).toString()+"px";

	/****parte per il box dei prezzi**/

	/*
	var $n;
	var divs = document.getElementById('TP_boxCentr').getElementsByTagName('div');
	var l = divs.length;

	for ($n=0;$n<l;$n++) 
	{
		if (largWin < 930) 
		{
			if((divs.item($n).className.indexOf('TP_30')>=0)&&(divs.item($n).style.width!='40%')) 
			{
				divs.item($n).style.width = '40%';
			}

			if (document.getElementById('TP_imgCentro1').style.display != 'none') 
			{
				document.getElementById('TP_imgCentro1').style.display = 'none';
				document.getElementById('TP_imgCentro2').style.display = 'none';
			}
		}
		else 
		{
			if((divs.item($n).className.indexOf('TP_30')>=0)&&(divs.item($n).style.width!='23%'))
			{
				divs.item($n).style.width = '23%';
			}

			if (document.getElementById('TP_imgCentro1').style.display != 'block') 
			{
				document.getElementById('TP_imgCentro1').style.display = 'block';
				document.getElementById('TP_imgCentro2').style.display = 'block';
			}
		}
	}
	*/
}

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 = "/imgs/home/tollfree800.gif";
tollFree1024 = new Image();
tollFree1024.src = "/imgs/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/customers/sale.shtml\"><img id=\"imgToll\" title=\""+alt+"\" alt=\""+alt+"\" src=\"/imgs/home/tollfree"+ris+".gif\" style=\"width:"+larg+";height:34;"+margini+"\" /></a>");
	document.writeln("<a href=\"/interne/designer/index.php\"><img id=\"imgToll\" title=\""+alt+"\" alt=\""+alt+"\" src=\"/imgs/home/tollfree"+ris+".gif\" style=\"width:"+larg+";height:34;"+margini+"\" /></a>");
}

/*
function cambiaImgToll() 
{
	if (largWin <= 900) 
	{
		var largToll = 170;
		var altToll = 34;
		var tipoImg = "800";
	}
	else 
	{
		var largToll = 328;
		var altToll = 33;
		var tipoImg = "1024";
	}

	var tagToll = document.getElementById("imgToll").style;
	
	tagToll.width = largToll+"px";
	tagToll.height = altToll+"px";
	cambiaImg('imgToll', "tollFree"+tipoImg);
}
*/

/****************************************************************/

/***** 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()	//coloraH6()
{
	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);
			}
		}
	}
}

function mostraLink(param) 	//il parametro  dato dal this lanciato dal link
{ 
	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 = "/imgs/home/menuShop/azzurro/freccia.gif";
	
	frecciaShopOver = new Image();
	frecciaShopOver.src = "/imgs/home/menuShop/blu/fecciablu.gif";

	shopMen = new Image();
	shopMen.src = "/imgs/home/menuShop/azzurro/shopforman.gif";

	shopMenOver = new Image();
	shopMenOver.src = "/imgs/home/menuShop/blu/shopformenblu.gif";

	shopWom = new Image();
	shopWom.src = "/imgs/home/menuShop/azzurro/shopforwoman.gif";

	shopWomOver = new Image();
	shopWomOver.src = "/imgs/home/menuShop/blu/shopforwomenblu.gif";

	shopStyle = new Image();
	shopStyle.src = "/imgs/home/menuShop/azzurro/shopbystyle.gif";

	shopStyleOver = new Image();
	shopStyleOver.src = "/imgs/home/menuShop/blu/shopbystyleblu.gif";

	pulsanteshop1 = new Image();
	pulsanteshop1.src = "/imgs/home/shopforwomen.gif";

	pulsanteshop2 = new Image();
	pulsanteshop2.src = "/imgs/home/shopformen.gif";

	pulsanteshop3 = new Image();
	pulsanteshop3.src = "/imgs/home/shopby.gif";
}

/****************************************************************/
/****************************************************************/

/***** funzione per il random dell'immagine in home page *****/

function randomImgHome() 
{
	var imgsHome=new Array();

	imgsHome[0] = new Array("/prada-shoes.html","donna45.jpg");
	imgsHome[1] = new Array("/interne/categorie/viewAll.php?id=66","donna40.jpg");
	imgsHome[2] = new Array("/shoes-44.html","donna51.jpg");
	imgsHome[3] = new Array("/shoes-82.html","donna54.jpg");
	imgsHome[4] = new Array("/shoes-82.html","donna62.jpg");
	imgsHome[5] = new Array("/shoes-28.html","donna1.jpg");
	imgsHome[6] = new Array("/prada-shoes.html","donna45.jpg");
	imgsHome[7] = new Array("/shoes-84.html","donna54.jpg");
	imgsHome[8] = new Array("/shoes-62.html","donna61.jpg");
	imgsHome[9] = new Array("/shoes-33.html","donna45.jpg");
	imgsHome[10] = new Array("/shoes-84.html","donna54.jpg");
	imgsHome[11] = new Array("/shoes-78.html","donna63.jpg");
	imgsHome[12] = new Array("/shoes-33.html","donna45.jpg");
	imgsHome[13] = new Array("/interne/categorie/viewAll.php?id=86","donna40.jpg");
	imgsHome[14] = new Array("/shoes-82.html","donna62.jpg");
	imgsHome[15] = new Array("/interne/categorie/viewAll.php?id=86","donna40.jpg");

	var r = randomNumber(0, 15);
	
	document.writeln("<a href=\""+imgsHome[r][0]+"\"><img src=\"/imgs/home/"+imgsHome[r][1]+"\" alt=\"\" border=\"0\" id=\"imgPromo\" /></a>");
}

function randomNumber(min,max)
{
	var m = min;
	var n = max;
	var r = m+Math.round(Math.random()*n);
	
	return(r);
}

/***************************************************************/

/***** immagini per le promozioni *****/

function assegnaImgsPromo() 
{
	var ImgsDonna = new Array();

	ImgsDonna[0] = new Array('/imgs/home/donna45.jpg','prada-shoes.html','');
	ImgsDonna[1] = new Array('/imgs/home/donna40.jpg','shoes-27.html','');
	ImgsDonna[2] = new Array('/imgs/home/donna41.jpg','shoes-20.html','');

	var ImgsUomo = new Array();

	ImgsUomo[0] = new Array('/imgs/home/donna48.jpg','shoes-28.html','');
	ImgsUomo[1] = new Array('/imgs/home/donna43.jpg','shoes-28.html','');

	var ImgsStyle = new Array();

	ImgsStyle[0] = new Array('/imgs/home/donna42.jpg','shoes-78.html','');
	ImgsStyle[1] = new Array('/imgs/home/donna36.jpg','shoes-44.html','');
	ImgsStyle[2] = new Array('/imgs/home/donna37.jpg','shoes-47.html','');

	immaginiPromo = new Array();

	/*
	immaginiPromo['shop1']=new Array('imgs/home/donna4.jpg','/shoes44.html','buy gucci handbags at discounted prices');
	immaginiPromo['shop2']=new Array('imgs/home/uomo.jpg','/shoes28.html','Prada shoes sport 2003-2004 Collections');
	immaginiPromo['shop3']=new Array('imgs/home/promo3.jpg','/shoes16.html','Prada shoes tweed/leather shoes from the latest collections');
 	*/
	//il secondo numero  il numero totale delle imgs: corrisponde all'ultimo elemento
	immaginiPromo['shop1'] = ImgsDonna[randomNumber(0,2)]; 
	immaginiPromo['shop2'] = ImgsUomo[randomNumber(0,1)];
	immaginiPromo['shop3'] = ImgsStyle[randomNumber(0,2)];
}

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();
	}
}
