var xmlHttp=new Array();
var checkUsername=false;
var checkURL=false;

function createXMLHttpRequest(name) {
	if (window.ActiveXObject) {
					xmlHttp[name] = new ActiveXObject("Microsoft.XMLHTTP");
	}else if (window.XMLHttpRequest) {
					xmlHttp[name] = new XMLHttpRequest();
	}
}
function g(namex){
	if (document.getElementById){
		return document.getElementById(namex);
	}else if (document.all){
		return document.all[namex];
	}else{
		return null;
	}
}

function openVat(value){

	if(value==0){
		g('CompanyDiv1').style.display='none';
		g('CompanyDiv2').style.display='none';
		g('CompanyDiv3').style.display='none';
	}else{
		g('CompanyDiv1').style.display='block';
		g('CompanyDiv2').style.display='block';
		g('CompanyDiv3').style.display='inline';
	}              
}


function getCity(province,name,dom){
	createXMLHttpRequest('city');
	xmlHttp['city'].open("get", '/register/ajax_get_city/'+province+'/'+name, false);
	xmlHttp['city'].send(null);

	if(xmlHttp['city'].status == 200){                
		text=xmlHttp['city'].responseText.split("[|]");
		g(dom).innerHTML=text[0];
	}else{
		alert('AJAX ERROR !');
	}
}

function getShop2Type(shoptype,name,dom){
	createXMLHttpRequest('shoptype');
	xmlHttp['shoptype'].open("get", '/register/ajax_get_shop2type/'+shoptype+'/'+name, false);
	xmlHttp['shoptype'].send(null);

	if(xmlHttp['shoptype'].status == 200){                
		text=xmlHttp['shoptype'].responseText.split("[|]");
		g(dom).innerHTML=text[0];
	}else{
		alert('AJAX ERROR !');
	}
}


function validateusername(Username){ 
	checkUsername=false;
	createXMLHttpRequest('indexusername');
	xmlHttp['indexusername'].open("get", "/register/ajax_get_username/"+Username, false);
	xmlHttp['indexusername'].send(null);
	
	if(xmlHttp['indexusername'].status == 200){
	text=xmlHttp['indexusername'].responseText.split("[|]");
	if(text[0]=='false'){
		checkUsername=true;  
	}else{
		checkUsername=false; 
	}
	}else{
		alert('AJAX ERROR !');    
	}
}

function checkUsernameFunc(Username){
	var checkThis;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(Username)){
		checkUsername=false;
		validateusername(Username);
		
		if(checkUsername){
			alert('ชื่อผู้ใช้นี้สามารถใช้ได้');
			g('UsernameId').focus();
		}else{
			alert('ไม่สามารถใช้ชื่อผู้ใช้นี้ได้ ชื่อผู้ใช้นี้ถูกใช้งานไปแล้ว');
			g('UsernameId').focus();
		}
					
	}else{
		checkUsername=false;
		  alert('กรุณาใส่ ชื่อผู้ใช้ให้ถูกต้อง ในรูปแบบของ อีเมล์');
		g('UsernameId').focus();
	}
	checkThis=checkUsername;
	checkUsername=false;
	return checkThis;
}

function checkUsernameFunc2(Username){
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(Username)){
		checkUsername=true;			
	}else{
		checkUsername=false;
	}
	return checkUsername;
}


function validateshopurl(url){ 
	checkURL=false;               
	createXMLHttpRequest('indexurl');
	xmlHttp['indexurl'].open("get", "/register/ajax_get_url/"+url, false);
	xmlHttp['indexurl'].send(null);
	if(xmlHttp['indexurl'].status == 200){
					text=xmlHttp['indexurl'].responseText.split("[|]");
									if(text[0]=='false'){
													checkURL=true;                
									}else{
													checkURL=false;               
									}
	}else{
					alert('AJAX ERROR !');    
	}
}

