function mouseOver(str1){
	eval("document.images['" + str1 + "'].src='image/but_" + str1 + "_on.gif'");
	return true;
}

function mouseOut(str1){
	eval("document.images['" + str1 + "'].src='image/but_" + str1 + ".jpg'");
	return true;
}

function mouseClick(str1){
	eval("document.images['" + str1 + "'].src='image/but_" + str1 + "_on.gif'");
	return true;
}

function openWin(a,w,h){
	// 1 for download acrobat reader instruction.
	var text;
	if(a == 1){
		URL = "instruction.php";
	}
	text = "toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,hotkeys=no,location=no,";
	text += "width=";
	text += w;
	text += ",height=";
	text += h;
	//alert(text);
	newWin = window.open(URL,"",text);
	//newWin.resizeTo(w,h);
	newWin.moveTo(0,0);
	newWin.document.close();
}

function openWin1(a,p,w,h){
	var text;
	URL = "teacher_data.php?name=" + a;
	URL += "&photo=";
	URL += p;
	text = "toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,hotkeys=no,location=no,";
	text += "width=";
	text += w;
	text += ",height=";
	text += h;
	newWindow = window.open(URL,'teacherWin',text);
	newWindow.moveTo(0,0);
	newWindow.focus();
	newWindow.document.close();
}

function openWinAdv(a,w,h,scroll){
	var text;
	URL = a;
	text = "toolbar=no,directories=no,status=no,resize=no,menubar=no,hotkeys=no,location=no,";
	text += "width=";
	text += w;
	text += ",height=";
	text += h;
	text += ",scrollbars=";
	text += scroll;
	newWindow = window.open(URL,'advWin',text);
	newWindow.moveTo(0,0);
	newWindow.focus();
	newWindow.document.close();
}

function openWinPro(a,w,h,scroll){
	var text;
	URL = a;
	text = "toolbar=no,directories=no,status=no,resize=no,menubar=no,hotkeys=no,location=no,";
	text += "width=";
	text += w;
	text += ",height=";
	text += h;
	text += ",scrollbars=";
	text += scroll;
	newWindow = window.open(URL,'proWin',text);
	newWindow.moveTo(0,0);
	newWindow.focus();
	newWindow.document.close();
}

function trim(str){
    var strlen = str.length;
    for (var i=strlen-1; i>=0; i--){
         if ((str.substring(i,i+1) <= " ")){ 
             str = str.substring(0,i); 
         }
         else{
             break;
         }
    }
    return str;
}

function isBlank(objname, obj){
    if (trim(obj.value) == ""){
        return "- " + objname + "\n";        
    }
    else{
        return "";
    }
}

function submitGB(theForm){
	valid_form = true;
	theForm.ready.value = 0;
	str_errmsg = "";
	str_errmsg = str_errmsg + isBlank("姓名", theForm.name);
	str_errmsg = str_errmsg + isBlank("我的意見", theForm.message);
	if (str_errmsg != ""){ 
		alert("請填上以下資料：\n\n" + str_errmsg + "\n");
		valid_form = false;
	}
	else{
		theForm.ready.value = 2;
	}
	return valid_form;
}

function viewGB(theForm){
	theForm.ready.value = 1;
}

//added by Albert
function openWin2(a,p,w,h,s){
	//Open a window for displaying extra-curricular activities
	
	var text;
	URL = "excurr_photo.php?fname=" + a;
	URL += "&photo=";
	URL += p;
	URL += "&slideshow=" + s;
	text = "toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,hotkeys=no,location=no,";
	text += "width=";
	text += w;
	text += ",height=";
	text += h;
	newWindow = window.open(URL,'teacherWin',text);
	newWindow.moveTo(0,0);
	newWindow.focus();
	newWindow.document.close();
}

function openWin2(a,cn,p,i,w,h,s){
	
	//Open a window for displaying extra-curricular activities
	
	var text;
	URL = "excurr_photo.php?fname=" + a;
	URL += "&cname=" + cn;
	URL += "&pid=" + i
	URL += "&photo=";
	URL += p;
	URL += "&slideshow=" + s;
	text = "toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,hotkeys=no,location=no,";
	text += "width=";
	text += w;
	text += ",height=";
	text += h;
	newWindow = window.open(URL,'teacherWin',text);
	newWindow.moveTo(0,0);
	newWindow.focus();
	newWindow.document.close();
}

function openWindow2(url,name,w,h){
	var text;
	
	text = "toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,hotkeys=no,location=no,";
	text += "width=";
	text += w;
	text += ",height=";
	text += h;
	newWindow = window.open(url,name,text);
	newWindow.moveTo(0,0);
	newWindow.focus();
	newWindow.document.close();
}

function openWin4(w,h){
	var text;
	URL = "/promotion_activity/library/question/2/main.htm";
	text = "toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,hotkeys=no,location=no,";
	text += "width=";
	text += w;
	text += ",height=";
	text += h;
	newWindow = window.open(URL,'LQ2',text);
	newWindow.moveTo(0,0);
	newWindow.focus();
	newWindow.document.close();
}

function openWin5(w,h){
	var text;
	URL = "promotion_activity/maths/iq/main.htm";
	text = "toolbar=no,directories=no,status=no,scrollbars=no,resize=no,menubar=no,hotkeys=no,location=no,";
	text += "width=";
	text += w;
	text += ",height=";
	text += h;
	newWindow = window.open(URL,'IQ1',text);
	newWindow.moveTo(0,0);
	newWindow.focus();
	newWindow.document.close();
}

	