var is_ie = navigator.appName == "Microsoft Internet Explorer";
var is_nav = navigator.appName == "Netscape";
var is_op = navigator.appName == "Opera";

function fetch_object(idname)
{
	if (document.getElementById)
	{
		return document.getElementById(idname);
	}
	else if (document.all)
	{
		return document.all[idname];
	}
	else if (document.layers)
	{
		return document.layers[idname];
	}
	else
	{
		return null;
	}
}

// -----------------------------------------------

function fix__content_in()
{
    o = fetch_object('content_in');
    hd = 300;
    
    if (is_nav || is_ie){
        if (is_nav){
            h_w = window.innerHeight;
        }
        if (is_ie) {
            h_w = document.body.offsetHeight;
        }
        h_c = h_w - hd;
        if (o.scrollHeight > h_c){
            o.style.height = h_c;
            //o.style.overflowY = 'scroll';
        }
    }
    
    if (is_op) {
        h_w = window.innerHeight;
        h_c = h_w - hd;
        if ((o.scrollHeight + 200) > h_c){
            o.style.height = h_c;
            //o.style.overflow = 'auto';
        }
    }
}

// ---------------------------------------------------
function theme(id)
{
    //ajax_do('theme.php?theme=' + id);
    fetch_object('ss').href='css/style.php?theme=' + id;
}

var content__scroll_n = 0;
function content__scroll(hid, t, max_n)
{
    var h = fetch_object(hid);
    var diff;
    
    max_n -= 20;
    
    if ((t == 1 && content__scroll_n == max_n) || (t == -1 && content__scroll_n == 0)){
        return;
    }
    
    content__scroll_n += t;
    
    /*if (is_ie){
        diff = 38 + Math.floor(blog_scroll_n / 3);
    } else {
        diff = 37;
    }*/
    diff = h.offsetHeight * content__scroll_n / 2;
    if (t == 1 && diff > h.scrollHeight){
        content__scroll_n -= t;
        return;
    }
    
    h.scrollTop = diff;
}

function protector__show(t)
{
    if (t == 1){
        sd = 'block';
        setTimeout('protector__show()', 3000);
    } else {
        sd = 'none';
    }
    
    h = fetch_object('protector');
    h.style.display = sd;
}

function hide_show_date(block) {
    var temp1 = fetch_object('date_'+block);
    var temp2 = fetch_object('date_plus_'+block);
    if (temp1.style.display=='block') {
        temp1.style.display='none';
        temp2.innerHTML = '-';
    } else {
        temp1.style.display='block';
        temp2.innerHTML = '+';
    }
    
}

function comments_change(i) {
    fetch_object('comments_form'+i).style.display='block';
    fetch_object('comments_button'+i).style.display='none';
}    