	
    //initiate variables for Drag Routines
    
    //var element;
	//var DragNow = false;
	//var dx=0;
	//var dy=0;
    //var hyperlink;
    
    
    /* Drag Routines ***
    function initDrag(e) {	
        e = (e)? e : event;		
        DragNow = true;
        element = document.getElementById("tooltipbox");
        //
        dx = Math.abs(parseInt(element.style.left) - e.clientX);
        dy = Math.abs(parseInt(element.style.top) - e.clientY);
        //declare mousemove and mouseup event
        document.onmouseup = stopDrag;
        document.onmousemove = startDrag;
	}

	function stopDrag() {
	    DragNow = false;
	}
	
	function startDrag(e) {
        e = (e)? e : event;
        if(DragNow) {
            element.style.top = (e.clientY - dy) + 'px';
            element.style.left = (e.clientX - dx) + 'px';
        }
	}
    *** End Drag Routines */

    function timer() {
        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var seconds = now.getSeconds();
        var Month = Array();
        Month[0] = "Gennaio";
        Month[1] = "Febbraio";
        Month[2] = "Marzo";
        Month[3] = "Aprile";
        Month[4] = "Maggio";
        Month[5] = "Giugno";
        Month[6] = "Luglio";
        Month[7] = "Agosto";
        Month[8] = "Settembre";
        Month[9] = "Ottobre";
        Month[10] = "Novembre";
        Month[11] = "Dicembre";
        if (hours<=9) { hours="0"+hours; }
        if (minutes<=9) { minutes="0"+minutes; }
        if (seconds<=9) { seconds="0"+seconds; }
        document.getElementById("timer").innerHTML = now.getDate()+" "+Month[now.getMonth()]+" "+now.getFullYear()+" - "+hours + ":" + minutes + ":" + seconds + " ";
        setTimeout("timer()", 1000);
    }
    //
	function leftBar (id) {
		if (id !== 0 ) {
			$("#leftBar *").css("color","");
			$("#"+id).css("color","#c00");
		}
	}
	function topBar (id) {
		if (id !== 0 ) {
			$("#topBar *").css("color","");
			$("#"+id).css("color","#c00");
		}
	}
    /*
	function ttbClose( obj, flg, startPos, file_name, H, V ) {            
        if( flg == "hide" ) {
            $("#"+hyperlink).css("font-weight", "normal");
            $("#"+obj).hide("slow");
        } else if( flg == "show" )  {
            var objLeft = document.getElementById(startPos).offsetLeft;
            var objTop = document.getElementById(startPos).offsetTop;
            var objWidth = document.getElementById(startPos).offsetWidth;
            var objHeight = document.getElementById(startPos).offsetHeight;
            var boxWidth = document.getElementById(obj).offsetWidth;
            hyperlink = startPos;
            // Call data_read();
            data_read( file_name );
            //
            $("#"+startPos).css("font-weight", "bold");
            if (H == "r") {
                $("#"+obj).css("left", ((objLeft-610)+objWidth)+'px');
            } else if (H == "l") {
                $("#"+obj).css("left", objLeft+'px');            
            }
            if (V == "b") {
                $("#"+obj).css("top", (objTop+objHeight+2)+'px');
            } else if (V == "t") {
                $("#"+obj).css("top", ((objTop-310)-(objHeight))+'px');
            }            
            $("#"+obj).show("slow");
        }
	}
    */

    function initDialog( data, id ) {
        var obj = document.getElementById(id);
        data_read( data );
    	$('#dialog').dialog({
			autoOpen: false,
            minHeight: 50,
			width: (screen.availWidth / 2) - 21, //- obj.offsetLeft - 21,
            height: 300, //(screen.availHeight) / 2, 
            position: ['center', 'center'],
            title: obj.innerHTML,
            show: 'blind'
		});
        //showDialog();
        //$( "#dialog" ).dialog({
        //   open: function(event, ui) { alert("Opening"); }
        //});
        //$( "#dialog" ).dialog({
        //   beforeclose: function(event, ui) { $('#dialog').html("OK"); }
        //});
        $( "#dialog" ).dialog({
           close: function(event, ui) { $('#dialog').html(""); }
        });
    	$('#dialog').dialog('open');

    }
    function showDialog() {
        //$.fx.speeds._default = 1000;
        $( "#dialog" ).dialog({
           open: function(event, ui) { alert("Opening"); }
        });
        $( "#dialog" ).dialog({
           close: function(event, ui) { alert("Closed"); }
        });
    	$('#dialog').dialog('open');
        return false;    
    }    
    
	/* Start: Data Read Routines */
	function CreateXmlHttpReq(handler) {
		var xmlhttp = null;
		if (window.XMLHttpRequest) {
			xmlhttp = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		//	xmlhttp = new XMLHttpRequest();
		xmlhttp.onreadystatechange = handler;
		return xmlhttp;
	}
	
	//
	function data_write() {
		if(httpRequest.readyState == 4 && httpRequest.status == 200) {
			document.getElementById("dialog").innerHTML = httpRequest.responseText;
		}
	}
	
	//
	function data_read( id ) {
        //id = "pmi.html";
		var getStr = "?doc=" + id + "&rand=" + escape(Math.random());
		httpRequest = CreateXmlHttpReq(data_write);
		// GET Method
		httpRequest.open("GET", "scripts/read_file.php" + getStr, true);
		httpRequest.setRequestHeader("connection", "close");
		httpRequest.send(null);
	}
	/* Stop: Data Read Routines */
    

