/* generated javascript */
if (!window.skin) {
	var skin = 'monaco';
	var stylepath = 'http://images.wikia.com/common/releases_200911.4/skins';
}

/* MediaWiki:Common.js */
/**
 * 이 스크립트는 마비노기 위키아 전체에 적용됩니다. 고칠 때는 주의해주세요.
 * 
 *
 * 스크립트를 넣을 때는 충분한 설명, 출처를 넣어주세요! 이후 관리가 어려워집니다.
 **/

 /* 시작: Edittool Bars */
  // [[MediaWiki:Edittools]]와 동시 편집 (순서 바꾸지 않기를!)
  function addCharSubsetMenu() {
   var specialchars = document.getElementById('specialchars');
   if (specialchars) {
    var menu = "<select style=\"display:inline\" onChange=\"chooseCharSubset(selectedIndex)\">";
    menu += "<option>위키 문법</option>";
    menu += "<option>문장 부호</option>";
    menu += "<option>특수 기호</option>";
    menu += "<option>틀</option>";
    menu += "<option>특수 함수</option>";
    menu += "<option>내용 꾸미기</option>";
    menu += "<option>기타</option>";
    menu += "<option>정비 요망</option>";
    menu += "</select>";
    specialchars.innerHTML = menu + specialchars.innerHTML;
    chooseCharSubset(0);
   }
  }
  function chooseCharSubset(s) {
   var l = document.getElementById('specialchars').getElementsByTagName('p');
   for (var i = 0; i < l.length ; i++) {
    l[i].style.display = i == s ? 'inline' : 'none';
    l[i].style.visibility = i == s ? 'visible' : 'hidden';
   }
  }
 /* 끝: Edittool Bars */
 /* 시작: Edittool-bar 옮기기 */
  // Cookie
  function SetCookie(cookieName, cookieValue) {
   var today = new Date();
   var expire = new Date();
   var nDays = 30;
   expire.setTime( today.getTime() + (3600000 * 24 * nDays) );
   document.cookie = cookieName + "=" + escape(cookieValue) + ";expires="+expire.toGMTString();
  }
  function GetCookie(name) {
   var i =0;
   while (i < document.cookie.length) {
    if (document.cookie.substr(i,name.length) == name) {
     var valend = document.cookie.indexOf(";",i+name.length+1);
      if (valend == -1) {
       valend = document.cookie.length;
      }
      return unescape(document.cookie.substring(i+name.length+1,valend));
     }
     i = document.cookie.indexOf(" ", i) + 1;
     if (i == 0) break;
    }
   }
  function chooseCharSubset(ss) {
   s = parseInt( ss );
   if ( isNaN(s) ) s = 0;
   if (SpecCharsAccesskeys.length==0) {
    if (is_opera) SpecCharsAccesskeys = new  Array("!","\"","§","$","%","&","/","(",")","=");
     else SpecCharsAccesskeys = new  Array("1","2","3","4","5","6","7","8","9","0","!","\"","§","$","%","&","/","(",")","=");
   }
    if (s>=0) {
     var l = document.getElementById('specialchars').getElementsByTagName('p');
     for (var i = 0; i < l.length ; i++) {
      if (i==s) {
       l[i].style.display = 'inline';  
       SetArrayAccessKeys(l[i].getElementsByTagName('a'),SpecCharsAccesskeys);
       } else l[i].style.display =  'none';
      }
    SetCookie('CharSubset', s);
   } 
  }
  // Accesskeys
  function SetArrayAccessKeys(elements, keys) {
   for (var i =0; i < elements.length;i++) {
    if (i < keys.length) {
     elements[i].setAttribute("accessKey",keys[i]);
     elements[i].setAttribute("title","alt-"+keys[i]);
    } else {
     elements[i].setAttribute("accessKey","");
     elements[i].setAttribute("title","");
    }
   }
  }
  SpecCharsAccesskeys = new Array(); 
  function addCharSubsetMenu() {
   var SpecCharsMove = true;
   var edittools = document.getElementById('specialchars');
   if (edittools) {
    var name;
    var menu=document.createElement("select");
    menu.style.display="inline";
    var line = edittools.getElementsByTagName('p');
    for (var i = 0; i < line.length ; i++) {
     if (line[i].className == "specialbasic" || line[i].className == "speciallang") {
      if (line[i].title) name=line[i].title;
       else name = line[i].id;
       menu.options[menu.options.length]=new Option(name);
     }
    }
    menu.onchange=function() {chooseCharSubset(this.selectedIndex);} ;
    if (SpecCharsMove) {
     edittools.insertBefore(menu,edittools.firstChild);
     } else {
     edittools.insertAfter(menu,edittools.firstChild);
    }
    var stdsubset = 0;
    if (GetCookie ("CharSubset")) stdsubset = parseInt( GetCookie ("CharSubset") );
    if ( isNaN(stdsubset) ) stdsubset = 0;
    menu.options[stdsubset].selected = true;
    chooseCharSubset(stdsubset);
    var charlinks = document.getElementById('toolbar').getElementsByTagName('a');
    for (var i=0; i < charlinks.length; i++) {
     charlinks[i].setAttribute("tabindex",8);
    }
   }
  }
  addOnloadHook(addCharSubsetMenu);
  //  Toolbar 옮기기
  function elementMoveto(node, refNode, pos) {
   if(node && refNode) {
    var parent = refNode.parentNode;
    if (pos && pos == 'after') refNode=refNode.nextSibling;
    try {
     parent.insertBefore(node, refNode);
    } catch (DOMException) {};
   }
  }
  // Toolbar 고정
  function fixToolbar(){
   var wpEditToolbar = document.getElementById("toolbar");
   var dropdownListEditTools = document.getElementById("dropdownListEditTools");
   elementMoveto(dropdownListEditTools , wpEditToolbar , 'after' );
   if (dropdownListEditTools) dropdownListEditTools.style.display="block";
   var editspecialchars = document.getElementById("specialchars");
   elementMoveto( editspecialchars, wpEditToolbar, 'after' );      
  }
  addOnloadHook(fixToolbar);
 /* 끝: Edittool-bar 옮기기 */

