// setting global variables
var jcdglobal = "http://www.jcdecaux.com/";
var jcnews = "news.asp";
var jcindex = "index.asp";
urlresult = String(document.location).split('/');
urlresult = String(urlresult[urlresult.length-1]).split('?');
var btns = new Array();
	difflangurl = "chinese/"+urlresult[0];
	if (typeof (difflang_comingsoon) !=  'undefined'){
		if (difflang_comingsoon){
			difflangurl = "#";
		} 
	} 
	btns['topnav_r1difflang'] = new Array("jpg", difflangurl , "_self", false);
	btns['topnav_r1global'] = new Array("jpg", jcdglobal, "_blank");
	btns['topnav_r1sitemap'] = new Array("jpg", "sitemap.html", "_self", false);
	btns['topnav_r1login'] = new Array("jpg", "login.asp", "_blank", false);
	btns['header_jcdgnews'] = new Array("jpg", "http://www.jcdecaux.com/content/jcdecaux_en/presse/communiques/", "_blank", false);
	btns['header_jcdnews'] = new Array("jpg", jcnews, "_self", false);
	btns['menu_about'] = new Array("jpg", "about_profile.html", "_self", false);
	btns['menu_products'] = new Array("jpg", "#", "_self", false);
	btns['menu_innovate'] = new Array("jpg", "innovate.html", "_self", false);
	btns['menu_event'] = new Array("jpg", "event.html", "_self", false);
	btns['menu_pressroom'] = new Array("jpg", "press_room.html", "_self", false);
	btns['menu_resources'] = new Array("jpg", "resources.asp", "_self", false);
	btns['menu_contactus'] = new Array("jpg", "contact_us.html", "_self", false);

var links = new Array();
	links['header_jcdlogo'] = new Array("jpg", jcdglobal, "_blank", false);
	links['header_jcdworld'] = new Array("jpg", "http://www.jcdecaux.com/content/jcdecaux_en/groupejcdecaux/implantations/", "_blank", false);
	links['header_coname'] = new Array("jpg", jcindex, "_self", false);

var randommax = new Array();
	randommax['mtr'] = 8;
	randommax['ael'] = 7;
	randommax['awe'] = 2;
	randommax['billboards'] = 3;
	randommax['pacific'] = 2;
	
if (menuselected!='' && menuselected!='news')
	eval("btns['"+menuselected+"'][3] = true;");
	

var subbtns = new Array();
	subbtns['menuorder'] = new Array();
	subbtns['menuorder'][0] = new Array('mtr', 'airportexpress', 'billboard');
	subbtns['menuorder'][1] = new Array('hkairport', 'macauairport');
	subbtns['menuorder'][2] = new Array('pacific', 'asiaworldexpo');
	
	subbtns['mtr'] = new Array("MTR", "mtr.html", "_self");
	subbtns['airportexpress'] = new Array("Airport Express", "ael.html", "_self");
	subbtns['hkairport'] = new Array("Hong Kong International Airport", "hkairport.html", "_self");
	subbtns['asiaworldexpo'] = new Array("AsiaWorld-Expo", "awe.html", "_self");
	subbtns['billboard'] = new Array("Outdoor Billboard", "billboards.html", "_self");
	subbtns['pacific'] = new Array("Pacific Place Passages", "pacific.html", "_self");
	subbtns['macauairport'] = new Array("Macau International Airport", "macauairport.html", "_self");

