//defind current language for the webpage.
var currlang = "big5";
var tempString = '';
var navAltText = new Array();
var switchLang1 = 'eng';
var switchLang2 = 'gb';
var m_copyright = '舦┮Τ ぃ眔锣更 &copy; 2008 翠皑穦';
var m_privacy = '╬留籔玂';
var nav1_coords, nav2_coords, nav3_coords, nav4_coords;

if(location.href.indexOf("/big5/")>-1)
{
	currlang = "big5";
	navAltText = new Array("さら拜肈","眔贱虫","拜肈臮","兵蹿の灿玥");
	switchLang1 = 'eng';
	switchLang2 = 'gb';
	m_copyright = '舦┮Τ ぃ眔锣更 &copy; 2008 翠皑穦';
	m_privacy = '╬留籔玂';
	nav1_coords = "6,15,21,77";
	nav2_coords = "6,115,21,178";
	nav3_coords = "6,221,21,284";
	nav4_coords = "6,323,21,401";
}
else if(location.href.indexOf("/gb/")>-1)
{
	currlang = "gb";
	navAltText = new Array("今日问题","得奖名单","问题回顾","条款及细则");
	switchLang1 = 'eng';
	switchLang2 = 'big5';
	m_copyright = '版权所有 不得转载 &copy; 2008 香港马会';
	m_privacy = '私隐与保安';
	nav1_coords = "6,15,21,77";
	nav2_coords = "6,115,21,178";
	nav3_coords = "6,221,21,284";
	nav4_coords = "6,323,21,401";
}
else if(location.href.indexOf("/eng/")>-1)
{
	currlang = "eng";
	navAltText = new Array("Today's Question","Winner Lists","Archive","Terms &amp; Conditions");
	switchLang1 = 'big5';
	switchLang2 = 'gb';
	m_copyright = 'Copyright (c) 2000-2008 The Hong Kong Jockey Club. All rights reserved.';
	m_privacy = 'Privacy and Security';
	nav1_coords = "3,2,21,112";
	nav2_coords = "3,129,21,204";
	nav3_coords = "3,229,21,283";
	nav4_coords = "3,306,21,432";
}

function genHeader() 
{
	tempString += '<table class="tb_header">';
	tempString += '<tr>';
	tempString += '	<td class="logo"><a href="http://www.hkjc.org.cn/big5/index.asp"><img src="../images/logo.gif" alt="&#39321;&#28207;&#39340;&#26371; The Hong Kong Jockey Club" /></a></td>';
	tempString += '	<td class="lang_switch"><img src="../images/'+ currlang +'/lang_switch.jpg" alt="" useMap="#langMap" /><map name="langMap"><area shape="rect" coords="0,0,62,22" href="#" onClick="switchlang(\''+ currlang +'\',\''+ switchLang1 +'\');return false;"><area shape="rect" coords="63,0,128,22" href="#" onClick="switchlang(\''+ currlang +'\',\''+ switchLang2 +'\');return false;"></map></td>';
	tempString += '	<td class="logo_bj"><!--<a href="http://www.beijing2008.cn/index.shtml" target="_blank"><img src="../images/logo_bj.gif" alt="Beijing 2008" /></a>--></td>';
	tempString += '</tr>';
	tempString += '</table>';
	
	document.write(tempString);
	tempString = '';
}

function genNav()
{
	tempString += '<img src="../images/' + currlang + '/' + navName + '.jpg" alt="" useMap="#navMap" />';
	tempString += '<map name="navMap">';
	tempString += '<area shape="rect" coords="' + nav1_coords + '" href="index.asp" alt="' + navAltText[0] + '" />';
	tempString += '<area shape="rect" coords="' + nav2_coords + '" href="result_weekly.html" alt="' + navAltText[1] + '" />';
	tempString += '<area shape="rect" coords="' + nav3_coords + '" href="archive.html" alt="' + navAltText[2] + '" />';
	tempString += '<area shape="rect" coords="' + nav4_coords + '" href="terms_and_conditions.html" alt="' + navAltText[3] + '" />';
	tempString += '</map>';
	
	document.write(tempString);
	tempString = '';
}

function genFooter() 
{
	document.write(m_copyright + '&nbsp;&zwnj;&nbsp; <a href="http://www.hkjc.org.cn/'+ currlang +'/others/corp_privacy.asp" target="_blank">'+ m_privacy +'</a>');

/*<!-- START Nielsen Online SiteCensus V6.0 -->
<!-- COPYRIGHT 2009 Nielsen Online -->*/
document.write('<scr' + 'ipt type="text/javascript" src="//secure-sg.imrworldwide.com/v60.js"></scr' + 'ipt>');
setTimeout(function()
{
try {
	var pvar = { cid: "hk-hkjc-wa", content: "org-cn", server: "secure-sg" };
	var trac = nol_t(pvar);
	trac.record().post();
	} catch (e) { }	
}, 500);
document.write('<noscr' + 'ipt><div><img src="//secure-sg.imrworldwide.com/cgi-bin/m?ci=hk-hkjc-wa&amp;cg=org-cn&amp;cc=1&amp;ts=noscript" width="1" height="1" alt="" /></div></noscr' + 'ipt>');
/*<!-- END Nielsen Online SiteCensus V6.0 -->*/
	
}

function switchlang(curr, next)
{
	var newURL = window.location.href.toString();
	
	if(newURL.indexOf("?") > -1)
		newURL = newURL.substring(0, newURL.indexOf("?"));
	
	if(newURL.indexOf("#") > -1)
		newURL = newURL.substring(0, newURL.indexOf("#"));
	
	window.location.href = newURL.replace("/"+curr+"/","/"+next+"/");
}
