////////////////////////////////////////////////////////////////////////////////////////////////
//
// GOMDOLINARA MENU STRUCTURE
//
////////////////////////////////////////////////////////////////////////////////////////////////

var menuStructure = [
    { "title" : "빗긴 시선", "sub" : [
   	    { "title" : "빗긴 시선", "actionType" : "link", "action" : context + "photoExhibitionList.gn" }
    ] },
    { "title" : "끄적거리다", "sub" : [
        { "title" : "끄적거리다", "actionType" : "link", "action" : context + "diary.gn?cmd=list" }
    ] },    
	{ "title" : "맑고 흐린날의 기억", "sub" : [
		{ "title" : "맑고 흐린날의 기억", "actionType" : "link", "action" : context + "giboard2/list.php?dbid=gom" }
//		{ "title" : "&#47751;&#51460; &#45720;&#50612;&#45459;&#45716; &#49444;&#47749;", "actionType" : "link", "action" : context + "profile.php" },
//		{ "title" : "&#45216;&#44060;&#46976; &#51060;&#47492;&#51032; &#49324;&#51652;&#52393;", "actionType" : "link", "action" : context + "giboardnalgae/list.php?dbid=nalgae"}
	] },
//	{ "title" : "계속되는 이야기", "sub" : [
//	    { "title" : "계속되는 이야기", "actionType" : "link", "action" : context + "0board2/?doc=bbs/gnuboard.php&bo_table=novel" }                                                                                     
//	] },
	{ "title" : "작업실", "sub" : [
		{ "title" : "작업실", "actionType" : "link", "action" : context + "deploy.gn?cmd=secondmemory" }
	] },
	{ "title" : "스크랩", "sub" : [       
     	{ "title" : "스크랩", "actionType" : "link", "action" : context + "scrapbookEx.gn?cmd=service" }
   	] },
	{ "title" : "노트", "sub" : [
         { "title" : "노트", "actionType" : "link", "action" : context + "dokuwiki/doku.php/index" }
	] },
	{ "title" : "방명록", "sub" : [
	    { "title" : "방명록", "actionType" : "link", "action" : context + "guestbook.gn?cmd=service" }
	] }	
//	{ "title" : "&#51452;&#50892;&#50728;&#44163;&#46308;", "sub" : [
//	                                                         		{ "title" : "JAVA", "actionType" : "link", "action" : context + "0board2/?doc=bbs/gnuboard.php&bo_table=db_java" },
//	                                                         		{ "title" : "DBMS", "actionType" : "link", "action" : context + "0board2/?doc=bbs/gnuboard.php&bo_table=db_db" },
//	                                                         		{ "title" : "DHTML", "actionType" : "link", "action" : context + "0board2/?doc=bbs/gnuboard.php&bo_table=db_javascript" },
//	                                                         		{ "title" : "UNIX/NT", "actionType" : "link", "action" : context + "0board2/?doc=bbs/gnuboard.php&bo_table=db_linux" },
//	                                                         		{ "title" : "DESIGN", "actionType" : "link", "action" : context + "0board2/?doc=bbs/gnuboard.php&bo_table=db_design" },
//	                                                         		{ "title" : "PHP/ASP", "actionType" : "link", "action" : context + "0board2/?doc=bbs/gnuboard.php&bo_table=db_php" },
//	                                                         		{ "title" : "FLEX", "actionType" : "link", "action" : context + "0board2/?doc=bbs/gnuboard.php&bo_table=db_as" },
//	                                                         		{ "title" : "VC++", "actionType" : "link", "action" : context + "0board2/?doc=bbs/gnuboard.php&bo_table=db_cpp" }
//    ] }
];
//if( mb_id != null ){
//	menuStructure[ 3 ][ "sub" ][ 3 ] = { 	"title" : "&#50526;&#49324;&#46988;", "actionType" : "link", 
//											"action" : context + "dokuwiki/doku.php/cwm/index" };
//}//if

////////////////////////////////////////////////////////////////////////////////////////////////
//
// GOMDOLINARA MENU PROCESS
//
////////////////////////////////////////////////////////////////////////////////////////////////