function checkURLFunc(ShopURL){
	var checkThis;
	if(g('ShopURL').value.length>=3){
		if(g('ShopURL').value.indexOf(' ') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย &');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('&') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย &');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('/') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย /');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('\\') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย \\');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf(',') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย ,');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('{') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย {');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('}') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย }');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('(') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย (');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf(')') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย )');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('*') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย *');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('+') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย +');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('%') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย %');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('$') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย $');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('#') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย #');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('!') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย !');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('?') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย ?');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('^') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย ^');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('=') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย =');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('[') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย [');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf(']') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย ]');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('|') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย |');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('\'') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย \'');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('\"') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย \"');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf(':') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย :');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf(';') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย ;');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('<') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย <');
			g('ShopURL').focus();
		}else if(g('ShopURL').value.indexOf('>') >= 0){
			checkURL=false;
			alert('กรุณาใส่ ชื่อร้านให้ถูกต้อง ภาษาอังกฤษและห้ามมีเครื่องหมาย >');
			g('ShopURL').focus();
		}else{
			checkURL=false;
			validateshopurl(ShopURL);
			if(checkURL){
							alert('ชื่อร้านนี้ี้สามารถใช้ได้');
							g('ShopURL').focus();
			}else{
							alert('ไม่สามารถใช้ชื่อร้านนี้ได้ ชื่อร้านนี้ถูกใช้งานไปแล้ว');
							g('ShopURL').focus();
			}	
		}
	}else{
		checkURL=false;
		alert('กรุณาใส่ ชื่อร้านค้า ตั้งแต่ 3 ตัวอักษรขึ้นไป');
		g('ShopURL').focus();	
	}
	checkThis=checkURL;
	checkURL=false;
	return checkThis;
}

function checkURLFunc2(ShopURL){
	var checkURL=false;
	if(g('ShopURL').value.length>=3){
		if(g('ShopURL').value.indexOf(' ') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('&') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('/') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('\\') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf(',') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('{') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('}') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('(') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf(')') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('*') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('+') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('%') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('$') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('#') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('!') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('?') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('^') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('=') >= 0){
			checkURL=false;	
		}else if(g('ShopURL').value.indexOf('[') >= 0){
			checkURL=false;	
		}else if(g('ShopURL').value.indexOf(']') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('|') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('\'') >= 0){
			checkURL=false;	
		}else if(g('ShopURL').value.indexOf('\'') >= 0){
			checkURL=false;	
		}else if(g('ShopURL').value.indexOf(':') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf(';') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('<') >= 0){
			checkURL=false;
		}else if(g('ShopURL').value.indexOf('>') >= 0){
			checkURL=false;
		}else{
			checkURL=true;
		}
	}else{
		checkURL=false;
	}
	return checkURL;
}


function validate(type,text){
   if(type=='email'){
                                var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                                return reg.test(text);
   }else if(type=='number'){
                    var IsFound = /^-?\d+$/.test(text);
        return IsFound;
   }else if(type=='english'){
                    var IsEnglish = text.match('/^[a-zA-Z \.\!\?]*$/');
                                return IsEnglish;
   }else if(type=='blank'){
                   var IsBlank = (text.length>0);
                   return IsBlank;
   }else if(type=='char6'){
                   var IsBlank = (text.length>=6);
                   return IsBlank;
   }else{
                   var IsBlank = (text.length>0);
                   return IsBlank;
   }
                return false;
}

function validatePass(text1,text2){
                if(text1==text2){
                                return false;
                }else{
                                return true;
                }
}

function validateThaiID(id){
                if(id.length != 13) return false;
                for(i=0, sum=0; i < 12; i++)
                sum += parseFloat(id.charAt(i))*(13-i); if((11-sum%11)%10!=parseFloat(id.charAt(12)))
                return false; return true;
}



