var postExistJavaScript = ' » Tin của bạn đã đăng rồi\n » Không đăng liên tiếp cùng một nội dung\n » Bạn có thể đăng lặp lại bản tin này sau 15 phút\n » Nếu vi nhiều lần tất cả tin đăng sẽ bi xóa';
var postOk = "Tin của bạn đã được đăng";
var postNotOk = " » Đăng tin xảy ra lỗi\n » Xem hướng dẫn và quy định khi đăng tin";
var messFullName = "Vui lòng nhập họ và tên";

var messcompanyName = "Vui lòng nhập tên doanh nghiệp";
var messAddress = "Vui lòng nhập địa chỉ";
var messLocation = "Vui lòng chọn Tỉnh / Thành phố";
var messTelephone = "Vui lòng nhập số điện thoại liên lạc";
var messContact = "Vui lòng nhập họ tên người liên hệ";
var messCareer = "Vui lòng chọn ngành nghề";
var messCompanyIntro = "Vui lòng nhập phần giới thiệu doanh nghiệp"; 
var messEmail = "Vui lòng nhập địa chỉ email sẽ dùng để đăng nhập";
var messPassword = "Vui lòng nhập mật khẩu dùng để đăng nhập";
var messconfirmPassword = "Mật khẩu xác nhận không đúng.\nXin nhập giống với mật khẩu đăng nhập";
var messSex = "Vui lòng chọn giới tính";

var messBody = "Vui lòng nhập nội dung";
var messFullNameSender = "Vui lòng nhập tên người gởi";
var messEmailSender = "Vui lòng nhập email người gởi";
var messFullNameReceiver = "Vui lòng nhập tên người nhận";
var messEmailReceiver = "Vui lòng nhập email người nhận";
var messEmailInvalid = "Email không hợp lệ";
var messSearch = "Nhập vào nội dung tìm kiếm";


if(document.images)	{
	on = new Image;
	off = new Image;
	sel = new Image;
	on.src = 'images/imgBulletRedNew1.gif';
	off.src='images/imgBulletBlack.gif';
	sel.src='images/imgBulletBlue.gif';
	
	smallOn = new Image;
	smallOff = new Image;
	
	smallOn.src ='images/imgBulletRedNew1.gif';
	smallOff.src ='images/imgBulletBlack.gif';
	
	memOn = new Image;
	memOff = new Image;
	
	memOn.src = 'images/imgBulletRedNew1.gif';
	memOff.src = 'images/imgBulletBlack.gif'; 
	
	folderOn = new Image;
	folderOff = new Image;
	folderOn.src = "images/imgFolderOpen1.gif";
	folderOff.src = "images/imgFolderOpen.gif";
	
}
    /*****************************************/
    function GetPostVariable(vName, vDef){
	var	str=location.href;
	var	pos=str.indexOf('?'.concat(vName).concat('='));

	if (pos==-1)
	{
		pos=str.indexOf('&'.concat(vName).concat('='));
		if (pos==-1) return vDef;
	}

	str=str.substring(pos + vName.length + 2);
	pos=str.indexOf('&');

	if (pos==-1)
	{
		pos=str.length;
	}

	if (pos > 0){
		str=str.substring(0, pos);
	}

	return str;
	}

    /*****************************************/

function checkChangePassword(f) {
	oldPassword = f.old_password.value;
	if(oldPassword == ''){
		alert('Vui lòng nhập mật khẩu củ');
		f.old_password.focus();
		return false;
	}
	newPassword1 = f.new_password1.value;
	if(newPassword1 == '') {
		alert('Vui lòng nhập mật khẩu mới');
		f.new_password1.focus();
		return false;
	}
	newPassword2 = f.new_password2.value;
	if (newPassword2 != newPassword1) {
		alert('Nhập lại mật khẩu mới không đúng');
		f.new_password2.focus();
		return false;
	}
}

function checkForm(f) {
	var user_email = f.user_email.value;
	var err=''
	if (Trim(user_email) == ''){
		err += messEmailInvalid;
		alert(err);
		f.user_email.focus();
		return false;
	}
	if (user_email.indexOf('@') <= 0 || user_email.indexOf('@') == user_email.length -1){
		err += messEmailInvalid;
	} else {
		var substr = user_email.substring(user_email.indexOf('@'),user_email.length);
		if (user_email.indexOf('.') <= 0) {
			err += messEmailInvalid;
		}
	}
	if (err != '') {
		alert(err);
		f.user_email.focus();
		return false;
	}
	var pass = f.user_password.value;
	if (Trim(pass) == '') {
		alert(messPassword);
		f.user_password.focus();
		return false;
	}
	return true;
}


