//Utility function to find element by id Cross Browser
function findElementById(id){return ( document.all+"" != "undefined" ? document.all[id] : document.getElementById(id) );}

function openPdvHome(sel){var ind = sel.options[sel.selectedIndex].value;if(ind != 0){window.location = "/home-punto-vendita.php?id="+ind;}}
//function openPdvLvl1(sel){var ind = sel.options[sel.selectedIndex].value;if(ind != 0){window.location = "/iper.php?id="+ind;}}

function openPopupCenter(url,name,ww,hh){
	var oWin;
	var pars=",top="+Math.floor((screen.height-hh)/2)+",left="+Math.floor((screen.width-ww)/2);
	oWin=window.open(url,name,'width='+ww+',height='+hh+',scrollbars=yes,toolbar=0,menubar=0,resizable=0'+pars);
	return oWin;
}

function openPopupCenterNosb(url,name,ww,hh){
	var oWin;
	var pars=",top="+Math.floor((screen.height-hh)/2)+",left="+Math.floor((screen.width-ww)/2);
	oWin=window.open(url,name,'width='+ww+',height='+hh+',scrollbars=0,toolbar=0,menubar=0,resizable=0'+pars);
	return oWin;
}

function menu_trasversale_on(on){
	var ob=null;
	for(i=1;i<=9;i++){
		ob=findElementById('menutras'+i);
		if (i==on) {
			ob.style.display = '';
		} else {
			ob.style.display = 'none';
		}
	}
}

function menu_trasversale_off(){
	var ob=null;
	for(i=1;i<=9;i++){
		ob=findElementById('menutras'+i);
		ob.style.display = 'none';
	}
}

/*function slideit(ind){
	var s1=findElementById('trSLIDE1');var s2=findElementById('trSLIDE2');var s3=findElementById('trSLIDE3');
	switch(ind){
	case 1:if(s2!=null){s2.style.display='none';}if(s3!=null){s3.style.display='none';}if(s1!=null){s1.style.display='';}break;
	case 2:if(s1!=null){s1.style.display='none';}if(s3!=null){s3.style.display='none';}if(s2!=null){s2.style.display='';}break;
	case 3:if(s1!=null){s1.style.display='none';}if(s2!=null){s2.style.display='none';}if(s3!=null){s3.style.display='';}break;
	}
}

function slide2(ind){
	var s1=findElementById('trSLIDE2_1');var s2=findElementById('trSLIDE2_2');var s3=findElementById('trSLIDE2_3');
	switch(ind){
	case 1:if(s2!=null){s2.style.display='none';}if(s3!=null){s3.style.display='none';}if(s1!=null){s1.style.display='';}break;
	case 2:if(s1!=null){s1.style.display='none';}if(s3!=null){s3.style.display='none';}if(s2!=null){s2.style.display='';}break;
	case 3:if(s1!=null){s1.style.display='none';}if(s2!=null){s2.style.display='none';}if(s3!=null){s3.style.display='';}break;
	}
}

function slideLeftBox(ind){
	var s1=findElementById('trLEFTBOX1');var s2=findElementById('trLEFTBOX2');var s3=findElementById('trLEFTBOX3');
	switch(ind){
	case 1:if(s2!=null){s2.style.display='none';}if(s3!=null){s3.style.display='none';}if(s1!=null){s1.style.display='';}break;
	case 2:if(s1!=null){s1.style.display='none';}if(s3!=null){s3.style.display='none';}if(s2!=null){s2.style.display='';}break;
	case 3:if(s1!=null){s1.style.display='none';}if(s2!=null){s2.style.display='none';}if(s3!=null){s3.style.display='';}break;
	}
}

var evidenza_top=1;
function evidenza_slide(dir){//true->basso - false->alto
	var top,bottom,elTop,elBottom;
	if(dir){top=evidenza_top;}else{top=evidenza_top-1;}
	bottom=top+4;
	elTop=findElementById('idEvidenza'+top);
	elBottom=findElementById('idEvidenza'+bottom);
	if((elTop!=null)&&(elBottom!=null)){
		if(dir){elTop.style.display='none';elBottom.style.display='';evidenza_top=top+1;}
		else{elBottom.style.display='none';elTop.style.display='';evidenza_top=top;}
	}
}*/

// Hide instruction text for password field
function txt2pwd(obj, pwd){
	//obj.style.visibility = "hidden";
	findElementById(obj).style.display = "none";
	findElementById(pwd).style.display="inline";
	findElementById(pwd).focus();
}
// Display instruction text for password field
function pwd2txt(obj, txt){
	if(findElementById(obj).value.length==0){
		//findElementById(txt).style.visibility = "visible";
		findElementById(obj).style.display = "none";
		findElementById(txt).style.display = "inline";
	}
}
// Display instruction text [str] if field is blank
// Clear instruction text if field is clicked
function resetField(obj,str){
	if(obj.value.length==0){obj.value=str;return;}
	if(obj.value==str){obj.value="";}
}