//var linkpath = '/preview/tc_chi/cac/'; 
var locapath = window.location.pathname;
if(document.location.href.search('/preview/')!=-1)
{

	var linkpath = '/epd/tc_chi/cac/';
}else
{
	var linkpath = 'http://www.epd.gov.hk/epd/tc_chi/cac/';
}

var MHeight = 0;
var widthL1 = 150;

var widthRemain = 760 - widthL1;

var isDOMxx = (document.getElementById ? true : false);
var isIE4xx = ((document.all && !isDOMxx) ? true : false);
var isNS4xx = (document.layers ? true : false);

var menu = new Array();
var litNow = new Array();
var popTimerxx = 0;

var OverL1 = '#326432', BackL1 = '#3c8757';
var OverL2 = '#028EB4', BackL2 = '#326432';
var BackL3 = '#dd7722';
var BackL4 = '#eea000';
var BackL5 = '#3080dd';
var BackL6 = '#2060bb';
var textL1 = '#ffffff';
var textL2 = '#222222';

var basepx = 87;
var heightL1 = 21;
var widthL2 = 185;

var popOldWidth = window.innerWidth;
var shead = '<td align=center valign=center width=14><img src='+basepath+'tc_chi/images/front/shead.gif border=0 height=13 width=14 ';
var search = '<td align=center valign=center width=14><img src='+basepath+'tc_chi/images/front/search.gif border=0 height=13 width=14 ';
var space = '<td align=center valign=center width=14><img src='+basepath+'tc_chi/images/front/spacer.gif border=0 height=13 width=14 ';
var HOME = '<td align=center valign=center width=14><img src='+basepath+'tc_chi/images/front/home.gif border=0 height=13 width=14 ';
var pdf = "<img src="+basepath+"tc_chi/images/front/get_adobe_reader.gif border=0 alt='取得 Adobe Reader'  height=31 width=88>";
var caring = "<img src="+basepath+"tc_chi/images/front/caring_org_0608.jpg border=0 alt='環保署獲頒「同心展關懷」2006/08年度標誌'  height=32 width=88>";
var changeText1 = '<div onmouseover=chtext1(this) onmouseout=chtext2(this)>';
var changeText2 = '</div>'

function chtext1(x){
x.style.color=textL2;
}
function chtext2(x){
x.style.color=textL1;
}

function bg() {
 if(navigator.appName=="Microsoft Internet Explorer") {
  document.body.background = basepath+'tc_chi/images/general/epd_bkg_new_ie.gif';
 } else {
  document.body.background = basepath+'tc_chi/images/general/epd_bkg_new_ns.gif';
 }
}

function writeMenus() {
if (!isDOMxx && !isIE4xx && !isNS4xx) return;

for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {
var str = '', itemX = 0, itemY = 0;
var swapbackCol = backCol;
var swapoverCol = overCol;

for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {
var itemID = 'menu' + currMenu + 'item' + currItem;
var w = (isVert ? width : length);
var h = (isVert ? length : width);

if(currMenu==0){
    backCol = swapbackCol;
  if(currItem==1){
     backCol = BackL3;
  }
  if(currItem==2){
     backCol = BackL4;
  }
  if(currItem==menu[currMenu].length-3){
     backCol = BackL5;
  }
  if(currItem==menu[currMenu].length-2){
     backCol = '';
  }    
  if(currItem==menu[currMenu].length-1){
     backCol = '';
  }  

} else {
backCol = swapbackCol;
}

if (isDOMxx || isIE4xx) {
str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; ';
if (backCol) str += 'background: ' + backCol + '; ';
str += '" ';

backCol = swapbackCol;
overCol = swapoverCol;
}
if (isNS4xx) {
str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
if (backCol) str += 'bgcolor="' + backCol + '" ';
backCol = swapbackCol;
overCol = swapoverCol;
}
if (currMenu==0 && currItem==menu[currMenu].length-1 || currMenu==0 && currItem==menu[currMenu].length-2){}else{ str += 'class="' + borderClass + '" ' };

str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')">';

str += '<table id="MENU" width="' + (w - 8) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4xx && borderClass ? 3 : 0) + '">' + "<tr onmouseout=clearstatus(); onmouseover=cursorhand(this,'"+href+"'); onclick=gourl('"+href+"','"+frame+"');>"  + image + '<td align="left" height="' + (h - 7) + '">' + '<a class="' + textClass + '" >' + text + '</a></td>';
if (target > 0) {

menu[target][0].parentMenu = currMenu;
menu[target][0].parentItem = currItem;

if (popInd) str += '<td class="' + textClass + '" align="right">' + popInd + '</td>';
}
str += '</tr></table>' + (isNS4xx ? '</layer>' : '</div>');
if (isVert) itemY += length + spacing;
else itemX += length + spacing;
}
if (isDOMxx) {
var newDiv = document.createElement('div');
document.getElementsByTagName('body').item(0).appendChild(newDiv);
newDiv.innerHTML = str;
ref = newDiv.style;
ref.position = 'absolute';
ref.visibility = 'hidden';
}

if (isIE4xx) {
document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>');
ref = getSty('menu' + currMenu + 'div');
}

if (isNS4xx) {
ref = new Layer(0);
ref.document.write(str);
ref.document.close();
}

for (currItem = 1; currItem < menu[currMenu].length; currItem++) {
itemName = 'menu' + currMenu + 'item' + currItem;
if (isDOMxx || isIE4xx) menu[currMenu][currItem].ref = getSty(itemName);
if (isNS4xx) menu[currMenu][currItem].ref = ref.document[itemName];
   }
}
with(menu[0][0]) {
ref.left = x;
ref.top = y;
ref.visibility = 'visible';
   }
}

