/*** 
This is the menu creation code - place it right after you body tag
Feel free to add this to a stand-alone js file and link it to your page.
**/

//Menu object creation
oCMenu=new makeCM("oCMenu") //Making the menu object. Argument: menuname

//Menu properties   
oCMenu.pxBetween=0
//Using the cm_page object to place the menu ----
oCMenu.fromLeft=0
oCMenu.fromTop=0
oCMenu.rows=1
oCMenu.menuPlacement=0
                                                             
oCMenu.offlineRoot="" 
oCMenu.onlineRoot="/cfsgweb/" 
oCMenu.resizeCheck=1 
oCMenu.wait=1000 
oCMenu.fillImg="cm_fill.gif"
oCMenu.zIndex=0

//Background bar properties
oCMenu.useBar=0

//Level properties - ALL properties have to be spesified in level 0
oCMenu.level[0]=new cm_makeLevel() //Add this for each new level
oCMenu.level[0].width="20%"
oCMenu.level[0].height=30 
oCMenu.level[0].regClass="clLevel0"
oCMenu.level[0].overClass="clLevel0over"
oCMenu.level[0].borderX=1
oCMenu.level[0].borderY=1
//oCMenu.level[0].borderClass="clLevel0border"
oCMenu.level[0].offsetX=5
oCMenu.level[0].offsetY=0
oCMenu.level[0].rows=0
oCMenu.level[0].arrow=0
oCMenu.level[0].arrowWidth=0
oCMenu.level[0].arrowHeight=0
oCMenu.level[0].align="bottom"

//EXAMPLE SUB LEVEL[1] PROPERTIES - You have to spesify the properties you want different from LEVEL[0] - If you want all items to look the same just remove this
oCMenu.level[1]=new cm_makeLevel() //Add this for each new level (adding one to the number)
oCMenu.level[1].width=oCMenu.level[0].width-2
oCMenu.level[1].height=30
oCMenu.level[1].regClass="clLevel1"
oCMenu.level[1].overClass="clLevel1over"
oCMenu.level[1].style=""

oCMenu.level[1].offsetX=-10
oCMenu.level[1].offsetY=1
oCMenu.level[1].borderClass="clLevel1border"
oCMenu.level[1].borderX=1 
oCMenu.level[1].borderY=1
oCMenu.level[1].rows=0
oCMenu.level[1].align="right" 


//EXAMPLE SUB level[2] PROPERTIES - You have to spesify the properties you want different from LEVEL[0] - If you want all items to look the same just remove this
oCMenu.level[2]=new cm_makeLevel() //Add this for each new level (adding one to the number)
//oCMenu.level[2].width="25%"
oCMenu.level[2].height=30
oCMenu.level[2].regClass="clLevel1"
oCMenu.level[2].overClass="clLevel1over"
oCMenu.level[2].offsetX=-10
oCMenu.level[2].offsetY=1
oCMenu.level[2].borderClass="clLevel1border"
oCMenu.level[2].borderX=1 
oCMenu.level[2].borderY=1
oCMenu.level[2].align="right" 


oCMenu.level[3]=new cm_makeLevel() //Add this for each new level (adding one to the number)
oCMenu.level[3].height=30
oCMenu.level[3].regClass="clLevel1"
oCMenu.level[3].overClass="clLevel1over"
oCMenu.level[3].offsetX=-10
oCMenu.level[3].offsetY=1
oCMenu.level[3].borderClass="clLevel1border"
oCMenu.level[3].borderX=1 
oCMenu.level[3].borderY=1
oCMenu.level[3].align="right" 

/******************************************
Menu item creation:
myCoolMenu.makeMenu(name, parent_name, text, link, target, width, height, regImage, overImage, regClass, overClass , align, rows, nolink, onclick, onmouseover, onmouseout) 
*************************************/
oCMenu.makeMenu('top0','','&nbsp;首 頁','home/chi/main.aspx','',50)
	