var navi = function( mainIdx, subIdx ){
	var subMenu = menuStructure[ mainIdx ].sub[ subIdx ];
	if( subMenu[ "actionType" ] == "link" ){
		location.href = subMenu[ "action" ];
	}//if	
};
var menuActivated = -1;
var hideSubMenu = function(){
	var subDiv = document.getElementById( "ctnrAppSubMenu" );
	if( subDiv != null ){
		subDiv.style.display = "none";
		menuActivated = -1;
	}//if	
};
var ctrlMenuView = function( obj, idx ){
	var ctnrSub = document.getElementById( "ctnrAppSubMenu" );
	if( !ctnrSub ){
		var body = document.getElementsByTagName("body").item(0);
		
		ctnrSub = document.createElement( "div" );
		ctnrSub.setAttribute( "id", "ctnrAppSubMenu" );
		ctnrSub.style.position = "absolute";
		ctnrSub.style.zIndex = "55";
		ctnrSub.style.top = "0";
		ctnrSub.style.left = "0";
		ctnrSub.style.background = templateColor;
		ctnrSub.style.display = "none";
		body.insertBefore( ctnrSub, body.firstChild );
	}//if

	var mainMenu = menuStructure[ idx ];
	if( idx != menuActivated && mainMenu.sub.length > 1 ){
		var str = "";
		str += "<table width='150' border='0' cellspacing='0' cellpadding='0'>";
		for( var i = 0; i < mainMenu.sub.length; i++ ){
			var subMenu = mainMenu.sub[ i ];
			str += "<tr ";
			str += " style='cursor:pointer;' ";
			if( subMenu[ "actionType" ] == "link" ){
				str += " onclick='navi( " + idx + ", " + i + " );' ";
			}//if
			str += ">";
			str += "<td align='center' style='color:white;padding-left:5px;padding-right:5px;padding-bottom:5px;'>";
			str += subMenu[ "title" ];
			str += "</td></tr>";
		}//for	
		str += "</table>";

		ctnrSub.innerHTML = str;
		ctnrSub.style.display = "block";
		
		var mainRect = LayerUtil.getBounds( obj );
		var subRect = LayerUtil.getBounds( ctnrSub );

		ctnrSub.style.top = mainRect.top + mainRect.height + 4;
		ctnrSub.style.left = mainRect.left + mainRect.width / 2 - subRect.width / 2;
		
		menuActivated = idx;			
	}//if
	
};
var initMenuView = function(){
	var ctnr = document.getElementById( "ctnrAppMenu" );

	var str = "";
	for( var i = 0; i < menuStructure.length; i++ ){
		var mainMenu = menuStructure[ i ];
		str += "<span style='cursor:pointer;' ";
		str += " onmouseover='ctrlMenuView( this, " + i + " );' ";
		str += " onclick='navi( " + i + ", 0 );' ";
		str += ">";
		str += mainMenu[ "title" ];
		str += "</span>";

		if( i < menuStructure.length - 1 ){
			str += "&nbsp;&nbsp;|&nbsp;&nbsp;";
		}//if
	};

	ctnr.innerHTML = str;
};

////////////////////////////////////////////////////////////////////////////////////////////////
//
// INTRO MOVIE PROCESS
//
////////////////////////////////////////////////////////////////////////////////////////////////

var introStart = function( event ){
	location.href = context;
//	LayerUtil.deactivateWindow();
//	
//	var div = document.getElementById( "gomdolinaraIntroCtnr" );
//	if( !div ){ 
//		var body = document.getElementsByTagName("body").item(0);
//		
//		div = document.createElement( "div" );
//		div.setAttribute( "id", "gomdolinaraIntroCtnr" );
//		div.style.position = "absolute";
//		div.style.zIndex = "110";
//		div.style.width = "704";
//		div.style.height = "504";
//		div.style.background = "white";
//		div.style.display = "none";
//		
//		body.insertBefore( div, body.firstChild );
//		
//		var str = "";
//		str += "<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'>";
//		str += "<tr><td id='gomdolinaraIntroSwfCtnr' align='center' valign='middle' onclick='introEnd();'>";
//		str += "</td></tr>";
//		str += "</table>";
//		
//		div.innerHTML = str;
//		
//		var introSo = new SWFObject( context + "img/intro.swf", "gomdolinaraIntro", "700", "500", "6", "#FFFFFF" );
//		introSo.addVariable( "version", "1.0" );
//		introSo.addParam( "scale", "noscale" );
//		introSo.addParam( "quality", "high" );
//		introSo.addParam( "allowScriptAccess", "*" );
//		introSo.write( "gomdolinaraIntroSwfCtnr" );
//	}//if
//	LayerUtil.setPositionToCenter( div );
//	div.style.display = "block";

};
var introEnd = function(){
	var introDiv = document.getElementById( "gomdolinaraIntroCtnr" );
	if( introDiv != null ){
		introDiv.style.display = "none";
		LayerUtil.activateWindow();
	}//if
};
////////////////////////////////////////////////////////////////////////////////////////////////
//
// SEARCH
//
////////////////////////////////////////////////////////////////////////////////////////////////

var search = function( keyCode ){
	if( keyCode == null || keyCode == 13 ){
		var q = document.getElementById( "searchInput" ).value;
		if( q != null && q.length > 0 ){
			//alert( q );
			location.href = context + "searchList.gn?q=" + q;
		}//if
	}//if
};

////////////////////////////////////////////////////////////////////////////////////////////////
//
// 
//
////////////////////////////////////////////////////////////////////////////////////////////////

EventUtil.regist( window, "load", function(){ 
	//initMenuView();
	EventUtil.regist( document.getElementsByTagName("body").item(0), "click", hideSubMenu );
} );