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 potrebbero essere anche in home ****/

function cambiaSelect(param)
{
	if (param.indexOf('.html')>-1) 
		this.location.href = param;
}	

/* Funzione per controllare che i campi della ricerca per prezzi non siano vuoti */

function controlSelect(that)
{
	var procedi=true;
	var sel=document[that].elements[0];
	for(c=0;c<sel.options.length;c++)
	{
		if(sel.options[c].selected)
		{
			if(sel.options[c].value=="sel") procedi=false;
		}
	}
	
	for(c=2;c<4;c++)
	{
		inpTx=parseInt(document[that].elements[c].value);
		if(isNaN(inpTx)) procedi=false;
	}
	
	if (procedi)
	{
		document[that].action="/interne/prices/index.php";
	}
}

/***** fine funzioni che potrebbero essere anche in home *****/

/**** precarico l'angolo a sinistra per il rollover dei tab***/

tabRollOver1=new Image();
tabRollOver1.src="/imgs/interne/new_interne/menu2_first_on.gif";

/***** funzione per il menu di sinistra nelle pagine interne *****/

function locatMenu(Url)
{
	if(Url =="") url=String(self.location);
	else url=String(Url);
	name=url.substring(url.lastIndexOf("/"),url.length);
	
	return name;
}

rangeIds = new Array(16,66,83,22,33,44,85,80);
categorie = new Array('/prada-shoes.html','/gucci-shoes.html','/ferragamo-shoes.html','/valentino-shoes.html','/prada-handbags.html','/gucci-handbags.html','/ferragamo-handbags.html','/gucci-wallets.html');

var mostrato=false;
// controlla se procedere o no a mostrare il menu della pagina. se  true il menu relativo 
// gi stato mostrato da mostraSel, se false viene mostrato da associaRange
function mostraSel()
{
	var nodo=document.getElementById('menuCont').getElementsByTagName("UL");
	mostra=true;
	//var nodo=nodoUL;
	//var nodo=nodoUL.childNodes;
	nome=locatMenu("");
	
	for (var i=0;i<nodo.length;i++) 
	{
		if (nodo[i].hasChildNodes())  
		{
			jN=nodo[i].childNodes;			
			for (var j=0;j<jN.length;j++) 
			{
				links=jN[j].childNodes;			
				for(l=0;l<links.length;l++)
				{
					if(links[l].tagName=="A")
					{
						if(locatMenu(links[l].href)==nome)
						{
							if (links[l].href != "http://sunglasses.styledrops.com/" 
							 && links[l].href != "http://www.styledrops.com/shoes-108.html"
							 && links[l].href != "http://www.styledrops.com/shoes-117.html" 
							 && links[l].href != "http://styledrops.com/shoes-108.html"
							 && links[l].href != "http://styledrops.com/shoes-117.html")
							 {
								if(mostra)
								{
									mostra=false;
									mostrato=true;
									evidenzia(jN[j]);
									aggiustaTesto(links[l]);
									nodo[i].style.display="block";
								}
							}
						}
					}
				}
			}
		}
	}
}

