function popup(url, width, height) {
	var wi = null;
	if (wi) wi.close();
	wi=window.open(url,"","width="+width+",height="+height+",location=no,resizable=yes,scrollbars=yes,status=no");
}

function stopMozSubmit(e){	
	if(e.preventDefault){e.preventDefault();}
}

function stop_submit(){		
	
	if(navigator.appName == 'Netscape'){
				window.addEventListener("submit", stopMozSubmit, false);								
				return true;
	}else {							
				event.returnValue=false;
				return false;			
	}
		
}

function stop_submit_new(totalcheck){

	if(navigator.appName == 'Netscape'){
		window.addEventListener("submit", stopMozSubmit, false);
		if (!totalcheck) {
			return true;
		} else {
			window.removeEventListener("submit", stopMozSubmit, false);
		}
	} else {
		if (!totalcheck) {
			event.returnValue=false;
			return false;
		}
	}
}


function toggleT(_w,_h)	{
	// _w : which ID (1) or (2)
	// _h : (h)ide or (s)how	
	if (document.all) {
	 	// e IE
		if (_h == 's') eval("document.getElementById('" + _w + "').style.visibility='visible';document.getElementById('" + _w + "').style.display='inline';");
		if (_h == 'h') eval("document.getElementById('" + _w + "').style.visibility='hidden'; document.getElementById('" + _w + "').style.display='none';");
	} else {
	 	// non e IE
		if (_h == 's'){
			eval("document.getElementById('" + _w + "').visibility='show';");
      eval("document.getElementById(_w).style.display='inline'");
      
		}
		if (_h == 'h'){
			eval("document.getElementById('" + _w + "').visibility='hide';");
			eval("document.getElementById(_w).style.display='none'");	
		}
	}
}

function ro_toggleT(_w,_h)	{
	// _w : which ID (1) or (2)
	// _h : (h)ide or (s)how	
	if (document.all) {
	 	// e IE
		if (_h == 's') eval("document.getElementById('" + _w + "').style.visibility='visible';document.getElementById('" + _w + "').style.display='inline';");
		if (_h == 'h') eval("document.getElementById('" + _w + "').style.visibility='hidden'; document.getElementById('" + _w + "').style.display='none';if(_w=='updatemap'){setTimeout('document.frm_ro_search.submit()',5000);}");
	} else {
	 	// non e IE
		if (_h == 's'){
			eval("document.getElementById('" + _w + "').visibility='show';");
      eval("document.getElementById(_w).style.display='inline'");
      
		}
		if (_h == 'h'){
			eval("document.getElementById('" + _w + "').visibility='hide';");
			eval("document.getElementById(_w).style.display='none'");	
			if(_w=='updatemap'){
        setTimeout('document.frm_ro_search.submit()',5000);
      }
		}
	}
}

function restoreStyle(form_name,field_name)	{
	document[form_name][field_name].style.color='';
	document[form_name][field_name].style.background='';
}

function disableReturn(event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		stop_submit()
	}
}


// separare in un altro js //


function getHalfPagePosition(axis)	{
	var x = 0;
	var y = 0;
	
	if(axis=="y"){
		var page_height = getPageSize("height");
		var scroll_y = getScrollPosition("y");
		var y = (page_height+scroll_y)/2;
		return y;
	}else{
		var page_width = getPageSize("width");
		var scroll_x = getScrollPosition("x");
		var x = (page_width+scroll_x)/2;
		return x;
	}
}

function getPosition(axis,oElement) {
	if( typeof( oElement.offsetParent ) != 'undefined' ) {
		for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
			posX += oElement.offsetLeft;
			posY += oElement.offsetTop;
		}
		if(axis=="y"){
			return posY;
		}else{
			return posX;
		}
	} else {
		if(axis=="y"){
			return oElement.y;
		}else{
			return oElement.x;
		}
	}
}

function getPageSize(param) {
	var width = 0;
	var height = 0;

	if( typeof( window.innerWidth ) == 'number' ) {
		//no-IE
		width = window.innerWidth;
		height = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE6
		width = document.documentElement.clientWidth;
		height = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE4
		width = document.body.clientWidth;
		height = document.body.clientHeight;
	}
	if(param=="height"){
		return height;
	}else{
		return width;
	}
}

function getScrollPosition(axis) {
	var scrollX = 0;
	var scrollY = 0;

	if( typeof( window.pageYOffset ) == 'number' ) {
		//netscape compliant
		scrollY = window.pageYOffset;
		scrollX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrollY = document.body.scrollTop;
		scrollX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrollY = document.documentElement.scrollTop;
		scrollX = document.documentElement.scrollLeft;
	}
	if(axis=="y"){
		return scrollY;
	}else{
		return scrollX;
	}
}

function previewInteger(value) {
  value=value.toString().replace(/[\D^+]/g,"");
  for (i=value.length;i>0;i-=3)
    value=value.substring(0,i)+"."+value.substr(i)
  return value.replace(/\.+$/,"");
}

function removeDots(value) {
  return value.replace(/\./g,"");
}

//mostra o nasconde il div chiamato
function show_div(div_id,status) {

	document.getElementById(div_id).className=status;
	
}

//mostra o nasconde il div chiamato e sostituisce la scritta del link
function show_div_from_link(div_id,status,link_id,label_link,label_href) {

	var new_status='';

	if (status=='hidden'){
		new_status='show';
	}else{
		new_status='hidden';
	}
	
	document.getElementById(div_id).className=status;
	document.getElementById(link_id).href="javascript:show_div_from_link(\""+div_id+"\",\""+new_status+"\",\""+link_id+"\",\""+label_href+"\",\""+label_link+"\");";
	document.getElementById(link_id).innerHTML=label_href;
}