var leftmenu = new Array();
	leftmenu['mtr'] = new Array();
	leftmenu['mtr']['menuorder'] = new Array('fact', 'formats', 'research', 'package','mediakit', 'map', 'guideline', 'gallery', 'calendar');
	leftmenu['mtr']['fact'] = new Array('gif', 'mtr_fact.html');
	leftmenu['mtr']['formats'] = new Array('gif', 'mtr_formats.html');
	leftmenu['mtr']['research'] = new Array('gif', 'mtr_research.html');
	leftmenu['mtr']['package'] = new Array('gif', 'mtr_package.html');
	leftmenu['mtr']['map'] = new Array('gif', 'mtr_map.html');
	leftmenu['mtr']['guideline'] = new Array('gif', 'mtr_guideline.html');
	leftmenu['mtr']['gallery'] = new Array('gif', 'mtr_gallery.html');
	leftmenu['mtr']['calendar'] = new Array('gif', 'mtr_calendar.html');
	leftmenu['mtr']['mediakit'] = new Array('gif', 'mtr_mediakit.html');
	
	
	leftmenu['ael'] = new Array();
	leftmenu['ael']['menuorder'] = new Array('fact', 'formats', 'research', 'package', 'mediakit', 'map', 'guideline', 'gallery', 'calendar');
	leftmenu['ael']['fact'] = new Array('gif', 'ael_fact.html');
	leftmenu['ael']['formats'] = new Array('gif', 'ael_formats.html');
	leftmenu['ael']['research'] = new Array('gif', 'ael_research.html');
	leftmenu['ael']['package'] = new Array('gif', 'ael_package.html');
	leftmenu['ael']['map'] = new Array('gif', 'ael_map.html');
	leftmenu['ael']['guideline'] = new Array('gif', 'ael_guideline.html');
	leftmenu['ael']['gallery'] = new Array('gif', 'ael_gallery.html');
	leftmenu['ael']['calendar'] = new Array('gif', 'ael_calendar.html');
	leftmenu['ael']['mediakit'] = new Array('gif', 'ael_mediakit.html');
	
	
	leftmenu['awe'] = new Array();
	leftmenu['awe']['menuorder'] = new Array('formats', 'package', 'map', 'guideline', 'gallery', 'calendar');
	leftmenu['awe']['formats'] = new Array('gif', 'awe_formats.html');
	leftmenu['awe']['package'] = new Array('gif', 'awe_package.html');
	leftmenu['awe']['map'] = new Array('gif', 'awe_map.html');
	leftmenu['awe']['guideline'] = new Array('gif', 'awe_guideline.html');
	leftmenu['awe']['gallery'] = new Array('gif', 'awe_gallery.html');
	leftmenu['awe']['calendar'] = new Array('gif', 'awe_calendar.html');
	
	
	leftmenu['pacific'] = new Array();
	leftmenu['pacific']['menuorder'] = new Array('formats', 'package', 'map', 'guideline', 'gallery', 'calendar');
	leftmenu['pacific']['formats'] = new Array('gif', 'pacific_formats.html');
	leftmenu['pacific']['package'] = new Array('gif', 'pacific_package.html');
	leftmenu['pacific']['map'] = new Array('gif', 'pacific_map.html');
	leftmenu['pacific']['guideline'] = new Array('gif', 'pacific_guideline.html');
	leftmenu['pacific']['gallery'] = new Array('gif', 'pacific_gallery.html');
	leftmenu['pacific']['calendar'] = new Array('gif', 'pacific_calendar.html');
	
	leftmenu['billboards'] = new Array();
	leftmenu['billboards']['menuorder'] = new Array(/*'formats', */'package', 'map', 'guideline'/*, 'gallery'*/);
	leftmenu['billboards']['formats'] = new Array('gif', 'billboards_formats.html');
	leftmenu['billboards']['package'] = new Array('gif', 'billboards_package.html');
	leftmenu['billboards']['map'] = new Array('gif', 'billboards_map.html');
	leftmenu['billboards']['guideline'] = new Array('gif', 'billboards_guideline.html');
	leftmenu['billboards']['gallery'] = new Array('gif', 'billboards_gallery.html');
	
	
	leftmenu['about'] = new Array();
	leftmenu['about']['menuorder'] = new Array('profile', 'jcd','transport', 'digital');
	leftmenu['about']['profile'] = new Array('gif', 'about_profile.html');
	leftmenu['about']['jcd'] = new Array('gif', 'about_jcd.html');
	leftmenu['about']['transport'] = new Array('gif', '');
	leftmenu['about']['digital'] = new Array('gif', '');
	
	leftmenu['hkia'] = new Array();
	//leftmenu['hkia']['menuorder'] = new Array('fact', 'formats','research', 'package', 'map', 'guideline', 'gallery', 'calendar');
	leftmenu['hkia']['menuorder'] = new Array('fact', 'formats', 'package',  /*'ratecard',*/ 'map',  'calendar');
	leftmenu['hkia']['fact'] = new Array('gif', 'hkia_fact.html');
	//leftmenu['hkia']['formats'] = new Array('gif', '#');
	leftmenu['hkia']['formats'] = new Array('gif', 'hkia_formats.html');
	//leftmenu['hkia']['research'] = new Array('gif', 'hkia_research.html');
	leftmenu['hkia']['package'] = new Array('gif', 'hkia_package.html');
	//leftmenu['hkia']['ratecard'] = new Array('gif', 'hkia_ratecard.html');
	leftmenu['hkia']['map'] = new Array('gif', 'hkia_map.html');
	//leftmenu['hkia']['guideline'] = new Array('gif', 'hkia_guideline.html');
	//leftmenu['hkia']['gallery'] = new Array('gif', 'hkia_gallery.html');
	leftmenu['hkia']['calendar'] = new Array('gif', 'hkia_calendar.html');
	
	leftmenu['mia'] = new Array();
	//leftmenu['mia']['menuorder'] = new Array('fact', 'formats', 'package', 'map', 'guideline', 'gallery', 'calendar');
	leftmenu['mia']['menuorder'] = new Array('fact', 'formats', 'package',  'map',   'calendar');
	//leftmenu['mia']['gallery'] = new Array('gif', 'mia_gallery.html');
	leftmenu['mia']['fact'] = new Array('gif', 'mia_fact.html');
	leftmenu['mia']['formats'] = new Array('gif', 'mia_formats.html');
	leftmenu['mia']['research'] = new Array('gif', 'mia_research.html');
	leftmenu['mia']['package'] = new Array('gif', 'mia_package.html');
	leftmenu['mia']['map'] = new Array('gif', 'mia_map.html');
	//leftmenu['mia']['guideline'] = new Array('gif', 'mia_guideline.html');
	leftmenu['mia']['calendar'] = new Array('gif', 'mia_calendar.html');
	


	