/* 편집창 위의 단추 추가 */
  function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText) {
   mwCustomEditButtons[mwCustomEditButtons.length] =
   {"imageFile": imageFile, "speedTip": speedTip, "tagOpen": tagOpen, "tagClose": tagClose, "sampleText": sampleText};
  }
  addCustomButton('http://images.wikia.com/suju/ko/images//4/43/Button_KST.png', '한국시간으로 서명하기', '--\~\~\~ \{\{풀기:KSTS\}\}', '', '');

 /* XXX from en: */
 var hasClass = (function () {
    var reCache = {};
    return function (element, className) {
        return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
    };
 })();

 /* ([[위키백과:관리자 요청/2007년 5월#스크립트 추가 요청]]) */
 /** Collapsible tables *********************************************************
 *
 *  Description: Allows tables to be collapsed, showing only the header. See
 *               Wikipedia:NavFrame.
 *  Maintainers: User:R. Koot
 */
 
 //var autoCollapse = 2;
 //var collapseCaption = "hide";
 //var expandCaption = "show";
 
 function collapseTable( tableIndex )
 {
    var Button = document.getElementById( "collapseButton" + tableIndex );
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
 
    if ( !Table || !Button ) {
        return false;
    }
 
    var Rows = Table.getElementsByTagName( "tr" ); 
 
    if ( Button.firstChild.data == collapseCaption ) {
        for ( var i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = "none";
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( var i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = Rows[0].style.display;
        }
        Button.firstChild.data = collapseCaption;
    }
 }
 
 function createCollapseButtons()
 {
    var tableIndex = 0;
    var NavigationBoxes = new Object();
    var Tables = document.getElementsByTagName( "table" );
 
    for ( var i = 0; i < Tables.length; i++ ) {
        if ( hasClass( Tables[i], "collapsible" ) ) {
            NavigationBoxes[ tableIndex ] = Tables[i];
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
 
            var Button     = document.createElement( "span" );
            var ButtonLink = document.createElement( "a" );
            var ButtonText = document.createTextNode( collapseCaption );
 
            Button.style.styleFloat = "right";
            Button.style.cssFloat = "right";
            Button.style.fontWeight = "normal";
            Button.style.textAlign = "right";
            Button.style.width = "6em";
 
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
            ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
            ButtonLink.appendChild( ButtonText );
 
            Button.appendChild( document.createTextNode( "[" ) );
            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( "]" ) );
 
            var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
            /* only add button and increment count if there is a header row to work with */
            if (Header) {
                Header.insertBefore( Button, Header.childNodes[0] );
                tableIndex++;
            }
        }
    }
 
    for ( var i = 0;  i < tableIndex; i++ ) {
        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
            collapseTable( i );
        }
    }
 }
 
 addOnloadHook( createCollapseButtons );

 /* ([[위키백과:관리자 요청/2007년 5월#스크립트 추가 요청]]) */
 /** Dynamic Navigation Bars (experimental) *************************************
  *
  *  Description: See [[:en:Wikipedia:NavFrame]].
  *  Maintainers: UNMAINTAINED
  */
 
  // set up the words in your language
  var autoCollapse = 2;
  var collapseCaption = "숨기기";
  var expandCaption = "보이기";
  var NavigationBarHide = '[' + collapseCaption + ']';
  var NavigationBarShow = '[' + expandCaption + ']';
  
  // set up max count of Navigation Bars on page,
  // if there are more, all will be hidden
  // NavigationBarShowDefault = 0; // all bars will be hidden
  // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
  var NavigationBarShowDefault = autoCollapse;
  
  
  // shows and hides content and picture (if available) of navigation bars
  // Parameters:
  //     indexNavigationBar: the index of navigation bar to be toggled
  function toggleNavigationBar(indexNavigationBar)
  {
     var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
     var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
  
     if (!NavFrame || !NavToggle) {
         return false;
     }
  
     // if shown now
     if (NavToggle.firstChild.data == NavigationBarHide) {
         for (
                 var NavChild = NavFrame.firstChild;
                 NavChild != null;
                 NavChild = NavChild.nextSibling
             ) {
             if ( hasClass( NavChild, 'NavPic' ) ) {
                 NavChild.style.display = 'none';
             }
             if ( hasClass( NavChild, 'NavContent') ) {
                 NavChild.style.display = 'none';
             }
         }
     NavToggle.firstChild.data = NavigationBarShow;
  
     // if hidden now
     } else if (NavToggle.firstChild.data == NavigationBarShow) {
         for (
                 var NavChild = NavFrame.firstChild;
                 NavChild != null;
                 NavChild = NavChild.nextSibling
             ) {
             if (hasClass(NavChild, 'NavPic')) {
                 NavChild.style.display = 'block';
             }
             if (hasClass(NavChild, 'NavContent')) {
                 NavChild.style.display = 'block';
             }
         }
     NavToggle.firstChild.data = NavigationBarHide;
     }
  }
  
  // adds show/hide-button to navigation bars
  function createNavigationBarToggleButton()
  {
     var indexNavigationBar = 0;
     // iterate over all < div >-elements 
     var divs = document.getElementsByTagName("div");
     for(
             var i=0; 
             NavFrame = divs[i]; 
             i++
         ) {
         // if found a navigation bar
         if (hasClass(NavFrame, "NavFrame")) {
  
             indexNavigationBar++;
             var NavToggle = document.createElement("a");
             NavToggle.className = 'NavToggle';
             NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
             NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
             
             var NavToggleText = document.createTextNode(NavigationBarHide);
             NavToggle.appendChild(NavToggleText);
             // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
             for(
               var j=0; 
               j < NavFrame.childNodes.length; 
               j++
             ) {
               if (hasClass(NavFrame.childNodes[j], "NavHead")) {
                 NavFrame.childNodes[j].appendChild(NavToggle);
               }
             }
             NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
         }
     }
     // if more Navigation Bars found than Default: hide all
     if (NavigationBarShowDefault < indexNavigationBar) {
         for(
                 var i=1; 
                 i<=indexNavigationBar; 
                 i++
         ) {
             toggleNavigationBar(i);
         }
     }
   
  }
  
  addOnloadHook( createNavigationBarToggleButton );

 /* ([[위키백과:관리자 요청/2007년 5월#스크립트 추가 요청]]) */
 /** "Technical restrictions" title fix *****************************************
  *
  *  Description:
  *  Maintainers: [[User:Interiot]], [[User:Mets501]]
  */
 
 // For pages that have something like Template:Lowercase, replace the title, but only if it is cut-and-pasteable as a valid wikilink.
 //	(for instance [[iPod]]'s title is updated.  <nowiki>But [[C#]] is not an equivalent wikilink, so [[C Sharp]] doesn't have its main title changed)</nowiki>
 //
 // The function looks for a banner like this: <nowiki>
 // <div id="RealTitleBanner">    <!-- div that gets hidden -->
 //   <span id="RealTitle">title</span>
 // </div>
 // </nowiki>An element with id=DisableRealTitle disables the function.
 var disableRealTitle = 0;		// users can disable this by making this true from their monobook.js
 if (wgIsArticle) {			// don't display the RealTitle when editing, since it is apparently inconsistent (doesn't show when editing sections, doesn't show when not previewing)
     addOnloadHook(function() {
 	try {
 		var realTitleBanner = document.getElementById("RealTitleBanner");
 		if (realTitleBanner && !document.getElementById("DisableRealTitle") && !disableRealTitle) {
 			var realTitle = document.getElementById("RealTitle");
 			if (realTitle) {
 				var realTitleHTML = realTitle.innerHTML;
 				realTitleText = pickUpText(realTitle);
 
 				var isPasteable = 0;
 				//var containsHTML = /</.test(realTitleHTML);	// contains ANY HTML
 				var containsTooMuchHTML = /</.test( realTitleHTML.replace(/<\/?(sub|sup|small|big)>/gi, "") ); // contains HTML that will be ignored when cut-n-pasted as a wikilink
 				// calculate whether the title is pasteable
 				var verifyTitle = realTitleText.replace(/^ +/, "");		// trim left spaces
 				verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length);	// uppercase first character
 
 				// if the namespace prefix is there, remove it on our verification copy.  If it isn't there, add it to the original realValue copy.
 				if (wgNamespaceNumber != 0) {
 					if (wgCanonicalNamespace == verifyTitle.substr(0, wgCanonicalNamespace.length).replace(/ /g, "_") && verifyTitle.charAt(wgCanonicalNamespace.length) == ":") {
 						verifyTitle = verifyTitle.substr(wgCanonicalNamespace.length + 1);
 					} else {
 						realTitleText = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleText;
 						realTitleHTML = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleHTML;
 					}
 				}
 
 				// verify whether wgTitle matches
 				verifyTitle = verifyTitle.replace(/^ +/, "").replace(/ +$/, "");		// trim left and right spaces
 				verifyTitle = verifyTitle.replace(/_/g, " ");		// underscores to spaces
 				verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length);	// uppercase first character
 				isPasteable = (verifyTitle == wgTitle);
 
 				var h1 = document.getElementsByTagName("h1")[0];
 				if (h1 && isPasteable) {
 					h1.innerHTML = containsTooMuchHTML ? realTitleText : realTitleHTML;
 					if (!containsTooMuchHTML)
 						realTitleBanner.style.display = "none";
 				}
 				document.title = realTitleText + " - Wikipedia, the free encyclopedia";
 			}
 		}
 	} catch (e) {
 		/* Something went wrong. */
 	}
     });
 }
 
 
 // similar to innerHTML, but only returns the text portions of the insides, excludes HTML
 function pickUpText(aParentElement) {
   var str = "";
 
   function pickUpTextInternal(aElement) {
     var child = aElement.firstChild;
     while (child) {
       if (child.nodeType == 1)		// ELEMENT_NODE 
         pickUpTextInternal(child);
       else if (child.nodeType == 3)	// TEXT_NODE
         str += child.nodeValue;
 
       child = child.nextSibling;
     }
   }
 
   pickUpTextInternal(aParentElement);
 
   return str;
 }

 // [[위키백과:사랑방/2007년 10월#미리 보기 강제 실시]] 참고
 // 소스: 프랑스어 위키백과
 /**
  * Force IP to preview before saving changes.
  * Copyright Marc Mongenet, 2006
  */
 function forcePreview() {
  if (wgUserName != null || wgAction != "edit") return;
  saveButton = document.getElementById("wpSave");
  if (!saveButton) return;
  saveButton.disabled = true;
  saveButton.value = "저장 (미리 보기 후)";
  saveButton.style.fontWeight = "normal";
  document.getElementById("wpPreview").style.fontWeight = "bold";
 }
 addOnloadHook(forcePreview);


 /* [[위키백과:관리자 요청/2007년 11월#Common.js 스크립트 추가 요청]] */
 /** 
  * IE6에서 투명 PNG 처리를 위한 스크립트.
  *
  * Correctly handle PNG transparency in Internet Explorer 6.
  * http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.
  *  
  * Adapted for Wikipedia by Remember_the_dot and Edokter.
  *  
  * http://homepage.ntlworld.com/bobosola/pnginfo.htm states "This page contains more information for
  * the curious or those who wish to amend the script for special needs", which I take as permission to
  * modify or adapt this script freely. I release my changes into the public domain.
  */  
 
 function PngFix()
 {
    if (document.body.filters && !window.PngFixDisabled)
    {
        var documentImages = document.images
        var documentCreateElement = document.createElement
        var funcEncodeURI = encodeURI
        
        for (var i = 0; i < documentImages.length;)
        {
            var img = documentImages[i]
            var imgSrc = img.src
            
            if (imgSrc.substr(imgSrc.length - 3).toLowerCase() == "png" && !img.onclick)
            {
                if (img.useMap)
                {
                    img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + encodeURI(imgSrc) + "')"
                    img.src = "http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif"
                    i++
                }
                else
                {
                    var outerSpan = documentCreateElement("span")
                    var innerSpan = documentCreateElement("span")
                    var outerSpanStyle = outerSpan.style
                    var innerSpanStyle = innerSpan.style
                    var imgCurrentStyle = img.currentStyle
                    
                    outerSpan.id = img.id
                    outerSpan.title = img.title
                    outerSpan.className = img.className
                    outerSpanStyle.backgroundImage = imgCurrentStyle.backgroundImage
                    outerSpanStyle.borderWidth = imgCurrentStyle.borderWidth
                    outerSpanStyle.borderStyle = imgCurrentStyle.borderStyle
                    outerSpanStyle.borderColor = imgCurrentStyle.borderColor
                    outerSpanStyle.display = "inline-block"
                    outerSpanStyle.fontSize = "0"
                    outerSpanStyle.verticalAlign = "middle"
                    if (img.parentElement.href) outerSpanStyle.cursor = "hand"
                    
                    innerSpanStyle.width = "1px"
                    innerSpanStyle.height = "1px"
                    innerSpanStyle.display = "inline-block"
                    innerSpanStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + funcEncodeURI(imgSrc) + "')"
                    
                    outerSpan.appendChild(innerSpan)
                    img.parentNode.replaceChild(outerSpan, img)
                }
            }
            else
            {
                i++
            }
        }
    }
 }
 
 if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substr(22, 1) == "6")
 {
    window.attachEvent("onload", PngFix)
 }
 
 /* 대문의 "문서" 탭을 "대문"으로 바꿉니다. */
 function MainPageRenameNamespaceTab() {
     try {
         var Node = document.getElementById('ca-nstab-main').firstChild;
         if (Node.textContent) {
             Node.textContent = "대문";
         } else if ( Node.innerText ) { // IE
             Node.innerText = "대문";
         } else {
             Node.replaceChild(Node.firstChild, document.createTextNode("대문"));
         }
     } catch (e) {
     }
 }
 
 if (wgPageName == "대문" || wgPageName == "토론:대문") {
     addOnloadHook(MainPageRenameNamespaceTab);
 }

 /** Username replace function (Template:USERNAME) *******************************
 * Inserts user name into
 * By Splarka
 */
 addOnloadHook(UserNameReplace);
 
 function UserNameReplace() {
      if (typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace) return;
      for (var i=0; UserName = document.getElementsByTagName("span")[i]; i++) {
          if ((document.getElementById('pt-userpage'))&&(UserName.getAttribute('id') == "insertusername")) {
              UserName.innerHTML = wgUserName;
          }
      }
 };

