/*
 * Popup
 */
function popup(url, w, h) {
	if (typeof w == "undefined") {
		w = '800';
	}
	if (typeof h == "undefined") {
		h = '600';
	}
	window.open(url, "Firstload", "height=" + h + ", width=" + w + ", scrollbars=yes");
}

if (window.addEventListener) {
    window.addEventListener('load', function () {
        if (document.getElementById('clientwindow_background')) {
            var links
            var i
            var showDownloadWindow = function(e) {
                document.getElementById('clientwindow_background').style.display='block'
                if (!e) {
                    e = window.event
                }
                e.cancelBubble=true
                if (e.stopPropagation) {
                    e.stopPropagation()
                }
                if (e.preventDefault) {
                    e.preventDefault()
                }
            }
            document.getElementById('clientwindow_background').addEventListener('click', function() {
                document.getElementById('clientwindow_background').style.display='none'
            }, false)
            links = document.getElementById('clientwindow_background').getElementsByTagName('a')
            for (i in links) {
                if (links.hasOwnProperty(i) && i != 'length') {
                    links[i].addEventListener('click', function() {
                        document.getElementById('clientwindow_background').style.display='none'
                    }, false)
                }
            }
            links = document.getElementsByTagName('a')
            for (i in links) {
                if (links.hasOwnProperty(i) && i != 'length') {
                    if (links[i].href == document.location.protocol + '//' + document.location.hostname + '/client/' ||
                        links[i].href == '/client/') {
                        links[i].addEventListener('click', showDownloadWindow, false)
                    }
                }
            }
        }
    }, false)
}