function showStatus() {
		window.status='® http://www.ALLonlines.com';
}
function checkTextBoxSearch (str) {
	var textVal = str.value;	
	if (Trim(textVal) == '') {
		alert(messSearch);
		str.focus();
		return false;
	}
	return true;
}
function checkPassword(str) {
	var textVal = str.value;	
	if (Trim(textVal) == '') {
		alert(messPassword);
		str.focus();
		return false;
	}
	return true;

}
function checkEmail(str){
	var textValue = str.value;
	var err=''
	if (Trim(textValue) == ''){
		err += messEmailInvalid;
		alert(err);
		str.focus();
		return false
	}
	if (textValue.indexOf('@') <= 0 || textValue.indexOf('@') == textValue.length -1){
		err += messEmailInvalid;		
	} else {
		var substr = textValue.substring(textValue.indexOf('@'),textValue.length);
		if (textValue.indexOf('.') <= 0) {
			err += messEmailInvalid;
		}
	}
	if (err != '') { 
		alert(err); 
		str.focus();
		return false;
	}
	return true;
}

function fnCategories(whereId){
		
	var url = "index_raovat.php?";
	var catId = GetPostVariable('cat_id');
	if (catId !=undefined) {
		url = url + "cat_id=" + catId;
	}
	var subCatId = GetPostVariable('sub_cat_id');
	

	if (subCatId !=undefined){
		url = url + "&sub_cat_id=" + subCatId;
	}	

	var isSub = GetPostVariable('is_sub');
	if(isSub !=undefined)  {
		url = url + "&is_sub=" + isSub;
	}

	var title = GetPostVariable('title');
	
	if (title !=undefined) {
		url = url + "&title=" + title;
	}
	
	var titleType = GetPostVariable('title_type');
	
	if (titleType !=undefined) {
		url = url + "&title_type=" + titleType;
	}
	var typePost = GetPostVariable('type_post');
	if (typePost !=undefined) {
		url = url + "&type_post=" + typePost;
	}
	
	url = url + "&where_id="+ whereId;
	
	document.location = url;
}	

function fnLogoCity(whereId){
		
	var url = "index_logo.php?";
	var catId = GetPostVariable('cat_id');
	if (catId !=undefined) {
		url = url + "cat_id=" + catId;
	}
	var subCatId = GetPostVariable('sub_cat_id');
	

	if (subCatId !=undefined){
		url = url + "&sub_cat_id=" + subCatId;
	}	

	var isSub = GetPostVariable('is_sub');
	if(isSub !=undefined)  {
		url = url + "&is_sub=" + isSub;
	}

	var title = GetPostVariable('title');
	
	if (title !=undefined) {
		url = url + "&title=" + title;
	}
	
	var titleType = GetPostVariable('title_type');
	
	if (titleType !=undefined) {
		url = url + "&title_type=" + titleType;
	}
	var typePost = GetPostVariable('type_post');
	if (typePost !=undefined) {
		url = url + "&type_post=" + typePost;
	}
	
	url = url + "&where_id="+ whereId;
	
	document.location = url;
}	

function fnPromotionCity(whereId){
		
	var url = "index_promotion.php?";
	var catId = GetPostVariable('cat_id');
	if (catId !=undefined) {
		url = url + "cat_id=" + catId;
	}
	var subCatId = GetPostVariable('sub_cat_id');
	

	if (subCatId !=undefined){
		url = url + "&sub_cat_id=" + subCatId;
	}	

	var isSub = GetPostVariable('is_sub');
	if(isSub !=undefined)  {
		url = url + "&is_sub=" + isSub;
	}

	var title = GetPostVariable('title');
	
	if (title !=undefined) {
		url = url + "&title=" + title;
	}
	
	var titleType = GetPostVariable('title_type');
	
	if (titleType !=undefined) {
		url = url + "&title_type=" + titleType;
	}
	var typePost = GetPostVariable('type_post');
	if (typePost !=undefined) {
		url = url + "&type_post=" + typePost;
	}
	
	url = url + "&where_id="+ whereId;
	
	document.location = url;
}	

