﻿var page=0;
var xmlhttp;
function change_text(tb_id, a_class, show_div) {
	a_id = "a" + tb_id;
	if (a_class=="over_login") {
		$("#sub_login").css("display", "block");
		$("#sub_login_e").css("display", "block");
		return;
	}
	else if (a_class=="normal_login") {
		$("#sub_login").css("display", "none");
		$("#sub_login_e").css("display", "none");
		return;
	}
	if (show_div=="enquiry_show") {
		$("#div_sub_eservice").css("display", "block");
		$("#eq_enquiry").css("display","block");
		return;
	}
	else if (show_div=="enquiry_hide") {
		$("#div_sub_eservice").css("display", "none");
		$("#eq_enquiry").css("display","none");
		return;
	}
	if (show_div=="eservice_show") {
		$("#div_sub_eservice").css("display","block");
		return;
	}
	else if (show_div=="eservice_hide") {
		$("#div_sub_eservice").css("display","none");
		return;
	}
	if (show_div=="profile_show") {
		$("#div_sub_profile").css("display","block");
		return;
	}
	else if (show_div=="profile_hide") {
		$("#div_sub_profile").css("display","none");
		return;
	}
	if (page != tb_id) {
		document.getElementById(a_id).className = a_class;
	}
}

function logout(type, lang) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="script/logout_function.php";
	if (type == 0) url = url + "?type=0";
	else if (type == 1) url = url + "?type=1";
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			if (lang == "chi") {
				load_banner(lang);
				//change_content("home.php");
				change_content("Profile/profile.php");
			}
			else {
				load_banner(lang);
				//change_content("home.php");
				change_content("Profile/profile_e.php");
			}
			set_css();
		}
	};
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function home_logout(lang) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="script/logout_function.php?type=0";
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			load_banner(lang);
			change_content("home.php");
			set_css();
		}
	};
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function reset() {
	document.getElementById("user").value="";
	document.getElementById("pass").value="";
	document.getElementById("captcha").value="";
	document.getElementById("alert_valid").innerHTML = "";
	document.getElementById("img_captcha").src = "captcha/securimage/securimage_show.php?" + Math.random();
}

function change_onReload() {
	var path = document.URL;
	if (path.match("profile")) {
		change_text("1", "over_a");
		page=1;
	}
	if (path.match("schedule")) {
		change_text("2", "over_a");
		page=2;
	}
	if (path.match("download")) {
		change_text("3", "over_a");
		page=3;
	}
	if (path.match("network") || path.match("Network")) {
		change_text("4", "over_a");
		page=4;
	}
	if (path.match("promote")) {
		change_text("5", "over_a");
		page=5;
	}
	if (path.match("information") || path.match("Information")) {
		change_text("6", "over_a");
		page=6;
	}
	if (path.match("enquiry")) {
		change_text("7", "over_a");
		page=7;
	}
	if (path.match("contact")) {
		change_text("8", "over_a");
		page=8;
	}
	if (path.match("recruit")) {
		change_text("9", "over_a");
		page=9;
	}
	if (path.match("login")) {
		change_text("11", "over_login");
		page=11;
	}
}
