//контекстное меню
function ContextMenu(){
  	this.x;
	this.y;
	this.time = -1;
	this.menu;
	this.height = 16;
	this.create = function(){
		this.menu = document.getElementById("context");
		
		this.addbutton(words["addphoto"], "formas.show( 'photo');");
		this.addbutton(words["addpan"], "formas.show('pan');");
        this.addbutton(words["addsticker"], "formas.show('sticker');");
		this.addbutton(words["addmark"], "formas.show('mark');");		
	//	if(member.member_name=='digimatix')
		this.addbutton(words["addobj"], "formas.show( 'object');");
        this.addbutton(words["getlink"], "map.getlink()");
		var bk = document.createElement("div");
		bk.className = "bk";
		this.menu.appendChild(bk);	
	}
	this.show = function(x,y){
		y = ((y + this.height) <= getlnsideWindowHeight()) ? y : getlnsideWindowHeight() - this.height;
		this.menu.style.left = x - 7+"px";
		this.menu.style.top = y - 7+"px";
		this.menu.style.display = "block";
	}
	this.hide = function(){
   		contextmenu.menu.style.display = "none";
		clearInterval(contextmenu.time);
	}
	this.addbutton = function(text,func){
	    var p =  document.createElement("div"),
        	link = document.createElement("a"),
			p2 = document.createElement("p");
        link.href = "";
		if(member.member_id==0 && (text!=words["addobj"] || text!=words["addpan"] || text!=words["addphoto"] || text!=words["addsticker"]))
			link.title = words["addObjId"]+" "+ words["reg"];	
		p2.innerHTML = text;
		link.appendChild(p2)
        p.appendChild(link)
		
 		p.onmouseover = function(){this.className = "select";clearInterval(contextmenu.time);}
 		p.onmouseout = function(){this.className = ""; contextmenu.time = setInterval(contextmenu.hide,600);}

		link.onclick = function(){
			if(member.member_id!=0 || (text!=words["addobj"] && text!=words["addpan"] && text!=words["addphoto"] && text!=words["addsticker"]))
				eval(func);
			else
				message(words["addObjId"])	
            contextmenu.hide();
			return false;
			}
		this.menu.appendChild(p);
		this.height += 15;
	}
	this.clear = function(){
  		this.menu.innerHTML = '';
	}
}