var ID;

function addPopup(id, width, height, image, url, timeout) {
	if(image.length > 0) {
		var obj = document.createElement('div');
		obj.id = id;
		obj.className = 'popup';
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = screen.availHeight;
		}
		else {
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		obj.style.left = Math.round(winW / 2) - Math.round(width / 2) + 'px';
		obj.style.top = Math.round(winH / 2) - Math.round(height / 2) + 'px';
		obj.style.zIndex = 100;
		var html = '<a href="' + url + '"><img src="' + image + '" height="' + height + '"px';
		html += 'width="' + width + 'px" border="0" /></a>';
		html += '<p><button type="submit" class="buttom" onclick="closePopup(\'' + id + '\');">Bezárás</button></p>';
		obj.innerHTML = html;
		document.body.appendChild(obj);
		ID = setInterval('closePopup(\'' + id + '\')', timeout * 1000);
	}
}

function closePopup(id) {
	clearInterval(ID);
	var obj = document.getElementById(id);
	if(obj) document.body.removeChild(obj);
}