/*
	Splash popup area script v 2.0
	Copyright (C) Atlant Telecom Web Laboratory, 2006, 2007, 2008
	Development by Vitaly Novik
	
	интеграция:
	- прописываем путь к данному javascript в <head>
	- после открытия <body> пишем <div id="mc3PUA_html"><!-- --></div>
	- открытие - вызов функции mc3PUAshow(some_html)
	- закрытие - вызов функции mc3PUAhide()
*/

var mc3PUA_id = 'mc3PUA_html'; // id обрамляющего блока
var mc3PUA_bgcolor = '#a2a2a2'; // цвет заливки фона
var mc3PUA_opacity = 45; // полупрозрачность фона
var mc3PUA_padding = 20; // отступ от краёв внутрь
var mc3PUA_position = 'mc'; // положение на экране (tl - вверху слева, 
											// tc - вверху вцентре, 
											// tr - вверху справа, 
											// ml - посередине слева, 
											// mc - посередине вцентре, 
											// mr - посередине справа, 
											// bl - внизу слева, 
											// bc - внизу вцентре, 
											// br - внизу справа)
											
document.write('<' + 'style type="text/css">#' + mc3PUA_id + ' { display:none; }<' + '/style>');

function mc3PUAshow(html) {
	var d = document;
	
	if (d.getElementById(mc3PUA_id)) {
	
		var iW = typeof(d.getElementById(mc3PUA_id).style.filter) != 'undefined' && /MSIE (5\.5)/.test(navigator.userAgent) ? document.body.clientWidth + 'px' : document.documentElement.clientWidth + 'px';
		var iH = document.compatMode=='CSS1Compat' && !window.opera ? document.documentElement.clientHeight + 'px' : document.body.clientHeight + 'px';
		
		var outHTML = '';
		
		d.getElementById(mc3PUA_id).innerHTML = '<' + '!-- --' + '>';
		d.getElementById(mc3PUA_id).style.display = 'block';
		d.getElementById(mc3PUA_id).style.position = 'fixed';
		d.getElementById(mc3PUA_id).style.left = '0px';
		d.getElementById(mc3PUA_id).style.top = '0px';
		d.getElementById(mc3PUA_id).style.width = iW;
		d.getElementById(mc3PUA_id).style.height = iH;
		d.getElementById(mc3PUA_id).style.zIndex = '1000000';
		
		if (typeof(d.getElementById(mc3PUA_id).style.filter) != 'undefined' && /MSIE (5\.5|6\.)/.test(navigator.userAgent)) {
			d.getElementById(mc3PUA_id).style.position = 'absolute';
			if (document.compatMode=='CSS1Compat' && !window.opera) {
				document.documentElement.onscroll = function() {
					d.getElementById(mc3PUA_id).style.top = document.documentElement.scrollTop + 'px';
				}
			} else {
				d.body.onscroll = function() {
					d.getElementById(mc3PUA_id).style.top = d.body.scrollTop + 'px';
				}
			}
		}
		
		/* iframe - фикс для IE<=6.0 #############################*/
		if (typeof(d.getElementById(mc3PUA_id).style.filter) != "undefined" && /MSIE (5\.5|6\.)/.test(navigator.userAgent)) {
			outHTML += '<' + 'iframe id="mc3PUA_frame" ' + 
							'style="display:block; position:absolute; ' + 
							'filter:Alpha(opacity=0); ' +
							'width:' + iW + '; height:' + iH + '; ' +
							'z-index:1;' +
							'"><' + '/iframe>';
		}
		
		/* область полупрозрачной подложки #############################*/
		outHTML += '<' + 'div id="mc3PUA_bg" style="' +
							'position:absolute; width:' + iW + '; ' +
							'height:' + iH + '; background:' + mc3PUA_bgcolor + '; ' +
							'z-index:2000000; display:none;' +
							'"><' + '!-- --' + '><' + '/div>';
		
		/* область контентной части #############################*/
		var v_pos = 'middle';
		var h_pos = 'center';
		switch (mc3PUA_position.substr(0,1)) {
			case 't': v_pos = 'top'; break;
			case 'm': v_pos = 'middle'; break;
			case 'b': v_pos = 'bottom'; break;
		}
		switch (mc3PUA_position.substr(1,1)) {
			case 'l': h_pos = 'left'; break;
			case 'c': h_pos = 'center'; break;
			case 'r': h_pos = 'right'; break;
		}
		outHTML += '<' + 'table cellpadding="0" cellspacing="0" ' + 
							'border="0" id="mc3PUA_cont" style="' + 
							'width:' + iW + '; height:' + iH + '; ' +
							'z-index:3000000; position:absolute;">' +
							'<' + 'tr><' + 'td id="mc3PUA_contd" style="padding:' + 
							mc3PUA_padding + 'px; text-align:' + h_pos + ';' + 
							' vertical-align:' + v_pos + ';">&nbsp;' +
							'<' + '/td><' + '/tr><' + '/table>';
		
		d.getElementById(mc3PUA_id).innerHTML = outHTML;
		
		html = html.replace(/'/gi, "\\'");
		
		for (i=1; i<=10; i++) {
			if (i<10) {
				if (sh_opacitySet != 'undefined') window.setTimeout("sh_opacitySet(document.getElementById('mc3PUA_bg'), " + (mc3PUA_opacity/10 * i) + ")", i*50);
				if (i==1)  window.setTimeout("document.getElementById('mc3PUA_bg').style.display = 'block'", i*50);
			} else {
				if (sh_opacitySet != 'undefined') window.setTimeout("sh_opacitySet(document.getElementById('mc3PUA_bg'), " + mc3PUA_opacity + ")", i*50);
				window.setTimeout("document.getElementById('mc3PUA_contd').innerHTML = '" + html + "'", i*50);
				window.setTimeout("document.getElementById('cap_input').focus();", i*50);
			}
		}
		
		window.onresize = function() {
			var iW = typeof(d.getElementById(mc3PUA_id).style.filter) != 'undefined' && /MSIE (5\.5)/.test(navigator.userAgent) ? document.body.clientWidth + 'px' : document.documentElement.clientWidth + 'px';
			var iH = document.compatMode=='CSS1Compat' && !window.opera ? document.documentElement.clientHeight + 'px' : document.body.clientHeight + 'px';
			if (d.getElementById('mc3PUA_html')) {
				d.getElementById('mc3PUA_html').style.width = iW;
				d.getElementById('mc3PUA_html').style.height = iH;
			}
			if (d.getElementById('mc3PUA_frame')) {
				d.getElementById('mc3PUA_frame').style.width = iW;
				d.getElementById('mc3PUA_frame').style.height = iH;
			}
			if (d.getElementById('mc3PUA_bg')) {
				d.getElementById('mc3PUA_bg').style.width = iW;
				d.getElementById('mc3PUA_bg').style.height = iH;
			}
			if (d.getElementById('mc3PUA_cont')) {
				d.getElementById('mc3PUA_cont').style.width = iW;
				d.getElementById('mc3PUA_cont').style.height = iH;
			}
		}
		
	}
	
}

function mc3PUAhide() {
	var d = document;
	if (d.getElementById(mc3PUA_id)) {
		d.getElementById(mc3PUA_id).innerHTML = '<' + '!-- --' + '>';
		d.getElementById(mc3PUA_id).style.display = 'none';
	}
}