function onload_doc() {
    try
    {
        if (getCookie('default_tool')) {
            var el_id = getCookie('default_tool');
            if (dgbi(el_id) != undefined) {
                slideToolsPanel(el_id);
            } else
                slideToolsPanel('calendar_tab');
        }
    }
    catch(E) {
    }
    preload_images();
    fixUploadFile();
    update_calendar();
    eval('do_init();');
}
function do_init() {
}
function do_nothing() {
}


function preload_images() {
    img1 = new Image();
    img1.src = "/images/checkboxunchecked.gif";
    img1 = new Image();
    img1.src = "/images/checkboxchecked.gif";
}

function dgbi(id) {
    return document.getElementById(id);
}

function confirmit(s) {
    return confirm(s);
}

function checkall(form, element) {
    arr = document.forms[form].elements[element];
    if (arr.length == undefined) {
        if (arr.checked) arr.checked = false;
        else arr.checked = true;
    } else {
        chkd = !arr[0].checked;
        for (i = 0; i < arr.length; ++i) {
            arr[i].checked = chkd;
        }
    }
}

function trim(s) {
    if (s == null || s == undefined) return false;
    return s.replace(/(^\s+)|(\s+$)/g, "");
}

//*** login ***//
function validate_login_form() {
    f = document.forms['form_login'];
    login = trim(f.elements['auth'].value);
    pwd = trim(f.elements['authp'].value);
    if (trim(login) == '') {
        f.elements['auth'].focus();
        return false;
    }
    if (trim(pwd) == '') {
        f.elements['authp'].focus();
        return false;
    }
    return true;
}
//logout
function do_logout() {
    document.forms['form_logout'].submit();
    return false;
}
function isValidEmail(fieldValue) {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/.test(fieldValue))    return true;
    return false;
}

function toggle_cb(cb_id, cb_img) {
    cb = dgbi(cb_id);
    if (cb.value == 1) {
        cb.value = 0;
        cb_img.src = '/images/checkboxunchecked.gif';
    } else {
        cb.value = 1;
        cb_img.src = '/images/checkboxchecked.gif';
    }
}

function validate_form_comment(f) {
    s = trim(f.elements['content'].value);
    dgbi('err_comm_1').style.display = 'none';
    if (s == '') {
        dgbi('err_comm_1').style.display = 'block';
        f.elements['content'].focus();
        return false;
    }
    return true;
}


function isie() {
    IE = document.all && (!window.opera);
    return IE;
}

var isPPOn = false;
var ppTransp = 0;

function tryCloseRW() {
    if (isPPOn) {
        isPPOn = false;
        if (isie()) {
            //document.body.style.overflow = 'auto';
            //document.documentElement.style.overflow = 'auto';
            document.body.style.overflow = '';
            document.documentElement.style.overflow = '';
        }
        var viewer = dgbi("roomsViewer");
        var rw = dgbi('regWin');
        var iw = dgbi('infoWin');
        var text_w = dgbi('infoMsg');
        var contact_panel = dgbi('contactUsPanel');
        var wall = dgbi("modalWall");
        if (rw != undefined) {
            rw.style.display = "none";
        }
        if (iw != undefined) {
            iw.style.display = "none";
        }
        if (text_w != undefined) {
            text_w.style.display = "none";
        }
        if (contact_panel != undefined) {
            contact_panel.style.display = "none";
        }
        if (viewer != undefined)
        {
            dgbi("screen_Image").style.className = "hidden_image";
            viewer.style.display = "none";
            var img = dgbi("screen_Image");
            img.src = "";
            img.style.visibility = "hidden";
        }
        wall.style.display = "none";
        wall.style.opacity = '0.0';
        wall.style.filter = 'alpha(opacity=0)';

        ppTransp = 0;
    }
    fixZIndex();
    return false;
}
function showRegForm(place) {
    tryCloseRW();
    wall = document.getElementById("modalWall");
    var regWin = document.getElementById('regWin');
    if (place == 1) {
        regWin.style.top = "50%";
        regWin.style.left = "50%";
        regWin.style.marginLeft = "-230px";
        regWin.style.marginTop = "-100px";
    } else if (place == 2) {
        regWin.style.top = "60px";
        regWin.style.left = "50%";
        regWin.style.marginLeft = "196px";
        regWin.style.marginTop = "0";
    }
    if (isie()) {
        document.documentElement.style.overflow = 'hidden';
        //window.scroll(0, 0);
        wall.style.position = "absolute";
        regWin.style.position = "absolute";
    }

    wall.style.display = "block";
    setTimeout("ppStep1('regWin')", 10);
    return false;
}

