﻿function submitEnquiryFormBak(){
	var fullname  = document.forms[0].fullname.value;
	var enquiry_str  = document.forms[0].enquiry.value;
	if(fullname.length==0){
		alert("Please enter your name!");
		return;
	}
	if(enquiry_str.length==0){
		alert("Please enter enquiry!");
		return;
	}
	document.forms[0].submit();
}

function submitLogout(){
	var answer = confirm("Do you confirm to logout?");
	if (answer){
		document.forms[0].action = "api_login.php";
		document.forms[0].submit();
	}
}

function showEnquiryType(obj){
	if(obj.value<0){
		return false;
	}
	document.forms[0].page_no.value = 1;
	document.forms[0].submit();
}

function showEnquiryTypeOnMain(enquirytype_val){
	document.forms[0].enquirytype.value = enquirytype_val;
	document.forms[0].page_no.value = 1;
	document.forms[0].submit();
}

function showEnquiryDetail(id){
	document.forms[0].action = "enquiry_detail.php";
	document.forms[0].enquiry_id.value = id;
	document.forms[0].submit();
}

function showEnquiryDetailBack(){
	//document.forms[0].action = "enquiry_main.php";
	//document.forms[0].submit();
	location.href = "enquiry_main.php";
}

function showEnquiryLeaveMessageBack(){
	document.forms[0].action = "enquiry_detail.php";
	document.forms[0].submit();
}

function showEnquiryLeaveMessage(){
	document.forms[0].action = "enquiry_message.php";
	document.forms[0].enquiryaction.value = document.forms[0].enquiryaction_message.value;
	document.forms[0].submit();
}

function showEnquiryRepliedByPhone(){
	document.forms[0].action = "enquiry_message.php";
	document.forms[0].enquiryaction.value = document.forms[0].enquiryaction_phone.value;
	document.forms[0].submit();
}

function showEnquiryRepliedByEmail(){
	document.forms[0].action = "enquiry_message.php";
	document.forms[0].enquiryaction.value = document.forms[0].enquiryaction_email.value;
	document.forms[0].submit();
}

function showNewProductByType(obj){
	if(obj.value<0){
		return false;
	}
	document.forms[0].page_no.value = 1;
	document.forms[0].submit();
}

function showNewProductByStatus(obj){
	document.forms[0].page_no.value = 1;
	document.forms[0].submit();
}

function showNewProductByPageNo(obj){
	document.forms[0].submit();
}

function showEnquiryByPageNo(obj){
	document.forms[0].submit();
}

function showNewProductNew(){
	document.forms[0].action = "new_product_detail.php";
	document.forms[0].submit();
}

function showBackNewProductList(){
	document.forms[0].action = "new_product_list.php";
	document.forms[0].product_type.value = -1;
	document.forms[0].submit();
}

function submitNewProductHTML(){
	var answer = confirm("Are you sure to generate HTML?");
	if (answer){
		document.forms[0].action = "api_control.php";
		document.forms[0].form_action.value = document.forms[0].action_pro_product_html.value;
		document.forms[0].submit();
	}
}

function submitNewProductHTMLUpload(){
	var answer = confirm("Are you sure to upload HTML?");
	if (answer){
		document.forms[0].action = "api_control.php";
		document.forms[0].form_action.value = document.forms[0].action_pro_product_upload.value;
		document.forms[0].submit();
	}
}

function showNewProductEdit(id){
	document.forms[0].action = "new_product_detail.php";
	document.forms[0].new_product_id.value = id;
	document.forms[0].submit();
}

function submitNewProductDetail(){
	var title  = document.forms[0].title.value;
	var url  = document.forms[0].url.value;
	var product_type  = document.forms[0].product_type.value;
	
	if(title.length==0){
		alert("Please enter the title!");
		return;
	}
	if(product_type==-1){
		alert("Please select the type!");
		return;
	}
	document.forms[0].submit();
}

