var menu_last_item_id='menu_toc';
var menu_last_item_clicked=null;
var menu_last_item_color;
var body_loaded=null;

function menu_open(item_id,item_name,url,last_item_id){
 if(item_id!=menu_last_item_id){
  document.getElementById(item_id).className='left_menu_selected';
  document.getElementById('header').innerHTML=item_name;
  document.getElementById('menu').src=url;

  document.getElementById(last_item_id).className='left_menu';

  return item_id;
 }else{
  return menu_last_item_id
 }
}

function tree_load(toc_id,dow,call_type){
 document.getElementById("expand_"+toc_id).src="img/icon/-.gif";
 document.getElementById("expand_"+toc_id).onclick=function(){
  this.toc_id=toc_id;
  document.getElementById("data_"+this.toc_id).style.display="none";
  this.src="img/icon/+.gif";
  this.onclick=function(){
   this.toc_id=toc_id;
   tree_load(this.toc_id,1);
  }
 }
 document.getElementById("data_"+toc_id).style.display="";
 if(dow==0){
  document.getElementById("data_"+toc_id).innerHTML="<span style='color:#CECECE;'>loading...</span>";
  if(call_type==0||call_type==null){
   document.getElementById("load_frame").src="?call=tree&toc_id="+toc_id;
  }else{
   document.getElementById("load_frame").src="?call=addTocRelation&toc_id="+toc_id+"&cng_id="+call_type;
  }
 }
}

function tree_load_insert(toc_id){
 parent.document.getElementById("data_"+toc_id).innerHTML=document.body.innerHTML;
}

function tree_body_load(toc_id,call_type){
 if(call_type==0){
  parent.parent.frames[2].location="?call=body&toc_id="+toc_id;
 }else if(call_type==1){
  //search
 }else if(call_type==2){
  parent.parent.frames[2].location="?call=bugbody&toc_id="+toc_id;
 }else if(call_type==3){
  parent.parent.frames[2].location="?call=logbody&toc_id="+toc_id;
 }else if(call_type==10){
 }
 if(menu_last_item_clicked!=null){
  document.getElementById("title_"+menu_last_item_clicked).style.background="#FFFFFF";
  document.getElementById("title_"+menu_last_item_clicked).style.color=menu_last_item_color;
 }
 document.getElementById("title_"+toc_id).style.background="#3369C0";
 menu_last_item_color=document.getElementById("title_"+toc_id).style.color;
 document.getElementById("title_"+toc_id).style.color="#FFFFFF";
 menu_last_item_clicked=toc_id;
}

function project_load(project_id){
 parent.frames[1].location='?call=menu&project='+project_id;
}

function open_data(parent_id,body_id,expand_id){
 if(document.getElementById(expand_id).style.backgroundImage=="url(img/icon/-.gif)"){
  document.getElementById(parent_id).style.border="1px solid #FFFFFF";
  document.getElementById(parent_id).style.background="";
  document.getElementById(body_id).style.display="none";
  document.getElementById(expand_id).style.backgroundImage="url(img/icon/+.gif)";
 }else{
  document.getElementById(expand_id).style.backgroundImage="url(img/icon/-.gif)";
  document.getElementById(parent_id).style.border="1px solid #808080";
  document.getElementById(parent_id).style.background="#FFFFCC";
  document.getElementById(body_id).style.display="";
 }
}
