﻿// JavaScript Document

var sub_con;
var sub;
var i;

function expand(mnu_con, mnu)
{

    if(sub_con!=undefined){sub_con.style.display="none";}
    
   i=0; 
    sub_con = document.getElementById(mnu_con);
    sub = document.getElementById(mnu);
    if(sub_con.style.display=="block")
    {
        i = sub.clientHeight;
        hh();
    }
    else
    {
        sh();
    }
}


function sh()
{
sub_con.style.height = i + 'px';
sub_con.style.display="block";
i = i + 5;
sub_con.style.height = i + 'px';
//alert('suveike'+sub_con.style.height+sub.clientHeight);
    if(i < sub.clientHeight)
        {
            setTimeout("sh()",10);
            //alert(sub.clientHeight);
        }
    if(i>=sub.clientHeight)
    {
    sub_con.clinetHeight = sub.clientHeight;
    }
} 

function hh()
{
sub_con.style.height = i + 'px';
i = i - 5;
//alert('suveike'+sub_con.style.height+sub.clientHeight);
    if(i > 0)
        {
            setTimeout("hh()",10);
            //alert(sub.clientHeight);
        }
    if(i<=0)
    {
    sub_con.style.display="none";
    }
}

//Prideda kablelius prie skaiciaus
function pridetiKablelius(strValue)
{
strValue = strValue.toString().replace(/,/g,'');
strValue += '';
if (isNaN(strValue)){alert('Įvedamas skaičius!');}
x = strValue.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}

//Keiciame spalva
function colorize(ctr)
{
var a = ctr.value;
if (a.indexOf("-") > -1)
    {
        ctr.style.color='green';
    }
    else
    {
        ctr.style.color='black';
    }
}


