﻿function check_null ( column, name )
{
	if( column.length == 0 )
		return name + "不可以空白 !\n";
	return "";
}
function check_upload ( aa, name ,ee )
{
	if( aa == ee )
		return name + "不可以空白 !\n";
	return "";
}
function check_telephonenumber ( telephone )
{
	var error = false;
	if( telephone.length <= 0 )
		return "聯絡電話：不可以空白 !\n";
	for( idx = 0 ; idx < telephone.length ; idx++ ) {
		if( !( ( telephone.charAt(idx) >= '0' && telephone.charAt(idx) <= '9' ) || ( telephone.charAt(idx) == '-' ) ) ) {
			error = true;
			break;
		}
	}
	if( error == true )
		return "通訊電話：只能是數字及'-'等符號 !\n";
	return "";
}
function check_email ( email )
{
   var len = email.length;
   if( len == 0 )
	   return "電子信箱：不可以空白 !\n";
   if((email.indexOf("@")==-1)||(email.indexOf("@")==0)||(email.indexOf("@")==(len-1)))
	  return "電子信箱：地址不合法 !\n";
   if((email.indexOf("@")!=-1)&&(email.substring(email.indexOf("@")+1,len).indexOf("@")!=-1))
	  return "電子信箱：地址不合法 !\n";
   if((email.indexOf(".")==-1)||(email.indexOf(".")==0)||(email.lastIndexOf(".")==(len-1)))
	  return "電子信箱：地址不完全 !\n";
   return "";
}
function check_LoginEmail ( email )
{
   var len = email.length;
   if( len == 0 )
	   return "帳號必需填寫 !\n";
   if((email.indexOf("@")==-1)||(email.indexOf("@")==0)||(email.indexOf("@")==(len-1)))
	  return "MaxParty的帳號是你的電子信箱 !\n";
   if((email.indexOf("@")!=-1)&&(email.substring(email.indexOf("@")+1,len).indexOf("@")!=-1))
	  return "MaxParty的帳號是你的電子信箱 !\n";
   if((email.indexOf(".")==-1)||(email.indexOf(".")==0)||(email.lastIndexOf(".")==(len-1)))
	  return "MaxParty的帳號是你的電子信箱 !\n";
   return "";
}
function check_select ( select, name )
{
	if( select.options[0].selected == true )
		return name + "必須選擇 !\n";
	return "";
}
function check_radio ( radio, name )
{
	var error = true;
	for( i=0; i < radio.length; i++ )
		if( radio[i].checked == true ) {
			error = false;
			break;
		}
	if( error == true )
		return name + "必須選擇 !\n";
	return "";
}
function keys()
{
	if(event.keyCode == 27)
	{
	event.returnValue = false;
	}
}
function check_imgfile( aa, name ,ee )
{
	if( aa != '' ){
	bb=aa.substring(aa.lastIndexOf('.')+1,aa.length);
	cc=['jpg','JPG','gif','GIF'];
	flag=0;
	for (i in cc) {if (bb==cc[i]) {flag=1;}}
	if (flag==0)
		return name + "檔案類型錯誤! 僅支援JPG及GIF格式。\n";
	return "";
}
return "";
}
function check_musicfile( aa, name ,ee )
{
	if( aa != ee ){
	bb=aa.substring(aa.lastIndexOf('.')+1,aa.length);
	cc=['mp3','MP3'];
	flag=0;
	for (i in cc) {if (bb==cc[i]) {flag=1;}}
	if (flag==0)
		return name + "檔案類型錯誤! 僅支援MP3格式。\n";
	return "";
}
return "";
}
function check_videofile( aa, name ,ee )
{
	if( aa != ee ){
	bb=aa.substring(aa.lastIndexOf('.')+1,aa.length);
	cc=['asf','ASF','wmv','WMV','mov','MOV','flv','FLV','mpg','MPG','rm','RM'];
	flag=0;
	for (i in cc) {if (bb==cc[i]) {flag=1;}}
	if (flag==0)
		return name + "檔案類型錯誤! 僅支援ASF、WMV、MOV、FLV、MPG及RM格式。\n";
	return "";
}
return "";
}