/** JSconfig ************
 * Global configuration options to enable/disable and configure
 * specific script features from [[MediaWiki:Common.js]] and
 * [[MediaWiki:Monobook.js]]
 * This framework adds config options (saved as cookies) to [[Special:Preferences]]
 * For a more permanent change you can override the default settings in your 
 * [[Special:Mypage/monobook.js]]
 * for Example: JSconfig.keys[loadAutoInformationTemplate] = false;
 *
 *  Maintainer: [[User:Dschwen]]
 */
 
var JSconfig =
{
 prefix : 'jsconfig_',
 keys : {},
 meta : {},
 
 //
 // Register a new configuration item
 //  * name          : String, internal name
 //  * default_value : String or Boolean (type determines configuration widget)
 //  * description   : String, text appearing next to the widget in the preferences
 //  * prefpage      : Integer (optional), section in the preferences to insert the widget:
 //                     0 : User profile
 //                     1 : Skin
 //                     2 : Math
 //                     3 : Files
 //                     4 : Date and time
 //                     5 : Editing
 //                     6 : Recent changes
 //                     7 : Watchlist
 //                     8 : Search
 //                     9 : Misc
 //
 // Access keys through JSconfig.keys[name]
 //
 registerKey : function( name, default_value, description, prefpage )
 {
  if( typeof JSconfig.keys[name] == 'undefined' ) 
   JSconfig.keys[name] = default_value;
  else {
 
   // all cookies are read as strings, 
   // convert to the type of the default value
   switch( typeof default_value )
   {
    case 'boolean' : JSconfig.keys[name] = ( JSconfig.keys[name] == 'true' ); break;
    case 'number'  : JSconfig.keys[name] = JSconfig.keys[name]/1; break;
   }
 
  }
 
  JSconfig.meta[name] = { 'description' : description, 'page' : prefpage || 0, 'default_value' : default_value };
 },
 
 readCookies : function()
 {
  var cookies = document.cookie.split("; ");
  var p =JSconfig.prefix.length;
  var i;
 
  for( var key in cookies )
  {
   if( cookies[key].substring(0,p) == JSconfig.prefix )
   {
    i = cookies[key].indexOf('=');
    //alert( cookies[key] + ',' + key + ',' + cookies[key].substring(p,i) );
    JSconfig.keys[cookies[key].substring(p,i)] = cookies[key].substring(i+1);
   }
  }
 },
 
 writeCookies : function()
 {
  for( var key in JSconfig.keys )
   document.cookie = JSconfig.prefix + key + '=' + JSconfig.keys[key] + '; path=/; expires=Thu, 2 Aug 2009 10:10:10 UTC';
 },
 
 evaluateForm : function()
 {
  var w_ctrl,wt;
  //alert('about to save JSconfig');
  for( var key in JSconfig.meta ) {
   w_ctrl = document.getElementById( JSconfig.prefix + key )
   if( w_ctrl ) 
   {
    wt = typeof JSconfig.meta[key].default_value;
    switch( wt ) {
     case 'boolean' : JSconfig.keys[key] = w_ctrl.checked; break;
     case 'string' : JSconfig.keys[key] = w_ctrl.value; break;
    }
   }
  }
 
  JSconfig.writeCookies();
  return true;
 },
 
 setUpForm : function()
 { 
  var prefChild = document.getElementById('preferences');
  if( !prefChild ) return;
  prefChild = prefChild.childNodes;
 
  //
  // make a list of all preferences sections
  //
  var tabs = new Array;
  var len = prefChild.length;
  for( var key = 0; key < len; key++ ) {
   if( prefChild[key].tagName &&
       prefChild[key].tagName.toLowerCase() == 'fieldset' ) 
    tabs.push(prefChild[key]);
  }
 
  //
  // Create Widgets for all registered config keys
  //
  var w_div, w_label, w_ctrl, wt;
  for( var key in JSconfig.meta ) {
   w_div = document.createElement( 'DIV' );
 
   w_label = document.createElement( 'LABEL' );
   w_label.appendChild( document.createTextNode( JSconfig.meta[key].description ) )
   w_label.htmlFor = JSconfig.prefix + key;
 
   wt = typeof JSconfig.meta[key].default_value;
 
   w_ctrl = document.createElement( 'INPUT' );
   w_ctrl.id = JSconfig.prefix + key;
 
   // before insertion into the DOM tree
   switch( wt ) {
    case 'boolean' : w_ctrl.type = 'checkbox'; break;
    case 'string'  : w_ctrl.type = 'text'; break;
   }
 
   w_div.appendChild( w_label );
   w_div.appendChild( w_ctrl );
   tabs[JSconfig.meta[key].page].appendChild( w_div );
 
   // after insertion into the DOM tree
   switch( wt ) {
    case 'boolean' : w_ctrl.defaultChecked = w_ctrl.checked = JSconfig.keys[key]; break;
    case 'string' : w_ctrl.defaultValue = w_ctrl.value = JSconfig.keys[key]; break;
   }
 
  }
  addEvent(document.getElementById('preferences').parentNode, 'submit', JSconfig.evaluateForm );
 }
}
 
JSconfig.readCookies();
addOnloadHook(JSconfig.setUpForm);
 
/***** 그림 정보 틀을 자동으로 불러옴 ********
 * Adds a link to subpages of current page
 * from commons.wikimedia.org
 *  Maintainers: [[User:Yonidebest]], [[User:Dschwen]]
 *  [[사용자:Kwj2772]]가 수정
 *  JSconfig items: bool 'loadAutoInformationTemplate'
 *                       (true=enabled (default), false=disabled)
 ****/
 
if (wgCanonicalSpecialPageName == '파일올리기') {
importScript('MediaWiki:Upload.js');
}

/* '최근 바뀜'과 '주시문서 최근 바뀜'을 1분마다 새로 고치는 소스 */
if (wgCanonicalSpecialPageName == 'RecentChanges' || wgCanonicalSpecialPageName == 'Watchlist') {
importScript('MediaWiki:Ajaxrc.js');
}

/* MediaWiki:Monaco.js */
