function numbersOnly(e) {
      var evt = (e) ? e : window.event;
      var key = (evt.keyCode) ? evt.keyCode : evt.which;

      if(key != null) {
        key = parseInt(key, 10);

        if((key < 48 || key > 57) && (key < 96 || key > 105)) {
          if(!isUserFriendlyChar(key))
            return false;
        }
        else {
          if(evt.shiftKey)
            return false;
        }
      }

      return true;
    }

function isUserFriendlyChar(val) {
  // Backspace, Tab, Enter, Insert, and Delete
  if(val == 8 || val == 9 || val == 13 || val == 45 || val == 46)
	return true;

  // Ctrl, Alt, CapsLock, Home, End, and Arrows
  if((val > 16 && val < 21) || (val > 34 && val < 41))
	return true;

  // The rest
  return false;
}






function checkValidateQuotation() 
{	
	var checkform = 0;
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	//Check standard
	var hasChecked = false;
	for(var i=1;i<16;i++)
	{
		if($("checkbox" + i).checked === true)
		{
			hasChecked = true;
		}
	}
	
	if($("In_Title").selectedIndex == 0)
	{
		checkform = 1;
		alert("Đề nghị đưa vào Chức danh") ;
		$("In_Title").focus() ;
	}
	else if($("In_FirstName").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Họ") ;
		$("In_FirstName").focus() ;
	}
	else if($("In_LastName").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Tên") ;
		$("In_LastName").focus() ;
	}
	else if($("In_Phone").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào điện thoại") ;
		$("In_Phone").focus() ;
	}
	
	else if($("In_Email").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Email") ;
		$("In_Email").focus() ;
	}
	else if(!filter.test($("In_Email").value))
	{
		checkform = 1 ;
		alert("Invalid E-mail !!") ;
		$("In_Email").focus() ;
	}
	
	else if($("In_Company").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Tên Công ty") ;
		$("In_Company").focus() ;
	}
	else if($("In_Address1").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Địa chỉ") ;
		$("In_Address1").focus() ;
	}
	else if($("In_Town").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Thị xã") ;
		$("In_Town").focus() ;
	}
	
	else if($("In_City").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Thành phố") ;
		$("In_City").focus() ;
	}
	else if($("In_Country").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Quốc gia") ;
		$("In_Country").focus() ;
	}
	else if($("In_PostCode").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Post Code") ;
		$("In_PostCode").focus() ;
	}
	else if(hasChecked == false)
	{
		checkform = 1;
		alert("Đề nghị đưa vào Tiêu chuẩn") ;
	}
	
	else if($("scope").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Phạm vi") ;
		$("scope").focus() ;
	}
	else if($("noofemployee").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Số lượng nhân viên") ;
		$("noofemployee").focus() ;
	}
	else if($("nooflocation").selectedIndex == 0)
	{
		checkform = 1;
		alert("Đề nghị đưa vào Số địa điểm") ;
		$("nooflocation").focus() ;
	}

	
	
	
	if (checkform == 1)
	{	
		return false;	
	} else {
		return confirm_alert();
	}	
}

function checkValidateTranferCer() 
{	
	var checkform = 0;
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	
	
	if($("Tr_Title").selectedIndex == 0)
	{
		checkform = 1;
		alert("Đề nghị đưa vào Chức danh") ;
		$("Tr_Title").focus() ;
	}
	else if($("Tr_FirstName").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Họ và tên người liên hệ") ;
		$("Tr_FirstName").focus() ;
	}
	else if($("Tr_Phone").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Điện thoại") ;
		$("Tr_Phone").focus() ;
	}
	else if($("Tr_Email").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Email Address") ;
		$("Tr_Email").focus() ;
	}
	else if(!filter.test($("Tr_Email").value))
	{
		checkform = 1 ;
		alert("Invalid E-mail !!") ;
		$("Tr_Email").focus() ;
	}
	else if($("Tr_Company").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Tên Công ty") ;
		$("Tr_Company").focus() ;
	}
	else if($("Tr_Address1").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Địa chỉ") ;
		$("Tr_Address1").focus() ;
	}
	else if($("Tr_Town").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Tỉnh/Thành phố") ;
		$("Tr_Town").focus() ;
	}
	else if($("Tr_CurrentBody").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Đã được chứng nhận bởi") ;
		$("Tr_CurrentBody").focus() ;
	}
	else if($("Tr_AssessDate").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Ngày cấp chứng nhận") ;
		$("Tr_AssessDate").focus() ;
	}
	else if($("Tr_ExpiryDate").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Ngày hết hiệu lực chứng nhận") ;
		$("Tr_ExpiryDate").focus() ;
	}
	else if($("Tr_SurvDate").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Ngày giám sát gần nhất") ;
		$("Tr_SurvDate").focus() ;
	}
	else if($("Tr_Standard").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Tiêu chuẩn áp dụng") ;
		$("Tr_Standard").focus() ;
	}
	else if($("Tr_Scope").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Phạm vi (ghi trên chứng chỉ)") ;
		$("Tr_Scope").focus() ;
	}
	else if($("Tr_Locations").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Số địa điểm") ;
		$("Tr_Locations").focus() ;
	}
	else if($("Tr_Employees").value =="")
	{
		checkform = 1;
		alert("Đề nghị đưa vào Số lượng nhân viên") ;
		$("Tr_Employees").focus() ;
	}
	else if($("Tr_Reason").selectedIndex == 0)
	{
		checkform = 1;
		alert("Đề nghị đưa vào Lý do chuyển đổi") ;
		$("Tr_Reason").focus() ;
	}

	
	
	
	if (checkform == 1)
	{	
		return false;	
	} else {
		return confirm_alert();
	}	
}


