function getXmlHttpObject() {
	var xmlHttp = null;

	try {
		xmlHttp = new XMLHttpRequest();
	}
	catch (e) {
		try {
			xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch (e) {
			xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
		}
	}

	if (xmlHttp == null) {
		alert('Ваш браузер не поддерживает AJAX.\nПожалуйста, воспользуйтесь альтернативным браузером.');
		return false;
	}

	return xmlHttp;
}


var tbi = new Array;
var tbs = new Array;
var tis = new Array;
var tid;

function getTabs() {
	var e = document.getElementById('mtTMLeft');
	if (!e) 
		return;

	var ch1 = e.childNodes;
	for (var i = 0; i < ch1.length; i++) {
		if (ch1[i].nodeName == 'DIV') {
			tbi[i] = new Array;
			var c = 0;
			var ch2 = ch1[i].childNodes;
			for (var y = 0; y < ch2.length; y++) {
				if (ch2[y].nodeName == 'DIV') {
					tbi[i][(c ? 'text' : 'name')] = ch2[y].innerHTML;
					c++;
				}
			}
		}
	}

	tid = document.createElement('DIV');
	e.innerHTML = '';

	var c = 0;
	for (var i in tbi) {
		if (tbi[i]['name'] && tbi[i]['text']) {
			tbs[c] = document.createElement('DIV');
			tbs[c].className = 'tBlock tBN';
			tbs[c].id = 'x' + c;
			tbs[c].innerHTML = tbi[i]['name'];

			tis[c] = document.createElement('DIV');
			tis[c].innerHTML = '<div class="tInfo">' + tbi[i]['text'] + '<\/div>';

			e.appendChild(tbs[c]);
			c++;
		}
	}

	e.appendChild(tid);

	setTab(0);
}

function setTab(n) {
	for (var i in tbs) {
		if (i == n) {
			tbs[i].className = 'tBlock';
			tbs[i].childNodes[0].onclick = function() {
				return true;
			};
		}
		else {
			tbs[i].className = 'tBlock tBN';
			tbs[i].childNodes[0].onclick = function() {
				setTab(this.parentNode.id.slice(1));
				return false;
			};
		}
	}

	tid.innerHTML = tis[n].innerHTML;
}

function readCookie(name, doc) {
	if (typeof doc === 'undefined') 
		doc = document;

	var c = doc.cookie, s = c.indexOf(name);
	if (s == -1) 
		return '';

	s += name.length + 1;

	var e = c.indexOf(';', s);
	if (e == -1) 
		e = c.length;

	return unescape(c.substring(s, e));
}

function setCookie(name, value, expires, path) {
	if (typeof expires === 'undefined' || expires === null) 
		expires = 365;
	if (typeof path === 'undefined') 
		path = '/';

	var expiry = new Date();
	expiry.setDate(expiry.getDate() + expires);
	document.cookie = name + '=' + escape(value) + (expires ? '; expires=' + expiry.toGMTString() : '') + (path ? '; path=' + path : '');
}

var popUp = {
	title: 'Пожалуйста, обратите внимание',

	message: '\
График работы магазина в праздничные дни:\
<div style="margin: 0.5em 0 0 20px">\
<span style="color: #F00">11 июня<\/span> — с 10:00 до 16:30\
<div style="margin: 0.5em 0 0">\
<span style="color: #F00">12–14 июня<\/span> — выходные дни\
<\/div>\
<\/div>',
/*
	message: '\
<div style="line-height: 1.6em; text-align: center">\
у нас новый телефон:<br>\
<big><b>(495) 725 37 21</b>\
<\/div>',
*/

	expiry: 4,

	init: function() {
		if (!document.body) {
			setTimeout('popUp.init()', 500);
			return;
		}

		if (readCookie('holidays_notice') == '1') 
			return;

		this.doc = document.createElement('div');
		this.doc.innerHTML = '\
<div id="windowblocker"><\/div>\
<div id="messagebox" onclick="popUp.show(); return false">\
<table align="center">\
	<tr>\
		<td>\
<div id="messageboxshadow">\
	<div id="messageboxframe">\
		<div id="titleline">\
			<a id="closer" href="#" onclick="popUp.show(); return false">X<\/a>\
			<div id="messageboxtitle"><\/div>\
		</div>\
\
	<div id="messageboxtext"><\/div>\
	<div id="messageboxclose"><a href="#" onclick="popUp.show(); return false">закрыть<\/a><\/div>\
	<\/div>\
<\/div>\
		<\/td>\
	<\/tr>\
<\/table>\
<\/div>';

		document.body.appendChild(this.doc);

		this.o = {
			wb: document.getElementById('windowblocker'),
			mb: document.getElementById('messagebox'),
			mt: document.getElementById('messageboxtitle'),
			mc: document.getElementById('messageboxtext')
		};

		this.show(this.message, this.title);
	},

	show: function(message, title, autoclose) {
		message = message == undefined ? '' : message;
		title = (title == undefined || title == '') ? '&nbsp;' : title;

		this.o.mt.innerHTML = title;
		this.o.mc.innerHTML = message;
		this.o.wb.style.display = this.o.mb.style.display = message ? 'block' : 'none';

		var v = message ? 'hidden' : '',
			a = navigator.userAgent.toLowerCase(),
			l,
			n = ['embed', 'object'];

		if ((/msie/.test(a) && !/opera/.test(a)) && (a.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1] < 7) 
			n.push('select');

		for (var i = 0; i < n.length; i++) {
			l = document.body.getElementsByTagName(n[i]);

			for (var j = 0; j < l.length; j++) 
				l[j].style.visibility = v;
		}

		if (autoclose != undefined) 
			setTimeout('popUp.show()', autoclose * 1000);

		if (!message) 
			setCookie('holidays_notice', '1', this.expiry);
	}
};

//popUp.init();