<!--

function MapSwapper(){
	var self = this;

	this.duration = 0.25;
	this.defaultUrl = 'html.php?default.html';
	this.modalWindowSize = {marginLeft: '200px', marginTop: '100px', width: '800px', height: '600px'};
	this.closeButtons = new Hash({over: new Element('img', {src: 'images/closea.gif'}), out: new Element('img', {src: 'images/close.gif'})});
	this.config = new Array();
	this.blocks = new Hash();

	this.config[01] = new Hash({src: 'images/redbox_01.gif', x: 148, y: 64, html: 'html.php?sklad.html'});
	this.config[02] = new Hash({src: 'images/redbox_02.gif', x: 183, y: 105, html: 'html.php?sklad.html'});
	this.config[03] = new Hash({src: 'images/redbox_03.gif', x: 218, y: 144, html: 'html.php?sklad.html'});
	this.config[04] = new Hash({src: 'images/redbox_04.gif', x: 252, y: 186, html: 'html.php?sklad.html'});
	this.config[05] = new Hash({src: 'images/redbox_05.gif', x: 310, y: 253, html: 'html.php?sklad.html'});
	this.config[06] = new Hash({src: 'images/redbox_06.gif', x: 371, y: 324, html: 'html.php?sklad.html'});
	this.config[07] = new Hash({src: 'images/redbox_07.gif', x: 414, y: 376, html: 'html.php?sklad.html'});
	this.config[08] = new Hash({src: 'images/redbox_08.gif', x: 479, y: 450, html: 'html.php?sklad.html'});
	this.config[09] = new Hash({src: 'images/redbox_09.gif', x: 261, y: 39, html: 'html.php?sklad.html'});
	this.config[10] = new Hash({src: 'images/redbox_10.gif', x: 294, y: 76, html: 'html.php?sklad.html'});
	this.config[11] = new Hash({src: 'images/redbox_11.gif', x: 326, y: 108, html: 'html.php?sklad.html'});
	this.config[12] = new Hash({src: 'images/redbox_12.gif', x: 360, y: 144, html: 'html.php?sklad.html'});
	this.config[13] = new Hash({src: 'images/redbox_13.gif', x: 436, y: 214, html: 'html.php?sklad.html'});
	this.config[14] = new Hash({src: 'images/redbox_14.gif', x: 497, y: 279, html: 'html.php?sklad.html'});
	this.config[15] = new Hash({src: 'images/redbox_15.gif', x: 542, y: 330, html: 'html.php?sklad.html'});
	this.config[16] = new Hash({src: 'images/redbox_16.gif', x: 610, y: 399, html: 'html.php?sklad.html'});
	this.config[17] = new Hash({src: 'images/redbox_17.gif', x: 656, y: 479, html: 'html.php?docking.html'});
	this.config[18] = new Hash({src: 'images/redbox_18.gif', x: 147, y: 136, html: 'html.php?office.html'});
	this.config[19] = new Hash({src: 'images/redbox_19.gif', x: 209, y: 215, html: 'html.php?office.html'});
	this.config[20] = new Hash({src: 'images/redbox_20.gif', x: 325, y: 362, html: 'html.php?office.html'});
	this.config[21] = new Hash({src: 'images/redbox_21.gif', x: 432, y: 495, html: 'html.php?office.html'});
	this.config[22] = new Hash({src: 'images/redbox_22.gif', x: 393, y: 68, html: 'html.php?office.html'});
	this.config[23] = new Hash({src: 'images/redbox_23.gif', x: 481, y: 133, html: 'html.php?office.html'});
	this.config[24] = new Hash({src: 'images/redbox_24.gif', x: 616, y: 262, html: 'html.php?office.html'});
	this.config[25] = new Hash({src: 'images/redbox_25.gif', x: 738, y: 380, html: 'html.php?office.html'});
	this.config[26] = new Hash({src: 'images/redbox_26.gif', x: 755, y: 644, html: 'html.php?office.html'});
	this.config[27] = new Hash({src: 'images/redbox_27.gif', x: 835, y: 636, html: 'html.php?office.html'});
	this.config[28] = new Hash({src: 'images/redbox_28.gif', x: 891, y: 643, html: 'html.php?avto.html'});

	this.init = function(){
		$$('area').each(function(el){
			var n = parseInt(el.readAttribute('rel'));

			var newImg = new Element('img', {src: self.config[n].get('src')});
			var newDiv = new Element('div').addClassName('block').setStyle({marginLeft: self.config[n].get('x') + 'px', marginTop: self.config[n].get('y') + 'px'}).hide();

			self.blocks.set(n, newDiv.insert({top: newImg}));

			$$('body').shift().insert({top: self.blocks.get(n)});

			Event.observe(el, 'mouseover', self.show);
			Event.observe(el, 'mouseout', self.hide);
			Event.observe(el, 'click', self.click);

			Event.observe($('close'), 'mouseover', function(e){
				Event.element(e).src = self.closeButtons.get('over').src;
			});
			Event.observe($('close'), 'mouseout', function(e){
				Event.element(e).src = self.closeButtons.get('out').src;
			});
			Event.observe($('close'), 'click', function(e){
				new Effect.BlindUp($('modalwindow'), {afterFinish: function(){
					$('content').update();
				    $('modalwindow').setStyle(self.modalWindowSize);
				}});
			});

			$('close').firstDescendant().src = self.closeButtons.get('out').src;
		});
	};

	this.show = function(e){
		var n = parseInt(Event.element(e).readAttribute('rel'));
		var el = self.blocks.get(n);

		if(!el.visible()){
			el.writeAttribute('status', 'mouseover');
			new Effect.Appear(el, {duration: self.duration, afterFinish: function(){
				if(el.readAttribute('status') == 'mouseout')
					new Effect.Fade(el, {duration: self.duration, afterFinish: function(){
						el.writeAttribute('status', '');
					}});
				else
					el.writeAttribute('status', '');
			}});
		}
	};

	this.hide = function(e){
		var n = parseInt(Event.element(e).readAttribute('rel'));
		var el = self.blocks.get(n);

		if(el.readAttribute('status') == 'mouseover')
			el.writeAttribute('status', 'mouseout');

		if(el.visible() && el.readAttribute('status') == '')
			new Effect.Fade(el, {duration: self.duration});
	};

	this.click = function(e){
		if(!$('modalwindow').visible()){
			var n = parseInt(Event.element(e).readAttribute('rel'));
			var	url = self.config[n].get('html').blank() ? self.defaultUrl : self.config[n].get('html');

			new Ajax.Request(url, {
				method: 'get',
				onSuccess: function(transport){
					$('content').update(transport.responseText);
				},
				onComplete: function(){
				    $('modalwindow').setStyle(self.modalWindowSize);
					new Effect.BlindDown($('modalwindow'));
				}
			});
		}
	};

	Event.observe(window, 'load', this.init);
}

var MapSwapperPtr = new MapSwapper();

//-->