
// Hien chu thich tren thanh trang thai
window.defaultStatus = "";
function winStatus(msg)
{
	window.status = msg;
	return true;
}

//Hien bang thông báo sau moi bien co click chuot
function Alert(msg,type,admin)
{
	if (admin == 1)		// Qu?n tr? h? th?ng
		return window.showModalDialog("../INCLUDE/Alert.asp?type="+type,msg,"dialogWidth:300px;dialogHeight:120px;scroll:0;help:0;status:0;center:1;edge=raised;resizable=0;");
	else
		return window.showModalDialog("INCLUDE/Alert.asp?type="+type,msg,"dialogWidth:300px;dialogHeight:120px;scroll:0;help:0;status:0;center:1;edge=raised;resizable=0;");	
}

//function Alert(msg,type)
//{
//	return window.showModalDialog("Include/alert.asp?type="+type,msg,"dialogWidth:300px;dialogHeight:120px;scroll:0;help:0;status:0;center:1;edge=raised;resizable=0;");
//}

// Lay giá tri moi khi thay doi combobox
function submitFrm(m_value)
{
	document.frm.Action.value = m_value;
	document.frm.submit();
	return true;
}
//Lay hanh dong tren Form
function setAction(value)
{
	try
	{
		document.frm.Action.value = value;
		return true;
	}catch(e){}
	return false;
}

//Popup d? Upload t?p tin Gi?y m?i h?p và TB Hoăn h?p
function OpenWinFrame(ID, loai, H, W)
{
	if (ID!= "")
	{
//		return showModalDialog("upload.asp?GM="+ID+"&loai="+loai,"","dialogWidth:"+W+"px;dialogHeight:"+H+"px;scroll:no;help:0;status:0;center:1;edge=sunken;resizable=1;");
		return showModalDialog("Upload.asp?GM="+ID+"&loai="+loai,"","dialogWidth:"+W+"px;dialogHeight:"+H+"px;scroll:no;help:0;status:0;center:1;edge=sunken;resizable=1;");
	}
}

// Popup d? xem nh?t kư c?p nh?t GMH/ TB Hoăn h?p
function Open_History(ID,H,W)
{
	if (ID!= "")
	{
		return showModalDialog("nhatky.asp?ID="+ID,"","dialogWidth:"+W+"px;dialogHeight:"+H+"px;scroll:yes;help:0;status:0;center:1;edge=sunken;resizable=0;");
	}
}

// Popup de xem nhat ky cap nhat van ban
function Open_History_VanBan(ID,H,W)
{
	if (ID!= "")
	{
		return showModalDialog("nhatky.asp?ID="+ID,"","dialogWidth:"+W+"px;dialogHeight:"+H+"px;scroll:yes;help:0;status:0;center:1;edge=sunken;resizable=0;");
	}
}

// Popup de cap nhat Tieu de va noi dung cua van ban can gop y
function Open_Update_VanBan(ID,loai,H,W)
{
	if (ID!= "")
	{
		return showModalDialog("Update.asp?ID="+ID+"&loai="+loai,"","dialogWidth:"+W+"px;dialogHeight:"+H+"px;scroll:yes;help:0;status:0;center:1;edge=sunken;resizable=0;");
	}
}


// Popup de Upload tap tin Lich công tác
function Upload_LCT(thang, nam, H, W)
{
	if (thang!= "")
	{
		return showModalDialog("Upload.asp?thang="+thang+"&nam="+nam,"","dialogWidth:"+W+"px;dialogHeight:"+H+"px;scroll:no;help:0;status:0;center:1;edge=sunken;resizable=1;");
	}
}

// Popup de Upload file Ban tin
function Upload_BANTIN(id, tenfile, ngaythang, H, W)
{
	if (id!= "")
	{
		return showModalDialog("Upload.asp?ID="+id+"&tenfile="+tenfile+"&ngaythang="+ngaythang,"","dialogWidth:"+W+"px;dialogHeight:"+H+"px;scroll:no;help:0;status:0;center:1;edge=sunken;resizable=1;");
	}
}

// Popup de Upload file Van ban can gop y
function Upload_VANBAN(id, ngaythang, H, W)
{
	if (id!= "")
	{
		return showModalDialog("Upload.asp?ID="+id+"&ngaythang="+ngaythang,"","dialogWidth:"+W+"px;dialogHeight:"+H+"px;scroll:no;help:0;status:0;center:1;edge=sunken;resizable=1;");
	}
}

//-----------------------So sánh ngày --------------------
//										Tra ve 1 neu day2 > day 1
//										Tra ve 0 neu day2 = day 1
//										Tra ve -1 neu day2 < day 1
//--------------------------------------------------------

function compare_two_day(day1, day2)
{
	var trave = 0;
	var nam1 = parseInt(day1.substring((day1.length)-4, day1.length), 10);
	var nam2 = parseInt(day2.substring((day2.length)-4, day2.length), 10);
	if (nam2 > nam1 )
	{
		trave = 1;
	}
	else		// nam2 <= nam1
	{
		trave = -1;
		if (nam2 == nam1)
		{
			var vt1 = day1.indexOf("/", 1);				// Lay vi trí ngày cua day1 12/xx/xxxx	->2
			var vt2 = day2.indexOf("/", 1);				//	Lay vi trí ngày cua day1 5/xx/xxxx	->1
//			var thang1 = day1.indexOf("/", vt1+1);			Vi tri bat dau cua thang1
//			var thang2 = day2.indexOf("/", vt2+1);			Vi tri bat dau cua thang2		
			var thang1 = parseInt(day1.substring(vt1+1, (day1.length)-5), 10);
			var thang2 = parseInt(day2.substring(vt2+1, (day2.length)-5), 10);
			if (thang2 > thang1)
			{
				trave = 1;
			}
			else		// thang1 <= thang2
			{
				trave = -1;
				if (thang2 == thang1)
				{
					ngay1 = parseInt(day1.substring(0, vt1), 10);
					ngay2 = parseInt(day2.substring(0, vt2), 10);
					if (ngay2 > ngay1)
					{
						trave = 1;
					}
					else
					{
						if (ngay2 == ngay1)
						{
							trave = 0;
						}
						else
						{
							trave = -1;
						}
					}
				}
			}
		}
	}
	return trave;
}

