
function mainaBaltuFonu(webroot){
    hide_other_sub_menu('');
    if(!fotoNeeksiste){
        if(fonsBalts){
            palielinaBildi(false);
            fonsBalts = false;
            nomainaPogas(aktivaBilde);
        }else{
            palielinaBildi(true);
            fonsBalts = true;
            nomainaPogas(aktivaBilde);
        }
    }
}

//something about resizing images
function palielinaBildi(palielinaat)
{
    
    var bildesNr = aktivaBilde;
    var bildesAugstumsSmall = fotoHeightSmall[bildesNr];
    var bildesAugstums = fotoHeight[bildesNr];
    var bildesPlatumsSmall = fotoWidthSmall[bildesNr];
    var bildesPlatums = fotoWidth[bildesNr];

    var millisec = 0;

    var speed = Math.round(millisec / (bildesAugstums - bildesAugstumsSmall));
    var hSpeed = Math.round(millisec / (bildesPlatums - bildesPlatumsSmall));
    var mSpeed = Math.round(millisec / 70);

    //determine the direction for the blending, if start and end are the same nothing happens
    if(palielinaat){
        //alert("hm");
        izmetMenu();
        //palielinaAugstumu(bildesAugstumsSmall, bildesAugstums, speed);
        changeHeight(bildesAugstums, 'flashMaskImage');
        changeWidth(bildesPlatums, 'flashMaskImage');
        //palielinaPlatumu(bildesPlatumsSmall, bildesPlatums, hSpeed);
        //removeMarginTop(mSpeed);
        var ekranaAugstums = document.body.clientHeight;
var augsmala = (ekranaAugstums-450)/2;
        changeTopMargin(70, 'flashMaskImage');
        
    }else if(!palielinaat) {
        paradaMenu();
        changeHeight(bildesAugstumsSmall, 'flashMaskImage');
        changeWidth(bildesPlatumsSmall, 'flashMaskImage');
        changeTopMargin(0, 'flashMaskImage');
        //samazinaAugstumu(bildesAugstumsSmall, bildesAugstums, speed);
        //samazinaPlatumu(bildesPlatumsSmall, bildesPlatums, hSpeed);
        //addMarginTop(mSpeed);
        //setTimeout('paradaMenu();', millisec);
        
    }
    
}

function paradaMenu()
{
    document.body.style.backgroundImage = 'url(/app/webroot/img/fons.jpg)';
    document.getElementById('contentDiv').style.margin = '21px 0px 21px 0px';
    document.getElementById('menuRow').style.display = 'block';
    document.getElementById('baltskvadrats').style.display = 'block';
    document.getElementById('sarkanskvadrats').style.display = 'none';
    document.getElementById('normalButtons').style.display = 'block';
    document.getElementById('whiteButtons').style.display = 'none';
    document.getElementById('imgDescription').style.display = 'block';
}

function izmetMenu()
{   
    document.getElementById('contentDiv').style.margin = '40px 0px 21px 0px';
    document.getElementById('menuRow').style.display = 'none';
    document.getElementById('baltskvadrats').style.display = 'none';
    document.getElementById('sarkanskvadrats').style.display = 'block';
    document.getElementById('normalButtons').style.display = 'none';
    document.getElementById('whiteButtons').style.display = 'block';
    document.getElementById('imgDescription').style.display = 'none';
    document.body.style.backgroundImage = 'url(/app/webroot/img/balts.jpg)';
}

function removeMarginTop(mSpeed)
{
    var timer = 0;
    for(i = 0; i <= 70; i++)
    {
        setTimeout("changeTopMargin(" + i + ",'" + "flashMaskImage" + "')",(timer * mSpeed));
        timer++;
    }
}

function addMarginTop(mSpeed)
{
    var timer = 0;
    for(i = 70; i >= 0; i--)
    {
        setTimeout("changeTopMargin(" + i + ",'" + "flashMaskImage" + "')",(timer * mSpeed));
        timer++;
    }
}

function changeTopMargin(height, id) {
    var object = document.getElementById(id).style;
    object.margin = ("-" + height + "px 0px 0px 0px");
}

function palielinaAugstumu(bildesAugstumsSmall, bildesAugstums, speed)
{
    var timer = 0;
    for(i = bildesAugstumsSmall; i <= bildesAugstums; i++)
    {
        setTimeout("changeHeight(" + i + ",'" + "flashMaskImage" + "')",(timer * speed));
        timer++;
    }
}

function palielinaPlatumu(bildesPlatumsSmall, bildesPlatums, hSpeed)
{
    var timer = 0;
    for(i = bildesPlatumsSmall; i <= bildesPlatums; i++)
    {
        setTimeout("changeWidth(" + i + ",'" + "flashMaskImage" + "')",(timer * hSpeed));
        timer++;
    }
}

function samazinaAugstumu(bildesAugstumsSmall, bildesAugstums, speed)
{
    var timer = 0;
    for(i = bildesAugstums; i >= bildesAugstumsSmall; i--)
    {
        setTimeout("changeHeight(" + i + ",'" + "flashMaskImage" + "')",(timer * speed));
        timer++;
    }
}

function samazinaPlatumu(bildesPlatumsSmall, bildesPlatums, hSpeed)
{
    var timer = 0;
    for(i = bildesPlatums; i >= bildesPlatumsSmall; i--)
    {
        setTimeout("changeWidth(" + i + ",'" + "flashMaskImage" + "')",(timer * hSpeed));
        timer++;
    }
}

function changeHeight(height, id) {
    var object = document.getElementById(id);
    object.height = (height);
}

function changeWidth(width, id) {
    var object = document.getElementById(id);
    object.width = (width);
}
function changeWidth2(width, id) {
    var object = document.getElementById(id);
    object.style.width = (width+"px");
}