// system global variable, do not modify
var submenuhighlighted = true;	// check if the submenu will highlighted by default
var showsubmenu = false;	// check if the submenu will be shown by default


function $(s){ return document.getElementById(s);}
// general show-hide function
function showhidediv(divname, isshow){
//alert(divname);
	if (isshow){
		if ($(divname) != undefined){
			$(divname).style.visibility = 'visible';
			$(divname).style.display = 'block';
		}
	}else{
		if ($(divname) != undefined){
			$(divname).style.visibility = 'hidden';
			$(divname).style.display = 'none';
		}
	}
}
// general image preloading
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// init page program for every page after html was loaded
function initpage(bottomheight){
	printtopmenu();
	printmainmenu();
	printsubmenu();
	printfootermenu(bottomheight);
	//printfootermenu();
	if (leftmenuitem != ''){
		printleftmenu(leftmenuitem, leftmenuselected);
	}
	$('hgnews').innerHTML =drawbutton('header_jcdgnews', false);
	$('hnews').innerHTML =drawbutton('header_jcdnews', false);
	$('hlogo').innerHTML =drawimglink('header_jcdlogo', false);
	$('hconame').innerHTML =drawimglink('header_coname', false);
}	
// preloading function for every page
function preLoadImages(divname){
	for ( key in btns ) {
		str = 'pimg'+key+' = newImage("images/menu/'+key+'.'+btns[key][0]+'");';
		eval (str);
		str = 'pimg'+key+'_o = newImage("images/menu/'+key+'_over.'+btns[key][0]+'");';
		eval (str);
	}
	for ( key in links ) {
		str = 'pimg'+key+' = newImage("images/menu/'+key+'.'+links[key][0]+'");';
		eval (str);
	}
	if (leftmenuitem != ''){
		thedata = eval("leftmenu['"+leftmenuitem+"']['menuorder']");
		for ( key in thedata ) {
			theitemkey = leftmenu[leftmenuitem]['menuorder'][key];
			theitem = eval("leftmenu['"+leftmenuitem+"']['"+theitemkey+"']");
			str = 'pimg'+leftmenuitem+theitemkey+' = newImage("images/menu/'+leftmenuitem+'_'+theitemkey+'.'+theitem[0]+'");';
			eval (str);
			str = 'pimg'+leftmenuitem+theitemkey+'_o = newImage("images/menu/'+leftmenuitem+'_'+theitemkey+'_over.'+theitem[0]+'");';
			eval (str);
		}		
	}
	return true;
}
// call showing submenu by default
function showsubmenubydefault(){
	mover($('img_menu_products'), 'menu_products');
	showsubmenu = true;
}

// gern button html for top right hand corner and main menu (folder = images/menu) 
function drawbutton(btnkey, isselected){
	thedata = eval("btns['"+btnkey+"']");
	html = '';
	html += '<div class="floatdiv" id="btn_'+btnkey+'">';
	html += '<a href="'+thedata[1]+'" target="'+thedata[2]+'">';
	html += '<img id="img_'+btnkey+'" src="images/menu/'+btnkey;
	if (thedata[3]) html += '_over';
	html += '.'+thedata[0]+'" ';
	html += ' onMouseOver="mover(this, \''+btnkey+'\')" ';
	html += ' onMouseOut="mout(this, \''+btnkey+'\')" ';
	html += ' border="0">';
	html += '</a>';
	html += '</div>';
	return html;
}
// gern link html without over image(folder = images/layout) 
function drawimglink(btnkey, isselected){
	thedata = eval("links['"+btnkey+"']");
	html = '';
	html += '<div class="floatdiv" id="btn_'+btnkey+'">';
	html += '<a href="'+thedata[1]+'" target="'+thedata[2]+'">';
	html += '<img id="img_'+btnkey+'" src="images/layout/'+btnkey;
	html += '.'+thedata[0]+'" ';
	html += ' border="0">';
	html += '</a>';
	html += '</div>';
	return html;
}

// mouse over and out functions  for top right hand corner and main menu
function mover(ele, btnkey){
	thedata = eval("btns['"+btnkey+"']");
	ele.src='images/menu/'+btnkey+'_over.'+thedata[0];
	if (btnkey == 'menu_products'){
		if ($('submenu').style.visibility == 'hidden' || submenuhighlighted){
			$('sbtn_mtr').className='submenu_btn_selected';
			submenuhighlighted = true;
		}
		showhidediv('submenu', true);
		showsubmenu = false;
	}else{	
		if (btnkey.substr(0, 5)=='menu_'){
			mout($('img_menu_products'), 'menu_products1');
			showsubmenu = false;
		}
	}
}

