// Modal Dialog Box
// copyright 8th July 2006 by Stephen Chapman
// http://javascript.about.com/
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration
function mdbPgW() {return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;}
function mdbPgH() {return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;}
function mdbPosL() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement && document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;}
function mdbPosT() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement && document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;}
function mdbGetObj(x){return document.getElementById(x);}
function mdbScrlFx(){var obol=mdbGetObj('mdbol');obol.style.top=mdbPosT()+'px';obol.style.left=mdbPosL()+'px'}
function mdbSzFx(){var obol=mdbGetObj('mdbol');obol.style.height=mdbPgH()+'px';obol.style.width=mdbPgW()+'px';}
/*Вставить mdbKP в body для закрытия по нажатию клавиш ESC. Пример: <body onKeyPress="mdbKP()"> // ENTER - убран из оброботки..*/
function mdbKP(e){ky=e?e.which:event.keyCode;if(ky==27)mdbHM();return false}
function mdbInf(h){tag=document.getElementsByTagName('select');for(i=tag.length-1;i>=0;i--)tag[i].style.visibility=h;tag=document.getElementsByTagName('iframe');for(i=tag.length-1;i>=0;i--)tag[i].style.visibility=h;tag=document.getElementsByTagName('object');for(i=tag.length-1;i>=0;i--)tag[i].style.visibility=h;}
function mdbSM(obl,wd,ht){
	var h='hidden';var b='block';var p='px';var obol=mdbGetObj('mdbol');var obbxd=mdbGetObj('mdbmbd');
	if (obol!=undefined && obbxd!=undefined) {
		obbxd.innerHTML = mdbGetObj(obl).innerHTML;
		obol.style.height=mdbPgH()+p;
		obol.style.width=mdbPgW()+p;
		obol.style.top=mdbPosT()+p;
		obol.style.left=mdbPosL()+p;
		obol.style.display=b;
		var tp=mdbPosT()+((mdbPgH()-ht)/2)-12;
		var lt=mdbPosL()+((mdbPgW()-wd)/2)-12;
		var obbx=mdbGetObj('mdbmbox');
		obbx.style.top=(tp<0?0:tp)+p;
		obbx.style.left=(lt<0?0:lt)+p;
		obbx.style.width=wd+p;
		obbx.style.height=ht+p;mdbInf(h);
		obbx.style.display=b;
	}
	return false;
}
function mdbHM(){var v='visible';var n='none';mdbGetObj('mdbol').style.display=n;mdbGetObj('mdbmbox').style.display=n;mdbInf(v);document.onkeypress='';}
function mdbInitmb(){
	var ab='absolute';var n='none';var obody=document.getElementsByTagName('body')[0];var frag=document.createDocumentFragment();var obol=document.createElement('div');
	obol.setAttribute('id','mdbol');
	obol.style.display=n;
	obol.style.position=ab;
	obol.style.top=0;
	obol.style.left=0;
	obol.style.zIndex=998;
	obol.style.width='100%';
	frag.appendChild(obol);
	var obbx=document.createElement('div');
	obbx.setAttribute('id','mdbmbox');
	obbx.style.display=n;
	obbx.style.position=ab;
	obbx.style.zIndex=999;
	var obl=document.createElement('span');
	obbx.appendChild(obl);
	var obbxd=document.createElement('div');
	obbxd.setAttribute('id','mdbmbd');
	obl.appendChild(obbxd);
	frag.insertBefore(obbx,obol.nextSibling);
	obody.insertBefore(frag,obody.firstChild);
	window.onscroll = mdbScrlFx;
	window.onresize = mdbSzFx;
}
////window.onload = mdbInitmb;
//////addEvent(document.body,'keypress',mdbKP,false);
//////addEvent(document.body,'onkeypress',mdbKP,false);
addLoadEvent(mdbInitmb);