/* function Item(image, text, href, frame, tall, spacing, target) */
/* Edit Menu Here -- Start */

menu[0] = new Array();
menu[0][0] = new Menu(true, '', 0, basepx, widthL1, OverL1, BackL1, 'itemBorder', 'itemText');
menu[0][1] = new Item1(HOME, changeText1+"主頁"+changeText2, 'http://www.epd.gov.hk/epd/cindex.html', '', 1, 0, 0);
menu[0][2] = new Item1(shead, changeText1+"行業環保支援中心"+changeText2, linkpath+'index.html', '', 1, 0, 0);
menu[0][3] = new Item1(space, "關於我們", linkpath+'aboutus/aboutus.html', '', 1, 0, 0);
menu[0][4] = new Item1(space, "最新消息", linkpath+'whatsnew/whatsnew.html', '', 1, 0, 1);
menu[0][5] = new Item1(space, "一般污染問題", linkpath+'com_poll/com_poll.html', '', 1, 0, 9);
menu[0][6] = new Item1(space, "環保法例指引及參考資料", linkpath+'com_guilde/com_guilde.html', '', 2, 0, 3);
menu[0][7] = new Item1(space, "申請牌照指引及有關法例", linkpath+'lic_applic/lic_applic.html', '', 2, 0, 4);
menu[0][8] = new Item1(space, "環保承辦商/顧問名錄", linkpath+'use_list/use_list.html', '', 2, 0, 5);
menu[0][9] = new Item1(space, "計劃和活動", linkpath+'pro_events/pro_events.html', '', 1, 0, 6);
menu[0][10] = new Item1(space, "常見問題", linkpath+'faq/faq.html', '', 1, 0, 7);
menu[0][11] = new Item1(space, "相關網站", linkpath+'use_links/use_links.html', '', 1, 0, 8);
menu[0][12] = new Item1(space, "網站指南", linkpath+'sitemap/sitemap.html', '', 1, 0, 0);
menu[0][13] = new Item1(search, changeText1+"進階搜尋"+changeText2, 'http://www.epd.gov.hk/epd/tc_chi/search/search.html', '', 1, 0, 0);
menu[0][14] = new Item1(space, '', '','', 0, 0, 0);
menu[0][15] = new Item1(space, pdf, 'http://www.chinese-t.adobe.com/products/acrobat/readstep2.html?c=hk', '_blank', 2.1, 0, 0);
//menu[0][15] = new Item1(space, caring, basepath+'tc_chi/caring/caring_logo.html', '_blank', 2.1, 0, 0);

menu[1] = new Array(); //What's New
menu[1][0] = new Menu(true, '>', widthL1, 0, widthL2, OverL2, BackL2, 'itemBorder', 'itemText');
menu[1][1] = new Item2(space,"建造業", 'http://www.epd.gov.hk/epd/tc_chi/greenconstruction/whatsnew/whatsnew.html', '_blank', 1, 0, 0);
menu[1][2] = new Item2(space,"汽車維修業", 'http://www.greengarage.com.hk/tc_chi/what/what.html', '_blank', 1, 0, 0);
menu[1][3] = new Item2(space,"物業管理", 'http://www.epd.gov.hk/epd/tc_chi/greenproperty/whatsnew/whatsnew.html', '_blank', 1, 0, 0);
menu[1][4] = new Item2(space,"飲食業", 'http://www.greenrestaurant-hk.org/tc_chi/what/what.html', '_blank', 1, 0, 0);
menu[1][5] = new Item2(space,"企業環保監理", linkpath+'cem/cem.html', '', 1, 0, 0);

