<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="kr.co.udapsoft.common.menu.*" %>
<%@ page import="kr.co.udapsoft.common.util.*" %>
<%@ page import="kr.co.hsnc.common.util.*" %> 
<%@ page import="com.udapsoft.waf.common.util.*" %>
<%@ page import="kr.co.hsnc.common.config.WAFConfig;" %>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />
<%
	ctx.init(request, response);
	String strTitle = WAFConfig.get("waf.ServerType");
%>
<%	if( ctx.isSignedOn() ) { %>
<%
	ValueObject params = ctx.getParams();
	ValueObject user = ctx.getUser();
	user.set("USE_SYSTEM", params.get("P_USE_SYSTEM"));
	ctx.setUser(user);

	MenuManager menuManager = new MenuManager(request);
	
	String USE_SYSTEM = menuManager.getUseSystem();	
	HelpManager hm = new HelpManager(request);
%>

<HTML>
<HEAD>
<TITLE>SGC이앤씨 전자조달 시스템</TITLE>
<!-- <META http-equiv="Content-Type" content="text/html; charset=utf-8"> -->
<!-- <META http-equiv="MSThemeCompatible" content="No"> -->
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<LINK href="/css/buyer/style.css" rel="stylesheet" type="text/css">
<STYLE>
html {
	height: 100%;
 	OVERFLOW-X : auto   ;
 	OVERFLOW-Y : hidden   ;	
 /* // filter: expression(document.execCommand("BackgroundImageCache", false, true)); */
}

BODY, form {
 	WIDTH      : 100%   ;
 	height     : 100%;
 	OVERFLOW-X : auto   ;
 	OVERFLOW-Y : hidden   ;
 	margin:0;
}
</STYLE>
<SCRIPT language="JavaScript" src="/js/common.js"></SCRIPT>
<SCRIPT language="JavaScript" src="/js/xmlhttp.js"></SCRIPT>
<SCRIPT language="JavaScript" src="/js/objects.js"></SCRIPT>
<SCRIPT language="JavaScript">

	/**
	 * 현재 사용하는 시스템 코드
	 */
	var USE_SYSTEM = "<%= USE_SYSTEM %>";

	/**
	 * Object에 이미지 src 변경 처리
	 */
    function setImg(obj, imgSrc) {
        obj.src = imgSrc;
    }

	/**
	 * ID에 해당하는 서브메뉴를 나타나도록 처리
	 */
	function showSubMenu(mainMenuId) {
		//var mainMenuObj = eval("document.all." + mainMenuId);
		var mainMenuObj = document.getElementById(mainMenuId);
		
		//setImg(mainMenuObj, mainMenuObj.getAttribute("on_image_path"));
		var subMenuObj = getSubMenuObj(mainMenuObj.getAttribute("index"));
		var cRects = mainMenuObj.getClientRects();
		
		subMenuObj.style.left = (cRects[0].left - 2) + "px";
	    subMenuObj.style.top  = (cRects[0].bottom - 1) + "px";
	    
		subMenuObj.style.display = "";
	}

	/**
	 * ID에 해당하는 서브메뉴를 숨김 처리
	 */
	function hideSubMenu(mainMenuId) {
		
		//var mainMenuObj = eval("document.all." + mainMenuId);
		var mainMenuObj = document.getElementById(mainMenuId);
		var subMenuObj = getSubMenuObj(mainMenuObj.getAttribute("index"));
		
		subMenuObj.style.display = "none";
		//setImg(mainMenuObj, mainMenuObj.getAttribute("off_image_path"));
	}

	/**
	 * 모든 서브메뉴를 숨김 처리
	 */
	function hideAllSubMenu() {
		if( window.subMenuLayer != null ) {
		    if( window.subMenuLayer.length == null ) {
		        window.subMenuLayer.style.display = "none";
		    }
		    else {
		        for( var i = 0 ; i < window.subMenuLayer.length ; i++ ) {
		            window.subMenuLayer[i].style.display = "none";
		        }
		    }
		}
	}

	/**
	 * index에 해당하는 서브메뉴의 Object를 리턴
	 */
	function getSubMenuObj(index) {
		var temp = document.all.subMenuLayer;
		if( temp.length == null )
			return temp;
		else
			return temp[index];
	}

	/**
	 * 시스템 이동
	 */
	/* function setSystem(sysId) {
		var f = document.MenuChangeForm;
		f.P_USE_SYSTEM.value = sysId;
		f.submit();
	} */

	function setSystem(systemObj){
		resetSystem();
		setImg(systemObj, systemObj.getAttribute("on_image_path"));
		var systemMenuObj = getSystemMenu(systemObj.getAttribute("index"));
		
		hideAllSystemMenu();
		
        var cRects = systemObj.getClientRects();
		var left = cRects[0].left - 10;
        systemMenuObj.style.left = left + "px";
        systemMenuObj.style.top  = 84 + "px";
        systemMenuObj.style.display = "inline";
		
		// 2단메뉴가 오른쪽으로 숨어버리는 경우에 대한 처        
        var systemMenuObjRects = systemMenuObj.getClientRects();
		var bodyWidth = window.document.body.clientWidth - 50;
		if( (systemMenuObjRects[0].right ) > bodyWidth ) {
			left = left - (systemMenuObjRects[0].right - bodyWidth);
			if( left < 0 ) left = 0;
	        systemMenuObj.style.left = left  + "px";
		}
        
		//document.getElementById("depth2_"+sysId).style.display="block";
		1283 - 1490 - 1430
		//systemMenu
	}
	/**
	 * 1단메뉴에 이미지 초기화
	 */
	function resetSystem() {
    	if( document.getElementsByName("system") != null ) {
    		if( document.getElementsByName("system").length == null ) {
    			setImg(document.getElementsByName("system"), document.getElementsByName("system").getAttribute("off_image_path"));
    			//document.all.system.is_selected = "N";
    		}
    		else {
    			for( var i = 0 ; i < document.getElementsByName("system").length ; i++ ) {
    				setImg(document.getElementsByName("system")[i], document.getElementsByName("system")[i].getAttribute("off_image_path"));
    				//document.all.system[i].is_selected = "N";
    			}
    		}
    	}
	}
	
    /**
     * index에 해당하는 2단메뉴의 Object를 리턴
     */
    function getSystemMenu(index) {
        var temp = document.getElementsByName("systemMenu");
        if( temp.length == null )
            return temp;
        else
            return temp[index];
    }
    
    /**
     * 모든 2단메뉴를 숨김 처리
     */
    function hideAllSystemMenu() {
    	
        if( document.getElementsByName("systemMenu") != null ) {
            if( document.getElementsByName("systemMenu").length == null ) {
            	document.getElementsByName("systemMenu").style.display = "none";
            }
            else {
                for( var i = 0 ; i < document.getElementsByName("systemMenu").length ; i++ ) {
                	document.getElementsByName("systemMenu")[i].style.display = "none";
                }
            }
        }
    }
	/**
	 * 메뉴 이동
	 */
	function goMenu(url, pgmGrName, pgmName) {
		if( url.substring(0, 1) != "#" ) {
			setNowLocation(pgmGrName, pgmName, url);
			//parent.document.frames['BodyFrame'].location.href = url;
			
			document.getElementById("menu_linker").href = url;
			
			document.getElementById("bodyFrame").src = url;

			hideAllSubMenu();
		}
		else {
			alert(url.substring(1, url.length));
		}
	}
	
	

	/**
	 * 현재위치 세팅
	 */
	function setNowLocation(pgmGrName, pgmName, url) {
		var strHtml = "&nbsp;&nbsp;&nbsp;";
	
		strHtml += "<IMG src='/img/main/location_bullet.gif' alt='' border='0'>"
		         + "<A href='default.screen' id='location' target='bodyFrame' class='now_location'><B>Home</B></A>&nbsp;&nbsp;";
	
		if( pgmGrName != null ) {
	
			strHtml += "<IMG src='/img/main/title_bullet.gif' width='4' height='7' alt='' border='0'>"
		             + "&nbsp;&nbsp;"
		             + "<A href='#' id='location' class='now_location'>" + pgmGrName + "</A>"
		             + "&nbsp;&nbsp;";
		}
	
		if( pgmName != null ) {
	
			strHtml += "<IMG src='/img/main/title_bullet.gif' width='4' height='7' alt='' border='0'>"
		             + "&nbsp;&nbsp;"
		             + "<A href='" + url + "' id='location' target='bodyFrame' class='now_location'>" + pgmName + "</A>"
		             + "&nbsp;&nbsp;";
		}
		try {
		
			if( document.all['NOW_LOCATION'] != null )
				document.all['NOW_LOCATION'].innerHTML = strHtml;	
	
		    else if( parent.document.all['NOW_LOCATION'] != null )
				parent.document.all['NOW_LOCATION'].innerHTML = strHtml;	
	
			else if( parent.parent.document.all['NOW_LOCATION'] != null )
				parent.parent.document.all['NOW_LOCATION'].innerHTML = strHtml;	
	
			else if( parent.parent.parent.document.all['NOW_LOCATION'] != null )
				parent.parent.parent.document.all['NOW_LOCATION'].innerHTML = strHtml;	
	
		}
		catch(errorObject) {
		
		}
	}
	
	function doResize(){
		allmenu.width = allLayer.document.body.scrollWidth; 
		allmenu.height = allLayer.document.body.scrollHeight;
		
	}

	function AllMenuViewLayer(id){
		if (document.all[id].style.display == "none"){
			document.getElementById("allLayer").src = "/all_menu.screen";
		 	document.all[id].style.display = "block";
		}else{
	   		document.all[id].style.display = "none";	
		}
	}
	
	function MyMenuViewLayer(id){
		if (document.all[id].style.display == "none"){
			document.all.myLayer.width = "1px";
			document.all.myLayer.height = "1px";
			document.getElementById("myLayer").src = "/my_menu.screen";
		 	document.all[id].style.display = "block";
		 	
		}else{
	   		document.all[id].style.display = "none";	
		}
     }
	function autoResize(){
		var bodyFrame = document.getElementById("bodyFrame");
		
		 var iframeHeight= document.body.scrollHeight - 119;   
		
		//alert(iframeHeight);
		bodyFrame.height = iframeHeight; 
	}
	
	/* 3 depth menu script start  */
	function onSubMenuOver(obj) {
	    try {
			obj.style.backgroundColor='#3f689e';
			obj.style.color = "white";
	    }
	    catch(errorObject) {
	        showErrorDlg(errorObject);
	    }
	}
	
	function onSubMenuOut(obj) {
	    try {
			obj.style.backgroundColor='#FFFFFF';
			obj.style.color = '#5e5e5e';
	    }
	    catch(errorObject) {
	        showErrorDlg(errorObject);
	    }
	}
	/* 3 depth menu script end  */

	function modifyUserInfo(){
		var url = "/lib/ModifyUserInfo.screen";
		var win_id = "_modifyUserInfo";
		window.open(url, win_id, "toolbar=no, width=450, height=250,directories=no,status=no,scrollbars=no,resize=no,menubar=no,target=new");
	}
</SCRIPT>
</HEAD>

<BODY onresize="autoResize()">
<A id='menu_linker' target='bodyFrame' href='' style="display:none" ></A>
<form name="MenuChangeForm" method="post" action="/main.screen" >
	<input type="hidden" name="P_USE_SYSTEM">

<div style="position:absolute;top:10px;right:20px;z-index:100;">
   <table border="0" cellpadding="0" cellspacing="0">
    <tr>
     <td><a href="/"><img src="/img/buyer/main/icon_home.png" /></a></td>
     <td>&nbsp;</td>
     <td><a href="javascript:modifyUserInfo();" style="text-decoration: none;"><b><%=user.get("user_name") %></b></a>님 로그인중입니다.</td>
     <td><img src="/img/buyer/main/icon_bar.gif" /></td>
     <td><img src="/img/buyer/main/btn_logout.gif" alt="logout"  onclick="self.location='/sign_off.screen';" style="cursor:pointer;" /></td>
    </tr>
    </table>  
</div>

<table align="center"  cellpadding="0" cellspacing="0" style="width:100%;"  border="0">
	<tr>
		<td valign="top" width="100%" height="100%" style="background-image:url('/img/buyer/main/top_bg.jpg'); background-repeat:repeat-x;">
			<table width="100%" height="100%" cellpadding="0" cellspacing="0" >
				<tr>
					<td height="84" valign="top" style="height:116px;">
						<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
							<tr>
								<td width="266" height="84" rowspan="2" align="center" valign="middle">
									<a href="/main.screen"><img src="/img/buyer/main/ebid_logo.png"  alt="전자조달시스템" /></a>
								</td>

					          <td height="42" align="right" valign="middle" class="t_white01_11" >
					            &nbsp;
					          </td>								
							<%-- 	<td width="" height="25" class="t_white01_11" style="padding-right:30px; color:#eae9e2;" align="right" ><img src="/img/main/icon_01.png" />&nbsp;<%=user.get("user_name") %>'s online.</td> --%>
							</tr>
							<tr>
								<!-- <td height="24" align="right"  valign="bottom" style="padding-bottom:2px; padding-right:18px;"> -->
								<td height="39" align="right"  valign="bottom" >
									<table width="auto" border="0" cellpadding="0" align="right" cellspacing="0" >
										<tr>
											
											<%	if( menuManager.getSystemSize() > 0 ) { %>
											<%		for( int i = 0 ; i < menuManager.getSystemSize() ; i++ ) { %>
											<%			ValueObject row = menuManager.getSystemValue(i); %>
											<%-- <%			if( menuManager.getUseSystem().equalsIgnoreCase(row.get("SYSTEM_ID")) ) { %>
			
					                 		<td height="22"><img src="<%= row.get("ON_IMAGE_PATH") %>" alt="<%=row.get("DSCR")%>"></td>
					                  		<td width="2"></td>
											<%			}
														else { %> --%>
				                  			<td height="24"><img id="system" name="system" src="<%= row.get("OFF_IMAGE_PATH") %>" 
				                  									  index="<%= i %>"
				                                                      onclick="setSystem(this)" 
			                                                          on_image_path='<%= row.get("ON_IMAGE_PATH") %>' 
																	  off_image_path='<%= row.get("OFF_IMAGE_PATH") %>' 
				                                                      style="cursor:pointer;" 
				                                                      border="0"
				                                                      alt="<%=row.get("DSCR")%>"></td>
				                  				
											<%		} %>
											<%	} %>
											<td width="50px;">&nbsp;</td>
										</tr>
									</table>
								</td>
							</tr>        
						</table>
					</td>
				</tr>
				
 				<tr>
		    		<td valign="top" align="center" style="height:100%;">   
						<IFRAME name="bodyFrame" id="bodyFrame" src="/default.screen" width="100%" height="100%" frameborder="0" id="BodyFrame" onload="autoResize(this)" ></IFRAME>
			 		</td>
		  		</tr> 			
			</table> 
		</td>
	</tr>	
</table>
						<!-- <div style="position:absolute; z-index:50;height:auto important; width:100%; ">
							<IFRAME name="bodyFrame" src="/default.screen" width="100%" height="100%" frameborder="0" id="BodyFrame" onload="autoResize(this)" ></IFRAME>
						</div> -->
</form>
<!-- sub_menu 레이어시작 -->
<% String paramStr = ""; %>
<%	if( menuManager.getSystemSize() > 0 ) { %>
<%		for( int i = 0 ; i < menuManager.getSystemSize() ; i++ ) { %>
<%			ValueObject row = menuManager.getSystemValue(i); %>
			<div id="systemMenu" name="systemMenu" index="<%= i %>" style="position:absolute; top:83px; Z-INDEX: 3; line-HEIGHT: 29px; display:none; cursor:pointer">
				<table height="25" border="0" align="left" cellpadding="0" cellspacing="0">
					<!-- <td><img src="/img/menu/group/start_line.gif"/></td> -->
				<%
				//String paramStr = "";
				for(java.util.Enumeration paramNames = request.getParameterNames(); paramNames.hasMoreElements();) {
					String paramName = (String)paramNames.nextElement();
					paramStr += paramName + "=" + request.getParameter(paramName) + "&";
				}

				for( int j = 0 ; j < menuManager.getMenuGroupSize() ; j++ ) { 
					ValueObject row2 = menuManager.getMenuGroupValue(j);
					if(row.get("SYSTEM_ID").equals(row2.get("SYSTEM_ID"))){
						
					
				%>  

					<!-- <td><img src="/img/buyer/main/sub_menu_bar.gif" /></td> -->
					<td class="smenu" id="pgm_group_<%= j %>" index="<%= j %>" onmouseover="showSubMenu('pgm_group_<%= j %>');" onmouseout ="hideSubMenu('pgm_group_<%= j %>');" style="cursor:hand;"><%= row2.get("PGM_GR_NAME")  %></td>
           	  		<td width="1"></td>
				<%	} %>
				<%} %>
				
          		</table>
			</div>
<%		} %>
<%	} %>			
<!-- <div align="left" style="top:74px; left:0; Z-INDEX: 3; VISIBILITY: visible; POSITION:absolute; line-HEIGHT: 29px; "> 
	상단 메뉴 2
	<table height="25" border="0" cellpadding="0" cellspacing="0">
		<tr> 
			<td width="100%" style="padding-right:60px;" >

          		</td>
        		<td width="15"></td>
      		</tr>
      		tr>
			<td height="23" bgcolor="B3D1CE" id="NOW_LOCATION" colspan="3">
                 &nbsp;&nbsp;&nbsp;<A href='default.screen' id='location' target='bodyFrame' class="now_location"><B>Home</B></A>
               </td>
      		</tr>
	</table>
    상단 메뉴 2
</div> -->
	
	<%
	for( int i = 0 ; i < menuManager.getMenuGroupSize() ; i++ ) { %>
	<%	ValueObject row = menuManager.getMenuGroupValue(i); %>
	<%	int subRowSetSize = menuManager.getSubMenuRowSetSize(i); 		
		int cnt_big = 0;
		int cnt_small = 0;
		for( int j = 0 ; j < subRowSetSize ; j++ ) {
			ValueObject subRow = menuManager.getSubMenuRowValue(i, j);
			if( subRow.get("GUBUN").equals("P") )
				cnt_big ++;
			else if( subRow.get("GUBUN").equals("L") && j != 0 && j != subRowSetSize - 1 )
				cnt_small ++;
		}
		int height = cnt_big * 22 + cnt_small * 10 + 2;
	%>
	<DIV id="subMenuLayer" 
	     onmouseover="showSubMenu('pgm_group_<%= i %>');"
	     onmouseout ="hideSubMenu('pgm_group_<%= i %>');"
	     style="position:absolute; left:1px; top:1px; z-index:1; display:none;">
		<TABLE width="<%= menuManager.getSubMenuWidth(i) %>" height="<%= height %>" border="0" cellspacing="0" cellpadding="0" style="cursor:pointer; 
		border-color: #a9bbd1; border-style: solid; border-top-width: 0px; border-bottom-width: 2px; border-right-width: 2px; border-left-width: 2px;
		filter=progid:DXImageTransform.Microsoft.fade(duration=0.2) progid:DXImageTransform.Microsoft.Shadow(color='#777777', direction=135, Strength=5);">

<%		

		for( int j = 0 ; j < subRowSetSize ; j++ ) { %>

<%			ValueObject subRow = menuManager.getSubMenuRowValue(i, j); %>

<%			if( subRow.get("GUBUN").equals("P") ) { %>
			        <TR height="26">		        
			            <TD onclick="parent.goMenu('<%= subRow.get("SCREEN_NAME") %>', '<%= params.get("PGM_GR_NAME") %>', '<%= subRow.get("PGM_NAME") %>');" 
			                onmouseover="onSubMenuOver(this);"
			                onmouseout ="onSubMenuOut(this);"
			                style="TEXT-INDENT:10px;"
			                align="left" bgcolor="white">
			            	<%-- 레이어의 길이를 자동 산출하기 위해 고정길이 글꼴 사용 --%>
			            	<%= subRow.get("PGM_NAME") %>
			            </TD>
			        </TR>
<%			
			}
			else if( subRow.get("GUBUN").equals("L") && j != 0 && j != subRowSetSize - 1 ) { %>

					<!-- Line -->
			        <TR height="10">
			        	<TD>
				            <TABLE border="0" cellspacing="0" cellpadding="0" width="100%">
				            	<TR>
				            		<TD bgcolor="white" width="4"></TD>
				            		<TD bgcolor="white"><IMG src="/img/main/menuline_bg.gif" border="0" width="100%" height="10"></TD>
				            		<TD bgcolor="white" width="4"></TD>
				        		</TR>
				        	</TABLE>
			        	</TD>
			        </TR>
					<!-- Line -->
<%			} %>

<%		} 

%>				
					<%-- <iframe width="100%" height="<%= height %>px" src="/main_submenu.screen?<%=paramStr%>i=<%= i %>&PGM_GR_NAME=<%=StringUtils.URLEncode(row.get("PGM_GR_NAME"))%>" style="margin:0; overflow-x:hidden; overflow-y:hidden;" marginwidth=0 marginheight=0 scrolling="no" frameborder="0"></iframe> --%>
		</TABLE>
	</DIV>
	<%	} %>
</BODY>
</HTML>
	
<%	}else { %>

<META HTTP-EQUIV="refresh" Content="0.1; url=/index.screen">

<%  } %>
