
var g_cont_id = 0;

function getElementPosition(elemId)
{
    var elem = elemId;
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
    var l = 0;
    var t = 0;
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }
    return {"left":l, "top":t, "width": w, "height":h};
}

function showPopup(cont_id,this_link, width, height) {	
    hidePopup();
    g_cont_id = cont_id + 1;
    el = 'popup_window_res_'+cont_id;
    document.getElementById(el).style.display = 'block';
    
    var pop_width = width + 50;
    var pop_height = height + 50;    
    var win_width = document.getElementById('body').offsetWidth;
    var win_height = document.getElementById('body').offsetHeight;    
    document.getElementById(el).style.left = (((win_width - pop_width)/2)-((win_width/2)-420))+'px';
    document.getElementById(el).style.top = ((win_height/2) - (pop_height/2))+'px';

    el_text = 'popup_window_text_'+cont_id;
    document.getElementById(el_text).style.width = (pop_width-70)+'px';    
    
}

function showPopupLeft(cont_id,this_link, width, height) {	
    hidePopup();
    g_cont_id = cont_id + 1;
    el = 'popup_window_res_'+cont_id;
    document.getElementById(el).style.display = 'block';
    
    var pop_width = width + 50;
    var win_height = document.getElementById('img_0').offsetTop - 11;    
    document.getElementById(el).style.left = '-6px';
    document.getElementById(el).style.top = win_height+'px';

    el_text = 'popup_window_text_'+cont_id;
    document.getElementById(el_text).style.width = (pop_width-70)+'px';    
    
}

function hidePopup() {
        if(g_cont_id) {
        	cont_id = g_cont_id - 1;
            el = 'popup_window_res_'+cont_id;
            el_player = 'popup_window_player_'+cont_id;
            player = document.getElementById(el_player);
            if(player) {
                    content_player = player.innerHTML;
                    player.innerHTML = '';
            }
            document.getElementById(el).style.display = 'none';
            if(player) {
                    player.innerHTML = content_player;
            }
        }
        g_cont_id = 0;
}

function preloader()  {
     var i = 0;
     imageObj = new Image();

     images = new Array();
     images[0]="images/contact_form.png"
     images[1]="images/contact_form2.png"

     for(i=0; i<2; i++) {
          imageObj.src=images[i];
     }
} 