oCMenu.makeMenu('top1','','&nbsp;研究及推介','research/chi/index.aspx?body=MarketCommentary','',85)
	oCMenu.makeMenu('sub10','top1','名家評論','research/chi/index.aspx?body=commentOfColumnist','',85)
	oCMenu.makeMenu('sub11','top1','今日港股','research/chi/index.aspx?body=MarketCommentary','',85)
	//oCMenu.makeMenu('sub13','top1','研究部推介','research/chi/index.aspx?body=InvestmentIdeas','',85)
	oCMenu.makeMenu('sub14','top1','個股評論','research/chi/index.aspx?body=CompanyAnalysis','',85)
	oCMenu.makeMenu('sub15','top1','研究報告','research/chi/index.aspx?body=ResearchReport','',85)
	        oCMenu.makeMenu('sub150','sub15','上市公司','research/chi/index.aspx?body=ResearchReport&type=Listed','',85)
	        oCMenu.makeMenu('sub151','sub15','新股介紹','research/chi/index.aspx?body=ResearchReport&type=IPO','',85)
	        oCMenu.makeMenu('sub152','sub15','特別報告','research/chi/index.aspx?body=ResearchReport&type=Special','',85)	
	oCMenu.makeMenu('sub16','top1','市場資訊','research/chi/index.aspx?body=DailyCommentary','',85)
	        oCMenu.makeMenu('sub160','sub16','港股美國預託證券及倫敦收市價','research/chi/index.aspx?body=DailyCommentary&type=ADRLSE','',200)
	        oCMenu.makeMenu('sub161','sub16','A – H 股股價對比','research/chi/index.aspx?body=DailyCommentary&type=AHComp','',200)
	        oCMenu.makeMenu('sub162','sub16','能源商品期貨價格','research/chi/index.aspx?body=DailyCommentary&type=Commodities','',200)
	        //oCMenu.makeMenu('sub163','sub16','美國國庫債券','research/chi/index.aspx?body=DailyCommentary&type=USTreBonds','',200)
	        oCMenu.makeMenu('sub164','sub16','每日指數','research/chi/index.aspx?body=DailyCommentary&type=DailyIndex','',200)
	        //oCMenu.makeMenu('sub165','sub16','股票拋空紀錄','research/chi/index.aspx?body=DailyCommentary&type=ShortSelling','',200)	
	        //oCMenu.makeMenu('sub166','sub16','昨日公佈之公司業績','research/chi/index.aspx?body=DailyCommentary&type=Result','',200)
	        //oCMenu.makeMenu('sub167','sub16','本週公佈之美國經濟數據','research/chi/index.aspx?body=DailyCommentary&type=USEcoInd','',200)		
   	//oCMenu.makeMenu('sub12','top1','美股一周','research/chi/index.aspx?body=USWeekly','',85)
   	oCMenu.makeMenu('sub17','top1','新股追蹤','research/chi/index.aspx?body=IPO','',85)
	        oCMenu.makeMenu('sub170','sub17','現正接受認購申請的新股','research/chi/index.aspx?body=IPO&type=Current','',160)
	        //oCMenu.makeMenu('sub171','sub17','擬上市公司','research/chi/index.aspx?body=IPO&type=Upcoming','',160)
	        oCMenu.makeMenu('sub172','sub17','已公開認購之新股','research/chi/index.aspx?body=IPO&type=Listed','',160)	

oCMenu.makeMenu('top2','','&nbsp;投 資 媒 體','','',80)
	oCMenu.makeMenu('sub21','top2','簡介','InvestmentMedia/chi/index.aspx?body=Introduction','',110)
	oCMenu.makeMenu('sub27','top2','3G流動通訊網絡','InvestmentMedia/chi/index.aspx?body=3G','',110)
	oCMenu.makeMenu('sub22','top2','互聯網','InvestmentMedia/chi/index.aspx?body=Internet','',110)
	oCMenu.makeMenu('sub23','top2','流動簡短訊息','InvestmentMedia/chi/index.aspx?body=Mobile','',110)
	oCMenu.makeMenu('sub24','top2','無線上網電話','InvestmentMedia/chi/index.aspx?body=WAP','',110)
	oCMenu.makeMenu('sub25','top2','個人數碼助理','InvestmentMedia/chi/index.aspx?body=PDA','',110)
	oCMenu.makeMenu('sub26','top2','音頻電話','InvestmentMedia/chi/index.aspx?body=IVRS','',110)


oCMenu.makeMenu('top3','','&nbsp;服 務 及 支 援','','',105)
//	oCMenu.makeMenu('sub30','top3','電郵','http://webmail.cashon-line.com','',105)
	oCMenu.makeMenu('sub31','top3','下載表格','ServiceSupport/chi/index.aspx?body=downloadcenter','',105)
	oCMenu.makeMenu('sub32','top3','常用聯繫','ServiceSupport/chi/index.aspx?body=usefullink','',105)