function showInfoWin() {
    tryCloseRW();
    wall = document.getElementById("modalWall");
    var iWin = document.getElementById('infoWin');

    if (isie()) {
        document.documentElement.style.overflow = 'hidden';
        //window.scroll(0, 0);
        wall.style.position = "absolute";
        iWin.style.position = "absolute";
    }
    wall.style.display = "block";
    setTimeout("ppStep1('infoWin')", 10);
    return false;
}

function showContactUsPanel() {
    tryCloseRW();
    wall = document.getElementById("modalWall");
    var iWin = document.getElementById('contactUsPanel');

    if (isie()) {
        document.documentElement.style.overflow = 'hidden';
        window.scroll(0, 0);
        wall.style.position = "absolute";
        iWin.style.position = "absolute";
    }
    wall.style.display = "block";
    setTimeout("ppStep1('contactUsPanel')", 10);
    return false;
}

function showLargeImage(url, isAdopt) {
    tryCloseRW();
    wall = document.getElementById("modalWall");
    var iWin = dgbi('roomsViewer');

    if (isie()) {
        document.documentElement.style.overflow = 'hidden';
        window.scroll(0, 0);
        wall.style.position = "absolute";
        iWin.style.position = "absolute";
    }
    wall.style.display = "block";
    setTimeout("ppStep1('roomsViewer')", 10);
    var img = dgbi("screen_Image");
    img.src = url;
    if (isAdopt)
    {
        img.style.width = "800px";
        img.style.height = "600px";
    }
    img.onload = function()
    {
        img.style.visibility = "visible";
    };
    return false;
}

function ppStep1(sw) {
    var wall = document.getElementById("modalWall");

    var ieop = ppTransp * 10;
    wall.style.opacity = '0.' + ppTransp;
    wall.style.filter = 'alpha(opacity=' + ieop + ')';
    ppTransp++;
    if (ppTransp > 4) setTimeout("ppStep2('" + sw + "')", 50);
    else setTimeout("ppStep1('" + sw + "')", 40);
}

function ppStep2(sw) {
    mpp = document.getElementById(sw);
    if (isie()) mpp.style.display = "block";
    else mpp.style.display = "table";
    isPPOn = true;
}

/// TOGGLER
var toggler = function(name, max) {
    this.name = name;
    this.max = max;
};
toggler.prototype.step = 0;
toggler.prototype.tm = 0;
toggler.prototype.max = 5;
toggler.prototype.name = '';
toggler.todo = function() {
};
toggler.prototype.mfunc = function (start, end, steps, i) {
    var zo = i / (steps - 1);
    var y = start + zo * zo * (end - start);
    return y;
}
toggler.prototype.mfunc2 = function (start, end, steps, i) {
    var zo = i / (steps - 1);
    var y = start + zo * zo * (end - start);
    return y;
}
toggler.prototype.mfunc = function (start, end, steps, i) {
    var zo = i / (steps - 1);
    var y = start + Math.sqrt(zo) * (end - start);
    return y;
}
toggler.prototype.forward = function () {
    if (this.step < (this.max - 1)) {
        this.step++;
        this.todo();
        this.tm = window.setTimeout(this.name + ".forward()", 40);
    }
}

toggler.prototype.backward = function () {
    if (this.step > 0) {
        this.step--;
        this.todo();
        this.tm = window.setTimeout(this.name + ".backward()", 40);
    }
}
toggler.prototype.go = function () {
    window.clearTimeout(this.tm);
    if (this.step == 0) this.forward();
    else this.backward();
}
toggler.prototype.goforward = function () {
    window.clearTimeout(this.tm);
    if (this.step < this.max) this.forward();
}
toggler.prototype.gobackward = function () {
    window.clearTimeout(this.tm);
    if (this.step != 0) this.backward();
}
/// END of TOGGLER

