// 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 InitAjax(){
　var ajax=false; 
　try { 
　　ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
　}catch(e){ 
　　try { 
　　　ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
　　} catch(E){ 
　　　ajax = false; 
　　} 
　}
　if(!ajax && typeof XMLHttpRequest!='undefined') { 
　　ajax = new XMLHttpRequest(); 
　} 
　return ajax;
}

function setCategory(id,prid){
	if(id==""){
		alert("Please select Product Line.");
	}else{
		　if (typeof(id) == 'undefined'){
		　　return false;
		　}
		　var url = "_productById.php?id="+ id + "&prid=" + prid;
		　var ajax = InitAjax();
		　ajax.open("GET", url, true); 
		　ajax.onreadystatechange = function() { 
		　　   if(ajax.readyState == 4 && ajax.status == 200) { 
				document.getElementById("product_td").innerHTML = ajax.responseText;
			  } 
	　	  }
	　    ajax.send(null); 
	}
}

function joinEpaper(email){
	
	if(email==""){
		alert("Please input Your Email.");
	}else if(!isEmail(email)){
		alert("Please input correct E-mail.");
	}else{	
		　var url = "_join_epaper.php?email="+ email;
		　var ajax = InitAjax();
		　ajax.open("GET", url, true); 
		　ajax.onreadystatechange = function() { 
		　　   if(ajax.readyState == 4 && ajax.status == 200) { 
				alert(ajax.responseText);
			  } 
	　	  }
	　    ajax.send(null); 
	}
	
}

function isdigit(s){
	var r,re;
	re = /\d*/i; //\d表示數字,*表示匹配多個數字
	r = s.match(re);
	return (r==s)?true:false;
}

function chkNumber(obj){
	if(!isdigit(obj.value)){
		alert("Please input number.");
		obj.focus();
	}
}

function delCard(id){
	var obj = document.fillForm;
	if(confirm("Are you sure to delete?")){
		obj.id.value = id;
		obj.u.value = "del";
		obj.submit();
	}
}

function resetFillForm(){
	var obj = document.fillForm;
	obj.reset();	
}

function sbFillForm(){
	if(chkFillForm()){
		var obj = document.fillForm;
		obj.u.value = "ok";
		obj.action = "cart-complete.php";
		obj.submit();
	}
}
function chkFillForm(){
	var obj = document.fillForm;
	var strVar = "";
	
	strVar = obj.real_name.value;
	if(strVar==""){
		alert("Please input the Name.");
		obj.real_name.focus();
		return false;
	}
	
	strVar = obj.phone.value;
	if(strVar==""){
		alert("Please input the Phone.");
		obj.phone.focus();
		return false;
	}
	
	strVar = obj.email.value;
	if(strVar==""){
		alert("Please input the E-mail.");
		obj.email.focus();
		return false;	
	}else if(!isEmail(strVar)){
		alert("Please input correct E-mail.");
		obj.email.focus();
		return false;	
	}
	
	strVar = obj.company.value;
	if(strVar==""){
		alert("Please input the Company Name.");
		obj.company.focus();
		return false;
	}	
	
	strVar = obj.country.value;
	if(strVar==""){
		alert("Please input the Country.");
		obj.country.focus();
		return false;
	}	
	
	return true;
}

function sbForm(){
	if(chkForm()){
		var obj = document.contactForm;
		obj.submit();
	}
}
function resetEmailFriendsForm(){
	var obj = document.emailFriendsForm;
	obj.reset();
}

function sbEmailFriendsForm(){
	if(chkEmailFriendsForm()){
		var obj = document.emailFriendsForm;
		obj.submit();
	}	
}
function chkEmailFriendsForm(){
	
	var obj = document.emailFriendsForm;
	var strVar = obj.real_name.value;
	if(strVar==""){
		alert("Please input Your Name.");
		obj.real_name.focus();
		return false;
	}

	strVar = obj.from_email.value;
	if(strVar==""){
		alert("Please input Your Email.");
		obj.from_email.focus();
		return false;
	}else if(!isEmail(strVar)){
		alert("Please input correct E-mail.");
		obj.from_email.focus();
		return false;	
	}
	
	strVar = obj.from_email.value;
	if(strVar==""){
		alert("Please input Your Email.");
		obj.from_email.focus();
		return false;
	}
	
	strVar = obj.emails.value;
	if(strVar==""){
		alert("Please input the Recipient Email.");
		obj.emails.focus();
		return false;
	}
	
	strVar = obj.subject.value;
	if(strVar==""){
		alert("Please input the Subjuct.");
		obj.subject.focus();
		return false;
	}	
	
	return true;
}

function sbproductSearchForm(){
	var strVar = "";
	strVar = document.productSearchForm.strKey.value;
	if(strVar == ""){
		alert("Please input the keywords.");
		document.productSearchForm.strKey.focus();
	}else{
		document.productSearchForm.submit();
	}
}




