var db_browser = null;
var db_h = null;
var db_rh = null;
var db1=0;
var db_hideleft = false;

function db_onload()
{
	db_browser = document.getElementById("browser");
	db_h = document.getElementById("db_h");
	db_rh = document.getElementById("db_resizehook");
	db_onresize();
	db_hideleft = false;
}

function db_onresize()
{

	if (db_h) 
	{
		db1=db_h.height;} else db1=666;

	if (db_rh)
	{
		db_rh.style.height=db1-276+"px";
	}
}

var db_obj = null;
var db_tmpobj = null;
var db_tmpobj2= null;
var db_tmpstr = "";

function db_checkswitch(obj) 
{
	db_tmpobj=document.getElementById(obj);
	if (db_tmpobj)
	{
		if (!db_is_checked(db_tmpobj))
		    db_set_checked(db_tmpobj, true);
		else
		    db_set_checked(db_tmpobj, false);
	}
}

function db_is_checked(checkbox) 
{
	return checkbox.style.backgroundPosition == "50% 0%";
}

function db_set_checked(checkbox,isChecked) 
{
    if(isChecked)
		checkbox.style.backgroundPosition = "50% 0%";
	else
		checkbox.style.backgroundPosition = "50% 100%"
}

function db_radio_off(obj) 
{
	db_tmpobj=document.getElementById(obj);
	if (db_tmpobj)
	{
		db_tmpobj.style.backgroundPosition = "center bottom";
	}
}

function db_radio_on(obj) 
{
	db_tmpobj=document.getElementById(obj);
	if (db_tmpobj)
	{
		db_tmpobj.style.backgroundPosition = "center top";
	}
}

function db_pos(obj, percent) 
{
	if (obj)
	{
		db_obj = obj;
		obj.style.backgroundPosition = "center "+percent;
	}
}

function db_iposback(obj) 
{
	if (obj) obj.style.backgroundPosition = "center top";
	db_obj = null;
}

function db_rpos(obj, percent) 
{
	if (obj)
	{
		db_obj = obj;
		obj.style.backgroundPosition = "right "+percent;
	}
}

function db_irposback(obj) 
{
	if (obj) obj.style.backgroundPosition = "right top";
	db_obj = null;
}

function db_rout() 
{
	if (db_obj) db_irposback(db_obj);
}

function db_out() 
{
	if (db_obj) db_iposback(db_obj);
}

function db_mpos(obj,percent) 
{
	if (obj)
	{
		db_obj = obj;
		db_tmpstr = obj.style.backgroundPosition;
		if (percent=="-34px")
		{
			if (db_tmpstr == "center top") {obj.style.backgroundPosition = "center -34px";} else 
			if (db_tmpstr == "") {obj.style.backgroundPosition = "center -34px";} else 
			if (db_tmpstr == "center -102px") {obj.style.backgroundPosition = "center -136px";}
		} else
		if (percent=="-68px")
		{
			if (db_tmpstr == "center -34px") {obj.style.backgroundPosition = "center -68px";} else 
			if (db_tmpstr == "center -136px") {obj.style.backgroundPosition = "center -170px";}
		}
		
	}
}
function db_mchange(obj) 
{
	
	if (obj)
	{
		db_obj = obj;
		db_tmpstr = obj.style.backgroundPosition;
		
			if (db_tmpstr == "") {obj.style.backgroundPosition = "center -102px";} else 
			if (db_tmpstr == "center top") {obj.style.backgroundPosition = "center -102px";} else 
			if (db_tmpstr == "center -34px") {obj.style.backgroundPosition = "center -136px";} else 
			if (db_tmpstr == "center -68px") {obj.style.backgroundPosition = "center -136px";} else 
			if (db_tmpstr == "center -102px") {obj.style.backgroundPosition = "center top";} else
			if (db_tmpstr == "center -136px") {obj.style.backgroundPosition = "center -34px";} else
			if (db_tmpstr == "center -170px") {obj.style.backgroundPosition = "center -34px";}
		

	}
}

function db_mout() 
{
	if (db_obj) 
	{
		db_tmpstr = db_obj.style.backgroundPosition;

		if ((db_tmpstr == "center -68px") || (db_tmpstr == "center -34px") || (db_tmpstr=="")) db_obj.style.backgroundPosition = "center top"; else
		if ((db_tmpstr == "center -136px") || (db_tmpstr == "center -170px")) db_obj.style.backgroundPosition = "center -102px";
		db_obj = null;
		
	}
}

function db_togglegroup(obj) 
{
	db_tmpobj=document.getElementById(obj);
	if (db_tmpobj)
	{
		db_tmpstr=db_tmpobj.style.visibility;
		if (db_tmpstr == "hidden") {db_tmpobj.style.visibility="visible";} else 
		if (db_tmpstr == "visible") {db_tmpobj.style.visibility="hidden";}  
	}
}

function db_togglehidepos(obj) 
{
	db_tmpobj=document.getElementById(obj);
	if (db_tmpobj)
	{
		if (db_hideleft) {db_tmpobj.style.left="229";} 
		else {db_tmpobj.style.left="-1"; }
	}
	
	db_tmpobj=document.getElementById("the_menu");
	if (db_tmpobj)
	{
		if (db_hideleft) {db_tmpobj.style.visibility="visible";} 
		else {db_tmpobj.style.visibility="hidden"; }
	}
	
	db_tmpobj=document.getElementById("in_content");
	if (db_tmpobj)
	{
        var w = document.documentElement.clientWidth;
		if (db_hideleft) {db_tmpobj.style.width=(w-255)+'px';} 
		else {db_tmpobj.style.width=(w-26)+'px'; }
	}
	db_tmpobj=document.getElementById("content");
	if (db_tmpobj)
	{
        var w = document.documentElement.clientWidth;
		if (db_hideleft) {db_hideleft = false; db_tmpobj.style.left="246"; db_tmpobj.style.width=(w-250)+'px';} 
		else {db_hideleft = true; db_tmpobj.style.left="17"; db_tmpobj.style.width=(w-21)+'px'; }
	}
    if (FrameContainer)
    {
        FrameContainer.DoResize();
    }
}

// Allows input for digits only in myfield element.
// e - onkeypress event.
function numbers_only(myfield, e)
{
    var key;
    var keychar;

    if (window.event)
       key = window.event.keyCode;
    else if (e)
       key = e.which;
    else
       return true;
    keychar = String.fromCharCode(key);

    // control keys
    if ((key==null) || (key==0) || (key==8) || 
        (key==9) || (key==13) || (key==27) )
       return true;

    // numbers
    else if ((("0123456789").indexOf(keychar) > -1))
       return true;

    else
       return false;
}

// Increments or decrements the value of myfield element.
// It is expected that myfield contains an integer number only or nothing.
function up_down(myfield, up)
{
    if(myfield.value != '')
    {
        var num = parseInt(myfield.value, 10);
        num = up == true ? num+1 : num-1;
        myfield.value = num;
    }
}

function db_go(address) 
{
	location.href=address;
}

