function find(n,d){
	var p,i,x;if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=find(n,d.layers[i].document); return x;
}

function swap(){
	var i,j=0,x,a=swap.arguments;document.sr=new Array; for(i=0;i<(a.length-1);i+=2)
	if ((x=find(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+1];}
}

function swaprest(){
	var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function zoom(img,w,h,tit){
	var popup,dim='width='+w+',height='+h+",scrollbars=1";
	popup=open('','popup',dim);
	if(!tit) tit='Zoom';
	with (popup.document){
	open("text/html", "replace");
	write('<html><head><title>'+tit+'</title></head>\n');
	write('<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onload="self.focus()">\n');
	write('<a href="javascript:self.close()" title="Click to close"><img src="'+img+'" border=0></a>\n');
	write('</body></html>');
	close()}
}

function middleWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
	    myWidth = window.innerWidth;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
  	}
	return (myWidth/2);
}

function middleHeight() {
	var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
	    myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    	//IE 4 compatible
	    myHeight = document.body.clientHeight;
	}
	return (myHeight/2);
}

function cambioForm(tasto) {
    elem=document.getElementById(tasto);	
	elem.style.color="#FF0000";
	return false;
}

function TargetBlank()
{
  var i = 0;
  var collegamenti = document.links;
  for (i=0; i<collegamenti.length; i++)
  {
    if (collegamenti[i].title == "Nuova finestra")
    {
	  collegamenti[i].title = "";
      collegamenti[i].target = "_blank";
    }
  }
}
window.onload = TargetBlank;


function getCookie(name){
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);

	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null
	} else begin += 2;

	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;
	
	return unescape(dc.substring(begin + prefix.length, end));
}

function quest(){
	var qchk = getCookie('consultori-questionario1');
	if (!qchk>0){
		document.location = '/pub?act=qst_shw';
	}
}

function Set_Cookie(name, value, expires, path, domain, secure) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

