/* 
   Simple JQuery Accordion menu.
   HTML structure to use:

   

Copyright 2007 by Marco van Hylckama Vlieg

web: http://www.i-marco.nl/weblog/
email: marco@i-marco.nl
Download by http://sc.xueit.com
Free for non-commercial use
*/

function initMenu() {
  $('#menu ul').hide();
  var cur = getParentNode();
  $('#menu ul'+cur).show();
  $('#menu li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#menu ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }
  
  /* 参数cid：表示Child Node #id */
  /* 参数pid：表示Parent Node #id */
  function getParentNode(){
	var cid = location.search;
	var pid = '';
	if(cid){
		cid = cid.split(".");
		cid = cid[0].substr(1,cid[0].length-1);	
		if(document.getElementById(cid)){
			pid = document.getElementById(cid).parentNode.parentNode.id;
		}
	}
	pid = pid?'#'+pid:':first';
	return pid;
}

$(document).ready(function() {initMenu();});
