function CkNumAlphaUnder(text){
	var tomatch=text.value.match(/[^A-Za-z0-9_\-]/g);
	if(text.value!=''){		
		if(tomatch)	{
			alert("Must insert alphabet, the numeral, the horizontal line or the agent.");
			text.focus();
			text.select();
			return false;
		}
	}
}
function CkNumAlpha(text){
	var tomatch=text.value.match(/[^A-Za-z0-9]/g);
	if(text.value!='')
	{		
		if(tomatch)
		{
			alert("Must insert alphabet or number.");
			text.focus();
			return false;
		}
	}
}

function CkNum(text){
	var tomatch=text.value.match(/[^0-9]/g);	
	if(text.value!='')
	{		
		if(tomatch)
		{
			alert("Must insert number.");
			text.focus();
			text.select();
			return false;
		}
	}
}
function CkMail(mail)
{
	var tomatch=/[A-Za-z0-9_\-\.]+@([0-9a-z][a-z0-9_\-\.]+)(\.)[A-Za-z\.]{2,}/;	
	if(mail.value!='')
	{		
		if(!tomatch.test(mail.value))
		{
			alert("E-mail format incorrect!!");
			mail.focus();
			mail.select();
			return false;
		}
	}
}
function CkPhoto(text){
	extname=GetExtName(text);
	if(!(extname=="jpg" || extname=="jpeg" || extname=="gif")){
		alert("相片格式錯誤！\n僅接受\"JPG\"或\"GIF\"檔案格式！");
		return false;
	}		
	return true;
}
function GetExtName(text){
	var extname='';
	var pointno=text.value.lastIndexOf('.');
	var len=text.value.length;
	for(i=pointno+1;i<len;i++){
		extname=extname + text.value.charAt(i);
	}
	extname=extname.toLowerCase();
	return extname;
}
function CkFileName(text){
	filename=GetFileName(text);
	var tomatch=filename.match(/[^A-Za-z0-9_-]/g);
	if(tomatch)
	{
		alert("上傳檔案檔名必需為英文字母、數字或底線，\n不可使用中文或包含特殊符號。!!");
		return false;
	}
	return true;
}
function GetFileName(text){
	var filename='';	//相片檔名
	var pointno1=text.value.lastIndexOf('\\');
	var pointno2=text.value.lastIndexOf('.');
	for(i=pointno1+1;i<pointno2;i++){
		filename=filename + text.value.charAt(i);
	}
	return filename;
}

function IsReadyContact(form){
  	if(form.con_name.value==''){
		alert("Please insert Last name.");
		form.con_name.focus();
		return false;
	}
	if(form.e_mail.value==''){
		alert("Please insert E-mail.");
		form.e_mail.focus();
		return false;
	}
	if(form.content.value==''){
		alert("Please insert Your opinion.");
		form.content.focus();
		return false;
	}
}
//關鍵字快速查詢
function IsReadyProdSearch(form){
	if(form.str_qry.value=='' || form.str_qry.value=='Please insert Key word'){
		alert("Please insert Key word.");
		form.str_qry.focus();
		return false;
	}
	if(form.qry_target[form.qry_target.selectedIndex].value=='prod'){
		form.action ="prod_search_list.php";
	}else{
		form.action ="comp_search_list.php";
	}
}
//產品進階查詢
function IsReadyProdAdSearch(form){
	if(form.str_qry.value=='' || form.str_qry.value=='Please insert Key word'){
		alert("Please insert Key word.");
		form.str_qry.focus();
		return false;
	}
}

//清除文字方塊文字
//關鍵字搜尋
function ClearTxt(txt){
	if(txt.value == 'Please insert Key word'){
		txt.value = '';
	}
}

//跳出視窗定位
function OpenPage(topage,pagename,w,h,bar,resize) { 
	x = (screen.width - w)/2;
	y = (screen.height - h)/2;
	window.open(topage,pagename,'left='+x+',top='+y+',width='+w+',height='+h+',scrollbars='+bar+',resizable='+resize);
}