function mout(ele, btnkey){
	if (btnkey == "menu_products1")
		btnkey1 = "menu_products";
	else
		btnkey1 = btnkey;
	thedata = eval("btns['"+btnkey1+"']");
	if (!thedata[3])
		ele.src='images/menu/'+btnkey1+'.'+thedata[0];
	if (btnkey == 'menu_products1'){
		showhidediv('submenu', false);
	}
	
}

// gern button html  for submenu
function drawsubbutton(btnkey, isselected){
	thedata = eval("subbtns['"+btnkey+"']");
	html = '';
	html += '<div class="submenu_btn" id="sbtn_'+btnkey+'" ';
	html += ' onMouseOver="smover(this)" ';
	html += ' onMouseOut="smout(this)" ';
	html += ' onClick="window.location.href=\''+thedata[1]+'\'" ';
	html += '>';
	html += '<img src="images/spacer.gif" height=1 width=52>';
	html += thedata[0];
	html += '</div>';
	return html;
}


// mouse over function  for submenu buttons
function smover(ele){
	showhidediv('submenu', true);
	if (submenuhighlighted){
		$('sbtn_mtr').className='submenu_btn';
		submenuhighlighted = false;
	}
	ele.className='submenu_btn_selected';
}
// mouse out function for submenu buttons
function smout(ele){
	showhidediv('submenu', true);
	ele.className='submenu_btn';
}

// mouse over function for submenu
function submenumin(){
	showhidediv('submenu', true);
	mover($('img_menu_products'), 'menu_products');
}
// mouse out function for submenu
function submenumout(){
	showhidediv('submenu', false);
	mout($('img_menu_products'), 'menu_products');
}
// if the user mouseover the header photo/flash, show/hide the sub-menu
function headerover(){
	if (!showsubmenu)
		mout($('img_menu_products'), 'menu_products1');
}
// output menus to html - top right hand corner
function printtopmenu(){
	html = '';
	html += '<div style="float:right">';
	html += drawbutton("topnav_r1difflang");
	html += '<div class="floatdiv"><img src="images/layout/topnav_arrow.jpg" border="0"></div>';
	html += drawbutton("topnav_r1global");
	html += '<div class="floatdiv"><img src="images/layout/topnav_arrow.jpg" border="0"></div>';
	html += drawbutton("topnav_r1sitemap");
	html += '<div class="floatdiv"><img src="images/layout/topnav_arrow.jpg" border="0"></div>';
	html += drawbutton("topnav_r1login");
	html += '<div class="floatdiv"><img src="images/layout/topnav_icon.jpg" border="0"></div>';
	html += '</div>';
	$('topmenu').innerHTML = html;
}

