function check_setup(the_form)
	{
		var board_url    = the_form.board_url.value;
		var pro_name    = the_form.pro_name.value;
		var sql_host   = the_form.sql_host.value;
		var sql_database   = the_form.sql_database.value;
		var sql_user      = the_form.sql_user.value;
		var sql_pass    = the_form.sql_pass.value;
		var adminname    = the_form.adminname.value;
		var adminpassword    = the_form.adminpassword.value;
		var adminpassword2    = the_form.adminpassword2.value;
		var email    = the_form.email.value;
		if ( (board_url=='')||(sql_host=='')||(sql_database=='')||(sql_user=='')||(adminname=='')||(adminpassword=='')||(adminpassword2=='')||(email=='')||(pro_name=='') )
		{
			alert("You must input em informations!");
			the_form.board_url.focus();
			return false;
		}
		if  (adminpassword!=adminpassword2)
			{
			alert("Two pass must be the same!");
			the_form.adminpassword.focus();
			return false;
			}
	}
			
function readyDiv() 
{
	var theHTML;
	theHTML = document.all.tags('div')['message'].innerText;
	document.all.tags('div')['message'].innerHTML = theHTML;
}

function cmdExec(cmd,opt) 
{
	document.body.all.tags('div')['message'].focus();
	message.document.execCommand(cmd,"",opt);
}

function createLink() 
{
	cmdExec("CreateLink");
}

function insertImage() 
{
	var sImgSrc = prompt("Image: ", "http://");
	if(sImgSrc!=null)
		cmdExec("InsertImage",sImgSrc);
}

function smile(xname) 
{
	if(xname!=null)
	{
		var sImgSrc="images/smileys/" +xname +".gif";
		cmdExec("InsertImage",sImgSrc);
	}
}


function go(where) 
{
	window.location.href = where;
}

