﻿function phtooltip_findPosX(obj) 

{

  var curleft = 0;

  if (obj.offsetParent) 

  {

    while (obj.offsetParent) 

        {

            curleft += obj.offsetLeft

            obj = obj.offsetParent;

        }

    }

    else if (obj.x)

        curleft += obj.x;

    return curleft;

}

 

 

function phtooltip_findPosY(obj) 

{

    var curtop = 0;

    if (obj.offsetParent) 

    {

        while (obj.offsetParent) 

        {

            curtop += obj.offsetTop

            obj = obj.offsetParent;

        }

    }

    else if (obj.y)

        curtop += obj.y;

    return curtop;

}

 

function phtooltip_show(tooltipId, parentId, posX, posY)

{

    it = document.getElementById(tooltipId);

    

    if ((it.style.top == '' || it.style.top == 0) 

        && (it.style.left == '' || it.style.left == 0))

    {

        // need to fixate default size (MSIE problem)

        it.style.width = it.offsetWidth + 'px';

        it.style.height = it.offsetHeight + 'px';

        

        a = document.getElementById(parentId); 

 

            // if tooltip is too wide, shift left to be within parent 

        if (posX + it.offsetWidth > a.offsetWidth) posX = a.offsetWidth - it.offsetWidth;

        if (posX < 0 ) posX = 0; 

 

        x = phtooltip_findPosX(a) - 374;

        y = phtooltip_findPosY(a) - 150;

        

        it.style.top = y + 'px';

        it.style.left = x + 'px';

    }

    

    it.style.visibility = 'visible'; 

}

 

function phtooltip_hide(id)

{

    it = document.getElementById(id); 

    it.style.visibility = 'hidden';

}

function toggleDDLValPosl() {
    var val = $("#ddlPoslVal").val();    
    loadValutaDDL(val);
}

function toggleDDLValIzvj() {
    var val = $("#ddlPoslIzvj").val();
    loadValutaDDL(val);
}

function loadValutaDDL(valuta) {
    var href = $(location).attr('href');
    if (href != null) {
        paramval = getUrlParam(href, 'val')
        if (paramval != null) {                      
            href = href.replace('val=' + paramval, 'val=' + valuta);
        } else {            
            href = href + "&val=" + valuta;
        }        
        window.location.href = href;
    }
}




