﻿// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function popWin(theUrl, width, height)
{
	window.open(theUrl,'popWin','width='+width+',height='+height+',toolbar=no,menubar=no,scrollbars=yes,resizable=yes')
	return false;
}

function changeDoctor(doctor, weekday, time1, time2)
{
	this.opener.document.getElementById("doctor").innerHTML = doctor;
	this.opener.document.getElementById("doctor_hidden").value = doctor;
//	changeTime(weekday, time1, time2);
	this.window.close();
}

/*function changeTime(weekday, time1, time2)
{
	this.opener.document.getElementById("time").remove(1);
	this.opener.document.getElementById("time").remove(2);
	var opt1 = this.opener.document.createElement('option');
	opt1.text= weekday + time1;
	this.opener.document.getElementById("time").add(opt1);
	var opt2 = this.opener.document.createElement('option');
	opt2.text= weekday + time2;
	this.opener.document.getElementById("time").add(opt2);
}*/

/*function addColor(tr)
{
	tr.style.backgroundColor="#CCCCCC";
}

function removeColor(tr)
{
	tr.style.backgroundColor="#FFFFFF";
}*/

/* Survey */
function checkSurvey(objname, cqnum, qnum)
{
	flag = false;
	obj = document.getElementsByName(objname);
	
	if (obj.length > 1)
	{
		for (i=0; i<obj.length; i++)
			if (obj[i].checked)
				flag = true;
	}
	else
	{
		if (obj.checked)
			flag = true;
	}		
	
	if (!flag)
	{
		document.getElementById("vm" + cqnum).innerHTML = "請回答以上問題";
	}
	else
	{
		document.getElementById("vm" + cqnum).innerHTML = "";
		showSurvey(qnum);
	}
}

function showSurvey(qnum)
{
	for (i=1; i<=6; i++)
	{
		document.getElementById("q" + i).style.visibility = "hidden";
	}
	document.getElementById(qnum).style.visibility = "visible";
}

/* Appointment Form */
function showTab(tab)
{
	document.getElementById("pi").style.visibility = "hidden";
	document.getElementById("bi").style.visibility = "hidden";
	document.getElementById(tab).style.visibility = "visible";
}

function combineBookingTime()
{
	document.getElementById("bookingTime").value = document.getElementById("weekday").value + " " + document.getElementById("time").value;
	//alert(document.getElementById("bookingTime").value);
}

function combineOthers(fieldA, fieldB, combineOthers)
{
	if (document.getElementById(fieldA).value == "其他")
	{
		document.getElementById(fieldB).disabled = false;
		document.getElementById(combineOthers).value = document.getElementById(fieldA).value + " " + document.getElementById(fieldB).value;
	}
	else
	{
		document.getElementById(fieldB).disabled = true;
		document.getElementById(fieldB).value = "";
		document.getElementById(combineOthers).value = document.getElementById(fieldA).value + " " + document.getElementById(fieldB).value;
	}
	//alert(document.getElementById(combineOthers).value);
}

/* FAQ Show Answer */
function clearAns()
{
	for (i=1; i<=7; i++)
	{
		document.getElementById("faqa" + i).innerHTML = "";
		document.getElementById("afaqa" + i).style.cursor = "pointer";
	}
}

function showAns(ans, anstxt, ansdiv)
{
	clearAns();
	document.getElementById(ans).innerHTML = anstxt + "<br /><br />";
	document.getElementById(ansdiv).style.height = "100%";
	document.getElementById("a" + ans).style.cursor = "default";
}

function changeAnsColor(id)
{
	document.getElementById("afaqa" + id).style.color = "#0271be";
}

function changeAnsOffColor(id,tid)
{
	document.getElementById("afaqa" + id).style.color = "#444444";
}

/* About */
function clearAboutInfo()
{
	for (i=1; i<=3; i++)
	{
		document.getElementById("aboutArrow" + i).src = "images/arrow_off.gif";
		document.getElementById("aboutInfoText" + i).style.color = "#000000";
		document.getElementById("aboutInfoText" + i).style.fontWeight = "normal";
	}
}

function showAboutInfo(id)
{
	clearAboutInfo();
	document.getElementById("aboutPhoto").src = "images/about_photo"+ id + ".gif";
	document.getElementById("aboutArrow" + id).src = "images/arrow_on.gif";
	document.getElementById("aboutInfoText" + id).style.color = "#0271be";
	document.getElementById("aboutInfoText" + id).style.fontWeight = "bold";
}

/* Testimonial */
function clearAbout()
{
	for (i=1; i<=5; i++)
	{
		document.getElementById("about" + i).style.visibility = "hidden";
	}
}

function showAbout(id)
{
	clearAbout();
	document.getElementById("about" + id).style.height = "100%";
	document.getElementById("about" + id).style.visibility = "visible";
}

/* Benefit (Gift)*/
function clearGiftTab()
{
	for (i=1; i<=3; i++)
	{
		document.getElementById("giftTab" + i).style.visibility = "hidden";
	}
}

function showGiftTab(tid)
{
	clearGift();
	clearGiftTab();
	document.getElementById("giftTab" + tid).style.visibility = "visible";
}

function clearGift()
{
	for (i=1; i<=2; i++)
	{
		document.getElementById("gift1" + i).style.visibility = "hidden";
	}
	for (i=1; i<=8; i++)
	{
		document.getElementById("gift2" + i).style.visibility = "hidden";
	}
	for (i=1; i<=2; i++)
	{
		document.getElementById("gift3" + i).style.visibility = "hidden";
	}
}

function showGift(id,tid)
{
	clearGift();
	clearGiftTab();
	showGiftTab(tid)
	//document.getElementById("gift" + id).style.height = "100%";
	document.getElementById("gift" + tid + id).style.visibility = "visible";
}

function changeGiftColor(id,tid)
{
	document.getElementById("gift_" + tid + id).style.color = "#0271be";
}

function changeGiftOffColor(id,tid)
{
	document.getElementById("gift_" + tid + id).style.color = "#000000";
}