function menuClick(lang_id, path){
	showHideMenu(path);
	window.open("index.php?com=news.ReadNews&cat_id=" + lang_id,"fContent");
	return false;
}

//Get array of element based on the classname
function getElementsByClass(searchClass,node,tag) {

        var classElements = new Array();
        if (node == null)
                node = document;
        if (tag == null)
                tag = '*';
        var els = node.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
        var j = 0;
        for (i = 0; i < elsLen; i++) {
                if (pattern.test(els[i].className) ) {
                        classElements[j] = els[i];
                        j++;
                }
        }
        return classElements;
}

/*
 * Function to show and hide menu. Also change the image to arrow right or down
 * depends on the path
 */
function showHideMenu(path){

	arrMenu = getElementsByClass('menu-item',null,'ul');
	//arrImage = getElementsByClass('menu-item-image',null,'img');

	// Set all image to be arrow right.
	//for(i=0;i<arrImage.length;i++){
	//	imgObj=arrImage[i];
	//	imgObj.src = "images/twist_close_1n.gif";
	//}

	//Set the correct root image to arrow down
	//imgObj = document.getElementById(path + '-image');
	//if(imgObj && imgObj.className=='menu-item-image')
	//	imgObj.src='images/twist_open_1n.gif';

	// Hide all the menu item at the beginning.
	for(i=0;i<arrMenu.length;i++){
		divObj=arrMenu[i];
		divObj.style.display = "none";
	}

	//Show all the root menu
	//for(i=1;i<50;i++){
	//	the1stletter = path.substr(0,1);
	//	divObj = document.getElementById(the1stletter+i);
	//	if(divObj){
	//		divObj.style.display = "block";
	//	}
	//}

	//Split the path into array. Ex: path = m1.2.1.3
	arrPath = path.split(".");
	curPath = '';
	for(j=0;j<arrPath.length;j++){
		curPath = curPath + (curPath==''?'':'.') + arrPath[j]; // e.g curPath = m1 ======> m1.* = curPath + '.' + i
		ulObj = document.getElementById('ul-'+curPath);
		if(ulObj){
			//alert(ulObj.id);
			ulObj.style.display = "block";
		}
		//imgObj = document.getElementById(curPath + '-image');
		//if(imgObj && imgObj.className=='menu-item-image')
		//	imgObj.src='images/twist_open_1n.gif';

		for(i=1;i<50;i++){
			divObj = document.getElementById(curPath + '.' + i);

			if(divObj){
				//alert(divObj.id);
				divObj.style.display = "block";
			}
		}
	}
}

// 3rd code from http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

//addLoadEvent(onLoadFunction);
addLoadEvent(function() {


//	ddlevelsmenu.init('menubar', 'sidebar');
//	if(varPath=='') varPath = 'm';
//	showHideMenu(varPath); // m for the the1stletter variable to be initiated
});