menu[2] = new Array(); //Common Pollution Problems
menu[2][0] = new Menu(true, '>', widthL1, 0, widthL2, OverL2, BackL2, 'itemBorder', 'itemText');
menu[2][1] = new Item2(space,"建造業", 'http://www.epd.gov.hk/epd/tc_chi/news_events/current_issue/achievements_construction.html', '_blank', 1, 0, 0);
menu[2][2] = new Item2(space,"汽車維修業", 'http://www.greengarage.com.hk/tc_chi/solutions/solutions.html', '_blank', 1, 0, 0);
menu[2][3] = new Item2(space,"物業管理", 'http://www.epd.gov.hk/epd/tc_chi/greenproperty/poll_pro/poll_pro.html', '_blank', 1, 0, 0);
menu[2][4] = new Item2(space,"飲食業", 'http://www.greenrestaurant-hk.org/tc_chi/solutions/solutions.html', '_blank', 1, 0, 0);

menu[3] = new Array(); //Compliance Guide and Reference Materials
menu[3][0] = new Menu(true, '>', widthL1, 0, widthL2, OverL2, BackL2, 'itemBorder', 'itemText');
menu[3][1] = new Item2(space,"建造業", 'http://www.epd.gov.hk/epd/tc_chi/greenconstruction/ref_mat/ref_mat.html', '_blank', 1, 0, 0);
menu[3][2] = new Item2(space,"汽車維修業", 'http://www.greengarage.com.hk/tc_chi/guidelines/guidelines.html', '_blank', 1, 0, 0);
menu[3][3] = new Item2(space,"物業管理", 'http://www.epd.gov.hk/epd/tc_chi/greenproperty/ref_mat/ref_mat.html', '_blank', 1, 0, 0);
menu[3][4] = new Item2(space,"飲食業", 'http://www.greenrestaurant-hk.org/tc_chi/guidelines/guidelines.html', '_blank', 1, 0, 0);
menu[3][5] = new Item2(space,"精明企業環保錦囊", linkpath+'com_guilde/com_guilde_bg.html', '', 1, 0, 0);
menu[3][6] = new Item2(space,"企業環保監理", linkpath+'com_guilde/com_guilde_cor.html', '', 1, 0, 0);
menu[3][7] = new Item2(space,"其他環保資料", linkpath+'com_guilde/com_guilde_resources.html', '', 1, 0, 0);


menu[4] = new Array(); //License Application Guidance and Relevant Legislations
menu[4][0] = new Menu(true, '>', widthL1, 0, widthL2, OverL2, BackL2, 'itemBorder', 'itemText');
menu[4][1] = new Item2(space,"建造業", 'http://www.epd.gov.hk/epd/tc_chi/greenconstruction/app_lic/app_lic.html', '_blank', 1, 0, 0);
menu[4][2] = new Item2(space,"汽車維修業", 'http://www.greengarage.com.hk/tc_chi/law/law.html', '_blank', 1, 0, 0);
menu[4][3] = new Item2(space,"物業管理", 'http://www.epd.gov.hk/epd/tc_chi/greenproperty/app_lic/app_lic.html', '_blank', 1, 0, 0);
menu[4][4] = new Item2(space,"飲食業", 'http://www.greenrestaurant-hk.org/tc_chi/law/law.html', '_blank', 1, 0, 0);
menu[4][5] = new Item2(space,"環境保護互動中心", 'http://www.epd.gov.hk/epd/epic/tc_chi/epichome.html', '_blank', 1, 0, 0);
menu[4][6] = new Item2(space,"商業牌照資訊服務", linkpath+'lic_applic/lic_applic_blis.html', '', 1, 0, 0);

menu[5] = new Array(); //Useful List of Environmental Contractors / Consultants
menu[5][0] = new Menu(true, '>', widthL1, 0, widthL2, OverL2, BackL2, 'itemBorder', 'itemText');
menu[5][1] = new Item2(space,"建造業", linkpath+'use_list/use_list_con.html', '', 1, 0, 0);
menu[5][2] = new Item2(space,"汽車維修業", 'http://www.greengarage.com.hk/tc_chi/suppliers/suppliers.html', '_blank', 1, 0, 0);
menu[5][3] = new Item2(space,"物業管理", 'http://www.epd.gov.hk/epd/tc_chi/greenproperty/list_ecc/list_ecc.html', '_blank', 1, 0, 0);
menu[5][4] = new Item2(space,"飲食業", 'http://www.greenrestaurant-hk.org/tc_chi/suppliers/suppliers.html', '_blank', 1, 0, 0);
menu[5][5] = new Item2(space,"企業環保監理", linkpath+'use_list/use_list_cor.html', '', 1, 0, 0);