pr_filter = new toggler("pr_filter", 5);
pr_filter.todo = function () {
    dgbi('pr_filterdiv').style.height = this.mfunc(23, 128, this.max, this.step) + "px";
    dgbi('pr_filtertable').style.width = this.mfunc(110, 630, this.max, this.step) + "px";
    dgbi('pr_filtertable').style.opacity = this.mfunc2(0, 1, this.max, this.step);
    + "px";
    dgbi('pr_filtertable').style.filter = "alpha(opacity = " + this.mfunc2(0, 100, this.max, this.step);
    +");"
    dgbi('pr_filterlink').blur();
    if (this.step == 1) {
        dgbi('pr_filterlink').style.backgroundPosition = "6px -16px";
    }
    if (this.step == 0) {
        dgbi('pr_filterlink').style.backgroundPosition = "6px 9px";
    }
}

function fixZIndex()
{
    var fakefile = dgbi("fileiinputcustom");
    if (fakefile)
        fakefile.style.zIndex = 0;
}

function showInfoText(my_heading, my_text) {
    tryCloseRW();
    dgbi('my_infomsg_heading').innerHTML = my_heading;
    dgbi('infomsg_text').innerHTML = my_text;
    wall = document.getElementById("modalWall");
    var iWin = document.getElementById('infoMsg');

    if (isie()) {
        document.documentElement.style.overflow = 'hidden';
        window.scroll(0, 0);
        wall.style.position = "absolute";
        iWin.style.position = "absolute";
    }
    wall.style.display = "block";
    setTimeout("ppStep1('infoMsg')", 10);
    return false;
}
function show_only_registered() {
    showInfoText(str_error, str_onlyreg_description);
}


function validate_msg(f) {
    c = trim(f.elements['content'].value);
    s = trim(f.elements['subject'].value);
    dgbi('err_msg_1').style.display = 'none';
    dgbi('err_msg_2').style.display = 'none';
    have_errors = false;
    if (s == '') {
        dgbi('err_msg_1').style.display = 'block';
        f.elements['subject'].focus();
        have_errors = true;
    }
    if (c == '') {
        dgbi('err_msg_2').style.display = 'block';
        f.elements['content'].focus();
        have_errors = true;
    }
    return !have_errors;
}

function validate_new_blog(f) {
    c = trim(f.elements['title'].value);
    dgbi('err_1').style.display = 'none';
    have_errors = false;
    if (c == '') {
        dgbi('err_1').style.display = 'block';
        f.elements['title'].focus();
        have_errors = true;
    }
    return !have_errors;
}
function validate_new_album(f) {
    c = trim(f.elements['title'].value);
    dgbi('err_1').style.display = 'none';
    have_errors = false;
    if (c == '') {
        dgbi('err_1').style.display = 'block';
        f.elements['title'].focus();
        have_errors = true;
    }
    return !have_errors;
}

function validate_blog_post(f) {
    c = trim(f.elements['content'].value);
    dgbi('err_1').style.display = 'none';
    have_errors = false;
    if (c == '') {
        dgbi('err_1').style.display = 'block';
        f.elements['content'].focus();
        have_errors = true;
    }
    return !have_errors;
}

function validate_blog_comment(f) {
    c = trim(f.elements['content'].value);
    dgbi('err_1').style.display = 'none';
    have_errors = false;
    if (c == '') {
        dgbi('err_1').style.display = 'block';
        f.elements['content'].focus();
        have_errors = true;
    }
    return !have_errors;
}
function validate_new_topic_form(f) {
    s = trim(f.elements['subject'].value);
    c = trim(f.elements['data'].value);
    dgbi('err_msg_1').style.display = 'none';
    dgbi('err_msg_2').style.display = 'none';
    have_errors = false;
    if (c == '') {
        dgbi('err_msg_2').style.display = 'block';
        f.elements['data'].focus();
        have_errors = true;
    }
    if (s == '') {
        dgbi('err_msg_1').style.display = 'block';
        f.elements['subject'].focus();
        have_errors = true;
    }
    return !have_errors;
}
function validate_forum_post(f) {
    c = trim(f.elements['data'].value);
    dgbi('err_msg_1').style.display = 'none';
    have_errors = false;
    if (c == '') {
        dgbi('err_msg_1').style.display = 'block';
        f.elements['data'].focus();
        have_errors = true;
    }
    return !have_errors;

}
function Expander(target, count, step, switcher, timeout, switcherid)
{
    var iteration = count;
    var timer = 40;
    if (!timeout)
        timer = timeout;
    var height;
    window._this = this;
    this.play = function()
    {
        if (!height)
        {
            height = dgbi(target).clientHeight;
            //height+= (!window.XMLHttpRequest && typeof(window.opera) == "undefined")?2:0;
        }
        if (iteration > 0)
        {
            var t = dgbi(target);
            height += t.expanded ? -step : step;
            if (height > 0)
            {
                t.style.height = height + "px";
                window.setTimeout("_this.play()", timer);
            }
            iteration--;
        }
        else
        {
            var t = dgbi(target);
            t.expanded = t.expanded ? false : true;
            if (switcher)
            {
                switcher.setAttribute("class", t.expanded ? "expander_down" : "expander");
                switcher.setAttribute("className", t.expanded ? "expander_down" : "expander");
            }
            if (switcherid)
            {
                var s = dgbi(switcherid);
                s.setAttribute("class", t.expanded ? "expander_arrow_down" : "expander_arrow");
                s.setAttribute("className", t.expanded ? "expander_arrow_down" : "expander_arrow");
            }
        }
        return false;
    }
}

