
	

	function escapeSingleQuote(str) {		
		str = str.replace(/\\/g,"\\\\");
		str = str.replace(/\'/g,"\\\'");	
		return str;
	}
	
	function SidwViewRow(idx, name, text, onclickEvent, isAdmin) {
		this.idx = idx;
		this.name = name;
		this.text = text;
		this.isAdmin = isAdmin
		this.onclickEvent = onclickEvent;
		this.renderRow = renderRow;
		
		this.isVisible = true;
		this.isDim = false;
	}
	
	function renderRow() {
		if (!this.isVisible) {
			return "";
		}
	    var target = "";
		if (this.isAdmin=="admin") target = "target=\"_blank\"";
	    var str = "<li id='sideViewRow_"+this.name+"'>";
	    if (this.isDim) {
	        str += "<a href=\"#\" class=\"dim\">";
	    } else {
			str += "<a href=\"#\" onclick=\"hideSideView(); clickAreaCheck=true;"+this.onclickEvent+"; return false;\">";
		}

	    str += this.text;
		if (!this.isDim) str+= "</a>";
		str+= "</li>";
		
		if (this.name=="member") str+= "<li class='dot_line'></li>";
	    return str;
	}

	function RoleCheck(){
		alert("ÇØ´ç ¼­ºñ½º´Â Á¤È¸¿ø ÀÌ»ó¸¸ »ç¿ë °¡´ÉÇÕ´Ï´Ù.");
	}
	
	function SideView(targetObj, curObj, encset, planetUserid, myNick, targetNick, grpid, mgrpid, grpname, node, rolecode, isAdmin) {
		this.targetObj = targetObj;
		this.curObj = curObj;
		this.encset = encset;
		this.planetUserid = planetUserid;
		this.myNick = myNick;
		this.targetNick = targetNick;
		this.grpid = grpid;
		this.mgrpid = mgrpid;
		this.grpname = grpname;
		this.node = (node == null ? "" : node);
		this.showLayer = showLayer;
		this.makeNameContextMenus = makeNameContextMenus;
		this.heads = new Array();
		this.insertHead = insertHead;
		this.tails = new Array();
		this.insertTail = insertTail;
		this.getRow = getRow;
		this.hideRow = hideRow;		
		this.dimRow = dimRow;

	    //this.insertTail("member", "È¸¿øÁ¤º¸", "goProfile('"+this.grpid+"', '"+this.mgrpid+"', '"+this.encset+"', '"+this.node+"')");
	    //this.insertTail("article", "ÀÛ¼º±Ûº¸±â",	"goArticle('"+this.grpid+"', '"+this.mgrpid+"', '"+this.item+"', '"+this.jobcode+"', '"+this.targetNick+"', '"+this.node+"', '"+ isAdmin +"')");

	if(rolecode >=25 ){
  	    this.insertTail("msg", "<img src='/images/arrow_orange.gif' align='absmiddle' width='3' height='7'> È¸¿øÁ¤º¸", "view_member_info('"+this.encset+"')");
		this.insertTail("msg", "<img src='/images/arrow_orange.gif' align='absmiddle' width='3' height='7'> ÂÊÁö º¸³»±â", "sendMemo('"+this.encset+"')");
		this.insertTail("msg", "<img src='/images/arrow_orange.gif' align='absmiddle' width='3' height='7'> Ä£±¸½ÅÃ»ÇÏ±â", "addFriend('"+this.encset+"')");
	    //this.insertTail("mail", "¸ÞÀÏ º¸³»±â", "goSendMail('"+this.grpid+"', '"+this.mgrpid+"', '"+this.encset+"','', '"+this.node+"')");
	    //this.insertTail("sms", "SMS º¸³»±â", "goMobileMsg()");
	}else{
  	    /*this.insertTail("msg", "ÂÊÁö º¸³»±â", "RoleCheck()");
	    this.insertTail("mail", "¸ÞÀÏ º¸³»±â", "RoleCheck()");
	    this.insertTail("sms", "SMS º¸³»±â", "RoleCheck()");*/
	}
	
/*	    this.insertTail("planet", "ÇÃ·¡´Ö °¡±â", "goPlanet('"+this.grpid+"', '"+this.mgrpid+"', '"+this.encset+"', '"+this.node+"')");
 	    this.insertTail("messenger", "DaumÄ£±¸Ãß°¡", "addMessengerFriend('"+this.grpid+"', '', '"+this.encset+"', '"+this.node+"')"); */

		if( this.targetNick == this.myNick ) {
	    }	    
	}
	
	function showLayer(isCafeon) {
		clickAreaCheck = true;
		var oSideViewLayer = document.getElementById(this.targetObj);
		var oBody = document.body;

	    if (oSideViewLayer == null) {
	        oSideViewLayer = document.createElement("DIV");
	        oSideViewLayer.id = this.targetObj;
	        oSideViewLayer.style.position = 'absolute';
			oSideViewLayer.style.zIndex = '9999999';
			oSideViewLayer.style.border = '2px solid #bbb';
			oSideViewLayer.style.padding = '2px';
			oSideViewLayer.style.background = '#fff';
			oSideViewLayer.style.width = '106px';
			oSideViewLayer.style.display = 'none';
	        oBody.appendChild(oSideViewLayer);
	    }
	    oSideViewLayer.innerHTML = this.makeNameContextMenus();
	    
	    if (!isCafeon) {
	        if (getAbsoluteTop(this.curObj) + this.curObj.offsetHeight + oSideViewLayer.scrollHeight + 100 > oBody.scrollHeight) {
	            oSideViewLayer.style.top = (getAbsoluteTop(this.curObj) - oSideViewLayer.scrollHeight + 4) + 'px';
	        } else {
	            oSideViewLayer.style.top = (getAbsoluteTop(this.curObj) + this.curObj.offsetHeight + 4) + 'px';
	        }
        } else {
        	oSideViewLayer.style.top = (getAbsoluteTop(this.curObj) + this.curObj.offsetHeight + 4) + 'px';
        }

        oSideViewLayer.style.left = getAbsoluteLeft(this.curObj) + 'px';
	    var objDisplay = document.getElementById(this.targetObj).style.display;
		if (objDisplay=="none") {
			divDisplay(this.targetObj, 'block');
		} else {
			divDisplay(this.targetObj, 'none');
		}
	}
	
	function makeNameContextMenus() {
	    var str = "<ul class=\"user_info_layer\">";
	    
	    var i=0;
	    for (i=this.heads.length - 1; i >= 0; i--) {
	    	str += this.heads[i].renderRow();
	    }
	   
	    var j=0;
	    for (j=0; j < this.tails.length; j++) {
		    str += this.tails[j].renderRow();
	    }
	    
	    str += "</ul>";
	    return str;
	}

	function getRow(name) {
		var i = 0;
		var row = null;
		for (i=0; i<this.heads.length; ++i) {
			row = this.heads[i];
			if (row.name == name) return row;
		}
		for (i=0; i<this.tails.length; ++i) {
			row = this.tails[i];
			if (row.name == name) return row;
		}
		return row;
	}
	
	function hideRow(name) {
		var row = this.getRow(name);
		if (row != null) {
			row.isVisible = false;
		}
	}
	
	function dimRow(name) {
		var row = this.getRow(name);
		if (row != null) {
			row.isDim = true;
		}
	}
	
	function insertHead(name, text, evt) {
		var idx = this.heads.length;
		var row = new SidwViewRow(-idx, name, text, evt);
		this.heads[idx] = row;
		return row;
	}
	
	function insertTail(name, text, evt) {
		var idx = this.tails.length;
		var row = new SidwViewRow(idx, name, text, evt);
		this.tails[idx] = row;
		return row;
	}
	
	// global function
	function initCSS() {
		var stl = "<style type='text/css'>";
		stl += ".user_info_layer {color:#333; font-size:11px; font-family:µ¸¿ò; text-align:left;}";		
		stl += ".user_info_layer {width:100%;}";
		stl += ".user_info_layer img {border:none;}";
		stl += ".user_info_layer li {list-style:none; width:100%; float:left;}";
		stl += ".user_info_layer li a {display:block; color:#333; padding:6px 0 3px 5px; text-decoration:none;}";
		stl += ".user_info_layer li a:hover {background:#f6f6f6; text-decoration:none;}";
		stl += ".user_info_layer li a.dim {color:#999;}";
		stl += ".user_info_layer li.dot_line {height:5px; overflow:hidden; background:url(/images/index_dot.gif) 0 2px no-repeat;}";
		stl += "</style>";	
		document.write(stl);
	}
	




	
	function getAbsoluteTop(oNode){
		var oCurrentNode=oNode;
		var iTop=0;
		while(oCurrentNode){
			if (oCurrentNode.tagName == "HTML") break;
			
			var top = (oCurrentNode.offsetTop) ? oCurrentNode.offsetTop : 0;
			var scroll = (oCurrentNode.scrollTop) ? oCurrentNode.scrollTop : 0;
			iTop+=(top - scroll);
			oCurrentNode=oCurrentNode.offsetParent;
		}
		return iTop;
	}

	function getAbsoluteLeft(oNode){
		var oCurrentNode=oNode;
		var iLeft=0;
		while(oCurrentNode){
			if (oCurrentNode.tagName == "HTML") break;
			
			var left = (oCurrentNode.offsetLeft) ? oCurrentNode.offsetLeft : 0;
			iLeft+=left;
			oCurrentNode=oCurrentNode.offsetParent;
		}
		return iLeft;
	}
	
	function divDisplay(id, act) {
		document.getElementById(id).style.display = act;
	}
	
	function hideSideView() {
        if (document.getElementById("nameContextMenu")) {
            divDisplay ("nameContextMenu", 'none');
        }
	}
	
	var clickAreaCheck = false;
	document.onclick = function() {
	    if (!clickAreaCheck) {
	    	hideSideView();
			if(document.getElementById("ScrapLayer")) { //½ºÅ©·¦ ·¹ÀÌ¾î
				divDisplay ("ScrapLayer", 'none');
			}
			if(document.getElementById("reply_emoticon")) { //µî¼ö³îÀÌ ÀÌ¸ðÆ¼ÄÜ
				divDisplay ("reply_emoticon", 'none');
			}
			if(document.getElementById("div_quick")) { //Ä«Æä°ü¸® Äü¸Þ´º
				divDisplay ("div_quick", 'none');
			}
			if(document.getElementById("sub_list")) { //°Ô½Ã±Û ÀÌµ¿
				divDisplay ("sub_list", 'none');
			}
			if(document.getElementById("sub_list2")) { //µî±Þ º¯°æ
				divDisplay ("sub_list2", 'none');
			}
			if(document.getElementById("sub_list3")) { // °Ë»ö µî±Þ º¯°æ
				divDisplay ("sub_list3", 'none');
			}
	    } else {
			clickAreaCheck = false;
		}
	}