menu[6] = new Array(); //Programs & Events
menu[6][0] = new Menu(true, '>', widthL1, 0, widthL2, OverL2, BackL2, 'itemBorder', 'itemText');
menu[6][1] = new Item2(space,"建造業", 'http://www.epd.gov.hk/epd/tc_chi/greenconstruction/aboutus/aboutus.html', '_blank', 1, 0, 0);
menu[6][2] = new Item2(space,"汽車維修業", 'http://www.greengarage.com.hk/tc_chi/snapshots/snapshots.html', '_blank', 1, 0, 0);
menu[6][3] = new Item2(space,"物業管理", 'http://www.epd.gov.hk/epd/tc_chi/greenproperty/aboutus/aboutus.html', '_blank', 1, 0, 0);
menu[6][4] = new Item2(space,"飲食業", 'http://www.greenrestaurant-hk.org/tc_chi/activity/activity.php', '_blank', 1, 0, 0);
menu[6][5] = new Item2(space,"企業環保監理", linkpath+'pro_events/pro_events_cem.html', '', 1, 0, 0);
menu[6][6] = new Item2(space,"其他環保資料", linkpath+'pro_events/pro_events_resources.html', '', 1, 0, 0);

menu[7] = new Array(); //FAQ
menu[7][0] = new Menu(true, '>', widthL1, 0, widthL2, OverL2, BackL2, 'itemBorder', 'itemText');
menu[7][1] = new Item2(space,"建造業", 'http://www.epd.gov.hk/epd/tc_chi/greenconstruction/faq/faq.html', '_blank', 1, 0, 0);
menu[7][2] = new Item2(space,"汽車維修業", 'http://www.greengarage.com.hk/tc_chi/faqs/faqs.html', '_blank', 1, 0, 0);
menu[7][3] = new Item2(space,"物業管理", 'http://www.epd.gov.hk/epd/tc_chi/greenproperty/faqs/faqs.html', '_blank', 1, 0, 0);
menu[7][4] = new Item2(space,"飲食業", 'http://www.greenrestaurant-hk.org/tc_chi/faqs/faqs.html', '_blank', 1, 0, 0);
menu[7][5] = new Item2(space,"企業環保監理", linkpath+'faq/faq_cem.html', '', 1, 0, 0);

menu[8] = new Array(); //Useful Links
menu[8][0] = new Menu(true, '>', widthL1, 0, widthL2, OverL2, BackL2, 'itemBorder', 'itemText');
menu[8][1] = new Item2(space,"建造業", 'http://www.epd.gov.hk/epd/tc_chi/greenconstruction/links/links.html', '_blank', 1, 0, 0);
menu[8][2] = new Item2(space,"汽車維修業", 'http://www.greengarage.com.hk/tc_chi/useful/useful.html', '_blank', 1, 0, 0);
menu[8][3] = new Item2(space,"物業管理", 'http://www.epd.gov.hk/epd/tc_chi/greenproperty/other/other.html', '_blank', 1, 0, 0);
menu[8][4] = new Item2(space,"飲食業", 'http://www.greenrestaurant-hk.org/tc_chi/useful/useful.html', '_blank', 1, 0, 0);
menu[8][5] = new Item2(space,"企業環保監理", 'http://www.epd.gov.hk/epd/tc_chi/how_help/tools_ems/iso14000.html', '_blank', 1, 0, 0);
menu[8][6] = new Item2(space,"清潔生產", 'http://www.cleanerproduction.hk/b5_index.asp', '_blank', 1, 0, 0);
menu[8][7] = new Item2(space,"環保設施可享稅務扣除", 'http://www.ird.gov.hk/chi/faq/2009_en.htm', '_blank', 1, 0, 0);
menu[8][8] = new Item2(space,"其他環保資料", linkpath+'use_links/use_links_resources.html', '', 1, 0, 0);

menu[9] = new Array(); //Common Pollution Problems
menu[9][0] = new Menu(true, '>', widthL1, 0, widthL2, OverL2, BackL2, 'itemBorder', 'itemText');
menu[9][1] = new Item2(space,"建造業", 'http://www.epd.gov.hk/epd/tc_chi/greenconstruction/poll_pro/poll_pro.html', '_blank', 1, 0, 0);
menu[9][2] = new Item2(space,"汽車維修業", 'http://www.greengarage.com.hk/tc_chi/solutions/solutions.html', '_blank', 1, 0, 0);
menu[9][3] = new Item2(space,"物業管理",'http://www.epd.gov.hk/epd/tc_chi/greenproperty/poll_pro/poll_pro.html', '_blank', 1, 0, 0);