function confirmSubmit(){
                validateusername(g('UsernameId').value);
                validateshopurl(g('ShopURL').value);
				if(!validate('blank',g('PackageId').value)){
                                alert('กรุณาเลือก แพ็กเกจของร้านค้า');
                                g('PackageId').focus();
                                return false;
                }else if(!validate('email',g('UsernameId').value)){
                                alert('กรุณาใส่ ชื่อผู้ใช้ให้ถูกต้อง ในรูปแบบของ อีเมล์');
                                g('UsernameId').focus();
                                return false;
                }else if(!checkUsername){
                                alert('ไม่สามารถใช้ชื่อผู้ใช้นี้ได้ ชื่อผู้ใช้นี้ถูกใช้งานไปแล้ว');
                                g('UsernameId').focus();
                                return false;
                }else if(!validate('blank',g('PasswordId').value) || g('PasswordId').value.length<6){
                                alert('กรุณาใส่ รหัสผ่าน ตั้งแต่ 6 ตัวอักษรขึ้นไป');
                                g('PasswordId').focus();
                                return false;
                }else if(!validate('blank',g('PasswordId2').value) || g('PasswordId2').value.length<6){
                                alert('กรุณาใส่ ยืนยันรหัสผ่านให้ตรงกัน 6 ตัวอักษรขึ้นไป');
                                g('PasswordId2').focus();
                                return false;
                }else if(!validatePass(g('PasswordId').value,('Password2').value)){
                                alert('ยืนยันรหัสผ่านไม่ถูกต้อง กรุณาตรวจสอบอีกครั้ง');
                                g('PasswordId2').focus();
                                return false;
                }else if((!g('BusinessType1').checked) && (!g('BusinessType2').checked)){
                                alert('กรุณาเลือก ประเภทธุรกิจร้านค้า');
                                g('BusinessType1').focus();
                                return false;
                }else if(!validate('blank',g('FirstName').value)){
                                alert('กรุณาใส่ ชื่อ');
                                g('FirstName').focus();
                                return false;
                }else if(!validate('blank',g('LastName').value)){
                                alert('กรุณาใส่ นามสกุล');
                                g('LastName').focus();
                                return false;
                }else if((!g('Gender1').checked) && (!g('Gender2').checked)){
                                alert('กรุณาเลือก เพศของท่าน');
                                g('Gender1').focus();
                                return false;
                }else if(!validate('blank',g('BirthDateDay').value)){
                                alert('กรุณาเลือก วัน');
                                g('BirthDateDay').focus();
                                return false;
                }else if(!validate('blank',g('BirthDateMonth').value)){
                                alert('กรุณาเลือก เดือน');
                                g('BirthDateMonth').focus();
                                return false;
                }else if(!validate('blank',g('BirthDateYear').value)){
                                alert('กรุณาเลือก ปี');
                                g('BirthDateYear').focus();
                                return false;
                }else if(!validate('email',g('Email').value)){
                                alert('กรุณาใส่ Email ให้ถูกต้อง');
                                g('Email').focus();
                                return false;
                }else if(!validate('blank',g('AddressDesc').value)){
                                alert('กรุณาใส่ ที่อยู่');
                                g('AddressDesc').focus();
                                return false;
                }else if(!validate('blank',g('ProvinceId').value)){
                                alert('กรุณาเลือก จังหวัด');
                                g('ProvinceId').focus();
                                return false;
                }else if(!validate('blank',g('CityId').value)){
                                alert('กรุณาเลือก เขตหรืออำเภอ');
                                g('CityId').focus();
                                return false;
                }else if(!validate('blank',g('ZipCode').value)){
                                alert('กรุณาใส่ รหัสไปรษณีย์');
                                g('ZipCode').focus();
                                return false;
                }else if(!validate('number',g('Mobile').value)){
                                alert('กรุณาใส่ เบอร์โทรศัพท์มือถือให้ถูกต้อง');
                                g('Mobile').focus();
                                return false;
                }else if(!validate('number',g('IdCardNumber').value)){
                                alert('กรุณาใส่ เลขที่บัตรประจำตัวประชาชนให้ถูกต้อง 13 หลัก');
                                g('IdCardNumber').focus();
                                return false;
                }else if(!validateThaiID(g('IdCardNumber').value)){
                                alert('กรุณาใส่ เลขที่บัตรประจำตัวประชาชนให้ถูกต้องตามความเป็นจริง 13 หลัก');
                                g('IdCardNumber').focus();
                                return false;
                }else if((!g('ProductType1').checked) && (!g('ProductType2').checked) && (!g('ProductType3').checked)){
                                alert('กรุณาเลือก ประเภทของสินค้า');
                                g('ProductType1').focus();
                                return false;
                }else if(!validate('blank',g('ShopTypeId').value)){
                                alert('กรุณาเลือก หมวดหมู่ร้านค้า');
                                g('ShopTypeId').focus();
                                return false;
                }else if(!validate('blank',g('Shop2TypeId').value)){
                                alert('กรุณาเลือก หมวดหมู่สินค้า');
                                g('Shop2TypeId').focus();
                                return false;
                }else if(!validate('blank',g('ShopName').value)){
                                alert('กรุณาใส่ ชื่อร้านภาษาไทย');
                                g('ShopName').focus();
                                return false;
                }else if(!validate('blank',g('ShopURL').value)){
                                alert('กรุณาใส่ ชื่อร้านภาษาอังกฤษ');
                                g('ShopURL').focus();
                                return false;
                }else if(!checkURLFunc2(g('ShopURL').value)){
                                alert('กรุณาใส่ ชื่อร้านภาษาอังกฤษ ห้ามเว้นวรรค');
                                g('ShopURL').focus();
                                return false;
                }else if(!checkURL){
                                alert('ไม่สามารถใช้ชื่อร้านนี้ได้ ชื่อร้านนี้ถูกใช้งานไปแล้ว หรือรูปแบบผิด');
                                g('ShopURL').focus();
                                return false;
                }else if(!checkURLFunc(g('ShopURL').value)){
                                alert('ไม่สามารถใช้ชื่อร้านนี้ได้ หรือรูปแบบผิด');
                                g('ShopURL').focus();
                                return false;
                }else if(!validate('blank',g('ProductDesc').value)){
                                alert('กรุณาใส่ สินค้า/บริการของร้าน');
                                g('ProductDesc').focus();
                                return false;
                }else if(!validate('blank',g('ShopDesc').value)){
                                alert('กรุณาใส่ รายละเอียดร้านค้า');
                                g('ShopDesc').focus();
                                return false;
                }else if(!validate('blank',g('CompanyName').value) && g('BusinessType2').checked){
                                alert('กรุณาใส่ ชื่อบริษัท');
                                g('CompanyName').focus();
                                return false;
                }else if(!validate('blank',g('ShopAddressDesc').value)){
                                alert('กรุณาใส่ ที่ตั้งของร้านค้า');
                                g('ShopAddressDesc').focus();
                                return false;
                }else if(!validate('blank',g('ShopProvinceId').value)){
                                alert('กรุณาเลือก จังหวัดร้านค้า');
                                g('ShopProvinceId').focus();
                                return false;
                }else if(!validate('blank',g('ShopCityId').value)){
                                alert('กรุณาเลือก อำเภอหรือเขตของร้านค้า');
                                g('ShopCityId').focus();
                                return false;
                }else if(!validate('number',g('ShopZipCode').value)){
                                alert('กรุณาใส่ รหัสไปรษณีย์ของร้านค้าให้ถูกต้อง');
                                g('ShopZipCode').focus();
                                return false;
                }else if(!validate('number',g('ShopTel').value) && g('BusinessType2').checked){
                                alert('กรุณาใส่ เบอร์โทรศัพท์ของร้านค้า');
                                g('ShopTel').focus();
                                return false;
                }else if(!validate('email',g('ShopEmail').value)){
                                alert('กรุณาใส่ Email ของร้านค้าให้ถูกต้อง');
                                g('ShopEmail').focus();
                                return false;
                }else{
                                if(window.confirm('ยืนยันการลงทะเบียน')==true){
                                                return true;
                                }else{
                                                return false;
                                }
                                return false;
                }
                return false;
}