function submitProProductStatus(id, actionID){
	document.forms[0].new_product_id.value = id;
	document.forms[0].form_action.value = actionID;
	document.forms[0].action = "api_control.php";
	document.forms[0].submit();
}

function showNewProductByOrder(sort_id){
	ori_sort_id = document.forms[0].page_sort_proproduct.value;
	order_id = document.forms[0].page_order_proproduct.value;
	order_asc = document.forms[0].page_order_proproduct_asc.value;
	order_desc = document.forms[0].page_order_proproduct_desc.value;
	if(sort_id==ori_sort_id){
		if(order_id==order_asc){
			document.forms[0].page_order_proproduct.value = order_desc;
		}else{
			document.forms[0].page_order_proproduct.value = order_asc;
		}
	}else{
		document.forms[0].page_sort_proproduct.value = sort_id;
		document.forms[0].page_order_proproduct.value = order_asc;
	}
	document.forms[0].submit();
}

function showEnquiryByOrder(sort_id){
	ori_sort_id = document.forms[0].page_sort_enquiry.value;
	order_id = document.forms[0].page_order_enquiry.value;
	order_asc = document.forms[0].page_order_enquiry_asc.value;
	order_desc = document.forms[0].page_order_enquiry_desc.value;
	if(sort_id==ori_sort_id){
		if(order_id==order_asc){
			document.forms[0].page_order_enquiry.value = order_desc;
		}else{
			document.forms[0].page_order_enquiry.value = order_asc;
		}
	}else{
		document.forms[0].page_sort_enquiry.value = sort_id;
		document.forms[0].page_order_enquiry.value = order_asc;
	}
	document.forms[0].submit();
}

function sumitRemoveNewProduct(objid,objname){
	var answer = confirm("Do you confirm to remove \"" + objname + "\"?");
	if (answer){
		document.forms[0].form_action.value = document.forms[0].action_pro_product_remove.value;
		document.forms[0].new_product_id.value = objid;
		document.forms[0].action = "api_control.php";
		document.forms[0].submit();
	}	
}

function showGihorseNameByStatus(obj){
	document.forms[0].page_no.value = 1;
	document.forms[0].submit();
}

function showGihorseNameByPageNo(obj){
	document.forms[0].submit();
}

function showGihorseNameByOrder(sort_id){
	ori_sort_id = document.forms[0].page_sort_gihorse_name.value;
	order_id = document.forms[0].page_order_gihorse_name.value;
	order_asc = document.forms[0].page_order_gihorse_name_asc.value;
	order_desc = document.forms[0].page_order_gihorse_name_desc.value;

	if(sort_id==ori_sort_id){
		if(order_id==order_asc){
			document.forms[0].page_order_gihorse_name.value = order_desc;
		}else{
			document.forms[0].page_order_gihorse_name.value = order_asc;
		}
	}else{
		document.forms[0].page_sort_gihorse_name.value = sort_id;
		document.forms[0].page_order_gihorse_name.value = order_asc;
	}
	document.forms[0].submit();
}

function showGihorseNameDetail(id){
	document.forms[0].action = "gihorse_name_detail.php";
	document.forms[0].gihorse_name_id.value = id;
	document.forms[0].submit();
}

function showGihorseNameDetailBack(){
	document.forms[0].action = "gi_horsepark_english_name_list.php";
	document.forms[0].submit();
}

function submitGihorseName(){
	var japname  = document.forms[0].japname.value;
	if(japname.length==0){
		alert("Please enter the Japanese name!");
		return;
	}
	document.forms[0].submit();	
}

/* List of Products - What's New - Start*/
function showWhatsNewProductNew(){
	document.forms[0].action = "product_whatsnews_detail.php";
	document.forms[0].submit();
}

function submitAddProductWhatsnews(){
	var content1  = document.forms[0].content1.value;
	var url1  = document.forms[0].url1.value;
	var content2  = document.forms[0].content2.value;
	var url2  = document.forms[0].url2.value;
	var content3  = document.forms[0].content3.value;
	var url3  = document.forms[0].url3.value;

	var product_type  = document.forms[0].product_type.value;
	
	if(content1.length==0){
		alert("Please enter the content for at least the traditional chinese version!");
		return;
	}
	if(product_type==-1){
		alert("Please select the type!");
		return;
	}
	document.forms[0].submit();
}