//	oCMenu.makeMenu('sub33','top3','CASH Visa Card','','',134)
	oCMenu.makeMenu('sub34','top3','時富金分','https://www.cashonline.com.hk/CashPoints/chi/index.aspx?body=Redemption&type=Monthly','',105)
//    oCMenu.makeMenu('sub35','top3','常見問題','ServiceSupport/chi/index.aspx?body=faq','',105)
    //19 Feb 2009 - new FAQ Format
    oCMenu.makeMenu('sub35','top3','常見問題','','',105)
	        oCMenu.makeMenu('sub350','sub35','證券交易','','',115)
                    oCMenu.makeMenu('sub3500','sub350','香港現金','securities/chi/index.aspx?headTitle=HKCash&body=FAQ','',85)
                    oCMenu.makeMenu('sub3501','sub350','香港孖展','securities/chi/index.aspx?headTitle=HKMargin&body=FAQ','',85)
                    oCMenu.makeMenu('sub3502','sub350','美國股票','securities/chi/index.aspx?headTitle=USStocks&body=FAQ','',85)
                    oCMenu.makeMenu('sub3503','sub350','中國B股','securities/chi/index.aspx?headTitle=ChinaBShares&body=FAQ','',85)
	        oCMenu.makeMenu('sub351','sub35','外匯交易','forex/chi/index.aspx?body=FAQ','',115)
	        oCMenu.makeMenu('sub352','sub35','期貨及期權交易','commodities/chi/index.aspx?headTitle=&body=FAQ','',115)

oCMenu.makeMenu('top4','','&nbsp;關 於 我 們','','',80)
	oCMenu.makeMenu('sub40','top4','榮獲獎項','','',80,'','','','','','','','','javascript:popUp("../../home/chi/AboutUs/awards/awards.aspx","Awards",780,650);')
	oCMenu.makeMenu('sub41','top4','聯絡我們','','',80,'','','','','','','','','javascript:popUp("../../home/chi/AboutUs/ContactUs/contactUs.aspx","ContactUs",780,650);')
	//oCMenu.makeMenu('sub42','top4','問卷調查','','',80,'','','','','','','','','javascript:popUp("/Survey/chi/Survey.aspx","Survey",780,650);')
	

oCMenu.makeMenu('top5','','&nbsp;就 業 機 會','http://www.cash.com.hk/chi/chi_careers.htm','_blank',80)	


oCMenu.makeMenu('top6','','&nbsp;網 頁 索 引','SiteMap/chi/index.aspx','',80)

//Leave this line - it constructs the menu
oCMenu.construct()		


//Extra code to find position:
function findPos(num){
  //alert(num)
  if(bw.ns4){   //Netscape 4
    x = document.layers["layerMenu"+num].pageX
    y = document.layers["layerMenu"+num].pageY
  }else{ //other browsers
    x=0; y=0; var el,temp
    el = bw.ie4?document.all["divMenu"+num]:document.getElementById("divMenu"+num);
    if(el.offsetParent){
      temp = el
      while(temp.offsetParent){ //Looping parent elements to get the offset of them as well
        temp=temp.offsetParent; 
        x+=temp.offsetLeft
        y+=temp.offsetTop;
      }
    }
    x+=el.offsetLeft
    y+=el.offsetTop
  }
  //Returning the x and y as an array
  return [x,y]
}
function placeElements(){
  //Changing the position of ALL top items:
  pos = findPos(0)
  oCMenu.m["top0"].b.moveIt(pos[0],pos[1])
  pos = findPos(1)
  oCMenu.m["top1"].b.moveIt(pos[0],pos[1])
  pos = findPos(2)
  oCMenu.m["top2"].b.moveIt(pos[0],pos[1])
  pos = findPos(3)
  oCMenu.m["top3"].b.moveIt(pos[0],pos[1])
  pos = findPos(4)
  oCMenu.m["top4"].b.moveIt(pos[0],pos[1])
  pos = findPos(5)
  oCMenu.m["top5"].b.moveIt(pos[0],pos[1])
  pos = findPos(6)
  oCMenu.m["top6"].b.moveIt(pos[0],pos[1])

  //Setting the fromtop value
  oCMenu.fromTop = pos[1]
}
placeElements()
//Setting it to re place the elements after resize - the resize is not perfect though..
oCMenu.onafterresize="placeElements()"
