	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	
	var contextMenuObj;
	var MSIE = navigator.userAgent.indexOf('MSIE')?true:false;
	var navigatorVersion = navigator.appVersion.replace(/.*?MSIE (\d\.\d).*/g,'$1')/1;	
	var activeContextMenuItem = false;
	function highlightContextMenuItem()
	{
		this.className='contextMenuHighlighted';
		activeContextMenuItem = this;
	}
	
	function deHighlightContextMenuItem()
	{
		this.className='';
	}
	
	function showContextMenu(e)
	 {
	  contextMenuSource = this;
	  if(activeContextMenuItem)activeContextMenuItem.className='';
	  if(document.all)e = event;
	  var xPos = e.clientX;
	  if(xPos + contextMenuObj.offsetWidth > (document.documentElement.offsetWidth-20)){
	   xPos = xPos + (document.documentElement.offsetWidth - (xPos + contextMenuObj.offsetWidth)) - 20; 
	  }
	  
	  var yPos = e.clientY;
	  if(window.document.body.scrollTop > 0)
	    {
	      yPos = (window.screen.Height) ? e.clientY + window.document.body.scrollTop -20 : e.clientY -20;
	    }
	    else if (window.pageYOffset) 
	    {
	      yPos = (window.pageYOffset > 0) ? e.clientY + window.pageYOffset -20 : e.clientY -20;
	    }
	    else
	    { yPos = e.clientY -20; }
	  /* * */
	  contextMenuObj.style.left = xPos + 'px';
	  contextMenuObj.style.top = yPos + 'px';
	  contextMenuObj.style.display='block';
	  return false; 
	}
 	
	function hideContextMenu(e)
	{
		if(document.all) e = event;
		if(e.button==0 && !MSIE){
			
		}else{
			contextMenuObj.style.display='none';
		}
	}
	
	function initContextMenu()
	{
		contextMenuObj = document.getElementById('contextMenu');
		contextMenuObj.style.display = 'block';
		var menuItems = contextMenuObj.getElementsByTagName('LI');
		for(var no=0;no<menuItems.length;no++){
			menuItems[no].onmouseover = highlightContextMenuItem;
			menuItems[no].onmouseout = deHighlightContextMenuItem;
			
			var aTag = menuItems[no].getElementsByTagName('A')[0];
			
			var img = menuItems[no].getElementsByTagName('IMG')[0];
			if(img){
				var div = document.createElement('DIV');
				div.className = 'imageBox';
				div.appendChild(img);
				
				if(MSIE && navigatorVersion<6){
					aTag.style.paddingLeft = '0px';
				}
				
				var divTxt = document.createElement('DIV');	
				divTxt.className='itemTxt';
				divTxt.innerHTML = aTag.innerHTML;
				
				aTag.innerHTML = '';
				aTag.appendChild(div);
				aTag.appendChild(divTxt);
				if(MSIE && navigatorVersion<6){
					div.style.position = 'absolute';
					div.style.left = '2px';
					divTxt.style.paddingLeft = '15px';
				}
				
				if(!document.all){
					var clearDiv = document.createElement('DIV');
					clearDiv.style.clear = 'both';
					aTag.appendChild(clearDiv);		
				}
			}else{
				if(MSIE && navigatorVersion<6){
					aTag.style.paddingLeft = '15px';
					aTag.style.width = (aTag.offsetWidth - 30) + 'px';
				}else{
					aTag.style.paddingLeft = '30px';
					aTag.style.width = (aTag.offsetWidth - 60) + 'px';
				}
			}
		}
		contextMenuObj.style.display = 'none';		
		document.documentElement.oncontextmenu = showContextMenu;
		document.documentElement.onclick = hideContextMenu;
	}

document.write('<ul id="contextMenu" style="z-index:99">');
document.write('<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>');
document.write('<td height="20px" style="font-family:dotum;font-size:12px;color:#000;background-color:#a0aeba;cursor:default;"><img src="_win/context_menu/title_icon.gif" alt="" style="margin-bottom:3px;" /><span style="position:absolute;width:20px;left:2px;top:2px;font-family:tahoma;color:#000;margin-left:20px;">MENU</span><span style="position:absolute;width:20px;left:0;top:0;font-family:tahoma;color:#fff;margin-left:20px;">MENU</span></td>');
document.write('<td width="45px;" height="20px" style="background-color:#a0aeba;" align="right"><img src="_win/context_menu/c3.gif" style="cursor:pointer;margin:0 0 4px 0;" alt="" /></td>');
document.write('</tr></table>');
document.write('<li><img src="_win/context_menu/01.png" alt="" /><a href="group_0.php" target="_child">MAIN</a></li>');
document.write('<li><img src="_win/context_menu/02.png" alt="" /><a href="bbs/board.php?bo_table=publicity" target="_child">게시판</a></li>');
document.write('<li><img src="_win/context_menu/03.png" alt="" /><a href="bbs/board.php?bo_table=humor" target="_child">휴게실</a></li>');
document.write('<li><img src="_win/context_menu/04.png" alt="" /><a href="bbs/board.php?bo_table=pds" target="_child">자료실</a></li>');
document.write('<li><img src="_win/context_menu/05.png" alt="" /><a href="bbs/board.php?bo_table=gallery1" target="_child">갤러리</a></li>');
document.write('<li><img src="_win/context_menu/14.png" alt="" /><a href="bbs/board.php?bo_table=talk" target="_child">채팅방</a></li>');
document.write('<li><img src="_win/context_menu/09.png" alt="" /><a href="bbs/board.php?bo_table=blog" target="_child">블로그</a></li>');
document.write('</ul>');

initContextMenu();