function showProductWhatsnewsByPageNo(obj){
	document.forms[0].submit();
}

function showProductWhatsnewsByStatus(obj){
	document.forms[0].page_no.value = 1;
	document.forms[0].submit();
}

function showProductWhatsnewsByType(obj){
	if(obj.value<0){
		return false;
	}
	document.forms[0].page_no.value = 1;
	document.forms[0].submit();
}

function showProductWhatsnewsByCountry(obj){
	if(obj.value<0){
		return false;
	}
	document.forms[0].page_no.value = 1;
	document.forms[0].submit();
}

function showProductWhatsnewsByOrder(sort_id){
	ori_sort_id = document.forms[0].page_sort_product.value;
	order_id = document.forms[0].page_order_product.value;
	order_asc = document.forms[0].page_order_product_asc.value;
	order_desc = document.forms[0].page_order_product_desc.value;
	if(sort_id==ori_sort_id){
		if(order_id==order_asc){
			document.forms[0].page_order_product.value = order_desc;
		}else{
			document.forms[0].page_order_product.value = order_asc;
		}
	}else{
		document.forms[0].page_sort_product.value = sort_id;
		document.forms[0].page_order_product.value = order_asc;
	}
	document.forms[0].submit();
}

function showProductWhatsnewsEdit(id){
	document.forms[0].action = "product_whatsnews_detail.php";
	document.forms[0].product_id.value = id;
	document.forms[0].submit();
}

function sumitRemoveProductWhatsnews(objid,objname){
	var answer = confirm("Do you confirm to remove \"" + objname + "\"?");
	if (answer){
		document.forms[0].form_action.value = document.forms[0].action_product_whatsnews_remove.value;
		document.forms[0].product_id.value = objid;
		document.forms[0].action = "api_control.php";
		document.forms[0].submit();
	}	
}

function submitProductWhatsnewsStatus(id, actionID){
	document.forms[0].product_id.value = id;
	document.forms[0].form_action.value = actionID;
	document.forms[0].action = "api_control.php";
	document.forms[0].submit();
}

function showProductWhatsnewsAdd(){
	document.forms[0].action = "product_whatsnews_detail.php";
	document.forms[0].submit();
}

function submitProductWhatsnewsHTML(){
	var answer = confirm("Are you sure to generate HTML?");
	if (answer){
		document.forms[0].action = "api_control.php";
		document.forms[0].form_action.value = document.forms[0].action_product_whatsnews_html.value;
		document.forms[0].submit();
	}
}

function submitProductWhatsnewsHTMLUpload(){
	var answer = confirm("Are you sure to upload HTML?");
	if (answer){
		document.forms[0].action = "api_control.php";
		document.forms[0].form_action.value = document.forms[0].action_product_whatsnews_upload.value;
		document.forms[0].submit();
	}
}

function submitProductWhatsnewsGenHTMLUpload(){
	var answer = confirm("Are you sure to upload HTML?");
	if (answer){
		document.forms[0].action = "api_control.php";
		document.forms[0].form_action.value = document.forms[0].action_product_whatsnews_html_upload.value;
		document.forms[0].submit();
	}
}

function submitAddProductWhatsnews(){
	var title_var  = document.forms[0].product_title.value;
	var content1  = document.forms[0].content1.value;
	var content2  = document.forms[0].content2.value;
	var content3  = document.forms[0].content3.value;
	var enable1  = document.forms[0].enable1[0].checked;
	var enable2  = document.forms[0].enable2[0].checked;
	var enable3  = document.forms[0].enable3[0].checked;
	
	if(title_var.length==0){
		alert("Please enter the title!");
		document.forms[0].product_title.focus();
		return;
	}
	if(enable1&&content1.length==0){
		alert("Please enter the content (Tra.Chi)!");
		document.forms[0].content1.focus();
		return;
	}
	if(enable2&&content2.length==0){
		alert("Please enter the content (Sim.Chi)!");
		document.forms[0].content2.focus();
		return;
	}
	if(enable3&&content3.length==0){
		alert("Please enter the content (Eng)!");
		document.forms[0].content3.focus();
		return;
	}
	document.forms[0].submit();
}