function confirmSubmitEdit(){
                
                if((!g('frmRegister').BusinessType1.checked) && (!g('frmRegister').BusinessType2.checked)){
                                alert('กรุณาเลือก ประเภทธุรกิจร้านค้า');
                                g('frmRegister').BusinessType1.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').FirstName.value)){
                                alert('กรุณาใส่ ชื่อ');
                                g('frmRegister').FirstName.focus();
                                return false;
                } if(!validate('blank',g('frmRegister').LastName.value)){
                                alert('กรุณาใส่ นามสกุล');
                                g('frmRegister').LastName.focus();
                                return false;
                }else if((!g('frmRegister').Gender1.checked) && (!g('frmRegister').Gender2.checked)){
                                alert('กรุณาเลือก เพศของท่าน');
                                g('frmRegister').Gender1.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').BirthDateDay.value)){
                                alert('กรุณาเลือก วัน');
                                g('frmRegister').BirthDateDay.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').BirthDateMonth.value)){
                                alert('กรุณาเลือก เดือน');
                                g('frmRegister').BirthDateMonth.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').BirthDateYear.value)){
                                alert('กรุณาเลือก ปี');
                                g('frmRegister').BirthDateYear.focus();
                                return false;
                }else if(!validate('email',g('frmRegister').Email.value)){
                                alert('กรุณาใส่ Email ให้ถูกต้อง');
                                g('frmRegister').Email.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').AddressDesc.value)){
                                alert('กรุณาใส่ ที่อยู่');
                                g('frmRegister').AddressDesc.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').ProvinceId.value)){
                                alert('กรุณาเลือก จังหวัด');
                                g('frmRegister').ProvinceId.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').CityId.value)){
                                alert('กรุณาเลือก เขตหรืออำเภอ');
                                g('frmRegister').CityId.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').ZipCode.value)){
                                alert('กรุณาใส่ รหัสไปรษณีย์');
                                g('frmRegister').ZipCode.focus();
                                return false;
                }else if(!validate('number',g('frmRegister').Tel.value)){
                                alert('กรุณาใส่ เบอร์โทรศัพท์ให้ถูกต้อง');
                                g('frmRegister').Tel.focus();
                                return false;
                }else if(!validate('number',g('frmRegister').Mobile.value)){
                                alert('กรุณาใส่ เบอร์โทรศัพท์มือถือให้ถูกต้อง');
                                g('frmRegister').Mobile.focus();
                                return false;
                }else if(!validate('number',g('frmRegister').IdCardNumber.value)){
                                alert('กรุณาใส่ เลขที่บัตรประจำตัวประชาชนให้ถูกต้อง 13 หลัก');
                                g('frmRegister').IdCardNumber.focus();
                                return false;
                }else if(!validateThaiID(g('frmRegister').IdCardNumber.value)){
                                alert('กรุณาใส่ เลขที่บัตรประจำตัวประชาชนให้ถูกต้องตามความเป็นจริง 13 หลัก');
                                g('frmRegister').IdCardNumber.focus();
                                return false;
                }else if((!g('frmRegister').ProductType1.checked) && (!g('frmRegister').ProductType2.checked) && (!g('frmRegister').ProductType3.checked)){
                                alert('กรุณาเลือก ประเภทของสินค้า');
                                g('frmRegister').ProductType1.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').ShopTypeId.value)){
                                alert('กรุณาเลือก หมวดหมู่ร้านค้า');
                                g('frmRegister').ShopTypeId.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').Shop2TypeId.value)){
                                alert('กรุณาเลือก หมวดหมู่สินค้า');
                                g('frmRegister').Shop2TypeId.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').ShopName.value)){
                                alert('กรุณาใส่ ชื่อร้านภาษาไทย');
                                g('frmRegister').ShopName.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').ShopURL.value)){
                                alert('กรุณาใส่ ชื่อร้านภาษาอังกฤษ');
                                g('frmRegister').ShopURL.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').CompanyName.value)){
                                alert('กรุณาใส่ ชื่อบริษัท');
                                g('frmRegister').CompanyName.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').ProductDesc.value)){
                                alert('กรุณาใส่ สินค้า/บริการของร้าน');
                                g('frmRegister').ProductDesc.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').ShopDesc.value)){
                                alert('กรุณาใส่ รายละเอียดร้านค้า');
                                g('frmRegister').ShopDesc.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').ShopProvinceId.value)){
                                alert('กรุณาเลือก จังหวัดร้านค้า');
                                g('frmRegister').ShopProvinceId.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').ShopCityId.value)){
                                alert('กรุณาเลือก อำเภอหรือเขตของร้านค้า');
                                g('frmRegister').ShopCityId.focus();
                                return false;
                }else if(!validate('number',g('frmRegister').ShopZipCode.value)){
                                alert('กรุณาใส่ รหัสไปรษณีย์ของร้านค้าให้ถูกต้อง');
                                g('frmRegister').ShopZipCode.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').ShopAddressDesc.value)){
                                alert('กรุณาใส่ ที่ตั้งของร้านค้า');
                                g('frmRegister').ShopAddressDesc.focus();
                                return false;
                }else if(!validate('number',g('frmRegister').ShopTel.value)){
                                alert('กรุณาใส่ เบอร์โทรศัพท์ของร้านค้า');
                                g('frmRegister').ShopTel.focus();
                                return false;
                }else if(!validate('email',g('frmRegister').ShopEmail.value)){
                                alert('กรุณาใส่ Email ของร้านค้าให้ถูกต้อง');
                                g('frmRegister').ShopEmail.focus();
                                return false;
                }else if(!validate('blank',g('frmRegister').PackageId.value)){
                                alert('กรุณาเลือก แพคเกจของร้านค้า');
                                g('frmRegister').PackageId.focus();
                                return false;
                }else {
                                if(window.confirm('ยืนยันการลงทะเบียน')==true){
                                                return true;
                                }else{
                                                return false;
                                }
                                return false;
                }
                return false;
}
