
jQuery(document).ready(function(){
	jQuery('#adOverlay').css({
		height: jQuery(document).height(),
		width: jQuery(document).width()
	});
});


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() {
	jQuery('#adOverlay, #'+popupAdConfig.adId).animate({
		opacity: 0
	}, 'slow', function(){
		jQuery(this).css('display', 'none')
	});
}


var output = '<map name="'+popupAdConfig.mapName+'">';
//for(var i in popupAdConfig.areas) {
for (var i=0; i<popupAdConfig.areas.length; i++) {
	var area = popupAdConfig.areas[i];
	output += '<area shape="rect" coords="'+area.map+'" href="'+area.href+'" onclick="'+area.onclick+'" />';
}
output += '</map>';


output += "<div id='adOverlay' onclick='adClose()' 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);