// output menus to html - main menu
function printmainmenu(){
	html = '';
	
	html += '<table align="left" border="0" cellpadding="0" cellspacing="0" width="824">';
	html += '<tr>';
	html += '<td><img src="images/layout/spacer.gif" height=1 width=40 border="0"></td>';
	html += '<td><img src="images/layout/spacer.gif" height=1 width=7 border="0"></td>';
	html += '<td><img src="images/layout/spacer.gif" height=1 width=151 border="0"></td>';
	html += '<td><img src="images/layout/menu_sap.jpg" border="0"></td>';
	html += '<td>'+drawbutton("menu_about", false)+'</td>';
	html += '<td><img src="images/layout/menu_sap.jpg" border="0"></td>';
	html += '<td>'+drawbutton("menu_products", false)+'</td>';
	html += '<td><img src="images/layout/menu_sap.jpg" border="0"></td>';
	html += '<td>'+drawbutton("menu_innovate", false)+'</td>';
	html += '<td><img src="images/layout/menu_sap.jpg" border="0"></td>';
	html += '<td>'+drawbutton("menu_event", false)+'</td>';
	html += '<td><img src="images/layout/menu_sap.jpg" border="0"></td>';
	html += '<td>'+drawbutton("menu_pressroom", false)+'</td>';
	html += '<td><img src="images/layout/menu_sap.jpg" border="0"></td>';
	//html += '<td>'+drawbutton("menu_resources", false)+'</td>';
	//html += '<td><img src="images/layout/menu_sap.jpg" border="0"></td>';
	html += '<td>'+drawbutton("menu_contactus", false)+'</td>';
	html += '<td><img src="images/layout/menu_end.jpg" border="0"></td>';
	html += '</tr>';
	html += '</table>';
	$('mainmenu').innerHTML = html;
}
// output menus to html - submenu
function printsubmenu(){
	divheight = 3*16 + 15 + 21;
	divwidth = 750;
	sidewidth = (824-divwidth)/2;
	html = '';
	
	html +='<div id=submenucontroller >';
	html +='<table align="left" border="0" cellpadding="0" cellspacing="0" width="824">';
	html +='<tr><td align=right>';
	html +='<img src="images/spacer.gif" width='+sidewidth+' height='+divheight+' border=0 onMouseOver="submenumout()">';
	html +='</td>';
	html +='<td align=center>';
	html +='<img src="images/spacer.gif" width='+divwidth+' height='+divheight+' border=0 onMouseOver="submenumin()" onMouseOut="submenumout()">';
	html +='<td align=left>';
	html +='<img src="images/spacer.gif" width='+sidewidth+' height='+divheight+' border=0 onMouseOver="submenumout()">';
	html +='</td>';
	html +='</td></tr>';
	html +='<tr><td colspan=3 onMouseOver="submenumout()">';
	html +='<img src="images/spacer.gif" width=824 height=5 border=0 onMouseOver="submenumout()">';
	html +='</td></tr>';
	html +='</table>';
	html +='</div>';
	
	html +='<div id=submenuitems>';
	html +='<table align="left" border="0" cellpadding="0" cellspacing="0" width="824">';
	html +='<tr><td><img src="images/layout/submenu_headbg.jpg" width="824" height="21" border="0"  onMouseOver="submenumin()" ></td></tr>';
	html +='<tr><td>';
	html +='<table align="left" border="0" cellpadding="0" cellspacing="0" width="824">';
	html +='<tr>';
	html +='<td background="images/layout/submenu_startbg.jpg" onMouseOver="submenumout()"><img src="images/layout/submenu_startbg.jpg" border="0" ></td>';
	html +='<td class="submenu_bg"  onMouseOver="submenumin()">';
	html +='<table align="left" border="0" cellpadding="0" cellspacing="0"  class="submenu_bg">';
	html +='<tr>';
	html +='<td width=246 valign=top>';
	for ( menukey in subbtns['menuorder'][0] ){
		html += drawsubbutton(subbtns['menuorder'][0][menukey], false);
	}
	html +='</td>';
	html +='<td width=1 valign=top><img src="images/spacer.gif" height=1 width=1></td>';
	html +='<td width=246 valign=top>';
	for ( menukey in subbtns['menuorder'][1] ){
		html += drawsubbutton(subbtns['menuorder'][1][menukey], false);
	}
	html +='</td>';
	html +='<td width=1 valign=top><img src="images/spacer.gif" height=1 width=1></td>';
	html +='<td width=246 valign=top>';
	for ( menukey in subbtns['menuorder'][2] ){
		html += drawsubbutton(subbtns['menuorder'][2][menukey], false);
	}
	html +='</td>';
	html +='</tr>';	
	html +='<tr><td colspan=5><img src="images/spacer.gif" height=15></td></tr>';
	html +='</table>';
	html +='</td>';
	html +='<td background="images/layout/submenu_endbg.jpg" onMouseOver="submenumout()"><img src="images/layout/submenu_endbg.jpg" border="0"></td>';
	html +='</tr>';
	html +='</table>';
	html +='</td></tr>';
	html +='</table>';
	html +='</div>';
	$('submenu').innerHTML = html;
}

// output menus to html - leftmenu
function printleftmenu(sectionname, selectedsection){
	themenu = eval("leftmenu['"+sectionname+"']");
	html = '';
	if (sectionname!='about')
		html += '<img src="images/spacer.gif" height=47><br>';
	else
		html += '<img src="images/menu/about_head.gif"><br>';
		
	for ( menukey in themenu['menuorder'] ){
		theitemkey = themenu['menuorder'][menukey];
		theitem = eval("themenu['"+theitemkey+"']");
		themenuprefix ='images/menu/'+sectionname+'_'+theitemkey;
		if (theitem[1]!=''){
			if (theitemkey != selectedsection){
				html += '<a href="'+theitem[1]+'"><img src="'+themenuprefix+'.'+theitem[0]+'" onMouseOver="this.src=\''+themenuprefix+'_over.'+theitem[0]+'\'" onMouseOut="this.src=\''+themenuprefix+'.'+theitem[0]+'\'" border=0></a><br>';
			}else{
				html += '<a href="'+theitem[1]+'"><img src="'+themenuprefix+'_over.'+theitem[0]+'" border=0></a><br>';
			}
		}else{
				html += '<img src="'+themenuprefix+'.'+theitem[0]+'" border=0><br>';
		}
	}	
	$('leftmenu').innerHTML = html;
	
}

