function sendPWD(){
	var str = prompt(window.sendPwd,"");
	if(str) window.location.replace('default.asp?cmd=sendPwd&cmdString='+escape(str));
}

function openPopUp(strURL,w,h,t,l,refName,e){
	e=e||event;
	w = w+20;
	h = h+20;
	var obj = document.getElementById?document.getElementById(refName):document.layers?document.layers[refName]:document.all?document.all[refName]:null;
	if(t==null||l==null){
		if(e){
			//var l=e.clientX-150;
			//var t=e.clientY-34;
			l=e.screenX+20;
			t=e.screenY-222;
		}else if(obj){
			obj.css=document.layers?obj:obj.style;
			t=obj.css.top||obj.css.pixelTop||obj.offsetTop||100;
			l=obj.css.left||obj.css.pixelLeft||obj.offsetLeft||100;
		}else{t=100,l=100;}
	} else if(t>>0!=t&&l>>0!=l){
		l=l=="cs"?screen.width/2-w/2:100;
		t=t=="cs"?screen.height/2-h/2:100;
	}
	if(oPopUp&&!oPopUp.closed) oPopUp.close();

	oPopUp = window.open(strURL,"PopUp","width="+w+",height="+h+",top="+t+",left="+l+",scrollbars=1,resizable=1");
	oPopUp.focus();
}

function expandNode(id){
	var obj = document.getElementById("lnk_"+id);
	obj.innerHTML=obj.innerHTML=="+"?"-":"+";
	obj=document.getElementById("row_"+id);
	obj.style.display=obj.style.display=="none"?"":"none";
	return false;
}

function checkOrderForm(frm){
	if(frm.courierID){
		if(frm.courierID.type=="select-one"){
			if(!(frm.courierID.options[frm.courierID.selectedIndex].value>>0)){
				alert(window.courier);
				frm.courierID.focus();
				return false;
			}
		}
		else if(frm.courierID.type=="radio"||frm.courierID.length){
			// elenco di radio
			if(frm.courierID.length){
				for(var i=0,courierChecked=false;i<frm.courierID.length;i++)
					if(frm.courierID[i].checked){
						courierChecked = true;
						break;
					}
				var radioToCheck = frm.courierID[0];
			}
			// radio singolo
			else{
				var courierChecked = frm.courierID.checked;
				var radioToCheck = frm.courierID;
			}
			if(!courierChecked){
				alert(window.courier);
				radioToCheck.focus();
				return false;
			}
		}
	}
	if(!(frm.paymentID.options[frm.paymentID.selectedIndex].value>>0)){
		alert(window.payment);
		frm.paymentID.focus();
		return false;
	}
	frm.action = "default.asp?cmd=sendOrder";
	return true;
}

function showHideCat(o){
	var list = o.parentNode.getElementsByTagName("ul");
	o.className = o.className=="open"?"folder":"open";
	for(var i=0;i<list.length;i++)
		if(o.parentNode==list[i].parentNode)
			list[i].style.display = list[i].style.display=="none"?"block":"none";
	return false;
}

function showVariant(customT1,customT2){
	customT1 = customT1>>0;
	customT2 = customT2>>0;
	var grid = document.getElementById("varaintsListBox");
	if(grid){
		var rowEls = grid.getElementsByTagName("TR");
		if(customT1) var rgx = new RegExp("_"+customT1+"_");
		else if(customT2) var rgx = new RegExp("_"+customT2+"$");
		// nascondo - mostro le righe
		for(var i=1,c=0;i<rowEls.length;i++){
			if(rgx&&rowEls[i].id.search(rgx)==-1)
				rowEls[i].style.display = "none";
			else{
				rowEls[i].style.display = "";
				rowEls[i].className = c%2==0?"bkg1":"bkg2";
				c++;
			}
		}
		// modifico l'action dei form carrello per mantenere selezionato il filtro
		var formList = grid.getElementsByTagName("FORM");
		for(var i=0;i<formList.length;i++)
			formList[i].action = (formList[i].action||"").replace(/\&filterID.*$/,"")+"&filterID="+(customT1||customT2);
	}
}

function checkConfiguratore(frm){
	var list = frm.elements;
	for(var i=0,obbl;i<list.length;i++){
		if(list[i].type=="select-one"){
			obbl = (list[i].name).split("_")[0];
			if(obbl=="true" && list[i].selectedIndex==0 && list[i].options.length>1){
				alert(window.productObbl);
				list[i].focus();
				return false;
			}
		}
	}
	return true;
}
function renewSession(){
	document.images["renewSession"].src = "renewSession.asp?par="+Math.random();
}
function cookieAlert(){
	if(!navigator.cookieEnabled){
		var w = 300;
		var h = 100;
		var left = (screen.width/2-w/2);
		var top = (screen.height/2-h/2);
		oTempTip = genTip('<h2>Attenzione!</h2><p>Il tuo browser ha i cookie disattivati<br />Per poter utilizzare correttamente i servizi offerti da questo sito e\' necessario attivare i cookie<br /><a href="#" onclick="removeTip();"><img src="ReadySkins/red/images/ico_close.gif" width="14" height="14" alt="" border="0" align="left" vspace="2" />&#160;chiudi</a></p>',w,h,left,top);
		document.body.appendChild(oTempTip);
		window.tempID = setTimeout('removeTip();',5000);
	}
}
function removeTip(){
	if(window.oTempTip)
		document.body.removeChild(window.oTempTip)
}
function genTip(msg,width,height,left,top){
	window.oTempTip = document.createElement("div");
	window.oTempTip.className = "alertBox";
	window.oTempTip.style.width = width+"px";
	window.oTempTip.style.height = height+"px";
	window.oTempTip.style.position = "absolute";
	window.oTempTip.style.left = left+"px";
	window.oTempTip.style.top = top+"px";
	window.oTempTip.innerHTML = msg;
	return oTempTip;
}

var oPopUp;
window.onunload = function(){if(oPopUp&&!oPopUp.closed) oPopUp.close();}
window.onload = function(){
					// perche' nn scada la sessione
					window.setInterval("renewSession();",1200000);
					cookieAlert();
				}


