function PopUpWin(pageurl,pagename,width,height)
{
	if (width==0 || width>screen.availWidth) width=screen.availWidth-150;
    if (height==0 || height>screen.availHeight) height=screen.availHeight-250;
    var left = (screen.availWidth - width)/2;
    var top = (screen.availHeight - height)/2;

	winpopup = open(pageurl,pagename,"location=0,status=0,toolbar=0,directories=0,menubar=0,scrollbars=1,resizable=0,width="+width+",height="+height+",left="+left+",top="+top);
	return winpopup;
}
function PopUpWinResize(width,height){

	if (width==0 || width>screen.availWidth) width=screen.availWidth-150;
    if (height==0 || height>screen.availHeight) height=screen.availHeight-250;
    var left = (screen.availWidth - width)/2;
    var top = (screen.availHeight - height)/2;

    window.resizeTo(width,height);
    window.moveTo(left,top);

}
function PopUpWin_scr(pageurl,pagename,width,height)
{
	if (width==0 || width>screen.availWidth) width=screen.availWidth-150;
    if (height==0 || height>screen.availHeight) height=screen.availHeight-250;
    var left = (screen.availWidth - width)/2;
    var top = (screen.availHeight - height)/2;

	winpopup = open(pageurl,pagename,"location=0,status=0,toolbar=0,directories=0,menubar=0,scrollbars=1,resizable=0,width="+width+",height="+height+",left="+left+",top="+top);
	return winpopup;
}
        function FiltraNumeriBis(e){
        //45=-
        //46=.
        //8=backspace
        //0= altro
         if (e.which){
         	if (e.which==45 || e.which==46 || e.which==8 || e.which==0 || (e.which>=48 && e.which<=57) || e.which==13)
            	return 1;
            else
            	return 0;
         }else{
         	if (e.keyCode==45 || e.keyCode==46 || e.keyCode==8 || e.keyCode==0 || (e.keyCode>=48 && e.keyCode<=57) || e.keyCode==13)
            	return 1;
            else
            	return 0;
         }
	    }

function SvuotaInputSelect(obj){

// 	if (obj.length>0)
//    for (i=(obj.length-1); i>=0; i--)
//    	obj.options[i]=null;
	while( v = obj.firstChild)
		obj.removeChild(v);

}

function new_Option(form,field,text,value,selected){
	var optobj = document.createElement("option");
    //optobj.text=text;
	var textobj = document.createTextNode(text);
    optobj.appendChild(textobj) ;
    optobj.value=value;
    if (selected==true) optobj.selected=true;
    document.forms[form].elements[field].appendChild(optobj);


//    caller = document.forms[form].elements[field];
//    caller.options[caller.length] = new Option(text,value);
//	            if (selected==true) caller.options[caller.length-1].selected = true;

}
function new_OptGroup(form,field,label){
	var optobj = document.createElement("optgroup");
    optobj.label=label;
    document.forms[form].elements[field].appendChild(optobj);
}

function setDisplayRow(layer, on)
{
	if (on) {
		if (DOM) {
            if (IE)
	            document.getElementById(layer).style.display = "block";
            else
	            document.getElementById(layer).style.display = "table-row";
		} else {
			document.all[layer].style.display = "block";
		}
	} else {
		if (DOM) {
			document.getElementById(layer).style.display = "none";
		} else {
			document.all[layer].style.display = "none";
		}
	}
}

function swapImage(imageid, src){
	 if (DOM)
	    document.getElementById(imageid).src = src;
	 else if (NS4)
	    document.images[imageid].src = src;
	 else
	    document.all[imageid].src = src;

}

function display_hover_prompt() { 
  var ie = document.all && !window.opera; 
  var dom = document.getElementById; 
  var iebody = (document.compatMode == 'CSS1Compat') ? document.documentElement : document.body; 
  var objref = (dom) ? document.getElementById('layermenu') : document.all.hormenu; 
  var scroll_top = (ie) ? iebody.scrollTop : window.pageYOffset; 
  var docwidth = (ie) ? iebody.clientWidth : window.innerWidth; 
  var docheight = (ie) ? iebody.clientHeight: window.innerHeight; 
  var objwidth = objref.offsetWidth; 
  var objheight = objref.offsetHeight; 
  //objref.style.left = docwidth/2-objwidth/2+'px'; 
  //objref.style.top = scroll_top+docheight/1.8-objheight/2+'px'; 
  objref.style.top = scroll_top; //-objheight/2+'px'; 
  var showonscrollvar = setInterval('static_hover_prompt()', 50); 
  objref.style.visibility = 'visible'; 
} 

function static_hover_prompt() { 
  var ie = document.all && !window.opera; 
  var dom = document.getElementById; 
  var iebody = (document.compatMode == 'CSS1Compat') ? document.documentElement : document.body; 
  var objref = (dom) ? document.getElementById('layermenu') : document.all.hormenu; 
  var scroll_top = (ie) ? iebody.scrollTop : window.pageYOffset; 
  var docwidth = (ie) ? iebody.clientWidth : window.innerWidth; 
  var docheight = (ie) ? iebody.clientHeight: window.innerHeight; 
  var objwidth = objref.offsetWidth; 
  var objheight = objref.offsetHeight; 
  //objref.style.top = scroll_top+docheight/1.8-objheight/2+'px'; 
  objref.style.top = scroll_top; //-objheight/2+'px'; 

} 
function hide_hover_prompt() { 
  var ie = document.all && !window.opera; 
  var dom = document.getElementById; 
  var iebody = (document.compatMode == 'CSS1Compat') ? document.documentElement : document.body; 
  var objref = (dom) ? document.getElementById('layermenu') : document.all.hormenu; 
  objref.style.visibility = 'hidden'; 
  if (typeof showonscrollvar != 'undefined') {
    clearInterval(showonscrollvar); 
  } 
} 

function do_scroll_menu(){
  if (window.addEventListener) { 
    window.addEventListener('load', display_hover_prompt, false) 
  } 
  else if (window.attachEvent) { 
    window.attachEvent('onload', display_hover_prompt) 
  } 
  else if (document.getElementById) {
     window.onload = display_hover_prompt; 
  }
}
//var DOM = (document.getElementById) ? 1 : 0;
//var NS4 = (document.layers) ? 1 : 0;
//IE = (navigator.userAgent.indexOf('MSIE') > -1) ? 1 : 0;
var POPWIN = false;
var POPWINALERT = false;