// output menus to html - footer
/******************************************************
function printfootermenu(){
	html = '';
	html += '<div style="float:left;">SALES ENQUIRY HOTLINE: (852) 2111-0111 EMAIL: <a href="mailto:info@jcdecaux.com.hk">info@jcdecaux.com.hk</a></div>';
	html += '<div style="float:right;"><a href="term_of_use.html">TERMS OF USE</a>';
	html += ' | JCDECAUX PEARL &amp; DEAN LTD. &copy; 2010';
	html += '</div>';
	$('footermenu').innerHTML = html;
}
/******************************************************/
function printfootermenu(bottomheight){
	html = '';
	if (typeof (bottomheight) ==  'undefined'){
		bottomheight = 65;
	}
	html += '<table align="left" border="0" cellpadding="0" cellspacing="0" width="824">';
	html += '<tr>';
	html += '<td style="background:url(images/layout/bottom_r0start.jpg) left top repeat-y;"><img src="images/spacer.gif" border="0" alt=""></td>';
	html += '<td class="contentBody"><img src="images/spacer.gif" width="750" height="'+bottomheight+'" border="0" alt=""></td>';
	html += '<td style="background:url(images/layout/bottom_r0end.jpg) left top repeat-y;"><img src="images/spacer.gif" border="0" alt=""></td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td style="background:url(images/layout/bottom_r1start.jpg) left top repeat-y;"><img src="images/spacer.gif" border="0" alt=""></td>';
	html += '<td class=footer_blue valign="top">';
	html += '<div style="float:left;">SALES ENQUIRY HOTLINE: (852) 2111-0111 EMAIL: <a href="mailto:info@jcdecaux.com.hk">info@jcdecaux.com.hk</a></div>';
	html += '<div style="float:right;"><a href="term_of_use.html">TERMS OF USE</a>';
	html += ' | JCDECAUX PEARL &amp; DEAN LTD. &copy; 2010';
	html += '</div>';
	html += '</td>';
	html += '<td style="background:url(images/layout/bottom_r1end.jpg) left top repeat-y;"><img src="images/spacer.gif" border="0" alt=""></td>';
	html += '</tr>';
	html += '<tr>';
	html += '<td><img src="images/layout/bottom_r2start.jpg" border="0" alt=""></td>';
	html += '<td background="images/layout/bottom_r2bg.jpg">&nbsp;</td>';
	html += '<td><img src="images/layout/bottom_r2end.jpg" border="0" alt=""></td>';
	html += '</tr>';
	html += '</table>';
	
	
	$('footermenu').innerHTML = html;
}
/******************************************************/

// functions for product - categorized photo drop-down show -- still in development
// function getting the anchor 
function getAnchor(){
	Url=top.window.location.href;
	u=Url.split("#");
	if (u.length==1) g='';
	else g=u[1];
	return g;
}

function showDefaultinfo(){
	theitem = getAnchor();	
	if (theitem != ''){
		u=theitem.split("_");
		if (u.length == 1){	
			
			openinfo(theitem);
			switch (theitem){
				case 'fatrain':
				case 'electronicads':
				showinfo(theitem+'_3');
				break;

				default:
				showinfo(theitem+'_1');
				break;
			}
		} else {
			openinfo(u[0]);
			showinfo(theitem);
		}
	}
}

var currdiv = '';
var curritem = '';
var currsubitem = '';

//var hassubformats = new Array('posterads_4', 'posterads_5', 'posterads_6', 'posterads_9', 'fatrain_9', 'electronicads_12');	
function showinfo(menuitemname){
	if (curritem!=''){
		showhidediv('photobox_'+curritem, false);
		$('menuitem_'+curritem).className="infodetails";
		
		if ($('menuitem_'+curritem+'_1a') != undefined ) {
			switch (curritem){
				case 'posterads_4': case 'posterads_5': case 'electronicads_12':
					change_imgonly(curritem, '');
					break;
				default:
					change_imgonly(curritem, 1);
				break;
			}
		}
	}
	
	if ($('menuitem_'+menuitemname+'_1a') != undefined ) {
		switch (menuitemname){
			case 'posterads_4': case 'posterads_5': case 'electronicads_12': case 'hkiaposterads_1': case 'hkiadigital_1':
				change_imgonly(menuitemname, '');
				break;
			default:
				change_imgonly(menuitemname, 1);
			break;
		}
	}
	showhidediv('photobox_'+menuitemname, true);
	$('menuitem_'+menuitemname).className="infodetails_selected";
	curritem = menuitemname;
	
	
	return false;
}

