//ea?oa///
function Map(mapdiv,w,h,edge){

		this.deltatop = 101;                              //iiei?aiea  aeiea n ea?oie
		this.deltaleft = 200;
		this.deltabot = 27;                               //noiia ionooiia
		this.deltaright= 202;
		
		this.scrmapw;                                     //?acia?u aeiea n ea?oie
		this.scrmaph;
		this.globscrmapw;   							//?acia?u aeiea n ea?oie aeiaaeuii
		this.globscrmaph;
		
		this.width = w;                                             //?acia?u enoiaiie ea?ou
		this.height = h;
		this.edge0 = edge;
		this.edge = edge;                                           //?acia?u eonea ea?ou
		this.level = 6;                                        //o?iaaiu ea?ou
		this.levels = this.level;
		this.zoom = 3200;                                       //  (zoom) ianooaa a iaiii eonea
		this.zoomArr = [0,400,800,1600,6400,25600,102400];
this.zoomArr = [0,400,800,1600,3200,6400,12800];
		this.x = 0;                                           //eii?aeiaou ea?ou aeiaaeuii(5500)
		this.y = 0;
		this.xx = 0;                                           //eii?aeiaou ea?ou
		this.yy = 0;
		this.numx;                                             //eieai aeaeiuo eoneia x/y
		this.numy;
		//    this.relX;                                             //eii?aeiaou ioiineoaeuii eonea
		//    this.relY;
		this.nx = 1;                                          //iiia? eaaa?aoa a oaeo
		this.ny = 1;
		this.image = [];                                      //eonee ea?ou
		this.image2 = [];
		this.center=[];                                       //eii?aeiaou oaio?a
		this.map;												// Iiaei?ea ea?ou
		this.proX = 0;	   									// eii?aeiaou i?ioioeia ea?ou
		this.proY = 0;										// eii?aeiaou i?ioioeia ea?ou
		this.zeroX = 0;	   									// eii?aeiaou 0,0 ea?ou aeiaaeuii
		this.zeroY = 0;
		
		this.layer1;         								// neie   1,2 aey eoneia ea?ou
		this.layer2;
		
		this.layer3;                                        //marks
		this.mark = [];
		var marknums = 0;
		
		this.layer4;                                        //photos
		this.photo = [];
		var photonums = 0;
		
		this.layer5;                                        //stickers
		this.sticker = [];
		var stickernums = 0;
		
		this.layer6;                                        //objects
		this.obj = [];
		var objnums = 0;
		
		this.layer7;                                        //objects
		this.pan = [];
		var pannums = 0;
		
		this.info = 1;                                     //iieo?eou eioi ii ea?oa
		
		this.ok = 0;
		this.ok2 = 0;
		
		
		
		this.globalcenterx = Math.floor((this.scrmapw/2 - this.proX + this.deltaleft)*this.zoom/this.edge);
		this.globalcentery = Math.floor((this.scrmaph/2 - this.proY + this.deltatop)*this.zoom/this.edge);

		this.show = function(){
			if(typeof(initl) == "undefined")
            	initl = constants['begin_zoom'];

	  		if(typeof(initl) != "undefined" ) {
//initl = this.level;
	  			for (var i=this.level; i>initl; i--) {
	               this.zoom = this.zoom / 2;
				}
			    this.level = initl;
this.zoom = this.zoomArr[this.level];

			}
            if(typeof(marker) != "undefined" ) {
                 this.zoom = 800;
				 this.level = 2;
            }
            if(typeof(markerError) != "undefined" ) {
                 message(markerError)
            }

   			this.over = document.createElement("div");
			this.over.id = "over";
			this.over.style.width = this.scrmapw+"px";
			this.over.style.height = this.scrmaph+"px";
			this.over.onmouseout = function(){cursor.change("openhand")}
      		document.getElementById(mapdiv).appendChild(this.over)
			// ?ann?ao eiee?aonaa o?aaoaiuo eaaa?aoia aey aae?aiey
			this.numx = Math.ceil(this.scrmapw / this.edge0) +3//+ 3;
			this.numy = Math.ceil(this.scrmaph / this.edge0) +3//+ 3;

//			this.center = new Array(Math.ceil(this.scrmapw/2),Math.ceil(this.scrmaph/2))
//			this.map = this.over.appendChild(document.createElement("div"));
			this.map = document.createElement("div");
			this.map.id="map";

            this.map.onclick = this.mapinfo;
 			this.map.onmousemove = this.getabscoords;
			this.map.onmouseover = this.gett;

//			this.map.ondblclick = this.setCenter; 				 //oaio?e?iaaou
   			this.map.oncontextmenu = this.right;
		    this.over.appendChild(this.map);
            Drag.init(this.map);                           //a?aa
            this.UpdateSize();
			
			var fragment = document.createDocumentFragment();

            this.layer1 = document.createElement("div");
            this.layer1.className = "layer"
			this.layer1.style.zIndex = "10";
            this.layer2 =  this.layer1.cloneNode(true);
            this.layer2.style.zIndex = "0";

            var tar = document.createElement("img");
			tar.height = tar.width = 53;
			tar.src="/images/target.gif";
			tar.id = "target";
	        if(map.level>=3 && map.level<5){ 
	            tar.width = 25;
				tar.height = 25;
			}
			else if(map.level>4){ 
	            tar.width = 18;
				tar.height = 18;
			}
			
			this.layer4 = document.createElement("div");
			this.layer4.className = "objectlayers"
            this.layer5 = this.layer4.cloneNode(true);
            this.layer6 = this.layer4.cloneNode(true);
			this.layer7 = this.layer4.cloneNode(true);
            this.layer3 = this.layer4.cloneNode(true);
			
			fragment.appendChild(this.layer1);
			fragment.appendChild(this.layer2);
			fragment.appendChild(tar);
			fragment.appendChild(this.layer3);
			fragment.appendChild(this.layer4);
			fragment.appendChild(this.layer5);
			fragment.appendChild(this.layer6);
			fragment.appendChild(this.layer7);
			this.map.appendChild(fragment);

  			this.createmapimg();                                 //nia?aou eonee

			if(typeof(initx) == "undefined"){
            	initx = constants['begin_x']; 
				inity = constants['begin_y'];
            }

			this.setCenter(initx+"&"+inity)
			
            var coords = document.createElement("div");
			coords.id = "coords";
            coords.innerHTML = ["@",map.level,":",(- Math.round(map.proX)),":",(- Math.round(map.proY))].join("");
			coords.onclick = function(){map.copybufer(coords.innerText)}
            document.getElementById("overmap").appendChild(coords);

		}
		this.copybufer = function(val){
			if(val){
			var a = val.replace(/&amp;/, "&")
	 		a = a.replace(/&amp;/, "&")	
            if (window.clipboardData && window.clipboardData.setData) {
					window.clipboardData.setData("Text", a);
					return true;
				}
			}
		}
    	this.createmapimg = function(){                 //nicaaou eonee ea?ou ia 2 neiy
	      var count = 0;
	      for(var i=1; i<=this.numy; i++){
	      	        for(var j=1; j<=this.numx; j++){
	                   this.image[count] = new MapPart(j,i);
	                   this.image[count].createmapimg();
  					   this.image2[count] = new MapPart(j,i);
					   this.image2[count].createmapimg2();
	                   count++;
	      	        }
	            }
	    }
		this.right = function(e){
				map.calculate_coords(e)
		   /*		contextmenu.clear();
				contextmenu.addbutton(words["addphoto"], "formas.show(map.xx+map.proX + map.deltaleft,map.yy+map.proY + map.deltatop, 'photo');");
				contextmenu.addbutton(words["addpan"], "formas.show(map.xx+map.proX + map.deltaleft,map.yy+map.proY + map.deltatop, 'photo');");
                contextmenu.addbutton(words["addsticker"], "formas.show(map.xx+map.proX + map.deltaleft,map.yy+map.proY + map.deltatop, 'sticker');");
				contextmenu.addbutton(words["addmark"], "formas.show(map.xx+map.proX + map.deltaleft,map.yy+map.proY + map.deltatop, 'mark');");
                contextmenu.addbutton(words["getlink"], "map.getlink()");*/

				contextmenu.show(map.xx+map.proX + map.deltaleft,map.yy+map.proY + map.deltatop);
				map.map.onclick = map.mapinfo;
				return false;
		}
		this.mapinfo = function(e){
  			if(map.info!=0){
                map.calculate_coords(e)
 				map.getObjects(1)
			 }
			map.info = 1;
		}
		this.getlink = function(){
			var value;			
			if (checkFlash()) {
				value = ["<span title='Скопировать ссылку в буфер'><object id='clip' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='162' height='16'><param name='allowScriptAccess' value='sameDomain' /><param name='flashvars' value='url=http://", location.host, "/?l=", map.level, "%26x=", map.x, "%26y=", map.y, "'><param name='allowFullScreen' value='false' /><param name='movie' value='/images/clipboard.swf' /><param name='quality' value='high' /><embed src='/images/clipboard.swf' quality='high' width='162' height='16' flashvars='url=http://", location.host, "/?l=", map.level, "%26x=", map.x, "%26y=", map.y, "' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object></span>"].join("");
				message(value, 1)
			}
			else {
				value = ["<p id='co' class='wh1'>http://", location.host, "/?l=", map.level, "&amp;x=", map.x, "&amp;y=", map.y, "</p>"].join("");			
				message(value, 1);
				var a = document.getElementById('co').innerHTML;
				this.copybufer(a);
			}
		}
		this.getabscoords = function(){           		// Iieo?aiea ye?aiiuo eii?aeiao ii aanie?oiui eii?aeiaoai ea?ou
		 	if (map.time != "") {
					clearInterval(map.time);
				}
				cursor.check();
		}
        this.gett = function(e){                              //eii?aeiaou i?e iaaaaaiee
            map.calculate_coords(e)

			map.proX = parseInt(map.map.style.left);
            map.proY = parseInt(map.map.style.top);
		}
		this.calculate_coords = function(e){
			var posx = 0, posy = 0;
            if (!e) var e = window.event;
			if (e.pageX || e.pageY) 	{
				posx = e.pageX;
				posy = e.pageY;
			}
			else if (e.clientX || e.clientY) 	{
				posx = e.clientX + document.body.scrollLeft
					+ document.documentElement.scrollLeft;
				posy = e.clientY + document.body.scrollTop
					+ document.documentElement.scrollTop;
			}
//            this.relX = posx - map.proX - map.deltaleft;
//			this.relY = posy - map.proY - map.deltatop;
			map.xx = Math.round(posx - map.proX - map.deltaleft);
			map.yy = Math.round(posy - map.proY - map.deltatop);

			map.x = Math.floor(map.xx*map.zoom/map.edge);
			map.y = Math.floor(map.yy*map.zoom/map.edge);
		}
		this.drag = function(a){
			if(a!=2)
	   			this.hideTarget();

            map.nx = Math.ceil(-map.proX/map.edge0) -1;
            map.ny = Math.ceil(-map.proY/map.edge0) -1;

			for(var i=0; i<map.image.length; i++) {
				if(constants['begin_zoom'] % 2 == 0 && map.level % 2 == 0 || constants['begin_zoom'] % 2 == 1 && map.level % 2 == 1){
					map.image[i].dragging(map.proX,map.proY);
				} else {
					map.image2[i].dragging(map.proX,map.proY);
				}
            }

	        this.globalcenterx = Math.floor((this.scrmapw/2 - this.proX)*this.zoom/this.edge);
	   		this.globalcentery = Math.floor((this.scrmaph/2 - this.proY)*this.zoom/this.edge);

            this.zeroX = Math.round(-map.proX/map.edge0*map.zoom);
            this.zeroY = Math.round(-map.proY/map.edge0*map.zoom);		

			if(typeof(mini) != "undefined")
				mini.updateframe();
			try{
			   document.getElementById("coords").innerHTML = ["@",map.level,":",map.zeroX,":",map.zeroY].join("");
			}
			catch(e){}
		}
        this.minidrag = function(){

			var sx = Math.floor(-constants['min_coord_x']/map.zoom*map.edge);
			var sy = Math.floor(-constants['min_coord_y']/map.zoom*map.edge);


            map.setParam("proX", sx-mini.left * (map.width/map.zoom*map.edge0)/mini.miniwidth);
       		map.setParam("proY", sy-mini.top * (map.height/map.zoom*map.edge0)/mini.miniheight);

//          this.globalcenterx = Math.floor((this.scrmapw/2 - this.proX)*this.zoom/this.edge);
//   		this.globalcentery = Math.floor((this.scrmaph/2 - this.proY)*this.zoom/this.edge);
            this.drag();
        }
	    this.setCenter = function(coords, s){

		var sx = Math.floor(constants['min_coord_x']/map.zoom*map.edge0);
		var sy = Math.floor(constants['min_coord_y']/map.zoom*map.edge0);

	      	if(coords){
				map.center = coords.split("&")
	  			x = map.center[0];
				y = map.center[1];
				x = Math.floor(x/(map.zoom/map.edge))
				y = Math.floor(y/(map.zoom/map.edge));
				if(typeof(s) != "undefined"){
                	x = x + this.scrmapw/2;
                	y = y + this.scrmaph/2;
				}

                var xx = x;
				var yy = y;	

                if(x > (this.width/this.zoom*this.edge - this.scrmapw/2 + sx))
					x = (this.width/this.zoom*this.edge - this.scrmapw/2 + sx)
                if(x <  sx+this.scrmapw/2)
					x = sx+this.scrmapw/2;
                if(y > (this.height/this.zoom*this.edge - this.scrmaph/2 + sy))
					y = (this.height/this.zoom*this.edge - this.scrmaph/2 + sy);
                if(y <  sy+this.scrmaph/2)
					y = sy+this.scrmaph/2;
	      	}


/*	        this.map.style.left = parseInt(this.map.style.left) - (x - this.scrmapw/2) - map.proX + "px"
	        this.map.style.top = parseInt(this.map.style.top) - (y - this.scrmaph/2) - map.proY + "px"

            this.proX = parseInt(this.map.style.left);
	        this.proY = parseInt(this.map.style.top);
*/
		
			this.proX = -x + this.scrmapw/2;
	        this.proY = -y + this.scrmaph/2;

			this.map.style.left = map.proX + "px"
	        this.map.style.top =  map.proY + "px"


			for(var i=0; i<map.image.length; i++) {
		   		map.image[i].dragging(map.proX,map.proY);
			}
            this.drag()

            this.getObjects();

           if((typeof(marker) == "undefined" && initx !=  constants['begin_x']) || map.layer6.childNodes.length!=0)
            this.showTarget(xx,yy); 
	    }

		this.showTarget = function(x,y){
//		    x = Math.floor(x/(map.zoom/map.edge))
//			y = Math.floor(y/(map.zoom/map.edge))
                var target = document.getElementById("target");
				if(typeof(initx) != "undefined" && initx!="a" && typeof(marker) == "undefined" && map.layer6.childNodes.length==0){
					target.src = "/files/icon/757998.png"
                    initx = "a"
					}
				else{
					target.src = "/images/target.gif"
				}
				target.style.display = "block";  
				try{ 
					if(map.level<=2 && initx == "a"){
			            target.width = 40;
						target.height = 40;
					}
					else if(map.level<=2 && initx != "a"){
			            target.width = 60;
						target.height = 60;
					}
			        else if(map.level>=3 && initx == "a"){ 
			            target.width = 25;
						target.height = 25;
					}
					else if(map.level>=3 && initx != "a"){ 
			            target.width = 40;
						target.height = 40;
					}
					target.style.left = x - target.width/2 + "px"
					target.style.top = y - target.height/2 + "px"
				}
				catch(e){}
		}
		this.hideTarget = function(){
                var target = document.getElementById("target");
				target.style.display = "none";
				target.src = "/images/target.gif"
		}

		//
		// Iaiiaeaiea ea?ou ni neiyie
		//
		this.update = function(){
		    this.edge = this.edge0;

            map.layer1.style.display = "block";
   	   		map.layer2.style.display = "block";
            map.ok = 0; map.ok2 = 0;
		    if(constants['begin_zoom'] % 2 == 0 && map.level % 2 == 0 || constants['begin_zoom'] % 2 == 1 && map.level % 2 == 1){
		    	for(var i=0; i<map.image.length; i++){
					this.image[i].update();
			 		this.image[i].img.onload = function(){
			 			map.ok = map.ok+1;
			 			//look("ban3", map.ok)
   /*какой уровень?*/	if((map.level==3 && map.ok>=12) || (map.level==4 && map.ok>=4) || (map.ok>=24) && map.image[0].img.src!="http://"+location.host+"/images/0.gif"){
			 			  	if(map.layer1.style.display == "block")	
								map.layer2.style.display = "none";
						   // 	map.layer1.style.zIndex = "10";
						//		map.layer1.style.direction= "ltr";
						//		map.layer2.style.direction= "";
						 //   	map.layer2.style.zIndex = "0";


			 				}
			 			}
		    	}


			} else {
				for(var i=0; i<map.image.length; i++){
					this.image2[i].update();
                    this.image2[i].img.onload = function(){
						map.ok2 = map.ok2+1;    // look("ban2", map.ok2)
						if((map.level==3 && map.ok2>=12) || (map.level==4 && map.ok2>=4) || (map.ok2>=24) && map.image2[0].img.src!="http://"+location.host+"/images/0.gif"){
						  	if(map.layer2.style.display == "block")
							map.layer1.style.display = "none";
					//		map.layer2.style.zIndex = "10";
					//		map.layer2.style.direction= "ltr";
					//		map.layer1.style.direction= "";
			   		//		map.layer1.style.zIndex = "0";

							}
						}
		    	}
            	
			}

	        this.globalcenterx = Math.floor((this.scrmapw/2 - this.proX)*this.zoom/this.edge);
	   	  	this.globalcentery = Math.floor((this.scrmaph/2 - this.proY)*this.zoom/this.edge);
			zoom.active = true;


		    mini.zoomframe();
			zoomer.update();

            for(var i=0; i<map.photo.length; i++){
				this.photo[i].updatesize();
	    	}
            for(var i=0; i<map.mark.length; i++){
				this.mark[i].updatesize();
	    	}
            for(var i=0; i<map.sticker.length; i++){
				this.sticker[i].updatesize();
	    	}
            for(var i=0; i<map.obj.length; i++){
				this.obj[i].updatesize();
	    	}
   //         map.ShowAllLayers();

	        this.globscrmapw = Math.round(this.scrmapw/map.edge0*map.zoom);
	   		this.globscrmaph = Math.round(this.scrmaph/map.edge0*map.zoom);

		    this.getObjects();


		 if(typeof(marker) == "undefined" || map.layer6.childNodes.length!=0)
            this.showTarget(initx,inity);
		}
        this.layerupdate = function(){          //Iaiiaeaiea ie?ieo eoneia
			for(var i=0; i<map.image.length; i++){
				if(constants['begin_zoom'] % 2 == 0 && map.level % 2 == 0 || constants['begin_zoom'] % 2 == 1 && map.level % 2 == 1)
			   		map.image2[i].setnull();
				else
			   		map.image[i].setnull();
			}
        }
		this.setParam = function(attr, value){      //Ia?aiao?u aeaa ea?ou
 /*			if (attr == "nx") {
				this.nx = value;
			}
	        if (attr == "ny") {
				this.ny = value;
			}                   */
			if (attr == "proX") {
			  	this.proX = value;
                this.map.style.left = this.proX + "px";
			}
			if (attr == "proY") {
			  	this.proY = value;
                this.map.style.top = this.proY + "px";
			}
		}


		//
		//
		//
		this.zooming = function(step){
            for(var i=0; i<this.image.length; i++) {
               if(constants['begin_zoom'] % 2 == 0 && map.level % 2 == 0 || constants['begin_zoom'] % 2 == 1 && map.level % 2 == 1)
					this.image[i].zooming();
				else
 	   	   			this.image2[i].zooming();
			}
			if (step == 2) {
				map.HideAllLayers();
		  	}

   			mini.zoomframe();
			zoomer.update();
		}

		//
		//
		//
        this.createMark = function(x,y,nfo){                 //nicaaou ia?ee
			var x = x/map.zoom*map.edge0;
            var y = y/map.zoom*map.edge0;
            marknums = map.mark.push(new Mark(nfo));
	        map.mark[marknums-1].create(x,y,(marknums - 1));
	    }
        this.addphoto = function(x,y,nfo){               //nicaaou ia?ee
			photonums = map.photo.push(new Photo(nfo));
	        map.photo[photonums-1].create(x,y,(photonums - 1));
	    }
		this.addpan = function(x,y,nfo){  			            //nicaaou ia?ee
			pannums = map.pan.push(new Pan(nfo));
	        map.pan[pannums-1].create(x,y,(pannums - 1));
	    }
	    this.createObject = function(x,y,nfo){               //nicaaou ia?ee
			objnums = map.obj.push(new Object(nfo));
	        map.obj[objnums-1].create(x,y,(objnums - 1));
	    }
	    this.createSticker = function(x,y,col){            //nicaaou ia?ee
            var x = x/map.zoom*map.edge0;
            var y = y/map.zoom*map.edge0;

			stickernums = map.sticker.push(new Sticker(col));
	        map.sticker[stickernums-1].create(x,y,(stickernums - 1));
	    }
		this.IconClick = function(id){
            for(var i=0; i<marknums; i++){
				map.mark[i].IconClick(id)
			}
		}
		this.UpdateSize = function(){
 			this.mlr = (this.width/this.zoom*this.edge);
			this.mlb = (this.height/this.zoom*this.edge);
		}
		this.resizeWin = function(w,h){

			document.getElementsByTagName("body")[0].style.overflow = "hidden";

            var allheight = getlnsideWindowHeight() ;
			var allwidth = getlnsideWindowWidth() ;			

			allwidth = (allwidth < 960) ? 960 : allwidth;
			allheight = (allheight < 590) ? 590 : allheight;
			
	//		document.getElementById("ban4").innerHTML = allwidth+" "+allheight;

	   		document.getElementById("catlist").style.height = allheight - document.getElementById("catlist").offsetTop- 15+"px";
			this.scrmaph = allheight - this.deltatop - this.deltabot;
			this.scrmapw = allwidth - this.deltaleft - this.deltaright;
			try{
				document.getElementById("overmap").style.width = this.scrmapw+"px"
				document.getElementById("overmap").style.height = this.scrmaph+"px"
			}catch(e){}

            this.globscrmapw = Math.round(this.scrmapw/map.edge0*map.zoom);
			this.globscrmaph = Math.round(this.scrmaph/map.edge0*map.zoom);


			if(map.over){
				try {
					map.over.style.width = map.scrmapw + "px";
					map.over.style.height = map.scrmaph + "px";
				}catch(e){}
        	}


	        if(map.proY){
				map.setParam("proY", (map.proY < 0 && map.proY + map.mlb < map.scrmaph) ? map.scrmaph - map.mlb : map.proY);
			  	map.drag(2);
	        }

			document.getElementsByTagName("body")[0].style.overflow = "auto";


	        if(mini)
   	   	    mini.resizeWin();
		}

		//
		// I?iaa?ea checkbox
		//
		this.hidelayers = function(check){
		  	if(check.name=="photos"){
		  	  	switch(check.checked){
		  	  	  case true:
                     map.layer4.style.display = 'block'
                     map.getObjects();
					 setcookie("photos",check.checked)
                     break;
		  	  	  case false:
                     map.layer4.style.display = 'none'
					 setcookie("photos",check.checked)
                     break;
				  default:
				  	 check.checked = true;
                     map.layer4.style.display = 'block'
				}
			}
            if(check.name=="stickers"){
                switch(check.checked){
		  	  	  case true:
                     map.layer5.style.display = 'block'
					 map.getObjects();
					 setcookie("stickers",check.checked)
                     break;
		  	  	  case false:
                     map.layer5.style.display = 'none'
					 setcookie("stickers",check.checked)
                     break;
				  default:
				     check.checked = true;
                     map.layer5.style.display = 'block'
				}
            }
			if(check.name=="pans"){
                switch(check.checked){
		  	  	  case true:
                     map.layer7.style.display = 'block'
					 map.getObjects();
					 setcookie("pans",check.checked)
                     break;
		  	  	  case false:
                     map.layer7.style.display = 'none'
					 setcookie("pans",check.checked)
                     break;
				  default:
				     check.checked = true;
                     map.layer7.style.display = 'block'
				}
            }
		}
        this.getObjects = function(param){

		map.ShowAllLayers();

		var loading = document.getElementById("loading");

            if(typeof(param) != "undefined"){
			   	allinfo.show("map",map.xx,map.yy);
				url = ['/objects/point/?x=',map.x,'&y=',map.y].join("");
				func = function(responseText, responseJS){
					if(responseJS.id_object!=0){
						var html_icons = "";
						for (var i=0; i<responseJS.id_category.length; i++){
							html_icons = [html_icons,"<img width='25' height='25' src='",icons[responseJS.id_category[i]].small,"' title='",icons[responseJS.id_category[i]].name,"'/>"].join("");
						}
						responseText =  ["<p class='photo'></p><div class='photod'><div id='ics'>",html_icons,"</div>",responseText,"<br/><p id='ank'><a class='ank' onclick=' showObjectId(",responseJS.id_object,")'>",words["anketa"],"</a></p></div>"].join("");
		            }else
						responseText =  ["<p class='photo'></p><div class='photod'>",responseText,"</div>"].join("");
					allinfo.setText(responseText);
                    allinfo.info.style.top = map.yy + map.deltatop + map.proY - allinfo.info.offsetHeight - 10 + "px";

					allinfo.setInt(2000);

				}

				postFile(null, url, func);
				return false;
            }
            else{

                var x = map.zeroX,
					y = map.zeroY,
					w = map.globscrmapw,
					h = map.globscrmaph,
					cp = document.boxes.photos.checked,
					cpa = document.boxes.pans.checked,
					cs = document.boxes.stickers.checked;

            	//load_start();
				loading.style.display = "block";
				url = ['/items/xml/?x=',x,'&y=',y,'&w=',w,'&h=',h,'&cp=',cp,'&cpa=',cpa,'&cs=',cs].join("");

				if(typeof(search) != "undefined" ){
					url = url+'&search='+encodeURIComponent(search);
					if(search_in)
						url = url+'&search_in';
				}
				if(catList != '')
					url = url+'&cat='+catList;

				func = function(responseXML) {
					//load_end();
					loading.style.display = "none";
					map.doXML(responseXML);
			    };
			    loadXML(url, func);
            }

         }
        this.doXML = function(xml){

		    map.layer4.innerHTML='';
		   	map.layer5.innerHTML='';
		   	map.layer6.innerHTML='';
			map.layer7.innerHTML='';

			var allphoto = xml.getElementsByTagName("photo");
			for(var i=allphoto.length-1; i>-1; i--){
				var allnfo = []

				allnfo.id_photo = allphoto[i].getAttribute("id");
				allnfo.name = allphoto[i].getAttribute("name");
				allnfo.author = allphoto[i].getAttribute("author");
				allnfo.dsc = allphoto[i].getAttribute("dsc");
				allnfo.email = allphoto[i].getAttribute("email");
				allnfo.date = allphoto[i].getAttribute("date");
				allnfo.img_small = allphoto[i].getAttribute("img_small");
				allnfo.img_big = allphoto[i].getAttribute("img_big");
				allnfo.img_biggest = allphoto[i].getAttribute("img_biggest");
				allnfo.last = allphoto[i].getAttribute("last");
				allnfo.img_count = allphoto[i].getAttribute("num_view");

				var x = allphoto[i].getAttribute("x");
				var y = allphoto[i].getAttribute("y");

				map.addphoto(x,y,allnfo)
			}
			
			var allpan = xml.getElementsByTagName("pan");

			for(var i=allpan.length-1; i>-1; i--){
				var allnfo = []

				allnfo.id_pan = allpan[i].getAttribute("id");
				allnfo.name = allpan[i].getAttribute("name");
				allnfo.author = allpan[i].getAttribute("author");
				allnfo.dsc = allpan[i].getAttribute("dsc");
				allnfo.email = allpan[i].getAttribute("email");
				allnfo.date = allpan[i].getAttribute("date");
				allnfo.img_small = allpan[i].getAttribute("img_small");
				allnfo.width = allpan[i].getAttribute("w");
				allnfo.height = allpan[i].getAttribute("h");
				allnfo.type = allpan[i].getAttribute("type");
				allnfo.img_big = allpan[i].getAttribute("img_big");
				allnfo.img_big_noflash = allpan[i].getAttribute("img_big_noflash");
				allnfo.img_biggest = allpan[i].getAttribute("img_biggest");
				allnfo.last = allpan[i].getAttribute("last");
				allnfo.img_count = allpan[i].getAttribute("num_view");

				var x = allpan[i].getAttribute("x");
				var y = allpan[i].getAttribute("y");

				map.addpan(x,y,allnfo)
			}


			var allsticker = xml.getElementsByTagName("sticker")
			for(var i=0; i<allsticker.length; i++){

				var allnfo = []

				allnfo.name = allsticker[i].getAttribute("name");
				allnfo.user = allsticker[i].getAttribute("author");
				allnfo.dsc = allsticker[i].getAttribute("dsc");
				allnfo.date = allsticker[i].getAttribute("date");
				allnfo.background = allsticker[i].getAttribute("background");
				allnfo.last = allsticker[i].getAttribute("last");

				var x = allsticker[i].getAttribute("x");
				var y = allsticker[i].getAttribute("y");

				map.createSticker(x,y,allnfo)
			}

			var allobject = xml.getElementsByTagName("object")

			for(var i=0; i<allobject.length; i++){
				var allnfo = []

				allnfo.name = allobject[i].getAttribute("name");
				allnfo.id = allobject[i].getAttribute("id");
				allnfo.adress = allobject[i].getAttribute("address");
				allnfo.icon = allobject[i].getAttribute("icon_cat");
				allnfo.category = allobject[i].getAttribute("id_category").split(",");
				allnfo.search = allobject[i].getAttribute("search");
				allnfo.plus = allobject[i].getAttribute("plus");

				var x = allobject[i].getAttribute("x");
				var y = allobject[i].getAttribute("y");


				map.createObject(x,y,allnfo)

			}
        }

		//
		//
		//
		 this.HideAllLayers = function(){
		   map.hideTarget();
    /*       if(constants['begin_zoom'] % 2 == 0 && map.level % 2 == 0 || constants['begin_zoom'] % 2 == 1 && map.level % 2 == 1) {
	   	   		map.layer2.style.display = "none";
		   } else {
 	   	   		map.layer1.style.display = "none";
		   }
    */        map.layer3.style.display = "none";
		 	map.layer4.style.display = "none";
		 	map.layer5.style.display = "none";
		 	map.layer6.style.display = "none";
			map.layer7.style.display = "none";
		 }

		 //
		 //
		 //
		 this.ShowAllLayers = function(){
		// 	map.layer1.style.display = "block";
   	   	//	map.layer2.style.display = "block";
            map.layer3.style.display = "block";
			map.layer4.style.display = "block";
			map.layer5.style.display = "block";
			map.layer6.style.display = "block";
			map.layer7.style.display = "block";
		 }
}