﻿ var layerTop=15;       //菜单顶边距
 var layerLeft=20;      //菜单左边距
 var layerWidth=170;    //菜单总宽
 var titleHeight=25;    //标题栏高度
 var contentHeight=120; //内容区高度
 var stepNo=15;         //移动步数，数值越大移动越慢

 var itemNo=0;runtimes=0;
 function addItem(itemTitle,itemContent){
   itemHTML='<div id=item'+itemNo+' itemIndex='+itemNo+' style="position:relative;left:0;top:'+(-contentHeight*itemNo)+'px;width:'+layerWidth+'px;">'+
   '<table width=100% cellspacing="0" cellpadding="0"><tr><td height="'+titleHeight+'px" onclick=changeItem('+itemNo+') class="titlestyle">'+itemTitle+'</td></tr>'+
       '<tr><td height="'+contentHeight+'px" class="contentstyle" valign="top">'+itemContent+'</td></tr></table></div>';
   document.getElementById("ssssasa").innerHTML += itemHTML;
   itemNo++;
 }
 //添加菜单标题和内容，可任意多项，注意格式：
 addItem('<li>加盟理由</li>','<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">'+
 '<tr><td class="rightTopchilden"><p class="a_l_indent_s"><img src="/images/arrowhead.gif">&nbsp;<a href="/joinUs1050_1001.shtml" >工作环境</a></p></td></tr>'+
 '<tr><td class="rightTopchilden"><p class="a_l_indent_s"><img src="/images/arrowhead.gif">&nbsp;<a href="/joinUs1050_1002.shtml" >薪酬福利</a></p></td></tr>'+
 '<tr><td class="rightTopchilden"><p class="a_l_indent_s"><img src="/images/arrowhead.gif">&nbsp;<a href="/joinUs1050_1003.shtml" >人才关怀</a></p></td></tr>'+
 '<tr><td class="rightTopchilden"><p class="a_l_indent_s"><img src="/images/arrowhead.gif">&nbsp;<a href="/joinUs1050_1004.shtml" >职位升迁</a></p></td></tr></table>'
 );
 
 addItem('<li>人才招聘</li>','<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">'+
 '<tr><td class="rightTopchilden"><p class="a_l_indent_s"><img src="/images/arrowhead.gif">&nbsp;<a href="/joinUs1051_1006.shtml" >中联人才观</a></p></td></tr>'+
 '<tr><td class="rightTopchilden"><p class="a_l_indent_s"><img src="/images/arrowhead.gif">&nbsp;<a href="/joinUs1051_1007.shtml" >招聘原则</a></p></td></tr>'+
 '<tr><td class="rightTopchilden"><p class="a_l_indent_s"><img src="/images/arrowhead.gif">&nbsp;<a href="/joinUs1051_1008.shtml" >最新招聘职位</a></p></td></tr></table>'
 );
 
 addItem('<li>心语中联</li>','<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">'+
 '<tr><td class="rightTopchilden"><p class="a_l_indent_s"><img src="/images/arrowhead.gif">&nbsp;<a href="/joinUs1052_1009.shtml" >总裁信箱</a></p></td></tr>'+
 '<tr><td class="rightTopchilden"><p class="a_l_indent_s"><img src="/images/arrowhead.gif">&nbsp;<a href="/joinUs1052_1010.shtml" >荣誉分享经验交流</a></p></td></tr>'+
 '<tr><td class="rightTopchilden"><p class="a_l_indent_s"><img src="/images/arrowhead.gif">&nbsp;<a href="/joinUs1052_1011.shtml" >员工访谈</a></p></td></tr></table>'
 );

 document.getElementById("itemsLayer").style.height=itemNo*titleHeight+contentHeight+5+'px';
 var toItemIndex=itemNo-1; var onItemIndex=itemNo-1;

 function changeItem(clickItemIndex){
   toItemIndex=clickItemIndex;
   if(toItemIndex-onItemIndex>0) moveUp(); else moveDown();
   runtimes++;
   if(runtimes>=stepNo){
   onItemIndex=toItemIndex;
   runtimes=0;}
   else
     setTimeout("changeItem(toItemIndex)",10);
 }

 function moveUp(){
   for(i=onItemIndex+1;i<=toItemIndex;i++)
    // eval('document.getElementById("item'+i+'").style.top=parseInt(document.getElementById("item'+i+'").style.top)-contentHeight/stepNo;');
   { document.getElementById("item"+i).style.top=parseInt(document.getElementById("item"+i).style.top)-contentHeight/stepNo+'px';
     //alert(document.getElementById("item"+i).style.top);
   }
 }

 function moveDown(){
   for(i=onItemIndex;i>toItemIndex;i--)
     //eval('document.getElementById("item'+i+'").style.top=parseInt(document.getElementById("item'+i+'").style.top)+contentHeight/stepNo;');
     {document.getElementById("item"+i).style.top=parseInt(document.getElementById("item"+i).style.top)+contentHeight/stepNo+'px';
      //alert(document.getElementById("item"+i));
      }
 }