function showProductWhatsnewsEdit(id){
	document.forms[0].action = "product_whatsnews_detail.php";
	document.forms[0].product_id.value = id;
	document.forms[0].submit();
}

/* List of Products - What's New - End*/

function openwin_sb(in_link,in_h)
{
	window.open(in_link,'','top=0,left=0,width=800,height=' + in_h +',scrollbars=yes,resizable=yes');
}

function showProductGSByOrder(sort_id){
	ori_sort_id = document.forms[0].page_sort_product_gs.value;
	order_id = document.forms[0].page_order_product_gs.value;
	order_asc = document.forms[0].page_order_product_gs_asc.value;
	order_desc = document.forms[0].page_order_product_gs_desc.value;
	if(sort_id==ori_sort_id){
		if(order_id==order_asc){
			document.forms[0].page_order_product_gs.value = order_desc;
		}else{
			document.forms[0].page_order_product_gs.value = order_asc;
		}
	}else{
		document.forms[0].page_sort_product_gs.value = sort_id;
		document.forms[0].page_order_product_gs.value = order_asc;
	}
	document.forms[0].submit();
}

function showProductGSAdd(){
	document.forms[0].action = "product_gs_detail.php";
	document.forms[0].submit();
}

function submitProductGSHTML(){
	var answer = confirm("Are you sure to generate HTML?");
	if (answer){
		document.forms[0].action = "api_control.php";
		document.forms[0].form_action.value = document.forms[0].action_product_gs_html.value;
		document.forms[0].submit();
	}
}

function showKodienPageAdd(){
	document.forms[0].action = "kodien_page_detail.php";
	document.forms[0].submit();
}

function submitKodienPageHTML(){
	var answer = confirm("Are you sure to generate HTML?");
	if (answer){
		document.forms[0].action = "api_control.php";
		document.forms[0].form_action.value = document.forms[0].action_kodien_page_html.value;
		document.forms[0].submit();
	}
}

function showKodienPageByPageNo(obj){
	document.forms[0].submit();
}

function showKodienPageByStatus(obj){
	document.forms[0].page_no.value = 1;
	document.forms[0].submit();
}

function showKodienPageByOrder(sort_id){
	ori_sort_id = document.forms[0].page_sort_kodien_page.value;
	order_id = document.forms[0].page_order_kodien_page.value;
	order_asc = document.forms[0].page_order_kodien_page_asc.value;
	order_desc = document.forms[0].page_order_kodien_page_desc.value;
	if(sort_id==ori_sort_id){
		if(order_id==order_asc){
			document.forms[0].page_order_kodien_page.value = order_desc;
		}else{
			document.forms[0].page_order_kodien_page.value = order_asc;
		}
	}else{
		document.forms[0].page_sort_kodien_page.value = sort_id;
		document.forms[0].page_order_kodien_page.value = order_asc;
	}
	document.forms[0].submit();
}

function showKodienPageEdit(id){
	document.forms[0].action = "kodien_page_detail.php";
	document.forms[0].kodien_page_id.value = id;
	document.forms[0].submit();
}

function submitRemoveKodienPage(objid,objtitle){
	var answer = confirm("Do you confirm to remove No." + objid + "?\n\n" + objtitle);
	if (answer){
		document.forms[0].form_action.value = document.forms[0].action_kodien_page_remove.value;
		document.forms[0].kodien_page_id.value = objid;
		document.forms[0].action = "api_control.php";
		document.forms[0].submit();
	}	
}