function fnProductCity(whereId){
		
	var url = "index_product.php?";
	var catId = GetPostVariable('cat_id');
	if (catId !=undefined) {
		url = url + "cat_id=" + catId;
	}
	var subCatId = GetPostVariable('sub_cat_id');
	

	if (subCatId !=undefined){
		url = url + "&sub_cat_id=" + subCatId;
	}	

	var isSub = GetPostVariable('is_sub');
	if(isSub !=undefined)  {
		url = url + "&is_sub=" + isSub;
	}

	var title = GetPostVariable('title');
	
	if (title !=undefined) {
		url = url + "&title=" + title;
	}
	
	var titleType = GetPostVariable('title_type');
	
	if (titleType !=undefined) {
		url = url + "&title_type=" + titleType;
	}
	var typePost = GetPostVariable('type_post');
	if (typePost !=undefined) {
		url = url + "&type_post=" + typePost;
	}
	
	url = url + "&where_id="+ whereId;
	
	document.location = url;
}	

function fnCompanyCity(whereId){
		
	var url = "index_company.php?";
	var catId = GetPostVariable('cat_id');
	
	if (catId !=undefined) {
		url = url + "cat_id=" + catId;
	}
	var subCatId = GetPostVariable('sub_cat_id');
	

	if (subCatId !=undefined){
		url = url + "&sub_cat_id=" + subCatId;
	}	

	var isSub = GetPostVariable('is_sub');
	if(isSub !=undefined)  {
		url = url + "&is_sub=" + isSub;
	}

	var title = GetPostVariable('title');
	
	if (title !=undefined) {
		url = url + "&title=" + title;
	}
	
	var titleType = GetPostVariable('title_type');
	
	if (titleType !=undefined) {
		url = url + "&title_type=" + titleType;
	}
	var typePost = GetPostVariable('type_post');
	if (typePost !=undefined) {
		url = url + "&type_post=" + typePost;
	}
	
	url = url + "&where_id="+ whereId;
	
	document.location = url;
}	

/* IE and NS6+ */
/* begin no click right */
function clickIE() {
	if (document.all) {
		return false;
	}
}
function clickNS(e) {
	if (document.layers||(document.getElementById&&!document.all)) {
		if (e.which==2||e.which==3) {
			return false;
		}
	}
}

/*****************************/

function checkVote(f,num) {
	var len = f.vote.length;
	var checked = false;
	w = 500;
	h = 300;
	var left = (screen.availWidth/2) - (w/2);
	var top = (screen.availHeight/2) - (h/2);

	if(num == "1") {
		window.open('votes.php','vote','width='+w+',height='+h+',scrollbars=0,status=0, left='+left+', top='+top)
		return true;
		
	} else {
		for (var i = 0; i< len; i++) {
			if (f.vote[i].checked==true){
				window.open('votes.php?vote=' + f.vote[i].value,'vote','width='+w+',height='+h+',left='+left+',top='+top);
				return true;
			}
		}
	}
	alert("Chọn mục bạn quan tâm nhất");
	f.vote.focus;
	return false;
}

function isPicture(userfile) {
	if (file !=undefined) {
		var file = userfile.value;
		if (file != '') {

			var len = file.length;
			k= file.indexOf('.');
			str = file.substring(k + 1,len) ;
			result = false;
			switch (str) {
				case "jpg":
					result = true;
					break;
				case "gif":
					result = true;
					break;
				case "png":
					result = true;
					break;
			}
			if (!result) {
				alert('Bạn chỉ upload tập tin: *.jpg,*.gif,*.png');
				return false;
			}
		}
	}
	return true;
}
function checkPostFormOld(f) {
	if (f.sub_cat_id  != undefined) {
		subCatId = f.sub_cat_id.value;
		if (subCatId == 0) {
			alert('Vui lòng chọn mục tin');
			f.sub_cat_id.focus();
			return false;
		}
	}
	if(f.sub_cat_id_mobile != undefined  ) {
		subCatIdMobile = f.sub_cat_id_mobile.value;
		if(subCatIdMobile == 0){
			alert('Vui lòng chọn mục tin');
			f.sub_cat_id_mobile.focus();
			return false;
		}
	}	
	var title = f.txt_title.value;
	if (Trim(title) == "") {
		alert('Vui lòng nhập vào tiêu đề');
		f.txt_title.focus();
		return false;
	}
	var expire = f.txt_expire_id.value;
	if(expire == "0") {
		alert('Vui lòng chọn số ngày đăng tin');
		f.txt_expire_id.focus();
		return false;
	}
	var body = f.txt_body.value;
	if (Trim(body) == "") {
		alert(messBody);
		f.txt_body.focus();
		return false;
	}
	var typePost = f.txt_type_post.value;
	if (typePost == "0") {
		alert('Vui lòng chọn loại tin');
		f.txt_type_post.focus();
		return false;
	}
	var whereId = f.txt_where_id.value;
	if (whereId == "0") {
		alert('Vui lòng chọn nơi đăng');
		f.txt_where_id.focus();
		return false;
	}

	isFile = isPicture(f.userfile1);
	if (!isFile) {
		return false;
	}
	isFile = isPicture(f.userfile2);
	if (!isFile) {
		return false;
	}
	return true;
}
/*
==================================================================
LTrim(string) : Returns a copy of a string without leading spaces.
==================================================================
*/
function LTrim(str)
/*
PURPOSE: Remove leading blanks from our string.
IN: str - the string we want to LTrim
*/
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}

