﻿var Thu=new Array(" Ch&#7911; Nh&#7853;t, "," Th&#7913; hai, "," Th&#7913; ba, "," Th&#7913; t&#432;, "," Th&#7913; n&#259;m, "," Th&#7913; sáu, "," Th&#7913; b&#7843;y, ");
var Thang=new Array("01","02","03","04","05","06","07","08","09","10","11","12");
var Ngay=new Array("","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");
today=new Date();
var Year=today.getYear();
if ((navigator.appName == "Microsoft Internet Explorer") && (Year < 2000))
	Year="19" + Year;
if (navigator.appName == "Netscape")
	Year=1900 + Year;

function previewImage(form) {
	form.img_small.src = form.file1.value;
	form.img_large.src = form.file2.value;
}

function CheckForm_Login(form)
{	
	if(form.username.value == "") {
		alert("Vui lòng nhập vào tên truy cập !");
	   	form.username.value="";
	   	form.username.focus();
	   	return false;
	}else if(form.password.value == "") {
		alert("Vui lòng nhập vào mật khẩu !");
	   	form.password.value="";
	   	form.password.focus();
	   	return false;
	}
	return true;
}

function CheckAll_up(form)
{
	for(var i=0;i<form.elements.length;i++)
	{
		var e=form.elements[i];
		if(e.name!='allbox_up')
			e.checked = form.allbox_up.checked;
	}
}

function CheckAll_bottom(form)
{
	for(var i=0;i<form.elements.length;i++)
	{
		var e=form.elements[i];
		if(e.name!='allbox_bottom')
			e.checked = form.allbox_bottom.checked;
	}
}

function Check_one(form)
{
	form.allbox_up.checked = false;
	//document.categories.allbox_bottom.checked = false;
}

function Check(form)
{
	var k=0;
	for(var i=0;i<form.elements.length;i++)
	{
		var e=form.elements[i];
		if(e.name!='allbox_bottom')
			if(e.checked)
				k++;
	}
	if(k>0)
	{
		return true;
	}
	else
	{
		alert("Bạn cần phải chọn một mục nào đó !");
		return false;
	}
	return true;
}

function Deleted()
{
	var str
	str = "Nếu bạn xóa mục này, tất cả những gì liên quan";
	str = str + "\n";
	str = str + "              đến mục này sẽ bị xóa hết !";
	str = str + "\n";
	str =str + "Bạn có chắc chắn muốn xóa không ?";
	if(confirm(str))
		return true;
	else
		return false;
}

function Delete_viewed(form,strURL)
{
	var str
	str = "Nếu bạn xóa mục này, tất cả những gì liên quan";
	str = str + "\n";
	str = str + "              đến mục này sẽ bị xóa hết !";
	str = str + "\n";
	str =str + "Bạn có chắc chắn muốn xóa không ?";
	if(confirm(str))
	{		
		form.action=strURL;
		form.submit();
		return true;
	}
	else
		return false;
}

function CheckForm_Admin(form)
{
	if(form.username.value == "") {
		alert("Vui lòng nhập tên truy cập !");
	   	form.username.value="";
	   	form.username.focus();
	   	return false;
	}else if(form.old_pwd.value == "") {
		alert("Vui lòng nhập mật khẩu cũ !");
	   	form.old_pwd.value="";
	   	form.old_pwd.focus();
	   	return false;	
	}else if(form.new_pwd.value == "") {
		alert("Vui lòng nhập mật khẩu mới !");
	   	form.new_pwd.value="";
	   	form.new_pwd.focus();
	   	return false;	
	}else if(form.new_pwd_again.value == "") {
		alert("Vui lòng xác nhận mật khẩu mới !");
	   	form.new_pwd_again.value="";
	   	form.new_pwd_again.focus();
	   	return false;
	}else if(form.new_pwd_again.value != form.new_pwd.value) {
		alert("Mật khẩu không giống nhau, Vui lòng thử lại !");
	   	form.new_pwd.value="";
		form.new_pwd_again.value="";
	   	form.new_pwd.focus();
	   	return false;
	}
	return true;
}

function Check_loai_tin(form)
{
	if(form.ten_loai_tin.value == "") {
		alert("Vui lòng nhập vào tên loại tin!");
	   	form.catName.focus();
	   	return false;
	}
	return true;
}
function Check_sub_loai_tin(form)
{
	if(form.ten_sub_loai_tin.value == "") {
		alert("Vui lòng nhập vào tên Sub loại tin!");
	   	form.catName.focus();
	   	return false;
	}
	return true;
}


function Check_tin_tuc(form)
{
	if(form.tieu_de.value == "") {
		alert("Vui lòng nhập giá trị vào các field !");
	   	form.tieu_de.focus();
	   	return false;
	}else if(form.tom_luoc.value == "") {
		alert("Vui lòng nhập giá trị vào các field !");
	   	form.tom_luoc.focus();
	   	return false;
	}else if(form.noi_dung.value == "") {
		alert("Vui lòng nhập giá trị vào các field !");
	   	form.noi_dung.focus();
	   	return false;
	}
	return true;
}

function popup(wURL,winname,vWidth,vHeight)
{
	//vWidth = 556;
	//vHeight = 340;

	//winDef = 'status=no,resizable=no,scrollbars=yes,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = 'status=yes,resizable=yes,scrollbars=yes,toolbar=yes,location=yes,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight-68)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth-25)/2);

	mywin=window.open(wURL,winname,winDef);
	mywin.focus();
	//window.mywin.document.close();
}

function wclose()
{
	window.opener.location.reload();
	self.close();
	return false;
}