var bh;
var pd = 27;
var d = document;
var ie7 = (d.all && !window.opera && window.XMLHttpRequest) ? true : false;

var min_height = function() {
    var mc = d.getElementById('main_content');
    if (!mc) return;
    bh = (self.innerHeight) ? self.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : (document.body) ? document.body.clientHeight : 0;
    if (bh > 0) {
        var hh = d.getElementById('header').offsetHeight;
        var fh = d.getElementById('footer').offsetHeight;
        var th = bh-hh-fh-pd;
        if(self.innerHeight || ie7) {
            mc.style.height = 'auto';
            mc.style.minHeight = th + 'px';
        } else {
            mc.style.height = th + 'px';
        };
        var dh = d.getElementsByTagName('body')[0].offsetHeight;
        var tt = d.getElementById('to_top');
        if (dh < bh) tt.style.visibility = 'hidden';
    };
};
var contact_button = function() {
    if (!d.getElementById('submit_button')) return;
    var btn = d.getElementById('submit_button');
    btn.onmouseover = function() {
        this.src = '/css/cssimg/posalji_hover.gif';
    };
    btn.onmouseout = function() {
        this.src = '/css/cssimg/posalji.gif';
    };
};
var windowHandle = null;
var windowHandle_closed = false;
var openWindow = function(url,width,height) {
    if (openWindow.arguments.length > 3) {
        windowHandle = window.open(url, '', openWindow.arguments[3] + ',left=' + ((screen.width/2+60)-width/2) + ',top=' + 50 + ',width=' + width + ',height=' + height);
    } else {
        windowHandle = window.open(url, '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=' + ((screen.width/2+60)-width/2) + ',top=' + 50 + ',width=' + width + ',height=' + height);
    };
    if (windowHandle_closed == true) {
        windowHandle_closed = false;
    };
};
var closeWindow = function() {
    if (windowHandle != null) {
        if (!windowHandle_closed) {
            windowHandle_closed = true;
            if (windowHandle.close) windowHandle.close();
        };
    };
};
var popmeup = function() {
    var lks = d.getElementsByTagName('a');
    var lksl = lks.length;
    for (var i = 0; i < lksl; i++) {
        lk = lks[i];
        if (lk.className.indexOf('popmeup') == -1) continue;
        lk.onclick = function() {
            closeWindow();
            openWindow(this.href,'500','500');
            return false;
        };
    };
};
if (d.getElementById && d.getElementsByTagName) {
    window.onload = function() {
        min_height();
        contact_button();
        popmeup();
    };
};