/*
==================================================================
RTrim(string) : Returns a copy of a string without trailing spaces.
==================================================================
*/
function RTrim(str)
/*
   PURPOSE: Remove trailing blanks from our string.
   IN: str - the string we want to RTrim

*/
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...

      var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;


      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}

/*
=============================================================
Trim(string) : Returns a copy of a string without leading or trailing spaces
=============================================================
*/
function Trim(str)
/*
   PURPOSE: Remove trailing and leading blanks from our string.
   IN: str - the string we want to Trim

   RETVAL: A Trimmed string!
*/
{
   return RTrim(LTrim(str));
}

function checkMailMess(f) {
	var body = f.txt_mail_mess.value;
	if (Trim(body) == '') {
		alert(messBody);
		f.txt_mail_mess.focus();
		return false;
	}
	return true;
}

function popup(p,w,h){
	var left = (screen.availWidth/2) - (w/2);
	var top = (screen.availHeight/2) - (h/2);
	window.open(p,'Open','width='+w+',height='+h+',scrollbars=0,status=0, left='+left+', top='+top)
}
function popupall(p,w,h){
	var left = (screen.availWidth/2) - (w/2);
	var top = (screen.availHeight/2) - (h/2);
	window.open(p,'Open','width='+w+',height='+h+',scrollbars=1,status=0, left='+left+', top='+top)
}
function checkMemberInfo(f){
	fullName = f.full_name.value;
	if(Trim(fullName) =='') {
		alert(messFullName );
		f.full_name.focus();
		return false;
	}
	return true;
}


function subCatChangeMobile(i,n,id,sessId) {
	postStr = '';
	if (n == 1){
		p = 4;
	}else if(n==2) {
		p = 10;
		postStr = '&post_id=' + id;
	}
	if(i > 32) {
		window.location.href='main.php?page=' + p + '&cat_id=2&sub_cat_id_mobile=' + i + postStr + "&"+ sessId;
	}

	deleteAnItem();	
	if (i != "0") {
		lenSub = eval("len" + i);
		for ( var j = 0; j < lenSub; j++){
			eval("document.frm.sub_cat_id_mobile.options[j]=arrCat" + i + "_" +  j);
		}
	}	
}
	
function deleteAnItemMobile() {   	
	for (var i = 0; i <document.frm.sub_cat_id_mobile.length; i++){		
		document.frm.sub_cat_id_mobile.options[i]=null 
	}

	document.frm.sub_cat_id_mobile.length=0
		
}
function clickHelpSearch() {
	mess = '-------------------- HƯỚNG DẪN TÌM KIẾM --------------------\n\nVí dụ tìm từ = Sony Ericsson T630\n+ Bạn gõ vào: Sony Ericsson T630\n+ Xem chi tiết tìm kiếm click vào "Hỏi đáp" từ menu chính';
	alert(mess);
}

function subCareerChange(i) {
	deleteAnItem();	
	if (i != "0") {
		lenSub = eval("len" + i);
		for ( var j = 0; j < lenSub; j++){
			eval("document.f1.txtSubCareer.options[j]=arrCat" + i + "_" +  j);
		}
	}	
}

function deleteAnItem() {   	
	for (var i = 0; i <document.f1.txtSubCareer.length; i++){		
		document.f1.txtSubCareer.options[i]=null 
	}
	document.f1.txtSubCareer.length=0;
}

