//checkall
function checkAll(){
	var chk = document.getElementById("checkall");
	var alen = document.frm.elements.length;
	for (i =0; i< alen; i++){
		var e = document.frm.elements[i];
		//Check box
	  	if ( e.type=='checkbox' && e.name!="checkall"){
	  			e.checked = chk.checked;
	  	}
	}
};
function onChangeFrm(action){

	if (confirm("Are you like change?")){
		document.frm.action = action;
		document.frm.submit();
	}
};
function onLinkUrl(aid, url){
	if (confirm("Would you like change it?")){
		document.getElementById(aid).href = url;
		return true;
	}
	return false;
};

////////////////////////////////
function checkAllNow(field)
{
	//alert(document.getElementById('notcheckall').value);
	if(document.getElementById('checkall').value == 'Chọn tất cả')
		checkAll(field)	
	//if(document.getElementById('notcheckall').value == 'Bỏ chọn'){
	//alert('done');
	//	uncheckAll(field)
	//}
};

function unCheckAllNow(field)
{
	if(document.getElementById('uncheckall').value == 'Bỏ chọn')
		uncheckAll(field)	
	//if(document.getElementById('notcheckall').value == 'Bỏ chọn'){
	//alert('done');
	//	uncheckAll(field)
	//}
};


function checkAll(field)
{
	if(field.length>=1)
	for (i = 0; i < field.length; i++)
		field[i].checked = true ;	
	else
		field.checked = true ;

};

function uncheckAll(field)
{
	if(field.length>=1)
	for (i = 0; i < field.length; i++)
		field[i].checked = false ;
	else
		field.checked = false ;
};
	

function ShowAll(field,p)
{
	var f=document.frm_list;
	var tmp='';	
	if(field.length>=1)
		for (i = 0; i < field.length; i++){
			if(field[i].checked)
				tmp+='~~~'+field[i].value;
		}
	else if(field.checked)	
		tmp=field.value;
	if(tmp)
	{
		if(window.confirm("Bạn có chắc chắn cho hiển thị các dữ liệu?"))
		{
			document.getElementById('listCheckAll').value=tmp;		
			f.action="?portal="+p+"&do=ShowAll";
			f.submit();	
		}
	}
	
};

function HiddenAll(field,p)
{
	var f=document.frm_list;
	var tmp='';	
	if(field.length>=1)
		for (i = 0; i < field.length; i++){
			if(field[i].checked)
				tmp+='~~~'+field[i].value;
		}
	else if(field.checked)	
		tmp=field.value;
	if(tmp)
	{
		if(window.confirm("Bạn có chắc chắn ẩn các dữ liệu?"))
		{
			document.getElementById('listCheckAll').value=tmp;
			f.action="?portal="+p+"&do=HiddenAll";
			f.submit();	
		}
	}
	
};

function DeleteAll(field,p)
{
	var f=document.frm_list;
	var tmp='';	
	if(field.length>=1)
		for (i = 0; i < field.length; i++){
			if(field[i].checked)
				tmp+='~~~'+field[i].value;
		}
	else if(field.checked)	
		tmp=field.value;
		
	if(tmp)
	{
		if(window.confirm("Bạn có chắc chắn xóa các dữ liệu vào Thùng rác?"))
		{
			document.getElementById('listCheckAll').value=tmp;		
			f.action="?portal="+p+"&do=DeleteAll";
			f.submit();	
		}
	}
	
};


function DeleteAllHome(field,p)
{
	var f=document.frm_list;
	var tmp='';	
	if(field.length>=1)
		for (i = 0; i < field.length; i++){
			if(field[i].checked)
				tmp+='~~~'+field[i].value;
		}
	else if(field.checked)	
		tmp=field.value;
	if(tmp)
	{
		if(window.confirm("Bạn có chắc chắn xóa các dữ liệu vào Thùng rác?"))
		{
			//document.getElementById('listCheckAll').value=tmp;		
			f.listCheckAll.value = tmp;
			f.action="?portal="+p+"&op=realestatenews&action=DeleteAll";
			f.submit();	
		}
	}
	
};

function RefreshNews(field,p)
{
	var f=document.frm_list;
	var tmp='';	
	if(field.length>=1)
		for (i = 0; i < field.length; i++){
			if(field[i].checked)
				tmp+='~~~'+field[i].value;
		}
	else if(field.checked)	
		tmp=field.value;
	if(tmp)
	{
		if(window.confirm("Bạn có chắc chắn refresh các dữ liệu vào không ?"))
		{		
			f.listCheckAll.value = tmp;
			f.action="?portal="+p+"&op=realestatenews&action=RefreshNews";
			f.submit();	
		}
	}
	
};

function RestoreAll(field,p)
{
	var f=document.frm_list;
	var tmp='';	
	if(field.length>=1)
		for (i = 0; i < field.length; i++){
			if(field[i].checked)
				tmp+='~~~'+field[i].value;
		}
	else if(field.checked)	
		tmp=field.value;
		
	if(tmp)
	{
		if(window.confirm("Bạn có chắc chắn khôi phục các dữ liệu?"))
		{
			document.getElementById('listCheckAll').value=tmp;		
			f.action="?portal="+p+"&do=RestoreAll";
			f.submit();	
		}
	}
	
};

function DropAll(field,p)
{
	var f=document.frm_list;
	var tmp='';	
	if(field.length>=1)
		for (i = 0; i < field.length; i++){
			if(field[i].checked)
				tmp+='~~~'+field[i].value;
		}
	else if(field.checked)	
		tmp=field.value;
	if(tmp)
	{
		if(window.confirm("Bạn có chắc chắn xóa khỏi cơ sở dữ liệu?"))
		{
			document.getElementById('listCheckAll').value=tmp;		
			f.action="?portal="+p+"&do=DropAll";
			f.submit();	
		}
	}
	
};

function changeWithoutSubmit(f,p)
{
	f.without.value=1;
	f.action="?portal="+p+"&do=update";	
	f.submit();
};

function changeClassName(v,class_)
{
	v.className=class_;
	return true;
};

function confirmWebsite()
{
	if(confirm("Bạn có chắc chắn thực hiện lệnh này? ( Are you sure? )"))		
		return true;
	else
		return false;
};

