﻿function change_img(ptagID, pSource) { 
	document.getElementById(ptagID).src = pSource; 
	return true; 
} 

function change_page(pPatternID, pBaseUrl, pNumberPage, pSelectClass) {
} 

function preview_img(pImgSrc){	
}

function img_resize(oImage, ph, pw) {
}

function set_div_point() {
	if (document.body.clientWidth <= 770) {
		document.getElementById("btn1").style.left = 183;
		document.getElementById("btn2").style.left = 303;
		document.getElementById("btn3").style.left = 423;
	} else {
		document.getElementById("btn1").style.left = ((document.body.clientWidth - 770) / 2) + 183;
		document.getElementById("btn2").style.left = ((document.body.clientWidth - 770) / 2) + 303;
		document.getElementById("btn3").style.left = ((document.body.clientWidth - 770) / 2) + 423;
	}
}

function show_home_top(pParam) {
	//p1 = image path
	//p2 = aspx path
	//p3 = swf path
	//p4 = current page
	var aParam;
	var sResult = "";
	if (pParam == "" || pParam == null || pParam == "[;][;]") {
		pParam = "[;][;]";
	}
	aParam = pParam.split("[;]");
	//content title
	switch (aParam[3]) {
		case "11":
			document.writeln("		<div id=\"btn1\" align=\"center\" style=\"position:absolute; left:-1000px; top:132px; width:101px; height:41px; z-index:1; background-image: url(" + aParam[0] + "1_01.gif);\">");
			document.writeln("			<table width=\"100%\" height=\"30\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table7\">");
			document.writeln("				<tr>");
			document.writeln("					<td align=\"center\" valign=\"middle\"><a class=\"button_click\" onmouseover=\"this.className=\'button_over\';\" onmouseout=\"this.className=\'button_click\';\" href=\"" + aParam[1] + "AAT1P0000011&p1=1&p2=1&p3=1&p4=0\">SDK<\/a><\/td>");
			document.writeln("				<\/tr>");
			document.writeln("			<\/table>");
			document.writeln("		<\/div>");
			document.writeln("		<div id=\"btn2\" align=\"center\" style=\"position:absolute; left:-1000px; top:132px; width:101px; height:41px; z-index:1; background-image: url(" + aParam[0] + "1_01.gif);\">");
			document.writeln("			<table width=\"100%\" height=\"30\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table8\">");
			document.writeln("				<tr>");
			document.writeln("					<td align=\"center\" valign=\"middle\"><a class=\"button_out\" onmouseover=\"this.className=\'button_over\';\" onmouseout=\"this.className=\'button_out\';\" href=\"" + aParam[1] + "AAT1P0000012&p1=1&p2=1&p3=1&p4=0\">感應卡開發<\/a><\/td>");
			document.writeln("				<\/tr>");
			document.writeln("			<\/table>");
			document.writeln("		<\/div>");
			document.writeln("		<div id=\"btn3\" align=\"center\" style=\"position:absolute; left:-1000px; top:132px; width:101px; height:41px; z-index:1; background-image: url(" + aParam[0] + "1_01.gif);\">");
			document.writeln("			<table width=\"100%\" height=\"30\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table9\">");
			document.writeln("				<tr>");
			document.writeln("					<td align=\"center\" valign=\"middle\"><a class=\"button_out\" onmouseover=\"this.className=\'button_over\';\" onmouseout=\"this.className=\'button_out\';\" href=\"" + aParam[1] + "AAT1P0000014&p1=1&p2=1&p3=1&p4=0\">印卡機<\/a><\/td>");
			document.writeln("				<\/tr>");
			document.writeln("			<\/table>");
			document.writeln("		<\/div>");
			break;
		case "12":
			document.writeln("		<div id=\"btn1\" align=\"center\" style=\"position:absolute; left:-1000px; top:132px; width:101px; height:41px; z-index:1; background-image: url(" + aParam[0] + "1_01.gif);\">");
			document.writeln("			<table width=\"100%\" height=\"30\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table7\">");
			document.writeln("				<tr>");
			document.writeln("					<td align=\"center\" valign=\"middle\"><a class=\"button_out\" onmouseover=\"this.className=\'button_over\';\" onmouseout=\"this.className=\'button_out\';\" href=\"" + aParam[1] + "AAT1P0000011&p1=1&p2=1&p3=1&p4=0\">SDK<\/a><\/td>");
			document.writeln("				<\/tr>");
			document.writeln("			<\/table>");
			document.writeln("		<\/div>");
			document.writeln("		<div id=\"btn2\" align=\"center\" style=\"position:absolute; left:-1000px; top:132px; width:101px; height:41px; z-index:1; background-image: url(" + aParam[0] + "1_01.gif);\">");
			document.writeln("			<table width=\"100%\" height=\"30\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table8\">");
			document.writeln("				<tr>");
			document.writeln("					<td align=\"center\" valign=\"middle\"><a class=\"button_click\" onmouseover=\"this.className=\'button_over\';\" onmouseout=\"this.className=\'button_click\';\" href=\"" + aParam[1] + "AAT1P0000012&p1=1&p2=1&p3=1&p4=0\">感應卡開發<\/a><\/td>");
			document.writeln("				<\/tr>");
			document.writeln("			<\/table>");
			document.writeln("		<\/div>");
			document.writeln("		<div id=\"btn3\" align=\"center\" style=\"position:absolute; left:-1000px; top:132px; width:101px; height:41px; z-index:1; background-image: url(" + aParam[0] + "1_01.gif);\">");
			document.writeln("			<table width=\"100%\" height=\"30\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table9\">");
			document.writeln("				<tr>");
			document.writeln("					<td align=\"center\" valign=\"middle\"><a class=\"button_out\" onmouseover=\"this.className=\'button_over\';\" onmouseout=\"this.className=\'button_out\';\" href=\"" + aParam[1] + "AAT1P0000014&p1=1&p2=1&p3=1&p4=0\">印卡機<\/a><\/td>");
			document.writeln("				<\/tr>");
			document.writeln("			<\/table>");
			document.writeln("		<\/div>");
			break;
		case "14":
			document.writeln("		<div id=\"btn1\" align=\"center\" style=\"position:absolute; left:-1000px; top:132px; width:101px; height:41px; z-index:1; background-image: url(" + aParam[0] + "1_01.gif);\">");
			document.writeln("			<table width=\"100%\" height=\"30\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table7\">");
			document.writeln("				<tr>");
			document.writeln("					<td align=\"center\" valign=\"middle\"><a class=\"button_out\" onmouseover=\"this.className=\'button_over\';\" onmouseout=\"this.className=\'button_out\';\" href=\"" + aParam[1] + "AAT1P0000011&p1=1&p2=1&p3=1&p4=0\">SDK<\/a><\/td>");
			document.writeln("				<\/tr>");
			document.writeln("			<\/table>");
			document.writeln("		<\/div>");
			document.writeln("		<div id=\"btn2\" align=\"center\" style=\"position:absolute; left:-1000px; top:132px; width:101px; height:41px; z-index:1; background-image: url(" + aParam[0] + "1_01.gif);\">");
			document.writeln("			<table width=\"100%\" height=\"30\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table8\">");
			document.writeln("				<tr>");
			document.writeln("					<td align=\"center\" valign=\"middle\"><a class=\"button_out\" onmouseover=\"this.className=\'button_over\';\" onmouseout=\"this.className=\'button_out\';\" href=\"" + aParam[1] + "AAT1P0000012&p1=1&p2=1&p3=1&p4=0\">感應卡開發<\/a><\/td>");
			document.writeln("				<\/tr>");
			document.writeln("			<\/table>");
			document.writeln("		<\/div>");
			document.writeln("		<div id=\"btn3\" align=\"center\" style=\"position:absolute; left:-1000px; top:132px; width:101px; height:41px; z-index:1; background-image: url(" + aParam[0] + "1_01.gif);\">");
			document.writeln("			<table width=\"100%\" height=\"30\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table9\">");
			document.writeln("				<tr>");
			document.writeln("					<td align=\"center\" valign=\"middle\"><a class=\"button_click\" onmouseover=\"this.className=\'button_over\';\" onmouseout=\"this.className=\'button_click\';\" href=\"" + aParam[1] + "AAT1P0000014&p1=1&p2=1&p3=1&p4=0\">印卡機<\/a><\/td>");
			document.writeln("				<\/tr>");
			document.writeln("			<\/table>");
			document.writeln("		<\/div>");
			break;
	}			
	document.writeln("		<table WIDTH=\"100%\" height=\"100%\" align=\"center\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">");
	document.writeln("			<tr>");
	document.writeln("				<td height=\"136\" align=\"center\">");
	document.writeln("					<TABLE WIDTH=\"770\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table1\">");
	document.writeln("						<TR>");
	document.writeln("							<TD><IMG SRC=\"" + aParam[0] + "4_02.gif\" WIDTH=\"770\" HEIGHT=\"30\" ALT=\"\"\/><\/TD>");
	document.writeln("						<\/TR>");
	document.writeln("						<TR>");
	document.writeln("							<TD><IMG SRC=\"" + aParam[0] + "4_01.gif\" WIDTH=\"770\" HEIGHT=\"106\" ALT=\"\"\/><\/TD>");
	document.writeln("						<\/TR>");
	document.writeln("					<\/TABLE>");
	document.writeln("				<\/td>");
	document.writeln("			<\/tr>");
	document.writeln("			<tr>");
	document.writeln("				<td height=\"50\" align=\"center\">");
	document.writeln("					<TABLE WIDTH=\"770\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table2\">");
	document.writeln("						<TR height=\"21\">");
	document.writeln("							<TD background=\"" + aParam[0] + "2_01.gif\">&nbsp;<\/TD>");
	document.writeln("						<\/TR>");
	document.writeln("						<TR HEIGHT=\"29\">");
	document.writeln("							<TD background=\"" + aParam[0] + "2_02.gif\">&nbsp;<\/TD>");
	document.writeln("						<\/TR>");
	document.writeln("					<\/TABLE>");
	document.writeln("				<\/td>");
	document.writeln("			<\/tr>");
	document.writeln("			<tr>");
	document.writeln("				<td align=\"center\">");
	document.writeln("					<TABLE height=\"100%\" WIDTH=\"770\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table4\">");
	document.writeln("						<tr height=\"100%\">");
	document.writeln("							<td WIDTH=\"183\">");
	document.writeln("								<TABLE WIDTH=\"100%\" height=\"100%\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table5\">");
	document.writeln("									<tr>");
	document.writeln("										<TD background=\"" + aParam[0] + "2_03.gif\" WIDTH=\"183\">")

}

function show_home_middle(pParam) {
	//p1 = image path
	//p2 = aspx path
	var aParam;
	var sResult = "";
	if (pParam == "" || pParam == null || pParam == "[;][;]") {
		pParam = "[;][;]";
	}
	aParam = pParam.split("[;]");
	//content title
	document.writeln("										<\/TD>");
	document.writeln("									<\/tr>");
	document.writeln("								<\/TABLE>");
	document.writeln("							<\/td>");
	document.writeln("							<td WIDTH=\"587\">");
	document.writeln("								<TABLE WIDTH=\"100%\" height=\"100%\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table6\">");
	document.writeln("									<tr HEIGHT=\"36\">");
	document.writeln("										<TD WIDTH=\"100\"><IMG SRC=\"" + aParam[0] + "3_01.gif\"\/><\/TD>");
	document.writeln("										<TD WIDTH=\"487\" background=\"" + aParam[0] + "2_04.gif\" class=\"banner\">");
	switch (aParam[3]) {
		case "11":
				document.writeln("										SDK");
			break;
		case "12":
				document.writeln("										FAQ");
			break;
		case "14":
				document.writeln("										聯絡我們");
			break;
	}	
	document.writeln("										<\/TD>");
	document.writeln("									<\/tr>");
	document.writeln("									<TR>");
	document.writeln("										<TD COLSPAN=\"2\" WIDTH=\"587\">");
	document.writeln("								<TABLE WIDTH=\"100%\" height=\"100%\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" ID=\"Table116\">");
	document.writeln("									<tr>");
	document.writeln("										<TD width=\"30\" background=\"" + aParam[0] + "2_05.gif\">&nbsp;<\/TD>");
	document.writeln("										<TD>");
}

function show_copyright_top(pParam) {
	//p1 = image path
	var aParam;
	var sResult = "";
	if (pParam == "" || pParam == null || pParam == "[;]") {
		pParam = "[;]";
	}
	aParam = pParam.split("[;]");
	//content
	document.writeln("										<\/TD>");
	document.writeln("									<\/tr>");
	document.writeln("									<TR HEIGHT=\"23\">");
	document.writeln("										<TD COLSPAN=\"2\"><IMG SRC=\"" + aParam[0] + "2_06.gif\" WIDTH=\"533\" HEIGHT=\"23\" ALT=\"\"\/><\/TD>");
	document.writeln("									<\/TR>");
	document.writeln("								<\/TABLE>");
	document.writeln("										<\/TD>");
	document.writeln("									<\/tr>");
	document.writeln("								<\/TABLE>");
	document.writeln("							<\/td>");
	document.writeln("						<\/tr>");
	document.writeln("					<\/TABLE>");
	document.writeln("				<\/td>");
	document.writeln("			<\/tr>");
	document.writeln("			<tr>");
	document.writeln("				<td align=\"center\" height=\"50\">");
	document.writeln("					<table border=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\" WIDTH=\"770\" ID=\"Table3\">");
	document.writeln("						<tr>");
	document.writeln("							<td align=\"center\" class=\"copyright\">");
}


function show_copyright_bottom(pParam) {
	//p1 = image path
	var aParam;
	var sResult = "";
	if (pParam == "" || pParam == null || pParam == "[;]") {
		pParam = "[;]";
	}
	aParam = pParam.split("[;]");
	//content
	document.writeln("							<\/td>");
	document.writeln("						<\/tr>");
	document.writeln("					<\/table>");
	document.writeln("				<\/td>");
	document.writeln("			<\/tr>");
	document.writeln("		<\/table>")
}

function cal(pmoney) {
	var ofm = document.forms[0];
	var t = 0;
	for (i = 0; i < ofm.elements["total"].length; i++) {
		ofm.total[i].value = eval(ofm.prod[i].value) * eval(ofm.qty[i].value);
		t += eval(ofm.total[i].value);
	}
	if (t >= pmoney) {ofm.trans.value = 0;} else {ofm.trans.value = 100;}
	ofm.alltotal.value = eval(t) + eval(ofm.trans.value);
}

function order() {
	var ofm = document.forms[0];
	var s = "";
	s = UnableToNull(ofm.f1, " 客戶名稱 ", s)
	s = UnableToNull(ofm.f2, " 聯絡人 ", s)
	s = UnableToNull(ofm.f3, " 收貨地址 ", s)
	s = UnableToNull(ofm.f4, " 聯絡電話 ", s)
	s = UnableToNull(ofm.email, " E-mail ", s)
	if (s.length > 0) {alert(s); return false}
	if (ofm.alltotal.value <= 100) {alert("請先輸入欲購買的數量!!");return false}
	ofm.FROM.value = ofm.email.value;
	ofm.BODY.value = document.getElementById("content").innerHTML;
	return true;
}

	//確認只能輸入0-9
	function InputNumber() {
		if (!((event.keyCode >= 48 && event.keyCode <= 57) || event.keyCode == 8 || event.keyCode == 13)) {
//		if (!/[0-9]/.test(String.fromCharCode(event.keyCode))) {
			alert("抱歉！此欄位只接受輸入數字【0-9】！");
//			alert("please enter number【0-9】 in this input Field !!");
			event.returnValue = false;
		}
	}

	//確認輸入是統一編號
	function CheckIsCID(poField, psFieldName, psErrorMsg, pbShowMsg) {	
		var cx = new Array;
		cx[0] = 1;
		cx[1] = 2;
		cx[2] = 1;
		cx[3] = 2;
		cx[4] = 1;
		cx[5] = 2;
		cx[6] = 4;
		cx[7] = 1;
		
		var NO = poField.value;
		if (NO.length != 0)	{
			var SUM = 0;
			if (NO.length != 8) {
				psErrorMsg += "\t您的【" + psFieldName + "】欄位錯誤，請輸入 8 個數字！\n";
				if (!pbShowMsg)	{
					poField.className = "WorryFocusOn";
					return psErrorMsg;
				}
				//p_field.focus();
				//alert("統一編號錯誤，要有 8 個數字");
				//return false;
			}
			  
			var cnum = NO.split("");
			for (i=0; i<cnum.length; i++) {
				if (NO.charCodeAt(i) < 48 || NO.charCodeAt(i) > 57) {
					psErrorMsg += "\t您的第" + (i + 1) + "個字元造成【" + psFieldName + "】欄位錯誤，請輸入 8 個 0-9 數字組合！\n";
					if (!pbShowMsg)	{
						poField.className = "WorryFocusOn";
						return psErrorMsg;
					}
					//poField.focus();
					//alert("統一編號錯誤，要有 8 個 0-9 數字組合");
					//return false;
				}
				SUM += cc(cnum[i] * cx[i]);
			}
			  
			if (SUM % 10 == 0) {
				//return true;
			} else if (cnum[6] == 7 && (SUM + 1) % 10 == 0) {
				//return true;
			} else {
				psErrorMsg += "\t您的【" + psFieldName + "】欄位錯誤，" + NO + "！\n";
				if (!pbShowMsg)	{
					poField.className = "WorryFocusOn";
					return psErrorMsg;
				}
				//poField.focus();
				//alert("統一編號："+NO+" 錯誤!");
				//return false;
			}
			if (pbShowMsg && psErrorMsg!="") {
				alert(psErrorMsg);
				poField.focus();
				return false;
			}

			function cc(n) {
				if (n > 9) {
					var s = n + "";
					n1 = s.substring(0,1) * 1;
					n2 = s.substring(1,2) * 1;
					n = n1 + n2;
				}
				return n;
			}
		}
	}
	
		//確認是否為email
	function CheckIsEmail(poField, psFieldName, psErrorMsg, pbShowMsg) {	
		if (poField.value != "" ) {
			data = poField.value.match(/^\S+@\S+\.\S+$/);
			if (!data || !poField.value) {
				psErrorMsg += "\t您的【" + psFieldName + "】欄位錯誤，不屬於Email規則！\n";
				if (!pbShowMsg) {
					poField.className = "WorryFocusOn";
					return psErrorMsg;
				}
				//poField.focus();
				//alert("您的【" + psFieldName +"】欄位不屬於mail規則！");
				//return true;
			} else {
				re = /(.+)\@+([\,\w\.-]+)/i;
				found = poField.value.match(re);
				if (! found) {
					psErrorMsg += "\t5您的【" + psFieldName + "】欄位錯誤，不屬於Email規則！\n";
					if (!pbShowMsg)	{
						poField.className = "WorryFocusOn";
						return psErrorMsg;
					}
				} else {
					dot_array=found[2].split(/[\,\.]+/);
					if ( dot_array.length < 2) {
						psErrorMsg += "\t1您的【" + psFieldName + "】欄位錯誤，不屬於Email規則！\n";
						if (!pbShowMsg)	{
							poField.className = "WorryFocusOn";
							return psErrorMsg;
						}
					} else {
						found[1]=found[1].replace( /^\s+/, '');
						found[1]=found[1].replace( /\s+$/, '');
						if(found[1].match(/\s+/)) {
							psErrorMsg += "\t2您的【" + psFieldName + "】欄位錯誤，不屬於Email規則！\n";
							if (!pbShowMsg)	{
								poField.className = "WorryFocusOn";
								return psErrorMsg;
							}
						}
					}
				}
				i = poField.value.indexOf('@');
				j = poField.value.indexOf('.', i);
				k = poField.value.indexOf(',');
				kk = poField.value.indexOf(' ');
				jj = poField.value.lastIndexOf('.') + 1;
				len = poField.value.length;
				if (i <= 0)	{           
					psErrorMsg += "\t3‧您的【" + psFieldName + "】欄位錯誤，不屬於Email規則！(沒有@)\n" 
					if (!pbShowMsg)	{
						poField.className = "WorryFocusOn";
						return psErrorMsg;
					}
				}
				else if (j <= (1+1)) { 
					psErrorMsg += "\t‧您的【" + psFieldName + "】欄位錯誤，不屬於Email規則！(少於兩個 . 符號)\n" 
					if (!pbShowMsg)	{
						poField.className = "WorryFocusOn";
						return psErrorMsg;
					}
				}
				else if (k != -1) {    
					psErrorMsg += "\t‧您的【" + psFieldName + "】欄位錯誤，不屬於Email規則！(含有,)\n" 
					if (!pbShowMsg)	{
						poField.className = "WorryFocusOn";
						return psErrorMsg;
					}
				} else if (len-jj < 2) { 
					psErrorMsg += "\t‧您的【" + psFieldName + "】欄位錯誤，不屬於Email規則！(最後一個 . 符號之後少於兩個字)\n" 
					if (!pbShowMsg)
					{
						poField.className = "WorryFocusOn";
						return psErrorMsg;
					}
				}
				else if (len-jj > 3) { 
					psErrorMsg += "\t‧您的【" + psFieldName + "】欄位錯誤，不屬於Email規則！(最後一個 . 符號之後多於三個字)\n" 
					if (!pbShowMsg) {
						poField.className = "WorryFocusOn";
						return psErrorMsg;
					}
				}
			}
			if (pbShowMsg && psErrorMsg!="") {
				alert(psErrorMsg);
				poField.focus();
				return false;
			}
		}
	}
	
		//不能為空值
	function UnableToNull(poField, psFieldName, psErrorMsg)	{	
		if (poField.value == "") {
			poField.className = "WorryFocusOn";
			psErrorMsg += "\t您的【" + psFieldName + "】欄位沒有填寫內容！\n";
			//poField.Focus();
			//alert("您的【" + psFieldName +"】欄位沒有填寫內容！");
			//return true;
		}
		return psErrorMsg;
	}