function checkRegister (f) {
	
	contactPerson = f.txtContactPersion.value;
	if (Trim(contactPerson) == "") {
		alert('Vui lòng nhập vào họ và tên người liên hệ');
		f.txtContactPersion.focus();
		return false;
	}
	if (Trim(f.txtEmail.value)==""){
		alert("Xin nhập vào địa chỉ email");
		f.txtEmail.focus();
		return false;
	}
	if (!checkEmail(f.txtEmail)) {
		return false
	}
	
	pass = f.txtPass.value;
	if(pass == '') {
		alert("Vui lòng nhập mật khẩu đăng nhập");
		f.txtPass.focus();
		return false;
	}

	passre=f.txtPassRe.value;
	if(pass != passre) {
		alert("      Mật khẩu xác nhận không đúng.\nXin nhập giống với mật khẩu đăng nhập");
		f.txtPassRe.value="";
		f.txtPassRe.focus();
		return false;
	}
	return true;	
}

function checkEditInfo (f) {
	
	contactPerson = f.txtContactPersion.value;
	if (Trim(contactPerson) == "") {
		alert('Vui lòng nhập vào họ và tên người liên hệ');
		f.txtContactPersion.focus();
		return false;
	}
	if (Trim(f.txtEmail.value)==""){
		alert("Xin nhập vào địa chỉ email");
		f.txtEmail.focus();
		return false;
	}
	if (!checkEmail(f.txtEmail)) {
		return false
	}	
	
	companyName = f.txtcompanyName.value;
	if (Trim(companyName) != "") {
	
		address = f.txtAddress.value;
		if (Trim(address) == "") {
			alert('Vui lòng nhập vào địa chỉ');
			f.txtAddress.focus();
			return false;
		}
		
		telephone = f.txtTel.value;
		if (Trim(telephone) == "") {
			alert('Vui lòng nhập số điện thoại');
			f.txtTel.focus();
			return false;
		}	
		
		cityWhereId = f.txtCityId.value;
		if (cityWhereId == "0") {
			alert('Vui lòng chọn địa danh');
			f.txtCityId.focus();
			return false;
		}
		
		careerId = f.txtcate.value;
		if (careerId == "0") {
			alert('Vui lòng chọn lĩnh vực');
			f.txtcate.focus();
			return false;
		}
		
		subCareerId = f.txtsubcate.value;		
		if (subCareerId == "0") {
			alert('Vui lòng chọn lĩnh vực con');
			f.txtsubcate.focus();
			return false;
		}	
		
		companyDesc = f.txtCompanyIntro.value;
		if (Trim(companyDesc) == ""){
			alert('Vui lòng nhập nội dung giới thiệu doanh nghiệp');
			f.txtCompanyIntro.focus();
			return false;
		} else if(companyDesc.length < 30) {
			alert('Phần giới thiệu doanh nghiệp phải lớn hơn 30 ký tự');
			f.txtCompanyIntro.focus();
			return false;
		}
	}	
	
	return true;	
}

function subCateChange(i) {
	deleteAnProduct();	
	if (i != "0") {
		lenSub = eval("len" + i);
		for ( var j = 0; j < lenSub; j++){
			eval("document.frm.txtsubcate.options[j]=arrCat" + i + "_" +  j);
		}
	}	
}

function deleteAnProduct() {   	
	for (var i = 0; i <document.frm.txtsubcate.length; i++){		
		document.frm.txtsubcate.options[i]=null 
	}
	document.frm.txtsubcate.length=0;
}

function checkPostForm (f) {
	
	cate_Id = f.cateId.value;
	if (cate_Id == '0') {
		alert('Vui lòng chọn mục tin');
		f.cateId.focus();
		return false;
	}
	
	Tittle = f.txtTittle.value;
	if(Trim(Tittle) == '') {
		alert("Vui lòng nhập tiêu đề tin");
		f.txtTittle.focus();
		return false;
	}

	StoDate=f.txtStoDate.value;
	if(StoDate=='0') {
		alert("Vui lòng chọn số ngày lưu tin");		
		f.txtStoDate.focus();
		return false;
	}
	
	Content = f.txtContent.value;
	if (Trim(Content) == "") {
		alert('Vui lòng nhập nội dung tin đăng');
		f.txtContent.focus();
		return false;
	}	
	
	City = f.txtCity.value;
	if (City == '0') {
		alert('Vui lòng chọn nơi đăng tin');
		f.txtCity.focus();
		return false;
	}
	
	return true;	
}

function checkEditPost (f) {
	
	tittleTin = f.tittle.value;
	if(Trim(tittleTin) == '') {
		alert("Vui lòng nhập tiêu đề tin");
		f.tittle.focus();
		return false;
	}
	
	contentTin = f.content.value;
	if (Trim(contentTin) == "") {
		alert('Vui lòng nhập nội dung tin đăng');
		f.content.focus();
		return false;
	}	
	
	return true;	
}

