function setAnchor(pUrl, anchorName) {
	var retUrl = pUrl;
	if(pUrl.indexOf("#") > -1) {
		retUrl = pUrl.replace(/\#.*/i, "#" + anchorName);
	}
	else {
		retUrl = pUrl + "#" + anchorName;
	}
	return retUrl;
}

//Per categorie laterali
var openUL = null;
var over = false;
function showBlock(el,e){
	e = e||event;
	
	if(e.stopPropagation) e.stopPropagation(); 
	else e.cancelBubble = true;
	
	var currentUL = el.getElementsByTagName("ul")[0];
	if(openUL)
		hideBlock(currentUL);
	
	openUL = currentUL;
	openUL.style.display = "block";
}
function closeBlock(){
	if(window.timeOutID)
		clearTimeout(window.timeOutID);
	window.timeOutID = setTimeout("hideBlock();",1000);
	window.over = false;
}
function hideBlock(currentUL){
	if(!currentUL && window.over) return;

	currentUL = currentUL||document.getElementById("root").getElementsByTagName("ul")[0];
	var o = openUL;
	while( o && o.nodeName=="UL" ){
		if(o == currentUL.parentNode.parentNode)
			break
		o.style.display = "none";
		o = o.parentNode.parentNode;
	}
	
}
//************************************************************


//Invio Password
function sendPWD(){
	window.open("lostPwd.asp", "LostPwd" , "scrollbars=yes,width=490,height=350");
/*var str = prompt("Inserire lo userID con cui vi siete registrati per ricevere la password per posta elettronica.","");
	if(str) window.location.replace('default.asp?cmd=sendPwd&cmdString='+escape(str));*/
}


function checkOrderForm(frm){
	if(frm.isGuestUser.value == 1) {
		if(!checkFRM(frm))
			return false;
	}		

	if(($("#ofcTransportCost").val()||"") == "") {
		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;
				}
			}
		}
		else {
	    if(!frm.chkQuote) {
	  		alert(window.courier);
	  		return false;
	    }
		}
	}
	
	if(($("#ofcCashCost").val()||"") == "") {
		if(frm.paymentID) {
			if(frm.paymentID.type=="select-one"){
				if(!(frm.paymentID.options[frm.paymentID.selectedIndex].value>>0)){
					alert(window.payment);
					frm.paymentID.focus();
					return false;
				}
			}
			else if(frm.paymentID.type=="radio"||frm.paymentID.length){
				// elenco di radio
				if(frm.paymentID.length){
					for(var i=0,payChecked=false;i<frm.paymentID.length;i++)
						if(frm.paymentID[i].checked){
							payChecked = true;
							break;
						}
					var radioToCheck = frm.paymentID[0];
				}
				// radio singolo
				else{
					var payChecked = frm.paymentID.checked;
					var radioToCheck = frm.paymentID;
				}
				if(!payChecked){
					alert(window.payment);
					radioToCheck.focus();
					return false;
				}
			}
		}
		else {
	    if(!frm.chkQuote) {
			  alert(window.payment);
			  return false;
			}
		}
	}
	
	frm.action = "default.asp?cmd=sendOrder";
	frm.submit();
	return false;
}

function writePopUp(strURL,w,h,t,l,refName,e, strHTML) {
	openPopUp("",w,h,t,l,refName,e);
	oPopUp.document.write(strHTML);
}

function openPopUp(strURL,w,h,t,l,refName,e){
	e=e||event;
	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.location.replace(strURL);
		//oPopUp.resizeTo(w,h);
		

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

var oPopUp;
onunload = function(){if(oPopUp&&!oPopUp.closed) oPopUp.close();}



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;
}

//Carrello ---
function emptyCart() {
	if(confirm("Svuotare il carrello?\nVerrano rimossi tutti gli articoli attualmente nel carrello.")) {
		window.location.href="default.asp?cmd=delCart";
	}
	return false;
}

function delCartSubProduct(id, parentId, title) {
	if(confirm("Eliminare l'articolo " + title + "?")) {
		window.location.href="default.asp?cmd=showCart&delSubId=" + id + "&parentId=" + parentId;
	}
	return false;
}
function delCartParentProduct(id, title) {
	if(confirm("Eliminare l'articolo " + title + " e tutti gli accessori?")) {
		window.location.href="default.asp?cmd=showCart&delParentId=" + id;
	}
	return false;
}
//--- Carrello


//Vetrina home page ---
	//Require jQuery
  $(document).ready(function(){
    
    $(".autoZoom").mouseover(function(event){
    	//alert($(this).parent().parent().attr("id"))
    	$(this).parent().parent().toggleClass("flashingBorder").toggleClass("flashingBorder_hover");
    	$(this).toggleClass("flashingBorder").toggleClass("flashingBorder_hover");
			$(this).stop(true);
    	$(this).animate({"width": "200px","left": "-50%","top": "-50%"}, "slow");
    	$(this).attr({"src" : $(this).attr("bsrc")});
    }).mouseout(function(event){
    	$(this).toggleClass("flashingBorder").toggleClass("flashingBorder_hover");
			$(this).stop(true);
    	$(this).animate({"width": "100px","left": "0%","top": "0%"}, "slow");
    	$(this).parent().parent().toggleClass("flashingBorder").toggleClass("flashingBorder_hover");
    	$(this).attr({"src" : $(this).attr("ssrc")});
    });

  });


//--- Vetrina home page