function submitKodienPageStatus(id, actionID){
	document.forms[0].kodien_page_id.value = id;
	document.forms[0].form_action.value = actionID;
	document.forms[0].action = "api_control.php";
	document.forms[0].submit();
}

function submitAddKodienPage(){
	var kodien_id  = document.forms[0].kodien_id.value;
	var kodien_title  = document.forms[0].kodien_title.value;
	var kodien_description  = document.forms[0].kodien_description.value;

	if(kodien_id==0){
		alert("Please enter ID!");
		document.forms[0].kodien_id.focus();
		return;
	}else if(kodien_title==0){
		alert("Please enter title!");
		document.forms[0].kodien_title.focus();
		return;
	}else if(kodien_description==0){
		alert("Please enter description!");
		document.forms[0].kodien_description.focus();
		return;
	}

	document.forms[0].submit();
}

function showKodienPageUploadFile(id, fileID){
	document.forms[0].kodien_page_id.value = id;
	document.forms[0].kodien_page_file_id.value = fileID;
	document.forms[0].action = "kodien_page_upload.php";
	document.forms[0].submit();
}

function submitUploadKodienPage(){
	file1 = document.forms[0].file1.value;
	fileext = "";
	var gotoSubmit = false;
	if(file1.length>3){
		fileext = file1.substring(file1.length-3,file1.length);
		fileext = fileext.toLowerCase();
		if(fileext=="jpg"||fileext=="gif"||fileext=="png"){
			gotoSubmit = true;
		}
	}
	if(gotoSubmit){
		document.forms[0].submit();
	}else{
		alert("Please upload only jpg/gif/png file.");
	}
}

function submitRemoveUploadKodienPage(){
	document.forms[0].form_action.value = document.forms[0].form_action_remove.value;
	var answer = confirm("Do you confirm to delete?");
	if (answer){
		document.forms[0].submit();
	}
}

function changeGenre(obj){
	var genrevalue = obj.value;
	obj.value = -1;
	document.forms[0].genre_tc.value = array_genre_tc[genrevalue];
	document.forms[0].genre_sc.value = array_genre_sc[genrevalue];
	document.forms[0].genre_en.value = array_genre_en[genrevalue];
}

function submitAddProductGS(){
	var product_title_tc  = document.forms[0].product_title_tc.value;
	var product_title_sc  = document.forms[0].product_title_sc.value;
	var product_title_en  = document.forms[0].product_title_en.value;
	var enable1  = document.forms[0].enable_tc[0].checked;
	var enable2  = document.forms[0].enable_sc[0].checked;
	var enable3  = document.forms[0].enable_en[0].checked;
	var platform_type  = document.forms[0].platform_type.value;

	if(enable1&&product_title_tc.length==0){
		alert("Please enter the title (tra.chi.)!");
		document.forms[0].product_title_tc.focus();
		return;
	}
	if(enable2&&product_title_sc.length==0){
		alert("Please enter the title (sim.chi.)!");
		document.forms[0].product_title_sc.focus();
		return;
	}
	if(enable3&&product_title_en.length==0){
		alert("Please enter the title (eng.)!");
		document.forms[0].product_title_en.focus();
		return;
	}
	if(platform_type==-1){
		alert("Please select the platform type!");
		document.forms[0].platform_type.focus();
		return;
	}
	document.forms[0].submit();
}

function showProductGSEdit(id){
	document.forms[0].action = "product_gs_detail.php";
	document.forms[0].product_gs_id.value = id;
	document.forms[0].submit();
}

function sumitRemoveProductGS(objid,objname){
	var answer = confirm("Do you confirm to remove \"" + objname + "\"?");
	if (answer){
		document.forms[0].form_action.value = document.forms[0].action_product_gs_remove.value;
		document.forms[0].product_gs_id.value = objid;
		document.forms[0].action = "api_control.php";
		document.forms[0].submit();
	}	
}