function quote_post(post_id) {
    form_tr = dgbi('f_post_reply_tr');
    //if comment form is hidden - display it
    if (form_tr.style.display == 'none') {
        if (isie()) {
            form_tr.style.display = 'block';
        } else {
            form_tr.style.display = 'table-row';
        }
    }
    text = dgbi('post_' + post_id);
    if (text.innerText == undefined) {
        text = text.textContent;
    } else {
        text = text.innerText;
    }
    text = '[quote]' + text + '[/quote]';
    dgbi('reply_ta').value = text;
    dgbi('reply_ta').focus();
}
function bb_preview_callback(resp) {
    dgbi('infomsg_text').innerHTML = resp;
}
function bb_preview(el_id) {
    data = dgbi(el_id).value;
    data = data.replace("+", "%2B");
    data = data.replace("=", "%3D");
    data = data.replace("&", "%26");
    data = data.replace("?", "%3F");
    showInfoText(str_preview, '<img src="/images/preloader_l.gif" style="margin-left: 170px;">');
    ajaxObj = new XMLHTTP("/ajax_servers/bb_previewer.php");
    ajaxObj.debug = 0;
    ajaxObj.format = 'text';
    ajaxObj.call("data=" + data, bb_preview_callback);
}

function fixUploadFile()
{
    var fakeFileUpload = document.createElement('div');
    fakeFileUpload.className = 'fakefile';
    fakeFileUpload.appendChild(document.createElement('input'));
    var image = document.createElement('img');
    image.src = '/images/icons/find_file_icon.png';

    fakeFileUpload.appendChild(image);
    var x = document.getElementsByTagName('input');
    for (var i = 0; i < x.length; i++) {
        if (x[i].type != 'file' || x[i].id == "fxFileInput") continue;
        if (x[i].getAttribute('noscript')) continue;
        if (x[i].parentNode.className != 'fileinputs') continue;

        x[i].className = 'file hidden';
        var clone = fakeFileUpload.cloneNode(true);
        x[i].parentNode.appendChild(clone);
        x[i].relatedElement = clone.getElementsByTagName('input')[0];
        if (x[i].value)
            x[i].onchange();
        x[i].onchange = x[i].onmouseout = function () {
            this.relatedElement.value = this.value;
        }
    }
}

function edit_photo(photo_id) {
    dgbi('editable_explain').style.display = 'none';
    dgbi('editable_form').style.display = 'block';

    dgbi('editable_photo').src = dgbi('thumb_' + photo_id).src;
    dgbi('editable_id').value = photo_id;
    dgbi('editable_title').value = dgbi('thumb_' + photo_id).title;
}

function delete_photo() {
    if (confirm(str_con_del_photo)) {
        dgbi('editable_action').value = 'delete_photo';
        dgbi('editable_form').submit();
    } else {
        return false;
    }
}