// show information for MTR-Format (change image only)
var hassubformats_desc = new Array('electronicads_12_1','electronicads_12_2', 'hkiaposterads_3_1', 'hkiaposterads_3_2', 'hkiaposterads_3_3', 'hkiaposterads_3_4', 'hkiaposterads_3_5', 'hkiabanners_1_1', 'hkiabanners_1_2', 'hkiabanners_1_3', 'hkiabanners_1_4','miabanners_1_1', 'miabanners_1_2', 'hkiadigital_1_1', 'hkiadigital_1_2', 'hkiadigital_1_3', 'hkiadigital_1_4', 'hkiadigital_1_5');	
function change_imgonly(photoid, imageno){	
	for (i=0; i<hassubformats_desc.length; i++){	
		if ($('menuitem_'+hassubformats_desc[i]+'c')!=undefined && $('menuitem_'+hassubformats_desc[i]+'c')!=null){
			$('menuitem_'+hassubformats_desc[i]+'c').style.display='none';
		}
		if ($('menuitem_'+hassubformats_desc[i]+'d')!=undefined && $('menuitem_'+hassubformats_desc[i]+'d')!=null){		
			$('menuitem_'+hassubformats_desc[i]+'d').style.display='none';
		}
	}
	if (currsubitem != ""  && $("menuitem_"+currsubitem+"b")!=undefined){
		$("menuitem_"+currsubitem+"b").className = "contentfloatafterli_dark";
	}
	if (imageno == ""){
		$('infophoto_'+photoid).src="images/photo/"+photoid+".jpg";
		currsubitem = "";		
	}else{
		
		$('infophoto_'+photoid).src="images/photo/"+photoid+"_"+imageno+".jpg";
		currsubitem = photoid+"_"+imageno;
		
		if ($("menuitem_"+currsubitem+"b")!=undefined){
			$("menuitem_"+currsubitem+"b").className = "contentfloatafterli_light";
		}
		
		for (i=0; i<hassubformats_desc.length; i++){	
			if (currsubitem == hassubformats_desc[i] && $('menuitem_'+hassubformats_desc[i]+'c')!=undefined && $('menuitem_'+hassubformats_desc[i]+'c')!=null && $('menuitem_'+hassubformats_desc[i]+'d')!=undefined && $('menuitem_'+hassubformats_desc[i]+'d')!=null){
				$("menuitem_"+currsubitem+"c").style.display='block';
				$("menuitem_"+currsubitem+"d").style.display='block';
			}
		}
		if ($("menuitem_hkiadigital_1_2d") != undefined){
		if (photoid == 'hkiadigital_1' && imageno >1){
			$("menuitem_hkiadigital_1_2b").className = "contentfloatafterli_light";
			$("menuitem_hkiadigital_1_2c").style.display='block';
			$("menuitem_hkiadigital_1_2d").style.display='block';
			if (imageno > 3){
				$("menuitem_hkiadigital_1_3b").className = "contentfloatafterli_dark";
			} else {
				$("menuitem_hkiadigital_1_3b").className = "contentfloatafterli_light";
			}
		} else {
			$("menuitem_hkiadigital_1_2b").className = "contentfloatafterli_dark";
			$("menuitem_hkiadigital_1_2c").style.display='none';
			$("menuitem_hkiadigital_1_2d").style.display='none';
		}
		}
		
	}
	
	return false;
}

// show-hide specific sub-category 
var formatsectionnames = new Array();
	formatsectionnames['posterads'] = 'PosterAds';
	formatsectionnames['fa'] = 'FeatureAds';
	formatsectionnames['exhibition'] = 'Exhibition &amp; Display';
	formatsectionnames['electronicads'] = 'ElectronicAds Format';
	formatsectionnames['posteradsae'] = 'PosterAds';
	formatsectionnames['faae'] = 'FeatureAds';
	formatsectionnames['exhibitionae'] = 'Exhibition &amp; Display';
	formatsectionnames['electronicadsae'] = 'ElectronicAds Format';
	formatsectionnames['hkiaposterads'] = 'PosterAds';
	formatsectionnames['hkiafeatureads'] = 'FeatureAds';
	formatsectionnames['hkiabanners'] = 'Banners';	
	formatsectionnames['hkiaexhibit'] = 'Exhibition Sites';
	formatsectionnames['hkiadisplay'] = 'Display Sites';
	formatsectionnames['hkiatrolley'] = 'Trolleys';
	formatsectionnames['hkiadigital'] = 'Electronic / Digital';
	formatsectionnames['hkiasponsorship'] = 'Sponsorship';
	formatsectionnames['hkiaexterior'] = 'Exteriors';

	formatsectionnames['miaposterads'] = 'PosterAds';
	formatsectionnames['miafeatureads'] = 'FeatureAds';
	formatsectionnames['miabanners'] = 'Banners';	
	formatsectionnames['miaexhibit'] = 'Exhibition Sites';
	formatsectionnames['miadisplay'] = 'Display Sites';
	formatsectionnames['miatrolley'] = 'Trolleys';
	formatsectionnames['miasponsorship'] = 'Sponsorship';
	formatsectionnames['miaexterior'] = 'Exterior';

function openinfo(divname){
	if ($('menu_fa')!=undefined && $('menu_fa')!=null && $('menuarr_fa')!=undefined && $('menuarr_fa')!=null ){
		if (divname.substr(0, 2)=='fa'){	
			showhidediv('menu_fa', true);
			$('menuarr_fa').src="images/infoopened.gif";
			
		}else{
			showhidediv('menu_fa', false);
			$('menuarr_fa').src="images/infoclosed.gif";
		}
	}
	
	if (currdiv != divname){
		if (currdiv!=''){
			if (currdiv!='fa'){
				showhidediv('menu_'+currdiv, false);
				$('menuarr_'+currdiv).src="images/infoclosed.gif";
			}
		}
		showhidediv('menu_'+divname, true);
		$('menuarr_'+divname).src="images/infoopened.gif";
		currdiv = divname;
	}else{
//		if (currdiv.substr(0, 2)!='fa'){
			showhidediv('menu_'+currdiv, false);
			$('menuarr_'+currdiv).src="images/infoclosed.gif";
			currdiv = '';
	//	}
	}
	if (divname.substr(0, 2)=='fa'){	
		$('currseleect').innerHTML = '&nbsp; > '+formatsectionnames['fa'];
	}else{
		if (formatsectionnames[divname]!="")
			$('currseleect').innerHTML = '&nbsp; > '+formatsectionnames[divname];
		else 
			$('currseleect').innerHTML = '';
	}
	return false;
}

