var ua=navigator.userAgent.toLowerCase();
var country=document.location.href.substr(document.location.href.indexOf("/", 7)+1, 2);
var countryPath = "/" + country + "/";

function jump2() {
	if (confirm("Are you sure want to logout and switch to other region?")) {
		document.location.href="/"+document.formNavCountry.country.options[formNavCountry.country.selectedIndex].value;
	} else {
		formNavCountry.country.selectedIndex = 3;
		return false;
	}
}

if (document.images) {
	
	nav1_off = new Image();
	nav1_off.src = countryPath + "images/nav/nav1_off.gif";
	nav1_on = new Image();
	nav1_on.src = countryPath + "images/nav/nav1_on.gif";	

	nav2_off = new Image();
	nav2_off.src = countryPath + "images/nav/nav2_off.gif";
	nav2_on = new Image();
	nav2_on.src = countryPath + "images/nav/nav2_on.gif";	

	nav3_off = new Image();
	nav3_off.src = countryPath + "images/nav/nav3_off.gif";
	nav3_on = new Image();
	nav3_on.src = countryPath + "images/nav/nav3_on.gif";	

	nav4_off = new Image();
	nav4_off.src = countryPath + "images/nav/nav4_off.gif";
	nav4_on = new Image();
	nav4_on.src = countryPath + "images/nav/nav4_on.gif";	
}

var strHTML;
strHTML = '<div id="div_navMember">';
strHTML += '<img src="'+countryPath+'images/vspace.gif" width="1" height="3" border="0"><br>';
strHTML += '<a href="'+countryPath+'membership/onlinevideo/" onMouseOver=ChangeImageOver("nav1") onMouseOut=ChangeImageOut("nav1")><img name="nav1" src="'+countryPath+'images/nav/nav1_off.gif" border=0></a><br>';
strHTML += '<a href="'+countryPath+'membership/q_and_a/" onMouseOver=ChangeImageOver("nav2") onMouseOut=ChangeImageOut("nav2")><img name="nav2" src="'+countryPath+'images/nav/nav2_off.gif" border=0></a><br>';
strHTML += '<a href="'+countryPath+'membership/news/" onMouseOver=ChangeImageOver("nav3") onMouseOut=ChangeImageOut("nav3")><img name="nav3" src="'+countryPath+'images/nav/nav3_off.gif" border=0></a><br>';
strHTML += '<a href="'+countryPath+'membership/private_blending/" onMouseOver=ChangeImageOver("nav4") onMouseOut=ChangeImageOut("nav4")><img name="nav4" src="'+countryPath+'images/nav/nav4_off.gif" border=0></a><br>';
strHTML += '<img src="'+countryPath+'images/nav/end.gif" border="0"><br>';
strHTML += '<a href="#" onMouseOver=hidemenu();><img src="/global/images/vspace.gif" width="82" height="100" border="0"></a>';
strHTML += '</div>';


function showmenu() {
	if ( (ua.indexOf("opera")==-1)&&((ua.indexOf("msie")!=-1)&&(ua.indexOf("windows")!=-1))||((ua.indexOf("msie 5")!=-1)&&(ua.indexOf("mac")!=-1)) ) {
		if (coordinate2.innerHTML == "") coordinate2.innerHTML = strHTML;
	}	
}

function hidemenu() {
	if ( (ua.indexOf("opera")==-1)&&((ua.indexOf("msie")!=-1)&&(ua.indexOf("windows")!=-1))||((ua.indexOf("msie 5")!=-1)&&(ua.indexOf("mac")!=-1)) ) {
		coordinate2.innerHTML=""
	}	
}

function drawNav() {
var strHTML;

	strHTML = '';
	strHTML += '<table cellpadding="0" cellspacing="0" border="0" width="734"><form name="formNavCountry">';
	strHTML += '<tr><td>'
	strHTML += '	<table cellpadding="0" cellspacing="0" border="0"><tr>';
	strHTML += '	<td class="menu"><a href="'+countryPath+'index.asp" class="menu" onMouseOver=hidemenu();>主頁</a></td>'
	strHTML += '	<td class="menu">&nbsp;|&nbsp;</td>'
	strHTML += '	<td class="menu"><a href="'+countryPath+'courses/index.asp" class="menu" onMouseOver=hidemenu();>芬芳課程</a></td>'
	strHTML += '	<td class="menu">&nbsp;|&nbsp;</td>'
	strHTML += '	<td class="menu"><a href="'+countryPath+'preorder/index.asp" class="menu" onMouseOver=hidemenu();>網上 Shopping</a></td>'
	strHTML += '	<td class="menu">&nbsp;|&nbsp;</td>'
	strHTML += '	<td class="menu"><a href="'+countryPath+'tutors/index.asp" class="menu" onMouseOver=hidemenu();>芬芳導師</a></td>'
	strHTML += '	<td class="menu">&nbsp;|&nbsp;</td>'
	strHTML += '	<td class="menu"><a href="'+countryPath+'registration/index.asp" class="menu" onMouseOver=hidemenu();>加入芬芳學堂</a></td>'
	strHTML += '	<td class="menu">&nbsp;|&nbsp;<div id="coordinate1" style="z-index:200;"><div id="coordinate2" style="position:absolute;"></div></div></td>'
	strHTML += '	<td class="menu"><a href="'+countryPath+'membership/index.asp" class="menu" onMouseOver="javascript:showmenu();">會員天地</a></td>'
	strHTML += '	<td class="menu">&nbsp;|&nbsp;</td>'
	strHTML += '	<td class="menu"><a href="'+countryPath+'about/index.asp" class="menu" onMouseOver=hidemenu();>關於我們</a></td>'
	strHTML += '	<td class="menu">&nbsp;|&nbsp;</td>'
	strHTML += '	<td class="menu"><a href="'+countryPath+'contact/index.asp" class="menu" onMouseOver=hidemenu();>聯絡我們</a></td>';
	strHTML += '	<td class="menu"><img src="/global/images/vspace.gif" width="1" height="18" border="0"></td>';
	strHTML += '	</tr></table>';
	strHTML += '</td>';
	strHTML += '<td class="menu" align="right">';
	strHTML += '		<select name="country" onChange="javascript:jump2();" class="pulldown">';
	strHTML += '		<option value="hk">Hong Kong 香港</option>';
	strHTML += '		<option value="tw">Taipei 台北</option>';
	strHTML += '		<option value="sz">Shenzhen 深圳</option>';
	strHTML += '		<option value="my" selected>Malaysia 馬來西亞</option>';
	strHTML += '		</select>';
	strHTML += '</td>';
	strHTML += '</tr></form>';
	strHTML += '</table>';
	
	document.write(strHTML);
}

// function to change images when mouse over
function ChangeImageOver(img) {
	if (document.images)
		document.images[img].src = eval(img + "_on.src")
}

// function to change images when mouse out
function ChangeImageOut(img) {
	if (document.images)
		document.images[img].src = eval(img + "_off.src")
}