function country_selected(sel_el) {
    if (sel_el.value == '0') {
        dgbi('geo_country_name').value = '';
        return true;
    }
    if (sel_el.value == 'show_full_list') {
        dgbi('geo_country_name').value = '';
        dgbi('inp_city_other').style.display = 'none';
        dgbi('country_sel').innerHTML = str_loading;
        ajaxObj = new XMLHTTP("/ajax_servers/build_geo_select.php");
        ajaxObj.debug = 0;
        ajaxObj.format = 'text';
        ajaxObj.call("act=get_all_countries", 'country_sel');
        return true;
    }
    dgbi('city_sel').innerHTML = str_loading;
    dgbi('inp_city_other').style.display = 'none';
    ajaxObj = new XMLHTTP("/ajax_servers/build_geo_select.php");
    ajaxObj.debug = 0;
    ajaxObj.format = 'text';
    ajaxObj.call("act=get_cities&country=" + sel_el.value, 'city_sel');
    dgbi('geo_country_name').value = sel_el.options[sel_el.selectedIndex].text;
    return true;
}
function city_selected(sel_el) {
    if (sel_el.value == 'other') {
        dgbi('inp_city_other').value = '';
        dgbi('inp_city_other').style.display = 'block';
    } else {
        if (sel_el.selectedIndex != -1 && sel_el.value != 0) {
            dgbi('inp_city_other').value = sel_el.options[sel_el.selectedIndex].text;
        }

        dgbi('inp_city_other').style.display = 'none';
    }
}

function jq_get_flashver() {
    var flashVer = -1;
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            var versionRevision = descArray[3];
            if (versionRevision == "") {
                versionRevision = descArray[4];
            }
            if (versionRevision[0] == "d") {
                versionRevision = versionRevision.substring(1);
            } else if (versionRevision[0] == "r") {
                ersionRevision = versionRevision.substring(1);
                if (versionRevision.indexOf("d") > 0) {
                    versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                }
            }
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        }
    } else if ($.browser.msie) {
        var version;
        var axo;
        var e;
        try {
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
            version = axo.GetVariable("$version");
        } catch (e) {
        }
        flashVer = version.replace("WIN ", "").replace(",", ".");
    }
    return flashVer;
}

function hide_table_col(table_id, col_num, do_show) {
    if (do_show) {
        if (isie()) {
            stl = 'block';
        } else {
            stl = 'table-cell';
        }
    }
    else stl = 'none';

    var tbl = dgbi(table_id);
    var rows = tbl.getElementsByTagName('tr');
    for (var row = 0; row < rows.length; row++) {
        var cels = rows[row].getElementsByTagName('td')
        if (cels.length == 0) cels = rows[row].getElementsByTagName('th')
        if (cels[col_num].style == undefined) continue;
        try {
            cels[col_num].style.display = stl;
        } catch(err) {
        }
    }
}

function ajax_fetch_popup_tpl(str_heading, str_tpl) {
    var str_loading = "<img src='/images/preloader_l.gif' style='margin-left: 170px; margin-top: 45px;'>";
    showInfoText(str_heading, str_loading);
    ajaxObj = new XMLHTTP("/ajax_servers/fetch_tpl.php");
    ajaxObj.debug = 0;
    ajaxObj.format = 'text';
    ajaxObj.call("tpl=" + str_tpl, 'infomsg_text');
}

/*************************************/
/********** CONTACT US ***************/
/*************************************/
function init_contact_panel() {
    ajax_fetch_popup_tpl(str_contact_us, 'contact_us');
    return false;
}
function sendMessage(f) {
    dgbi('contact_error_1').style.display = 'none';
    dgbi('contact_error_2').style.display = 'none';
    dgbi('contact_error_3').style.display = 'none';
    dgbi('contact_error_4').style.display = 'none';
    dgbi('contact_error_5').style.display = 'none';


    var res = true;
    var errors = new Array();
    var n_errors = 0;
    var name = trim(f.elements['contact_username'].value);
    var email = trim(f.elements['contact_email'].value);
    var title = trim(f.elements['contact_title'].value);
    var text = trim(f.elements['contact_text'].value);

    if (!isValidEmail(email)) {
        f.elements['contact_email'].focus();
        res = false;
        errors[n_errors] = 3;
        ++n_errors;
    }
    if (name == '') {
        f.elements['contact_username'].focus();
        res = false;
        errors[n_errors] = 4;
        ++n_errors;
    }
    if (email == '') {
        f.elements['contact_email'].focus();
        res = false;
        errors[n_errors] = 2;
        ++n_errors;
    }
    if (title == '') {
        f.elements['contact_title'].focus();
        res = false;
        errors[n_errors] = 1;
        ++n_errors;
    }

    if (text == '') {
        f.elements['contact_text'].focus();
        res = false;
        errors[n_errors] = 5;
        ++n_errors;
    }
    if (res == false) {
        for (err in errors) {
            code = errors[err];
            dgbi('contact_error_' + code).style.display = 'block';
        }
    } else {
        dgbi('sending_message').style.display = 'block';
        ajaxObj = new XMLHTTP("/ajax_servers/send_message.php");
        ajaxObj.debug = 0;
        ajaxObj.format = "text";
        ajaxObj.method = "POST";
        var parameters = "name=" + encodeURIComponent(name) + "&text=" + encodeURIComponent(text) + "&email=" + email + "&title=" + title;
        ajaxObj.call(parameters, sendingCallback);
    }
    return false;
}

