/*
----------------
04/11/2011 overlay javascript unobotrusive
by Giulio Pons
http://www.barattalo.it/2011/11/07/unobtrusive-javascript-to-add-an-overlay-banner
----------------
*/

function ovRemove(){d=document;g=d.getElementsByTagName("body")[0];g.removeChild(d.getElementById("ovContainer"));g.removeChild(d.getElementById("ovContainer0"));document.onkeydown=null}function ov_add(a){d=document;w=window;e=d.documentElement;g=d.getElementsByTagName("body")[0];if(d.getElementById("ovContainer"))return;mObj0=g.appendChild(d.createElement("div"));mObj0.id="ovContainer0";mObj0.style.height=e.scrollHeight+"px";mObj=g.appendChild(d.createElement("div"));mObj.id="ovContainer";mObj.style.height=e.scrollHeight+"px";ovObj=mObj.appendChild(d.createElement("div"));ovObj.id="ovBox";if(d.all&&!w.opera)ovObj.style.top=e.scrollTop+"px";x=w.innerWidth||e.clientWidth||g.clientWidth;y=w.innerHeight||e.clientHeight||g.clientHeight;ovObj.style.left=(x-ovObj.offsetWidth)/2+"px";ovObj.innerHTML=a;ovObj.style.top=(y-ovObj.offsetHeight)/2+"px";btn=ovObj.appendChild(d.createElement("a"));btn.id="ovClose";btn.appendChild(d.createTextNode("X"));btn.href="#";btn.onclick=function(){ovRemove();return false}}function ov_event(a,b,c){document.onkeydown=function(a){a=a||window.event;if(a.keyCode==27){ovRemove()}};if(a.addEventListener){a.addEventListener(b,c,false);return true}else if(a.attachEvent){var d=a.attachEvent("on"+b,c);return d}else{return false}}function ov_css(a){var b=document.createElement("style");b.type="text/css";if(b.styleSheet){b.styleSheet.cssText=a}else{b.appendChild(document.createTextNode(a))}document.getElementsByTagName("head")[0].appendChild(b)}ov_event(window,"load",overlay);

function overlay() {
	// CUSTOMIZE CSS
	ov_css (
		"#ovContainer0 {background-color:#000;position:absolute; width:100%; height:100%; top:0px; left:0px; z-index:10000; "+
		"opacity: .70;filter: alpha(opacity=70);-ms-filter: \"alpha(opacity=70)\";-khtml-opacity: .70;-moz-opacity: .70;}"+
		"#ovContainer {background-color:transparent;position:absolute; width:100%; height:100%; top:0px; left:0px; z-index:10000; }"+
		"#ovBox { padding:10px;position:relative; width:500px; min-height:150px; border:4px solid #cccccc; background:#fff url(http://www.barattalo.it/wp-content/themes/stardust/images/flowers.png) 270px -20px no-repeat; }"+
		"#ovContainer > #ovBox { position:fixed; }"+
		"#ovBox #ovClose { display:block; position:absolute; top:10px;right:10px;margin:5px;  padding:3px; border:0; font:12px arial; text-transform:uppercase; text-align:center; color:#fff; background-color:#DC2B7C; text-decoration:none; }"
	);
	// CUSTOMIZE HTML and GO!
	ov_add(
		"<p style='font-size:13px;line-height:20px;padding:120px 0 0 0;'>This is an HTML text message.<br/>You can download this javascript <a href='http://www.barattalo.it/2011/11/07/unobtrusive-javascript-to-add-an-overlay-banner'>here</a>.</p>"
	);
}