function submitProductGSStatus(id, actionID){
	document.forms[0].product_gs_id.value = id;
	document.forms[0].form_action.value = actionID;
	document.forms[0].action = "api_control.php";
	document.forms[0].submit();
}

function showProductGSUploadFile(id, fileID){
	document.forms[0].product_gs_id.value = id;
	document.forms[0].product_gs_file_id.value = fileID;
	document.forms[0].action = "product_gs_upload.php";
	document.forms[0].submit();
}

function submitUploadProductGS(){
	file1 = document.forms[0].file1.value;
	fileext = "";
	var gotoSubmit = false;
	if(file1.length>3){
		fileext = file1.substring(file1.length-3,file1.length);
		fileext = fileext.toLowerCase();
		if(fileext=="jpg"||fileext=="gif"||fileext=="png"){
			gotoSubmit = true;
		}
	}
	if(gotoSubmit){
		document.forms[0].submit();
	}else{
		alert("Please upload only jpg/gif/png file.");
	}
}

function submitRemoveUploadProductGS(){
	document.forms[0].form_action.value = document.forms[0].form_action_remove.value;
	var answer = confirm("Do you confirm to delete?");
	if (answer){
		document.forms[0].submit();
	}
}

function showCompanyTypeOthers(){
	var lang = document.forms[0].lang.value;
	var obj1 = document.getElementById("company_type_other_div");
	if(document.forms[0].company_type.value==6){
		if(lang=="1"){
			alert("請輸入公司性質.");
		}else if(lang=="2"){
			alert("Please fill the type of company.");
		}else if(lang=="3"){
			alert("请输入公司性质.");
		}
		obj1.style.visibility = "visible";
		document.forms[0].company_type_other.focus();
	}else{
		obj1.style.visibility = "hidden";
	}
}

function showCountryCode(){
	var country = document.forms[0].country.value;
	if(country=="1"){
		document.forms[0].phone_country.value = "86";
	}else if(country=="2"){
		document.forms[0].phone_country.value = "886";
	}else if(country=="3"){
		document.forms[0].phone_country.value = "852";
	}else if(country=="4"){
		document.forms[0].phone_country.value = "853";
	}else if(country=="5"){
		document.forms[0].phone_country.value = "82";
	}else if(country=="6"){
		document.forms[0].phone_country.value = "65";
	}else if(country=="7"){
		document.forms[0].phone_country.value = "60";
	}else if(country=="8"){
		document.forms[0].phone_country.value = "66";
	}else if(country=="9"){
		document.forms[0].phone_country.value = "63";
	}else if(country=="10"){
		document.forms[0].phone_country.value = "";
	}
}

