
//============    language switch    ============
function switchLang(from,to) {
	var currentStr = window.location.href;
	currentStr = currentStr.replace("/" + from + "/", "/" + to + "/");
	currentStr = currentStr.replace("lang=" + from, "lang=" + to);
	window.location.href = currentStr;
	if (to == "en") {
		parent.document.title = "PolyVision Eyecare Centres";
	} else {
		parent.document.title = "理大護眼中心";	
	}
}


// ============    page top scroll    ============

function pageTopScroll(){
	var x1 = x2 = x3 = 0; 
	var y1 = y2 = y3 = 0; 
	if(document.documentElement){
		x1 = document.documentElement.scrollLeft || 0;
		y1 = document.documentElement.scrollTop || 0;
	}
	if(document.body){
		x2 = document.body.scrollLeft || 0;
		y2 = document.body.scrollTop || 0;
	}
	x3 = window.scrollX || 0;
	y3 = window.scrollY || 0;
	var x = Math.max(x1, Math.max(x2, x3));
	var y = Math.max(y1, Math.max(y2, y3)); 
	window.scrollTo(Math.floor(x / 1.3), Math.floor(y / 1.3));
	if(x > 0 || y > 0){
		window.setTimeout("pageTopScroll()", 30);
	}
}

// ============ show/hide, swap image ============

function unhide(divID) {
	var item = document.getElementById(divID);
	if (item) {
	  item.className=(item.className=='hideanswerpanel')?'showanswerpanel':'hideanswerpanel';
	}
}

var q1 = q2 = q3 = q4 = 0; 
var root='../images/';

var icoHide = "../images/ico_hide.gif";
var icoShow = "../images/ico_show.gif"
function swapImg(ima){
	var el = document.getElementById(ima);
	var vSrc = el.getAttribute("src");
	//alert(vSrc);
	if(vSrc.indexOf("ico_show.gif") != -1)
	{
		el.src = icoHide;
		/*
		if(navigator.appName.indexOf("Explorer") != -1)//for IE
		{
			el.src = icoHide;
		}
		else	
		{
			el.setAttribute("src", icoHide);
		}
		*/
	}
	else if(vSrc.indexOf("ico_hide.gif") != -1)
	{
		el.src = icoShow;
		/*
		if(navigator.appName.indexOf("Explorer") != -1)//for IE
		{
			el.src = icoShow;
		}
		else
		{
			el.setAttribute("src", icoShow);
		}
		*/
	}
	
}
 
function swapImg1(ima){ 
	if(q1==0){
		ima.setAttribute('src',root+'ico_hide.gif');
		q1++;
	} 
	else{
		ima.setAttribute('src',root+'ico_show.gif');
		q1--;
	} 
} 
function swapImg2(ima){ 
	if(q2==0){
		ima.setAttribute('src',root+'ico_hide.gif');
		q2++;
	} 
	else{
		ima.setAttribute('src',root+'ico_show.gif');
		q2--;
	} 
} 
function swapImg3(ima){ 
	if(q3==0){
		ima.setAttribute('src',root+'ico_hide.gif');
		q3++;
	} 
	else{
		ima.setAttribute('src',root+'ico_show.gif');
		q3--;
	} 
} 
function swapImg4(ima){ 
	if(q4==0){
		ima.setAttribute('src',root+'ico_hide.gif');
		q4++;
	} 
	else{
		ima.setAttribute('src',root+'ico_show.gif');
		q4--;
	} 
} 
