function build_skin_options(current_theme) {
    document.write('<select id="Select_theme" onchange="change_skin2(this.value)" style="width: 250px;margin:2px; margin-left:-2px">');
    build_option("Theme_wss_basic", current_theme, "default");
    build_option("Theme_wss_black_bg", current_theme, "black background");
    build_option("Theme_wss_red_buttons", current_theme, "red buttons");
    document.write('</select>');
}

function build_option(tema, current_theme, nome) {
    if (current_theme == tema)
        document.write('<option id="' + tema + '" value="' + tema + '" selected>' + nome + '</option>');
    else
        document.write('<option id="' + tema + '" value="' + tema + '" >' + nome + '</option>');
}
function select_skin() {
    document.getElementById('div_skin_selection').style.display = 'inline';
}

function close_select_skin_window() {
    document.getElementById('div_skin_selection').style.display = 'none';
}
function change_skin2(param) {
    __doPostBack(param, '');
    this.selected = true;
}

function clear_search_box() {
    if (document.getElementById('what_to_find').value == "Find in this site")
        document.getElementById('what_to_find').value = "";
}

function set_search_box() {

    if (document.getElementById('what_to_find').value == "")
        document.getElementById('what_to_find').value = "Find in this site";
}

//------------------------------------------


function cerca_con_google_in(sitoricerca) {
    if (document.getElementById("what_to_find").value == "Find in this site") {
        alert("type the string to be found");
        document.getElementById("what_to_find").value = "";
        document.getElementById("what_to_find").focus();
        return;
    }
    var url = "http://www.google.it/search?hl=it&q=" + document.getElementById("what_to_find").value + "+site%3A" + sitoricerca + "&meta=";
    window.open(url, 'iwin', 'width=800, height=500,resizable=yes, scrollbars=yes');
    //show_page_button(url);
}
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 bdy_onload() {
    if (window.child_onload)
        child_onload();
}

function bdy_onkeypress(event) {
    
    if (is_enter(event)) {
        var search_txt = document.getElementById('what_to_find').value
        if (search_txt != "Find in this site" && search_txt != "") {
            cerca_con_google_in('http://www.pragmanet.eu/wss');
            return;
        }
    }

    if (typeof check_enter == 'function')
        check_enter(event);
}

function is_enter(e) {
    if (e)
    { e = e } else { e = window.event }
    if (e.which)
    { var keycode = e.which } else { var keycode = e.keyCode }
    if (keycode == 13) {
        return true;
    }
    return false
}





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'; }
} 