function opensmmenu(divname){	
	if (currdiv != divname){
		showhidediv('menu_'+divname, true);
		$('menuarr_'+divname).src="images/infoopened.gif";
		if (currdiv != ''){
			showhidediv('menu_'+currdiv, false);
			$('menuarr_'+currdiv).src="images/infoclosed.gif";
		}
		currdiv = divname;
	}else{
		showhidediv('menu_'+currdiv, false);
		$('menuarr_'+currdiv).src="images/infoclosed.gif";
		currdiv = '';
	}
	return false;
}

// functions for random images
function gernRandomHeadImg(prefix){	
	switch (prefix){
		case "":
		return '<img src="images/spacer.gif"  border="0" width=550 height=188>';
		break;
		case "hkia":
		return '<img src="images/headerimg/hkia.jpg"  width="550" height="188" border="0">';
		break;
		case "mia":
		return '<img src="images/headerimg/moia.jpg"  width="550" height="188" border="0">';
		break;
		default:			
			numOfImgs = randommax[prefix];
			if (numOfImgs == undefined || numOfImgs == null || numOfImgs == 0 ){
				return '<img src="images/spacer.gif"  border="0" width=550 height=188>';
			}
			lastvalue = getCookieVal('last'+prefix);
			if (lastvalue != ""){
				lastvalue = lastvalue*1;
			}else{
				//alert('cookie missed! '+document.cookie);
			}
			if (lastvalue <=0 || lastvalue > numOfImgs){		
				lastvalue = -1;	
			}
			vNum = 0;	
			counter=0;
			while ((vNum <=0 || vNum > numOfImgs) || (vNum==lastvalue && lastvalue != -1)){
				vNum = Math.random();
				vNum = Math.round(vNum* (numOfImgs-1))+1;
				counter++;
			}
			//alert(counter+' times')
			setCookieVal('last'+prefix, vNum);
			return '<img src="images/headerimg/'+prefix+'_'+vNum+'.jpg"  border="0">'
		break;
	}
}

// cookiesfunction 
var sap = ";";
function setCookieVal(valkey,val){
	str = "";	
	thearr = getCookiearr();
	strfound = false;
	for (i=0; i<thearr.length; i++){		
		theitem = thearr[i].split("=");
		thisvalkey = theitem[0];
		if (thisvalkey == valkey){
			thisval = val;
			strfound = true;
		}else{
			thisval = theitem[1];
		}
		if (thisvalkey != "" && thisvalkey != 'undefined'){
			str += thisvalkey+"="+thisval+""+sap;
		}
	}
	if (!strfound){
		str = valkey+"="+val+""+sap + str;
	}
	setCookie(str);
}
function getCookieVal(valkey){
	val = "";
	thearr = getCookiearr();
	
	for (i=0; i<thearr.length; i++){		
		theitem = thearr[i].split("=");
		theitem[0] = trim(theitem[0]);
		//alert("|"+theitem[0]+"|"+(theitem[0] == valkey));
		if (theitem[0] == valkey){			
			//alert('hit');
			val = theitem[1];
			break;
		}
	}
	return val;
}
function setCookie(str){
	now=new Date( )
	now.setTime( now.getTime( ) + 1000 * 60 * 5 )
	document.cookie= str+";expires=" + now.toGMTString( )
}

function getCookiearr(){
	cookieval = getCookie();
	thecookiearr = new Array();
	if (cookieval !=null)
		thecookiearr = cookieval.split(sap);
	return thecookiearr;
}
function getCookie(){
	return document.cookie;
}


function trim(str){
	return str.replace(/^\s+|\s+$/g,"");
}



function setStyles(tableid, tablestyles){
	var tb = $(tableid);
	bgcolors = tablestyles;
	var tr = tb.firstChild;
	var cn = 0;
	
	while(tr){		
		if (tr.nodeName == 'TR'){
			ni = cn++ % tablestyles.length;
			tr.className = tablestyles[ni];
		}
		tr = tr.nextSibling;
	}
}

function sparking(id){

	if ($(id).style.display=='none') $(id).style.display='block';
	else $(id).style.display='none'
	window.setTimeout("sparking('"+id+"')", 500);
}

function setStyles_multiCol(tableid, tablestyles, resetheader){
	var tb = $(tableid);
	bgcolors = tablestyles;
	var tr = tb.firstChild;
	var cn = 0;
	
	while(tr){		
		if (tr.nodeName == 'TR'){
			if (tr.className != resetheader){
				ni = cn++ % tablestyles.length;
				tr.className = tablestyles[ni];
			} else {
				cn = 0;
			}
		}
		tr = tr.nextSibling;
	}
}