var loadingImage = '<img src="/img/load_1.gif" height="16" width="16" />'

function doNothing( )
{
        return true
}
window.onerror = doNothing

function do_enter(pathto, div)
{
        var xmlObject = new XmlHttp(loadingImage)

        xmlObject.setReturnFunction(function(text, div)
        {
                if (text != '') $(div).innerHTML = text
        })

        xmlObject.getContents('/content/dcontent/' + div + '/' + pathto, div)
}

function run()
{
        default_page = $('a1_1').id
        reg_page = $('a1_3').id
        run_menu()
}

function run_menu()
{
        var tda = new Array()
        for (var i = 1 ; i < 6 ; i++)
        {
                tda[i] = 'a1_' + i
                if ($(tda[i]).id == default_page)
                {
                        $(tda[i]).className = tda[i] + "o"
                        $(tda[i]).onmouseover = function()
                        {
                                this.className=this.id + "o"
                        }
                        $(tda[i]).onmouseout = function()
                        {
                                this.className=this.id + "o"
                        }
		}
                else if ($(tda[i]).id == reg_page)
                {
                        $(tda[i]).className = tda[i] + "a"
                        $(tda[i]).onmouseover = function()
                        {
                                this.className=this.id + "o"
                        }
                        $(tda[i]).onmouseout = function()
                        {
                                this.className=this.id + "a"
                        }
                        $(tda[i]).onclick = function()
                        {
                                location.href='/content/reg'
                        }
		}
		else
		{
                        $(tda[i]).className = tda[i] + "a"
                        $(tda[i]).onmouseover = function()
                        {
                                this.className=this.id + "o"
                        }
                        $(tda[i]).onmouseout = function()
                        {
                                this.className=this.id + "a"
                        }
                        $(tda[i]).onclick = function()
                        {
                                do_enter(this.id,'main_body')
                                default_page = this.id
                                run_menu()
                        }
		}
	}

        focus_enter = false

        $('a1_6').className = 'a1_6a'
        $('a1_6').onmouseover = function()
        {
                this.className = 'a1_6o'
                $('a2_3').style.visibility = 'visible'
                if(focus_enter == false)
                {
                        $('ido').focus()
                        focus_enter = true
                }
        }
        $('a1_6').onmouseout = function()
        {
                this.className = 'a1_6a'
                $('a2_3').style.visibility = 'hidden'
        }
        $('a2_3').onmouseover = function()
        {
                $('a1_6').className = 'a1_6o'
                $('a2_3').style.visibility = 'visible'
                if(focus_enter == false)
                {
                        $('ido').focus()
                        focus_enter = true
                }
        }
        $('a2_3').onmouseout = function()
        {
                $('a1_6').className = 'a1_6a'
                $('a2_3').style.visibility = 'hidden'
        }
        $('a1_6').onclick = function()
        {
        }

}

function inputValue(id)
{
        return $(id).value
}

function send_post(pathto, div, data)
{
        var xmlObject = new XmlHttp()

        xmlObject.setReturnFunction(function(text, div)
        {
                if (text != '') $(div).innerHTML = text
        })

        xmlObject.postContents(pathto, div, data)
}

function do_login()
{
        var xmlObject = new XmlHttp(loadingImage)

        $('a2_3').onmouseout = function()
        {
                $('a1_6').className = $('a1_6').id + "o"
                $('a2_3').style.visibility = 'visible'
        }
        $('a2_3').style.backgroundColor='#ffffff'

        username = document.login_form.ido.value
        if (!username)
        {
                $('a2_3').onmouseout = function()
                {
                        $('a1_6').className = $('a1_6').id + "a"
                        $('a2_3').style.visibility = 'hidden'
                }
                $('a2_3').style.backgroundColor = '#7E7A24'
                alert('Neįvedėte savo ID')
                return false
        }
        password = document.login_form.pass.value
        if (!password)
        {
                $('a2_3').onmouseout = function()
                {
                        $('a1_6').className = $('a1_6').id + "a"
                        $('a2_3').style.visibility = 'hidden'
                }
                $('a2_3').style.backgroundColor = '#7E7A24'
                alert('Neįvedėte slaptažodžio')
                return false
        }

        xmlObject.setReturnFunction(function(text, div)
        {
                if(text=='')
                {
                        window.location = "https://acta.lt/valdymas/klientas/" + username
                }
                else
                {
                        $(div).innerHTML = text
                        $('a2_3').onmouseout = function()
                        {
                                $('a1_6').className = $('a1_6').id + "a"
                                $('a2_3').style.visibility = 'hidden'
                        }
                        $('a2_3').style.backgroundColor = '#7E7A24'
                }
        })

        xmlObject.getContents('/valdymas/auth.php?user=' + username + '&pass=' + password, 'login')
}

function set_static_1()
{
        $('a2_3').onmouseout = function()
        {
                $('a1_6').className = $('a1_6').id + "o"
                $('a2_3').style.visibility = 'visible'
        }
}

addLoadEvent(run)
