
var popupAdConfig = {
	link: popupLink,
	img: {
		src: popupImage,
		width: 458,
		height: 430
	},
	areaLink: {
		top: 20,
		left: 0,
		height: 410,
		width: 458
	},
	areaClose: {
		top:0,
		left:408,
		height: 50,
		width: 50
	},
	mapName: 'popupAdMap',
	adId: 'popupAdId',
	overlayOpacity: 0.8
};


function createMap(obj) {
	var bottom = obj.top + obj.height;
	var right = obj.left + obj.width;
	return ''+obj.left+','+obj.top+','+right+','+bottom;
}


function getCSSPosition() {
	var marginTop = -popupAdConfig.img.height / 2;
	var marginLeft = -popupAdConfig.img.width / 2;
	return 'margin-top:'+marginTop+'px; margin-left:'+marginLeft+'px;';
}


function adClose() {
	document.getElementById('adOverlay').style.display="none";
	document.getElementById(popupAdConfig.adId).style.display="none";
}


var output = "<map name='"+popupAdConfig.mapName+"'>"
			+"<area shape='rect' coords='"+createMap(popupAdConfig.areaClose)+"' href='javascript:void(0);' onclick='adClose();'>"
			+"<area shape='rect' coords='"+createMap(popupAdConfig.areaLink)+"' href='"+popupAdConfig.link+"'>"
		+"</map>";

output += "<div id='adOverlay' style='position:absolute; top:0; left:0; height:"+document.documentElement.clientHeight+"px; width:100%; z-index:100; background-color: black; opacity:"+popupAdConfig.overlayOpacity+";  filter:alpha(opacity="+(100*popupAdConfig.overlayOpacity)+");'>"
			+"</div>";
	
output += "<div id='"+popupAdConfig.adId+"' style='position:absolute; top:50%; left:50%; "+getCSSPosition()+" z-index:101;'>"
			+"<img src='"+popupAdConfig.img.src+"' width='"+popupAdConfig.img.width+"' height='"+popupAdConfig.img.height+"' border='0' usemap='#"+popupAdConfig.mapName+"' />"
		+"</div>";
		
document.write(output);