function sendingCallback(resp) {
    if (resp == "1")
    {
        dgbi('sending_message').style.display = 'none';
        tryCloseRW();
    }
    else
    {
        dgbi('sending_message').style.display = 'none';
        dgbi('contact_error_6').style.display = 'block';
    }
}
function close_main_panel() {
    setCookie('m_panel_state', '0', 90);
    document.getElementById('adv_panel').expanded = true;
    new Expander('adv_panel', 11, 10, null, 10, 'expan').play();
}
function open_main_panel() {
    setCookie('m_panel_state', '1', 90);
    document.getElementById('adv_panel').expanded = false;
    new Expander('adv_panel', 11, 10, null, 10, 'expan').play();
}
function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()) + ";path=/";
}
function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function slidePostPannels(id)
{
    if (dgbi(id).getAttribute("class") == "right_l" || dgbi(id).getAttribute("className") == "right_l")
    {
        if (id == "fbt")
        {
            dgbi("bbt").setAttribute("class", "right_l");
            dgbi("bbt").setAttribute("className", "right_l");
            dgbi("forum_panel").style.display = "block";
            dgbi("blog_panel").style.display = "none";
        }
        else {
            dgbi("fbt").setAttribute("class", "right_l");
            dgbi("fbt").setAttribute("className", "right_l");
            dgbi("forum_panel").style.display = "none";
            dgbi("blog_panel").style.display = "block";
        }
        dgbi(id).setAttribute("class", "left_l");
        dgbi(id).setAttribute("className", "left_l");
    }

}
function slideToolsPanel(id)
{
    var target = dgbi(id);
    var parent = target.parentNode;
    var replaced = isie() ? parent.childNodes[0] : parent.childNodes[1];
    if (target == replaced)
        return;
    if (isie())
    {
        replaced.childNodes[0].style.display = "none";
        replaced.childNodes[1].style.display = "block";
    }
    else
    {
        replaced.childNodes[1].style.display = "none";
        replaced.childNodes[3].style.display = "block";
    }


    parent.removeChild(target);
    parent.replaceChild(target, replaced);
    parent.appendChild(replaced);
    if (isie())
    {
        target.childNodes[0].style.display = "block";
        target.childNodes[1].style.display = "none";
    }
    else {
        target.childNodes[1].style.display = "block";
        target.childNodes[3].style.display = "none";
    }

    if (id == "calendar_tab")
    {
        dgbi("calendar_content").style.display = "block";
        dgbi("calculator_content").style.display = "none";
        dgbi("shark_content").style.display = "none";

    }
    else if (id == "calc_tab")
    {
        dgbi("calculator_content").style.display = "block";
        dgbi("calendar_content").style.display = "none";
        dgbi("shark_content").style.display = "none";
    }
    else {
        dgbi("calculator_content").style.display = "none";
        dgbi("calendar_content").style.display = "none";
        dgbi("shark_content").style.display = "block";
    }
    setCookie('default_tool', id, 90);

}

function markBlog(id,type)
{
      ajaxObj = new XMLHTTP("/blogs/index.html");
      ajaxObj.debug = 0;
      ajaxObj.format = 'text';
      ajaxObj.call("id=" + id + "&rank=" + type,markCallback);
}

function markCallback(resp) {
     var resp= resp.split(":");
     if(resp.length == 1)
     {
       alert(resp[0]);
       return;  
     }
     var mark = parseInt(dgbi("rate"+resp[0]).innerHTML) + (resp[1]==0?1:-1);
     var class_css = mark>=0?"true":"false";
     dgbi("rate"+resp[0]).setAttribute("class", class_css);
     dgbi("rate"+resp[0]).setAttribute("className", class_css);
     dgbi("rate"+resp[0]).innerHTML = mark;
     dgbi("ratec"+resp[0]).style.display="none";
}