function submitEnquiryForm(){
	var lang = document.forms[0].lang.value;
	var type = document.forms[0].type.value;

	var user_name  = document.forms[0].user_name;	
	var country  = document.forms[0].country;
	var phone_country  = document.forms[0].phone_country;
	var phone  = document.forms[0].phone;
	var email  = document.forms[0].email;
	var enquiry_type  = document.forms[0].enquiry_type;
	var enquiry  = document.forms[0].enquiry;
	var confirmation  = document.forms[0].confirmation;

	if(user_name.value.length==0){
		if(lang=="1"){
			alert("請輸入姓名.");
		}else if(lang=="2"){
			alert("Please fill the name.");
		}else if(lang=="3"){
			alert("请輸入姓名.");
		}
		user_name.focus();
		return;
	}else if(country.value==0){
		if(lang=="1"){
			alert("請選擇國家/地區.");
		}else if(lang=="2"){
			alert("Please select country/region.");
		}else if(lang=="3"){
			alert("请选择国家/地区.");
		}
		country.focus();
		return;
	//}else if(phone_country.value.length==0){
	//	if(lang=="1"){
	//		alert("請輸入聯絡號碼(區號).");
	//	}else if(lang=="2"){
	//		alert("Please fill the contact no. of country/region.");
	//	}
	//	phone_country.focus();
	//	return;
	}else if(phone.value.length==0){
		if(lang=="1"){
			alert("請輸入聯絡號碼.");
		}else if(lang=="2"){
			alert("Please fill the contact no.");
		}else if(lang=="3"){
			alert("请輸入联络号码.");
		}
		phone.focus();
		return;
	}else if(email.value.length==0){
		if(lang=="1"){
			alert("請輸入電郵地址.");
		}else if(lang=="2"){
			alert("Please fill the email address.");
		}else if(lang=="3"){
			alert("请輸入电邮地址.");
		}
		email.focus();
		return;
	}else if(!checkMail(email.value)){
		if(lang=="1"){
			alert("請輸入正確電郵地址.");
		}else if(lang=="2"){
			alert("Please fill a valid email address.");
		}else if(lang=="3"){
			alert("请輸入正确电邮地址.");
		}
		email.focus();
		return;
	}else if(enquiry.value.length==0){
		if(lang=="1"){
			alert("請輸入查詢內容.");
		}else if(lang=="2"){
			alert("Please fill the enquiry content.");
		}else if(lang=="3"){
			alert("请输入查询内容.");
		}
		enquiry.focus();
		return;
	}else if(confirmation.value.length==0){
		if(lang=="1"){
			alert("請輸入確認字串.");
		}else if(lang=="2"){
			alert("Please fill the confirmation text.");
		}else if(lang=="3"){
			alert("请输入确认字串.");
		}
		confirmation.focus();
		return;
	}

	if(type==1||type==3){
		var company_name = document.forms[0].company_name;
		var company_type  = document.forms[0].company_type;
		var company_type_other  = document.forms[0].company_type_other;
		if(company_name.value.length==0){
				if(lang=="1"){
					alert("請輸入公司名稱.");
				}else if(lang=="2"){
					alert("Please fill the company name.");
				}else if(lang=="3"){
					alert("请输入公司名称.");
				}
				company_name.focus();
				return;
		}else if(company_type.value==0){
			if(lang=="1"){
				alert("請選擇公司性質.");
			}else if(lang=="2"){
				alert("Please select type of company.");
			}else if(lang=="3"){
				alert("请选择公司性质.");
			}
			company_type.focus();
			return;
		}else if(company_type.value==6&&company_type_other.value==0){
			if(lang=="1"){
				alert("請輸入公司性質(其他).");
			}else if(lang=="2"){
				alert("Please fill the type of comapny(Others).");
			}else if(lang=="3"){
				alert("请输入公司性质(其他).");
			}
			company_type_other.focus();
			return;
		}

	}
	document.forms[0].submit();
}

function checkMail(x)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(x);
}


/* List of Products - What's New Asia - Start*/
function showProductWhatsnewsAsiaAdd(){
	document.forms[0].action = "product_whatsnews_asia_detail.php";
	document.forms[0].submit();
}

function submitAddProductWhatsnewsAsia(){
	var product_title  = document.forms[0].product_title.value;
	var content1  = document.forms[0].content1.value;
	var product_country  = document.forms[0].product_country.value;
	
	if(content1.length==0){
		alert("Please enter the content!");
		document.forms[0].content1.focus();
		return;
	}
	if(product_country==0){
		alert("Please select the country!");
		document.forms[0].product_country.focus();
		return;
	}
	document.forms[0].submit();
}

function showProductWhatsnewsAsiaByPageNo(obj){
	document.forms[0].submit();
}

function showProductWhatsnewsAsiaByStatus(obj){
	document.forms[0].page_no.value = 1;
	document.forms[0].submit();
}

function showProductWhatsnewsAsiaByType(obj){
	if(obj.value<0){
		return false;
	}
	document.forms[0].page_no.value = 1;
	document.forms[0].submit();
}