function sbJoinForm(){
	if(chkJoinForm()){
		var obj = document.joinForm;
		obj.u.value = "ok";
		obj.submit();
	}
}
function chkJoinForm(){
	var obj = document.joinForm;
	var strVar = "";
	
	
	strVar = obj.email.value;
	if(strVar==""){
		alert("Please input the E-mail.");
		obj.email.focus();
		return false;	
	}else if(!isEmail(strVar)){
		alert("Please input correct E-mail.");
		obj.email.focus();
		return false;	
	}
	
	strVar = obj.password.value;
	if(strVar==""){
		alert("Please input the Password.");
		obj.password.focus();
		return false;
	}	
	
	if(!(strVar==obj.re_password.value)){
		alert("The two passwords must be consistent.");
		obj.password.focus();
		return false;
	}		
	
	
	strVar = obj.f_name.value;
	if(strVar==""){
		alert("Please input the First Name.");
		obj.f_name.focus();
		return false;
	}
	
	strVar = obj.l_name.value;
	if(strVar==""){
		alert("Please input the Last Name.");
		obj.l_name.focus();
		return false;
	}
	
	strVar = obj.address.value;
	if(strVar==""){
		alert("Please input the Address.");
		obj.address.focus();
		return false;
	}		
	
	
	strVar = obj.city.value;
	if(strVar==""){
		alert("Please input the City.");
		obj.city.focus();
		return false;
	}	
	

	strVar = obj.country.value;
	if(strVar==""){
		alert("Please input the Country.");
		obj.country.focus();
		return false;
	}	
	
	strVar = obj.phone.value;
	if(strVar==""){
		alert("Please input the Phone.");
		obj.phone.focus();
		return false;
	}
	
	var tmp_obj = obj.b_type;
	if(!chkSelect(tmp_obj)){
		alert("Please select the Business Type.");
		return false;
	}
	
	
	tmp_obj = obj.application;
	
	if(!chkSelect(tmp_obj)){
		alert("Please select the Application.");
		return false;
	}	
	
	
	return true;
}


function sbPartnerForm(){
	if(chkPartnerForm()){
		var obj = document.partnerForm;
		obj.u.value = "ok";
		obj.submit();
	}
}
function chkPartnerForm(){
	var obj = document.partnerForm;
	var strVar = "";
	

	strVar = obj.password.value;
	if(strVar==""){
	}else{	
		if(!(strVar==obj.re_password.value)){
			alert("The two passwords must be consistent.");
			obj.password.focus();
			return false;
		}		
	}
	
	strVar = obj.f_name.value;
	if(strVar==""){
		alert("Please input the First Name.");
		obj.f_name.focus();
		return false;
	}
	
	strVar = obj.l_name.value;
	if(strVar==""){
		alert("Please input the Last Name.");
		obj.l_name.focus();
		return false;
	}
	
	strVar = obj.address.value;
	if(strVar==""){
		alert("Please input the Address.");
		obj.address.focus();
		return false;
	}		
	
	
	strVar = obj.city.value;
	if(strVar==""){
		alert("Please input the City.");
		obj.city.focus();
		return false;
	}	
	

	strVar = obj.country.value;
	if(strVar==""){
		alert("Please input the Country.");
		obj.country.focus();
		return false;
	}	
	
	strVar = obj.phone.value;
	if(strVar==""){
		alert("Please input the Phone.");
		obj.phone.focus();
		return false;
	}
	
	var tmp_obj = obj.b_type;
	if(!chkSelect(tmp_obj)){
		alert("Please select the Business Type.");
		return false;
	}
	
	
	tmp_obj = obj.application;
	
	if(!chkSelect(tmp_obj)){
		alert("Please select the Application.");
		return false;
	}	
	
	
	return true;
}

function login(){
	if(chkLoginForm()){
		var obj = document.loginForm;
		obj.submit();
	}
}

function chkLoginForm(){
	var obj = document.loginForm;
	var strVar = "";
	strVar = obj.email.value;
	if(strVar == ""){
		alert("Please input the ID.");
		obj.email.focus();
		return false;
	}
	strVar = obj.password.value;
	if(strVar == ""){
		alert("Please input the Password.");
		obj.password.focus();
		return false;
	}	
	return true;
}


function openWindow(url,width,height){
   window.open(url,"openWindow","toolbar=no,scrightbars=no,menubar=no,status=no,location=no,width="+width+",height="+height);
}




function chkSelect(tmpobj){
	var flag = false;
	for (var i = 0; i < tmpobj.length; i++){
		if(tmpobj[i].checked){
			flag = true;
			break;
		}
	}
	return flag;
}

function isEmail(txt){    
	var pattern =/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,3}|\d+)$/i;    
	return pattern.test(txt);    
}

//-->