function checkProductForm (f) {
	
	productName = f.txtproductName.value;
	if(Trim(productName) == '') {
		alert("Vui lòng nhập vào tên sản phẩm dịch vụ");
		f.txtproductName.focus();
		return false;
	}

	StoDate=f.txtStoDate.value;
	if(StoDate=='0') {
		alert("Vui lòng chọn thời gian lưu tin");		
		f.txtStoDate.focus();
		return false;
	}
	price = f.txtPrice.value;
	if (price != "") {
		if (!checkNumber(price)) {
			alert('Nhập giá không hợp lệ');
			f.txtPrice.focus();
			return false;
		}
	}	
	/*
	Price = f.txtPrice.value;
	if (Trim(Price) == '') {
		alert('Vui lòng nhập vào giá sản phẩm hoặc gõ dòng chữ "Vui lòng gọi"');
		f.txtPrice.focus();
		return false;
	}	
	*/
	SellCity = f.txtSellCity.value;
	if (SellCity == '0') {
		alert('Vui lòng chọn nơi đăng sản phẩm dịch vụ');
		f.txtSellCity.focus();
		return false;
	}
	
	cate = f.txtcate.value;
	if (cate == '0') {
		alert('Vui lòng chọn lĩnh vực');
		f.txtcate.focus();
		return false;
	}
	
	subcate = f.txtsubcate.value;
	if (subcate == '0') {
		alert('Vui lòng chọn lĩnh vực con');
		f.txtsubcate.focus();
		return false;
	}
	/*
	smallpicture = f.txtsmallpicture.value;
	if(Trim(smallpicture) == '') {
		alert("Vui lòng chọn hình nhỏ của sản phẩm");
		f.txtsmallpicture.focus();
		return false;
	}
	
	bigpicture = f.txtbigpicture.value;
	if(Trim(bigpicture) == '') {
		alert("Vui lòng chọn hình lớn của sản phẩm");
		f.txtbigpicture.focus();
		return false;
	}
	*/
	productdetail = f.txtproductdetail.value;
	if(Trim(productdetail) == "") {
		alert("Vui lòng nhập vào nội dung mô tả sản phẩm");
		f.txtproductdetail.focus();
		return false;
	}
	
	return true;
}

function checkEditProduct (f) {
	
	productName = f.txtproductName.value;
	if(Trim(productName) == '') {
		alert("Vui lòng nhập vào tên sản phẩm dịch vụ");
		f.txtproductName.focus();
		return false;
	}
	
	price = f.txtPrice.value;
	if (price != "") {
		if (!checkNumber(price)) {
			alert('Nhập giá không hợp lệ');
			f.txtPrice.focus();
			return false;
		}
	}	
	
	productdetail = f.txtproductdetail.value;
	if(Trim(productdetail) == "") {
		alert("Vui lòng nhập vào nội dung mô tả sản phẩm dịch vụ");
		f.txtproductdetail.focus();
		return false;
	}
	
	cate = f.txtcate.value;
	if (cate == '0') {
		alert('Vui lòng chọn lĩnh vực');
		f.txtcate.focus();
		return false;
	}
	
	subcate = f.txtsubcate.value;
	if (subcate == '0') {
		alert('Vui lòng chọn lĩnh vực con');
		f.txtsubcate.focus();
		return false;
	}
	
	if (f.ispromotion.checked) {	
		
		promoprice = f.promotionprice.value;
		if (promoprice != "") {
			if (!checkNumber(promoprice)) {
				alert('Nhập giá khuyến mãi không hợp lệ');
				f.promotionprice.focus();
				return false;
			}
		}
		
		promotion_start = f.promotionstart.value;
		if (Trim(promotion_start) == '') {
			alert('Vui lòng nhập vào thời gian bắt đầu khuyến mãi');
			f.promotionstart.focus();
			return false;
		}
		
		promotion_stop = f.promotionstop.value;
		if (Trim(promotion_stop) == '') {
			alert('Vui lòng nhập vào thời gian kết thúc khuyến mãi');
			f.promotionstop.focus();
			return false;
		}		
	}	
	return true;
}

function checkNumber(x){
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(x)) {
		result=true
	} else{
		//alert("Vui lòng nhập vào số hợp lệ")
		result = false
	}
	return result;
}