function DateFromItalianDateString (sringa){
            var str = sringa;
            var first_part = "";
            if (str.substr(1,1)== "/"){
                first_part=str.substr(0,1);
                str=str.substr(2,99);
            }
            if (str.substr(2,1)== "/"){
                first_part=str.substr(0,2);
                str=str.substr(3,99);
            }
            if (first_part=="") 
            return null;
            var second_part = "";
            if (str.substr(1,1)== "/"){
                second_part=str.substr(0,1);
                str=str.substr(2,99);
            }
            if (str.substr(2,1)== "/"){
                second_part=str.substr(0,2);
                str=str.substr(3,99);
            }
            if (second_part=="") 
            return null;    
            if (str.length == 2)
            str="20"+str;
            return new Date(second_part+"/"+first_part+"/"+str);
        }
        


//------------------------------------------

        function date_format(date) {
            var month = "" + (date.getMonth() + 101);
           
            var day = "" + (date.getDate()+100);
            var year = "" + date.getFullYear();
            return (day.substr(1, 2) + "/" + month.substr(1, 2) + "/" + year.substr(2, 3));
        }


function show_page_link(page_name) {
    jWindow = window.open(page_name, 'iwin', 'width=800, height=500, resizable=yes, scrollbars=yes');
    jWindow.focus();
}
function show_page_button(page_name) {
    jWindow = window.open(page_name, 'iwin', 'width=800, height=500, resizable=yes, scrollbars=yes');
    jWindow.focus();
    return (false);
}



function menu_on(td_id, submenu_id, position) {

    if (submenu_id != '') {
        var div_submenu = document.getElementById(submenu_id);
        div_submenu.style.display = "inline";
    }
    var td_menu = document.getElementById(td_id);
    if (position == 'first')
        td_menu.className = "HMenuCell_MouseOn_first menu_width_first  menu_padding menu_height";
    if (position == 'intermediate')
        td_menu.className = "HMenuCell_MouseOn_intermediate  menu_width menu_padding  menu_height";
    if (position == 'last')
        td_menu.className = "HMenuCell_MouseOn_last menu_width menu_padding menu_height";
}

//---------------------------------------
function menu_off(td_id, submenu_id, position) {
    if (submenu_id != '') {
        var div_submenu = document.getElementById(submenu_id);
        div_submenu.style.display = "none";
    }
    if (position == 'first')
        document.getElementById(td_id).className = "HMenuCell_MouseOff_first menu_width_first  menu_padding menu_height";
    if (position == 'intermediate')
        document.getElementById(td_id).className = "HMenuCell_MouseOff_intermediate menu_width menu_padding menu_height";

    if (position == 'last')
        document.getElementById(td_id).className = "HMenuCell_MouseOff_last menu_width menu_padding menu_height";
}

function current_time_for_trace() {
   var currentTime = new Date()
   //Number of milliseconds since 1/1/1970 @ 12:00 AM
   var num = currentTime.getTime()/1000 -1219313000
   return num.toFixed (3) ;
}

 
function on_submit() {
   document.getElementById("trace_time_on_submit").innerHTML = current_time_for_trace() ;
}

function bdy_onmousedown(event) {
    
    if (document.getElementById('onmousedown_flag'))
        show_coords(event)
}


//----------------------------------------------------
function f_scrollTop() {
    return f_filterResults(
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
} //------------------------------------------------------

function help_on_off(div, onoff) {

    if (onoff == true) {
        document.getElementById(div).style.display = 'block';
        document.getElementById(div).style.left = '0';
        document.getElementById(div).style.top = '0';
    }
    else
    { document.getElementById(div).style.display = 'none'; }
}

/* autocomplete for dropdownlist */

function autoSelect(selObj) {
    if (typeof selObj.userWord == 'undefined') {
        selObj.userWord = "";
        selObj.userWord2 = "";
        selObj.oldNdx = 0;
    }

    if (event.keyCode == 13 || event.keyCode == 27) {
        selObj.userWord2 = selObj.userWord = "";
        return;
    }

    if (event.keyCode == 8) {
        selObj.userWord2 = selObj.userWord = "";
        selObj.options[0].selected = true;
        selObj.options[0].focus();
        return;
    }

    thekey = String.fromCharCode(event.keyCode);
    selObj.userWord += thekey;
    for (var i = 0; i < selObj.options.length; i++) {
        var txt = selObj.options[i].text.toUpperCase();
        if (txt.indexOf(selObj.userWord) == 0) {
            selObj.options[i].selected = true;
            selObj.userWord2 = selObj.userWord;
            selObj.oldNdx = selObj.selectedIndex;
            break;
        }
    }
    if (selObj.oldNdx != selObj.selectedIndex)
        selObj.options[selObj.oldNdx].selected = true;
}

function autoSelect_clear(selObj) {
    if (typeof selObj.userWord != 'undefined') 
        selObj.userWord2 = selObj.userWord = "";
}