menu[9][4] = new Item2(space,"飲食業", 'http://www.greenrestaurant-hk.org/tc_chi/solutions/solutions.html', '_blank', 1, 0, 0);
menu[9][5] = new Item2(space,"企業環保監理", linkpath+'cem/cem.html', '', 1, 0, 0);
/* Edit Menu Here -- End */

nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');

if (isNS4xx) document.captureEvents(Event.CLICK);
document.onclick = clickHandle;

function AddMenuHeight(y) {
        MHeight = MHeight + y - 1;
}

function cursorhand(x,y) {
	x.style.cursor = 'hand';
        window.status = y;
}

function clearstatus() {
 	window.status='';
}

function gourl(x,y) {
	if(y==''){
	window.location = x;
	} else {
	window.open(x,y);
	}
}

function getRef(id) {
if (isDOMxx) return document.getElementById(id);
if (isIE4xx) return document.all[id];
if (isNS4xx) return document.layers[id];
}

function getSty(id) {
return (isNS4xx ? getRef(id) : getRef(id).style);
}

function popOver(menuNum, itemNum) {
clearTimeout(popTimerxx);
hideAllBut(menuNum);
litNow = getTree(menuNum, itemNum);
changeCol(litNow, true);
targetNum = menu[menuNum][itemNum].target;
if (targetNum > 0) {
thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);
thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);
with (menu[targetNum][0].ref) {
left = parseInt(thisX + menu[targetNum][0].x);
top = parseInt(thisY + menu[targetNum][0].y);
visibility = 'visible';
      }
   }
}

function popOut(menuNum, itemNum) {
if ((menuNum == 0) && !menu[menuNum][itemNum].target)
hideAllBut(0)
else
popTimerxx = setTimeout('hideAllBut(0)', 500);
}

function getTree(menuNum, itemNum) {

itemArray = new Array(menu.length);

while(1) {
itemArray[menuNum] = itemNum;

if (menuNum == 0) return itemArray;
itemNum = menu[menuNum][0].parentItem;
menuNum = menu[menuNum][0].parentMenu;
   }
}

function changeCol(changeArray, isOver) {
for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
if (changeArray[menuCount]) {
newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
// Change the colours of the div/layer background.
with (menu[menuCount][changeArray[menuCount]].ref) {

if(menuCount==0 && (changeArray[menuCount]==1 || changeArray[menuCount]==2 || changeArray[menuCount]==menu[menuCount].length-3 || changeArray[menuCount]==menu[menuCount].length-2 || changeArray[menuCount]==menu[menuCount].length-1) ){		
} else {
if (isNS4xx) bgColor = newCol;
else backgroundColor = newCol;
}
         }
      }
   }
}

function hideAllBut(menuNum) {
var keepMenus = getTree(menuNum, 1);
for (count = 0; count < menu.length; count++)
if (!keepMenus[count])
menu[count][0].ref.visibility = 'hidden';
changeCol(litNow, false);
}

function Menu(isVert, popInd, x, y, width, overCol, backCol, borderClass, textClass) {

this.isVert = isVert;

this.popInd = popInd;

this.x = x;
this.y = y;
this.width = width;
this.overCol = overCol;
this.backCol = backCol;
this.borderClass = borderClass;
this.textClass = textClass;
this.parentMenu = null;
this.parentItem = null;
this.ref = null;

}

function Item1(image, text, href, frame, length, spacing, target) {
this.image = image + ' name="' + text + '"></td>';
this.text = text;
this.href = href;
this.frame = frame;

if(length > 1) {
  this.length = (length - 1) * heightL1 * 1.6;
} else {
  this.length = length * heightL1;  
}
AddMenuHeight(this.length);

this.spacing = spacing;
this.target = target;
this.ref = null;
}

function Item2(image, text, href, frame, length, spacing, target) {
this.image = image + ' name="' + text + '"></td>';
this.text = text;
this.href = href;
this.frame = frame;

if(length > 2) {
  this.length = heightL1 * (1.6 + (length-2)*0.7);
} else if(length > 1) {
  this.length = heightL1 * 1.6;
} else {
  this.length = length * heightL1;  
}

this.spacing = spacing;
this.target = target;
this.ref = null;
}

function moveRoot()
{
 with(menu[0][0].ref) left = ((parseInt(left) < 100) ? 100 : 5);
}

function clickHandle(evt)
{
 if (isNS4xx) document.routeEvent(evt);
 hideAllBut(0);
}
