﻿/**Javascript*/
function dangky()
{		
	var form 		= document.frm;
	//Ho ten
	checkTextLength(form.sMname.value,2,100,form.sMname,FULL_NAME_INVALID);
	if(!checkAll())	return false;
	
	//Dia chi
	checkTextLength(form.sMaddress.value,2,100,form.sMaddress,ADD_INVALID);
	if(!checkAll())	return false;
	//dien thoai
	//if(form.sMtel.value != '')
		checkTelePhone(form.sMtel.value,form.sMtel,TELL_INVALID);
	if(!checkAll())	return false;
	//ngay sinh
	if(!checkDate(form.sMdbirthday.value,form.sMmbirthday.value,form.sMybirthday.value,BIRTHDAY_INVALID))
	{
		if(hasFocus==false)
		{
			hasFocus=true;
			form.sMdbirthday.focus();
		}	
	}
	if(!checkAll())	return false;
	//email
	if(form.sMemail.value != '')	
		CheckFullEmail(form.sMemail.value,form.sMemail,EMAIL_INVALID);
	if(!checkAll())	return false;
	//ho ten
	/*checkTextLength(form.sSname.value,2,100,form.sSname,FULL_NAME_INVALID);
	if(!checkAll())	return false;
	//ngay sinh
	if(!checkDate(form.sSdbirthday.value,form.sSmbirthday.value,form.sSybirthday.value,BIRTHDAY_INVALID))
	{
		if(hasFocus==false)
		{
			hasFocus=true;
			form.sSdbirthday.focus();
		}	
	}*/
	if(!checkAll())	return false;
	//ten cha
	if(form.sSfathername.value != '')
		checkTextLength(form.sSfathername.value,2,100,form.sSfathername,FULL_NAME_INVALID);
	if(!checkAll())	return false;
	//ten me
	if(form.sSmothername.value != '')
		checkTextLength(form.sSmothername.value,2,100,form.sSname,FULL_NAME_INVALID);
	if(!checkAll())	return false;
	//file goi kem		
	filename = form.sFilename.value;
	if(filename !='')
	{
		if (!check_file_ext(filename))
		{
			errormsg = errormsg + FILE_INVALD + '\n';
			if(hasFocus==false)
			{
				hasFocus=true;
				form.sFilename.focus();
			}		
		}
		if (!check_file_size(filename))
		{
			errormsg = errormsg + FILE_INVALD + '\n';
			if(hasFocus==false)
			{
				hasFocus=true;
				form.sFilename.focus();
			}
		}
	}
	//update by Phan Quang Dung 
	//ngay 11/10/2007
	filename2 = form.sFilename2.value;
	if(filename2 !='')
	{
		if (!check_file_ext(filename2))
		{
			errormsg = errormsg + FILE_INVALD + '\n';
			if(hasFocus==false)
			{
				hasFocus=true;
				form.sFilename2.focus();
			}		
		}
		if (!check_file_size(filename2))
		{
			errormsg = errormsg + FILE_INVALD + '\n';
			if(hasFocus==false)
			{
				hasFocus=true;
				form.sFilename2.focus();
			}
		}
	}
	
	filename3 = form.sFilename3.value;
	if(filename3 !='')
	{
		if (!check_file_ext(filename3))
		{
			errormsg = errormsg + FILE_INVALD + '\n';
			if(hasFocus==false)
			{
				hasFocus=true;
				form.sFilename3.focus();
			}		
		}
		if (!check_file_size(filename3))
		{
			errormsg = errormsg + FILE_INVALD + '\n';
			if(hasFocus==false)
			{
				hasFocus=true;
				form.sFilename3.focus();
			}
		}
	}
	//end update
	
	if(!checkAll())	return false;
	//ho ten
	//checkTextLength(form.sSreason.value,10,1000,form.sSreason,REASON_INVALD);
	//if(!checkAll())	return false;
	checkImageSecurity(form.sImagesecurity,3,IMAGE_INVALD,true);
	if(!checkAll())	return false;
	if(form.sImagesecurity.value.toLowerCase() != form.imgSecurity.value.toLowerCase())
	{
		errormsg=errormsg+IMAGE_INVALD;
		if(hasFocus==false)
		{
			hasFocus=true;
			form.sImagesecurity.focus();
		}		
	}
	if(!checkAll())	return false;
	//
	if(checkAll()){	
		form.submit();
		return true;
	}
	return false;
}