function showProductWhatsnewsAsiaByOrder(sort_id){
	ori_sort_id = document.forms[0].page_sort_product.value;
	order_id = document.forms[0].page_order_product.value;
	order_asc = document.forms[0].page_order_product_asc.value;
	order_desc = document.forms[0].page_order_product_desc.value;
	if(sort_id==ori_sort_id){
		if(order_id==order_asc){
			document.forms[0].page_order_product.value = order_desc;
		}else{
			document.forms[0].page_order_product.value = order_asc;
		}
	}else{
		document.forms[0].page_sort_product.value = sort_id;
		document.forms[0].page_order_product.value = order_asc;
	}
	document.forms[0].submit();
}

function showProductWhatsnewsAsiaEdit(id){
	document.forms[0].action = "product_whatsnews_asia_detail.php";
	document.forms[0].product_id.value = id;
	document.forms[0].submit();
}

function sumitRemoveProductWhatsnewsAsia(objid,objname){
	var answer = confirm("Do you confirm to remove \"" + objname + "\"?");
	if (answer){
		document.forms[0].form_action.value = document.forms[0].action_product_whatsnews_remove.value;
		document.forms[0].product_id.value = objid;
		document.forms[0].action = "api_control.php";
		document.forms[0].submit();
	}	
}

function submitProductWhatsnewsAsiaStatus(id, actionID){
	document.forms[0].product_id.value = id;
	document.forms[0].form_action.value = actionID;
	document.forms[0].action = "api_control.php";
	document.forms[0].submit();
}

function showProductWhatsnewsAsiaAdd(){
	document.forms[0].action = "product_whatsnews_asia_detail.php";
	document.forms[0].submit();
}

function submitProductWhatsnewsAsiaHTML(){
	var answer = confirm("Are you sure to generate HTML?");
	if (answer){
		document.forms[0].action = "api_control.php";
		document.forms[0].form_action.value = document.forms[0].action_product_whatsnews_html.value;
		document.forms[0].submit();
	}
}

function submitProductWhatsnewsAsiaHTMLUpload(){
	var answer = confirm("Are you sure to upload HTML?");
	alert("Testing is still in the progress. Please upload files by FTP software or try later.");
	//if (answer){
	//	document.forms[0].action = "api_control.php";
	//	document.forms[0].form_action.value = document.forms[0].action_product_whatsnews_asia_upload.value;
	//	document.forms[0].submit();
	//}
}

function submitAddProductWhatsnewsAsia_bu(){
	var title_var  = document.forms[0].product_title.value;
	var content1  = document.forms[0].content1.value;
	
	if(title_var.length==0){
		alert("Please enter the title!");
		document.forms[0].product_title.focus();
		return;
	}
	if(content1.length==0){
		alert("Please enter the content!");
		document.forms[0].content1.focus();
		return;
	}
	document.forms[0].submit();
}

function showProductWhatsnewsAsiaEdit(id){
	document.forms[0].action = "product_whatsnews_asia_detail.php";
	document.forms[0].product_id.value = id;
	document.forms[0].submit();
}

/* List of Products - What's New Asia - End*/

function submitEnquiryMessageForm(){
	var lang = document.forms[0].lang.value;
	var enquiry  = document.forms[0].enquiry;
	var confirmation  = document.forms[0].confirmation;

	if(enquiry.value.length==0){
		if(lang=="1"){
			alert("請輸入查詢內容.");
		}else if(lang=="3"){
			alert("Please fill the enquiry content.");
		}else if(lang=="2"){
			alert("请输入查询内容.");
		}
		enquiry.focus();
		return;
	}else if(confirmation.value.length==0){
		if(lang=="1"){
			alert("請輸入確認字串.");
		}else if(lang=="3"){
			alert("Please fill the confirmation text.");
		}else if(lang=="1"){
			alert("请输入确认字串.");
		}
		confirmation.focus();
		return;
	}else if(confirmation.value.length<4){
		if(lang=="1"){
			alert("確認字串為四位字串.");
		}else if(lang=="3"){
			alert("Please fill 4 digit confirmation text.");
		}else if(lang=="1"){
			alert("确认字串为四位字串.");
		}
		confirmation.focus();
		return;
	}

	document.forms[0].submit();
}


/* image preload...*/
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_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_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];}
}