function associaRange(r_Id)
{
	mostra=true;
	var controlla=false; 
	var indice=0;
	
	for(y=0;y<rangeIds.length;y++)
	{
		if(r_Id == rangeIds[y])
		{
			indice=y;
			controlla=true;
		}
	}
	
	if(!mostrato)
	{ 
		var nodo=document.getElementById('menuCont').getElementsByTagName("UL");
		
		for(var i=0;i<nodo.length;i++) 
		{
			if(nodo[i].hasChildNodes())  
			{
				jN=nodo[i].childNodes;			
				for(var j=0;j<jN.length;j++) 
				{
					links=jN[j].childNodes;			
					for(l=0;l<links.length;l++)
					{
						if(links[l].tagName=="A")
						{
							if(links[l].href != "http://sunglasses.styledrops.com/" 
							&& links[l].href != "http://www.styledrops.com/shoes-108.html" 
							&& links[l].href != "http://www.styledrops.com/shoes-117.html" 
							&& links[l].href != "http://styledrops.com/shoes-108.html" 
							&& links[l].href != "http://styledrops.com/shoes-117.html" 
							&& links[l].href != "http://styledrops.droplet.local/shoes-108.html" 
							&& links[l].href != "http://styledrops.droplet.local/shoes-117.html")
							{
								var part=locatMenu(links[l].href); // mi restituisce l' ultima parte dell' href
								var tempHref=part.substring(part.lastIndexOf("-")+1,part.lastIndexOf("."));
								
								if(tempHref==r_Id)
								{
									evidenzia(jN[j]);
									aggiustaTesto(links[l]);
									nodo[i].style.display = "block";
									//mostrato=false;
								} 
								else
								{
									if(controlla && part==categorie[indice]) 
									{
										if(mostra)
										{
											mostra=false;
											evidenzia(jN[j]);
											aggiustaTesto(links[l]);
											nodo[i].style.display="block";
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

function evidenzia(lin)
{
	lin.style.color="red";
	lin.style.fontWeight="bold";
	lin.style.backgroundColor="#236E97";
	lin.style.display="block";
	lin.style.width="98%"; // per IE
	lin.style.listStyleImage="url(/imgs/interne/new_interne/frecciaM.gif)";
	lin.style.paddingLeft="3px";
	//lin.style.lineHeight="14px"
}

function aggiustaTesto(lin)
{
	lin.style.fontSize="12px";
}

function mmenu(mID) 
{
	var menu = document.getElementById(mID);
	var display = menu.style.display;

	menu.style.display = (display == "block") ? "none" : "block";

	if (mID.length=="submenu-1".length) 
	{
		var uls = document.getElementsByTagName("ul");
		for (i=0;i<uls.length;i++) 
		{
			if (uls[i].id==mID) uls[i].style.display = "block";
		}
	}

	nome=locatMenu("");

	var nodoUL=document.getElementById(mID).parentNode.parentNode;
	var nodo=nodoUL.childNodes;

	for (var i=0;i<nodo.length;i++) 
	{
		if ((nodo[i].tagName=="LI")&&(nodo[i].hasChildNodes()))  
		{
			for (var j=0;j<nodo[i].childNodes.length;j++) 
			{
				if((nodo[i].childNodes[j].tagName=="UL")&&(nodo[i].childNodes[j].id!=mID)) 
				{
					nodo[i].childNodes[j].style.display="none";
				}
			}
		}
	}
	
	var menu=new Array("submenu-1","submenu-2","submenu-3");
	for (var i=0;i<menu.length;i++) 
	{
		var myUls=document.getElementById(menu[i]).getElementsByTagName("ul");
		if (nodoUL.id.indexOf(menu[i])==-1)
		{
			for (var j=0;j<myUls.length;j++) 
			{
				 myUls[j].style.display="none";
			}
		}
	}
}

/****************************************************************/
/*************  funzione per i tab ***********************/

function assegnaCambio(nomeEl, on, off) 
{
	var elementi = document.getElementById(nomeEl).getElementsByTagName('a');
	var lunAn = elementi.length;
	var j;
	
	for(j=0;j<lunAn;j++) 
	{
		elementi[j].onmouseover = function() 
		{	
			cambiaSfondo(this, on);
			return false;
		}
		elementi[j].onmouseout = function() 
		{	
			cambiaSfondo(this, off);
			return false;
		}
	}
}

function cambiaSfondo(nome, classe)
{
	nome.previousSibling.className = classe; 
}

/****************************************************************/
/****** funzione per il cambiamento di nome*******/


function sintetizza(stilista, azione) 
{
	var tit1 = document.getElementById('titH1');
	var testo_ti1;
	
	/*if(azione == 'cat')
	{
		tit1.innerHTML = stilista + ' Corner';
	}
	else*/ if(azione == 'prod')
	{
		var newString = stilista + ' >';
		var re = new RegExp(stilista, 'gi');
		tit1.firstChild.nodeValue = tit1.firstChild.nodeValue.replace(re, newString);
	}
	
	var n = 0;
	var tit2 = document.getElementsByTagName('h2');
	var l = tit2.length;
	var a;
	var testo;
	var re = new RegExp(stilista, 'gi');

	for(n=0; n<l; n++) 	//scorro gli h2
	{ 
		if(tit2.item(n).className == 'secButtons')	//scorro gli h2 che hanno classe secbuttons
		{ 
			a = tit2.item(n).getElementsByTagName('a').item(0);
		
			if(a) 	//questo il caso sia un link
			{ 
				testo = a.firstChild.nodeValue;
				a.firstChild.nodeValue = testo.replace(re, '');
			}
			else 
			{
				//questo  il caso in cui non sia un link, ma l'elemento evidenziato
				testo = document.getElementById('evidenza').firstChild.nodeValue;
				document.getElementById('evidenza').firstChild.nodeValue = testo.replace(re, '');
			}
		}
	}
}

/****************************************************************/

/***** funzione che regola la scelta della taglia nelle pagine della categoria e del prodotto***/

function scegliTaglia(questo) 
{
	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);
	}
	else if(mioForm.sizes.type == "hidden") 
		inviaDati(mioForm);
}

function inviaDati(mioForm) 
{
	mioForm.action="/interne/cart/index.php";
	mioForm.submit();
}

/* Funzione che cambia l'action registazione utente in step2.php*/

function changeAction() 
{
	document.getElementById("makeReg").value = "true";
	document.checkon.action = "step3.php";
}

/***livello con il freeshipping **/


/***** 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 leggiValCookie(offset) 
{
	var endstr = document.cookie.indexOf(";", offset);
	if(endstr == -1)
		endstr = document.cookie.length;
	
	return unescape(document.cookie.substring(offset, endstr));
}

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 cancellaCookie(name) 
{
	var exp = new Date();
	exp.setTime(exp.getTime()-1);
	var cval = leggiCookie(name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

/****************************************************************/

function avviso(idPopUp) 
{
	cokieId="divPopUp"+idPopUp;
	
	/*if (leggiCookie("divPopUpToll")==null) 
	{
		setTimeout("document.getElementById('divPopUpToll').style.display='block'",2000);
		scriviCookie("divPopUpToll","true");
		setTimeout("chiudiToll()",15000);
  	}
	else */if (leggiCookie(cokieId)==null) 
	{
		document.getElementById('iframePopUp').src="/interne/categorie/popUpOutlet.php?id="+idPopUp;
	}
}

function avvisoIndex()
{
	if (leggiCookie("divPopUpToll") == null) 
	{
		setTimeout("document.getElementById('divPopUpToll').style.display='block'",2000);
		scriviCookie("divPopUpToll","true");
		setTimeout("chiudiToll()",15000);
  	}
}

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';
}

function getScrollXY() 
{
	var scrOfX = 0, scrOfY = 0;
	if (typeof(window.pageYOffset) == 'number') 
	{
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} 
	else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) 
	{
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} 
	else if (document.documentElement &&( document.documentElement.scrollLeft || document.documentElement.scrollTop)) 
	{
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	
	return [ scrOfX, scrOfY ];
}

function sposta() 
{
	a=new String(getScrollXY());
	coords=a.split(',');
	document.getElementById('divPopUp').style.top=coords[1]+'px';
}

/**************************************************/
// funzione per la scelta della option della select

function selezionaVoce(select,valore) 
{
	/** parametri di ingresso: nome select, valore option
	azione: seleziona l'option della select con il valore indicato*/
	
	var opt=eval("document.getElementById('"+select+"').getElementsByTagName('option')");
	var l=opt.length;
	
	for (var n=0;n<l;n++) 
	{
		if (opt.item(n).value==valore) 
		{
			opt.item(n).selected='selected';
		}
	}
}


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;
	}
	
	document.frmLanguage.action = redUrl;
	document.frmLanguage.submit();
	*/
		
	cancellaCookie('lang');
	scriviCookie('lang', value);
	
	document.getElementById('lang').value = value;
}


function redirectChange(value)
{	
	cancellaCookie('change');
	scriviCookie('change', value);
	
	document.frmChange.change.value = value;
	document.frmChange.submit();
}

function redirectContinent(value)
{	
	cancellaCookie('continent');
	scriviCookie('continent', value);
	
	document.getElementById('continent').value = value;
}


/****************************************************************/

/***** 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("popupInterne", "true");
			document.getElementById('frameArchive').style.visibility = 'hidden';
		}
	}
}

function popupArchive() 
{
	/*if(leggiCookie("popupInterne") == null) 
	{*/
		muoviRidotto3('frameArchive', -300, 300, "top", 15);
		//setTimeout("viaBici()", 5000);
	//}
}

function viaBici() 
{
	//document.getElementById('frameArchive').style.visibility='hidden';
	//muoviRidotto3('frameArchive', 300, -300, "top", 15);
	var arrivo = -370;
	muoviRidotto3('frameArchive', 316, arrivo, "left", 8);

}