function MM_jumpMenu(targ,selObj,restore)
{ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function check_mkcu(ck)
{
		var mk1    = ck.moi1.value;
		var mk2    = ck.moi2.value;
		var mkcu   = ck.mkcu.value;
	
		if ( (mk1=='')||(mk2==''))
		{
			alert("You must input old pass and two new pass.");
			ck.mkcu.focus();
			return false;
		}
		if  (mk1!=mk2)
		{
			alert("Password and confirm pass must be the same!");
			ck.moi1.focus();
			return false;
		}		
}
function check_searchform(str)
	{
		if (str.value=='')
		{
			alert("Input the key word for search");
			str.focus;
			return false;
		}
		return true;
	}
	
	function checkall(){
		for (var i = 0; i < document.memberlist.elements.length; i++) {
			if ( document.memberlist.all.checked==true ){
				document.memberlist.elements[i].checked = true;
			}
			else{
				document.memberlist.elements[i].checked = false;
			}
		}
	}

function xoa_thoikhoabieu(id)
{
var is_confirmed = confirm("Ban co chac chan muon xoa thoi khoa bieu khong?")
if (is_confirmed) self.location.href="index.php?menu=del&type=thoikhoabieu&id="+id; else return false;
}

function xoa_lichcongtac(id)
{
var is_confirmed = confirm("Ban co chac chan muon xoa lich cong tac khong?")
if (is_confirmed) self.location.href="index.php?menu=del&type=lichcongtac&id="+id; else return false;
}

function xoa_thongbao(id)
{
var is_confirmed = confirm("Ban co chac chan muon xoa thong bao khong?")
if (is_confirmed) self.location.href="index.php?menu=del&type=thongbao&id="+id; else return false;
}


function xoa_nhomme(id)
{
var is_confirmed = confirm("Do you want to delete this master group?")
if (is_confirmed) self.location.href="index.php?menu=del&type=nhomme&mid="+id; else return false;
}

function xoa_nhomcon(id)
{
var is_confirmed = confirm("Do you want to delete this child group?")
if (is_confirmed) self.location.href="index.php?menu=del&type=nhomcon&cid="+id; else return false;
}

function check_sort(the_form,num)
	{
		var c= the_form.all.tags("select");
		vitri= new Array (num);
		for (var i=1;i<=num;i++) vitri[i]= c.item(i-1).value;	
		for (var j=1;j<=num;j++)
		{
			var check=false;
			for(var k=1;k<=num;k++)	if (vitri[k]==j) check=true;
			if (check==false) 
				{	
					alert("Order is incorrect. Please check again!!!");
					return false;
				}
		}
	alert("Order is ordered!!!");
	}
	
function checkall(){
		for (var i = 0; i < document.memberlist.elements.length; i++) {
			if ( document.memberlist.all.checked==true ){
				document.memberlist.elements[i].checked = true;
			}
			else{
				document.memberlist.elements[i].checked = false;
			}
		}
	}


function xoa_newsview(group,cgroup,id)
{
var is_confirmed = confirm("Do you want to delete this news?")
if (is_confirmed) self.location.href="index.php?menu=del&type=newsview&group="+group+"&cgroup="+cgroup+"&id="+id;
else return false;
}

function xoa_picture(group,id)
{
var is_confirmed = confirm("Do you want to delete this picture?")
if (is_confirmed) self.location.href="index.php?menu=tranganh&cat_pid="+group+"&del="+id;
else return false;
}

function xoa_music(id)
{
var is_confirmed = confirm("Do you want to delete this song?")
if (is_confirmed) self.location.href="index.php?menu=music&del="+id;
}


function xoa_member(id)
{
var is_confirmed = confirm("Do you want to delete this member? Note: delete member, all news of it will be deleted!.")
if (is_confirmed) self.location.href="index.php?menu=del&type=deluser&uid="+id; else return false;
}

function checkall(){
		for (var i = 0; i < document.memberlist.elements.length; i++) {
			if ( document.memberlist.all.checked==true ){
				document.memberlist.elements[i].checked = true;
			}
			else{
				document.memberlist.elements[i].checked = false;
			}
		}
	}

function check_form(the_form)
	{
		var tieude    = the_form.title.value;
		var mota   = the_form.content_desc.value;
		var nhom      = the_form.nhom_id.value;
		var upload    = the_form.file1.value;
		
		if (tieude=='')
		{
			alert("Please input title");
			the_form.title.focus();
			return false;
		}

		if (mota=='')
		{
			alert("Please input description");
			the_form.content_desc.focus();
			return false;
		}

		if  (nhom=='')
			{
			alert("Please choose news group");
			the_form.nhom_id.focus();
			return false;
			}
	if  (upload=='') the_form.checkup.value="khong";
		else the_form.checkup.value="co";
	var filename= upload.substring(upload.lastIndexOf("\\")+1,upload.length);
	var dotpos=filename.lastIndexOf('.');
	var ext=filename.substr(dotpos+1,3);
	ext=ext.toLowerCase();
	if(ext!="")
		if((ext!="gif") && (ext!="jpg") && (ext!="png") && (ext!="bmp")){
				alert("Image type is GIF, JPG, PNG, BMP. Please input again");
				return false;
		}
		return true;
	}

function check_form_music(the_form)
	{
		var name    = the_form.name.value;
		var upload  = the_form.file1.value;
		
		if (name=='')
		{
			alert("Please input song name");
			the_form.name.focus();
			return false;
		}
		
		if (upload=='')
		{
			alert("Please input music upload");
			the_form.file1.focus();
			return false;
		}
		

	var filename= upload.substring(upload.lastIndexOf("\\")+1,upload.length);
	var dotpos=filename.lastIndexOf('.');
	var ext=filename.substr(dotpos+1,3);
	ext=ext.toLowerCase();
	if(ext!="")
		if((ext!="mp3") && (ext!="wma") && (ext!="wav") && (ext!="mid")&& (ext!="rm")){
				alert("Music type is mp3, wma, wav, mid, rm. Please input again");
				return false;
		}
		return true;
	}

function check_form_video(the_form)
	{
		var name    = the_form.name.value;
		var upload  = the_form.file1.value;
		
		if (name=='')
		{
			alert("Please input name");
			the_form.name.focus();
			return false;
		}
		
		if (upload=='')
		{
			alert("Please input video or upload");
			the_form.file1.focus();
			return false;
		}
		
	var filename= upload.substring(upload.lastIndexOf("\\")+1,upload.length);
	var dotpos=filename.lastIndexOf('.');
	var ext=filename.substr(dotpos+1,3);
	ext=ext.toLowerCase();
	if(ext!="")
		if((ext!="dat") && (ext!="avi") && (ext!="wav") && (ext!="mpg")&& (ext!="swf")){
				alert("Video type is wav, avi, dat, mpg, swf. Please input again");
				return false;
		}
		return true;
	}

function check_form_video_edit(the_form)
	{
		var name    = the_form.name.value;
		
		if (name=='')
		{
			alert("Please input name");
			the_form.name.focus();
			return false;
		}
		return true;
	}

function check_form_pic_edit(the_form)
	{
		var name    = the_form.name.value;
		
		if (name=='')
		{
			alert("Please input name");
			the_form.name.focus();
			return false;
		}
		return true;
	}

function check_form_music_edit(the_form)
	{
		var name    = the_form.name.value;
		
		if (name=='')
		{
			alert("Please input name");
			the_form.name.focus();
			return false;
		}
		return true;
	}


function mOvr(src) {
		if (!src.contains(event.fromElement)) {
			src.style.cursor = 'hand';
			src.style.backgroundColor = '#6699CC';
		}

	}
function mOut(src) {
		if (!src.contains(event.toElement)) {
			src.style.cursor = 'default';
			src.style.backgroundColor = '#003366';
		}
	}
function mClk(src) {
		if(event.srcElement.tagName=='TD'){
			src.children.tags('A')[0].click();
		}
	}


function check_loginform(the_login)
	{
		var the_email    = the_login.username.value;
		var the_password = the_login.password.value;
	
		if ( (the_email=='')||(the_password=='') )
		{
			alert("Please input username and password");
			the_login.username.focus();
			return false;
		}
	}
function check_gopy(ck)
{
		var ten    = ck.name.value;
		var noidung = ck.nd.value;
	
		if ( (ten=='')||(noidung=='') )
		{
			alert("Input name and descriptions");
			ck.name.focus();
			return false;
		}
}
function check_mk(ck)
{
		var mk1    = ck.moi1.value;
		var mk2    = ck.moi2.value;
	
		if ( (mk1=='')||(mk2=='') )
		{
			alert("Input new password two time");
			ck.moi1.focus();
			return false;
		}
		if  (mk1!=mk2)
		{
			alert("New pass and confirm pass must be the same!");
			ck.moi1.focus();
			return false;
		}		
}

function check_nhom(ck)
{
		var ten   = ck.tennhom.value;
				
		if(ten=='')
		{
			alert("Please input group name");
			ck.tennhom.focus();
			return false;
		}
		
		if((ck.group_type.value!='3')&&(ck.menu_link.checked==true))
		{
			alert("Chi loai menu la duong link moi duoc phep chon link!");
			ck.menu_link.focus();
			return false;			
		}
		
		if((ck.group_type.value=='3')&&(ck.menu_link.checked!=true))
		{
			alert("Loai menu la duong link phai chon duong link!");
			ck.menu_link.focus();
			return false;
		}
		if ((ck.menu_link.checked==true)&&(ck.web_link.value==''))
		{
			alert("Loai menu la duong link phai nhap duong link!");
			ck.tloai.focus();
			return false;		
		}
}

function check_lichcongtac(ck)
{
		var name_desc   = ck.name_desc.value;
		var noidung   = ck.noidung.value;
		var post_date = ck.post_date.value;
		var upload    = ck.file1.value;
				
		if(name_desc=='')
		{
			alert("Phai nhap tieu de lich cong tac");
			ck.name_desc.focus();
			return false;
		}
		
		if(noidung=='')
		{
			alert("Phai nhap noi dung chi tiet");
			ck.noidung.focus();
			return false;
		}

		if(post_date=='')
		{
			alert("Phai nhap ap dung tu ngay");
			ck.post_date.focus();
			return false;
		}
		
	if  (upload=='') ck.checkup.value="khong";
		else ck.checkup.value="co";
	var filename= upload.substring(upload.lastIndexOf("\\")+1,upload.length);
	var dotpos=filename.lastIndexOf('.');
	var ext=filename.substr(dotpos+1,3);
	ext=ext.toLowerCase();		
}

function check_thoikhoabieu(ck)
{
		var name_desc   = ck.name_desc.value;
		var noidung   = ck.noidung.value;
		var upload    = ck.file1.value;
				
		if(name_desc=='')
		{
			alert("Phai nhap ten lop");
			ck.name_desc.focus();
			return false;
		}
		
		if(noidung=='')
		{
			alert("Phai nhap noi dung chi tiet");
			ck.noidung.focus();
			return false;
		}
		
	if  (upload=='') ck.checkup.value="khong";
		else ck.checkup.value="co";
	var filename= upload.substring(upload.lastIndexOf("\\")+1,upload.length);
	var dotpos=filename.lastIndexOf('.');
	var ext=filename.substr(dotpos+1,3);
	ext=ext.toLowerCase();		
}


function check_themuser(ck)
{
		var ten    = ck.ten.value;
		var mk1    = ck.moi1.value;
		var mk2    = ck.moi2.value;
	
		if ( (ten=='')||(mk1=='')||(mk2=='') )
		{
			alert("Please input enough informations in (*)");
			ck.ten.focus();
			return false;
		}
		if  (mk1!=mk2)
		{
			alert("New pass an confirm pass must be the same!");
			ck.moi1.focus();
			return false;
		}		
}

function check_suauser(ck)
{
		var ten    = ck.ten.value;
	
		if  (ten=='')
		{
			alert("Please input enough informations in (*)");
			ck.ten.focus();
			return false;
		}
}

function check_doitennhom(ck)
{
		var ten    = ck.tenmoi.value;
		
		if (ten=='')
		{
			alert("Please input new name !");
			ck.tenmoi.focus();
			return false;
		}
}

function checktxt(checkbox,textbox)
	{
	var textb=document.forms.add[textbox]
	var chkb=document.forms.add[checkbox]
	if (chkb.checked == true)
		{
		textb.disabled=false;
		}		
	else
		{
		textb.disabled=true
		textb.value='';
		}
	}
	
function giatrinhom(checkbox,textbox)
	{
	var textb=document.forms.post[textbox]
	var chkb=document.forms.post[checkbox]
	if (chkb.value == true)
		{
		textb.disabled=false
		}		
	else
		{
		textb.disabled=true
		}
	}
  
  
 function Toggle(e)
    {
	if (e.checked) {
	    document.messageList.toggleAll.checked = AllChecked();
	}
	else {
	    document.messageList.toggleAll.checked = false;
	}
    }

function ToggleAll(e)
    {
		if (e.checked)   CheckAll();	
			else 	 ClearAll();
    }

function CheckAll()
    {
		var ml = document.messageList;
		var len = ml.elements.length;
		if(len>2)
		{
		for (var i = 0; i < len-1; i++) 
		{ 
			var e = ml.chkid[i];
			 e.checked = true;
		  }
		}
    }

function ClearAll()
    {
		var ml = document.messageList;
		var len = ml.elements.length;
		if(len>2)
		{
		for (var i = 0; i < len-1; i++) 
		
		{
			var e = ml.chkid[i];
			e.checked = false
		}
	}
    }
	
function ChuyenTrangThai1()
{
	var ml = document.messageList;
	var len = ml.elements.length;
	var sId="";
		if(len>2){	
			for (var i = 0; i < len-1; i++) 
				{
				var e = ml.chkid[i];
				if (e.checked==true) sId=sId+"!"+e.value;
				}
				}
			else if (ml.chkid.checked==true) sId="!"+ml.chkid.value
		
		if (sId=="") alert("You must choose at least one news.!")
			else 
			{
				var is_confirmed = confirm("Do you want to change?");
				if (is_confirmed) self.location.href="include/p_chuyen_1_many.php?sid="+sId;	
			}

			
}

function ChuyenTrangThai0()
{
	var ml = document.messageList;
	var len = ml.elements.length;
	var sId="";
		if(len>2){	
			for (var i = 0; i < len-1; i++) 
				{
				var e = ml.chkid[i];
				if (e.checked==true) sId=sId+"!"+e.value;
				}
				}
			else if (ml.chkid.checked==true) sId="!"+ml.chkid.value
		
	if (sId=="") alert("You must choose at least one news.!")
		else 
		{
		var is_confirmed = confirm("Do you want to change?");
		if (is_confirmed) self.location.href="include/p_chuyen_0_many.php?sid="+sId;	
		}
}

function XoaHangLoat() //Xoa tin
{
	var ml = document.messageList;
	var len = ml.elements.length;
	var sId="";
		if(len>2){	
			for (var i = 0; i < len-1; i++) 
				{
				var e = ml.chkid[i];
				if (e.checked==true) sId=sId+"!"+e.value;
				}
				}
			else if (ml.chkid.checked==true) sId="!"+ml.chkid.value
		
	if (sId=="") alert("You did'nt check news .!")
		else 
		{
		var is_confirmed = confirm("Do you want to delete all checked news?");
		if (is_confirmed) self.location.href="include/p_xoa_many.php?sid="+sId;	
		}
}

function check_nhom_album(ck)
{
		var ten_en   = ck.tennhom_en.value;
	
		if  (ten_en=='')
		{
			alert("Please input album name");
			ck.tennhom_en.focus();
			return false;
		}
}

function check_doitennhom_album(ck)
{
		var ten_en  = ck.tenmoi_en.value;
			
		if (ten_en=='')
		{
			alert("Please input new pic name !");
			ck.tenmoi_en.focus();
			return false;
		}
}

function xoa_nhom_album(id)
{
	var is_confirmed = confirm("Do you want to delete this allbum group?")
	if (is_confirmed) self.location.href="index.php?menu=del&type=nhom_album&mid="+id; else return false;
}

function xoa_adv(id)
{
var is_confirmed = confirm("Ban co thuc su muon xoa quang cao nay khong?")
if (is_confirmed) self.location.href="index.php?menu=del&type=adv&aid="+id; else return false;
}

function xoa_adv_web(id)
{
var is_confirmed = confirm("Ban co thuc su muon xoa lien ket nay khong?")
if (is_confirmed) self.location.href="index.php?menu=del&type=adv_web&aid="+id; else return false;
}

function XoaHangLoatGopY() //Xoa gop y
{
	var ml = document.messageList;
	var len = ml.elements.length;
	var sId="";
		if(len>2){	
			for (var i = 0; i < len-1; i++) 
				{
				var e = ml.chkid[i];
				if (e.checked==true) sId=sId+"!"+e.value;
				}
				}
			else if (ml.chkid.checked==true) sId="!"+ml.chkid.value
		
	if (sId=="") alert("Ban chua chon gop y nao.!")
		else 
		{
		var is_confirmed = confirm("Ban co chac chan muon xoa gop y khong?");
		if (is_confirmed) self.location.href="include/p_xoa_many_gopy.php?sid="+sId;	
		}
}

function check_suaquangcao(ck)
{
		var ten    = ck.ten.value;
		var file = ck.file1.value;
		var lienket = ck.link.value;
		var thoigian = ck.hieuluc.value;
	
		if ( (ten=='')||(lienket=='')||(thoigian==''))
		{
			alert("Nhap day du thong tin co dau (*)");
			ck.ten.focus();
			return false;
		}
		else
		{
			if (isNaN(parseInt(thoigian))) 
			{
				alert("Thoi gian hieu luc phai nhap so!");
				ck.hieuluc.focus();
				return false;
			}
		}
		
		if  (file=='') ck.fileup.value="khong";
		else ck.fileup.value="co";
	var filename= file.substring(file.lastIndexOf("\\")+1,file.length);
	var dotpos=filename.lastIndexOf('.');
	var ext=filename.substr(dotpos+1,3);
	ext=ext.toLowerCase();
	if(ext!="")
		if((ext!="gif") && (ext!="jpg") && (ext!="png") && (ext!="bmp")){
				alert("Chi cho phep tai cac anh dang GIF, JPG, PNG, BMP. Hay chon lai");
				return false;
		}
		return true;
}
