function btn_save_idea_onclick(f){
	if (!verify(f)){
		return false;
	}
	f.submit();
}
function resizeImageWithLink(max_width, width, height, objImage) {
	if (width > max_width)	{
		objImage.onclick = function () { openImage (objImage.src, height, width) };
		objImage.className = "image_link";
	}
}

function resizeImageWithoutLink(max_width, objImage) {
	if (objImage.width > max_width)	{
		objImage.width = max_width;
	}
}

function openImage(vLink, vHeight, vWidth)
{
	var sLink = (typeof(vLink.href) == 'undefined') ? vLink : vLink.href;

	if (sLink == '')
	{
		return false;
	}

	winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	newwin = open('', '_blank', winDef);

	newwin.document.writeln('<title>UBND quan Ngo Quyen</title><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<a href="" onClick="window.close(); return false;"><img src="', sLink, '" alt="', 'Dong lai', '" border=0></a>');
	newwin.document.writeln('</body>');

	if (typeof(vLink.href) != 'undefined')
	{
		return false;
	}
}

function goto_url(p_url,p_open_new_win)
{
	if (parseInt(p_open_new_win)==1){
		open_me(p_url, 0, 1, 1, 1, 1, 0, 1, 1, 300, 450, 0, 0);
	}else{
		window.parent.location = p_url;	
	}
}

//Xu ly khi NSD nhan vao nut anh cua don vi chua cac function.
//Trong man hinh danh sach nguoi su dung cua mot ung dung (goi tu file dsp_all_function.php va dsp_all_staff_for_application)
function show_menu_on_parent_menu(img_obj){
	var v_count;
	//Thay doi anh hien thi cua modul
	var v_img_path = img_obj.src.substring(0, img_obj.src.lastIndexOf('/') + 1);
	if (img_obj.status == "on"){
		img_obj.status = "off";
		eval('img_obj.src = v_img_path + "close.gif"');
	}else{
		img_obj.status = "on";
		eval('img_obj.src = v_img_path + "open.gif"');
	}
	try{	
		//dat che do hien thi cho cac tr_function thuoc modul
		v_count = document.all.tr_menu.length;
		if (v_count){
			for (var i=0; i<v_count; i++){
				if (img_obj.status == "on"){
					if (eval('document.all.tr_menu[i].parent_menu == img_obj.parent_menu')){
						eval('document.all.tr_menu[i].style.display = "block"');
					}
				}else{
					if (eval('document.all.tr_menu[i].parent_menu == img_obj.parent_menu')){
						eval('document.all.tr_menu[i].style.display = "none"');
					}
				}
			}
		}else{
			if (img_obj.status == "on"){
				if (eval('document.all.tr_menu.parent_menu == img_obj.parent_menu')){
					eval('document.all.tr_menu.style.display = "block"');
				}
			}else{
				if (eval('document.all.tr_menu.parent_menu == img_obj.parent_menu')){
					eval('document.all.tr_menu.style.display = "none"');
				}
			}
		}
	}catch(e){;}
}

//Xu ly khi NSD nhan vao ten loai danh muc
function show_list_on_listtype(p_listtype_obj,p_row_obj){
	var v_count;
	
	if (p_listtype_obj.status == "on"){
		p_listtype_obj.status = "off";
	}else{
		p_listtype_obj.status = "on";
	}
	try{	
		//dat che do hien thi cho cac tr_user thuoc unit
		v_count = p_row_obj.length;
		if (v_count){
			for (var i=0; i<v_count; i++){
				if (p_listtype_obj.status == "on"){
					if (eval('p_row_obj[i].listtype == p_listtype_obj.listtype')){
						eval('p_row_obj[i].style.display = "block"');
					}
				}else{
					if (eval('p_row_obj[i].listtype == p_listtype_obj.listtype')){
						eval('p_row_obj[i].style.display = "none"');
					}
				}
			}
		}else{
			if (p_listtype_obj.status == "on"){
				if (eval('p_row_obj.listtype == p_listtype_obj.listtype')){
					eval('p_row_obj.style.display = "block"');
				}
			}else{
				if (eval('p_row_obj.listtype == p_listtype_obj.listtype')){
					eval('p_row_obj.style.display = "none"');
				}
			}
		}
	}catch(e){;}
}


function see_article_from_date(p_from_date_obj, p_website_id,p_menu_id, p_parent_menu_id, p_fuseaction)
{

	var v_date_value = p_from_date_obj.value;
	
	if (v_date_value!="")
	{
		window.location = "index.asp?website_id=" + p_website_id + "&menu_id=" + p_menu_id + "&parent_menu_id=" + p_parent_menu_id + "&fuseaction=" + p_fuseaction + "&from_date=" + (v_date_value) + "&show_date=1" ;
	}
}

function txt_search_keydown(form,p_goto_url){
	key = event.keyCode;
	if (key==13 && form.txt_search.value!="" && form.txt_search.value.length>1){
		btn_search_onclick(form,p_goto_url);
	}	
}
function btn_search_onclick(form,p_goto_url){
	if (form.txt_search.value!="" && form.txt_search.value.length>1){
		go_url = p_goto_url + "&txt_search=" + form.txt_search.value;
		go_url = go_url + "&search_type=" + form.search_type.value;
		window.location =  go_url ;			
	}		
}

function txt_advance_search_keydown(form,p_goto_url){
	key = event.keyCode;
	if (key==13){
		btn_advance_search_onclick(form,p_goto_url);
	}	
}

function btn_advance_search_onclick(form,p_goto_url)
{
	if (form.txt_search.value!="" && form.txt_search.value.length>1){
		var v_menu_id_list;
		v_menu_id_list = checkbox_value_to_list(form.chk_menu_id,",");
		go_url = p_goto_url + "&txt_search=" + form.txt_search.value;
		go_url = go_url + "&menu_id_list=" + v_menu_id_list;
		window.location =  go_url ;
	}
}

function submit_vote(p_form_name,p_action)
{
	//p_action: 0: Vote or 1: View result;
	
	var frm = p_form_name;	
	if (p_action == 0){
		if (frm.hdn_vote_id.value == ""){
			alert('Hay chon mot trong cac muc truoc khi bieu quyet!');
			return;
		}
	}
	var j = 0;
	for (i=0; i < frm.elements.length - 2; i++){
		if(frm.elements[i].type=='radio'){
			j = j + 1; //options
		}
	}	
	var v_height = (j * 23) + 79;
	if (v_height < 78){
		v_height = 78;
	}
	var url = "poll/index.asp?poll_id=" + frm.hdn_poll_id.value;
		url += "&vote_id=" + frm.hdn_vote_id.value;
		url += "&fuseaction=" + p_action;
	window.open(url,'','scrollbars=yes,resizeable=no,locationbar=no,width=375,height='+v_height+',left='.concat((screen.width - 500)/2).concat(',top=').concat((screen.height - 250)/2));
}


function select_link_onchange(form){
	if (form.sel_link.value=="-1")
		return;
	for (i=0; i<form.sel_link.length; i++) 
	{
		if (form.sel_link.options[i].selected) 
		{
			if (form.sel_link.options[i].new_win=="1")
				open_me(form.sel_link.options[i].goto_url, 0, 1, 1, 1, 1, 0, 1, 1, 300, 450, 0, 0);
			else
				window.parent.location = form.sel_link.options[i].goto_url;
			return;
		}		
	}
}	
/*************************************************
*	Mo mot window popup va ghi noi dung ra cua so popup
**************************************************/

function print_alert(title,height, width, css_file_name,style, title_alert, content_alert,imageURL){
	content_alert = content_alert.replace('&#39;',"'");
	content_alert = content_alert.replace("&#34;",'"');
		
	winDef = 'status=no,resizable=yes,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(height).concat(',').concat('width=').concat(width).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - height)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - width)/2);
	newwin = open('', '_blank', winDef);
	newwin.document.writeln('<html>');
	newwin.document.writeln('<head>');
	newwin.document.writeln('<title>'+title+'</title>');
	newwin.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">');
	newwin.document.writeln('<link rel="stylesheet" href="' + css_file_name + '" type="text/css">');
	newwin.document.writeln('</head>');
	newwin.document.writeln('<body topmargin=3 leftmargin=0 marginheight=0 marginwidth=0 class=body_alert>');
	newwin.document.writeln('<table class="table_alert" align="center">');
	if(style==0){
		newwin.document.writeln('<tr>');
		newwin.document.writeln('<td class=alert_title>');
		newwin.document.writeln(title_alert);
		newwin.document.writeln('</td>');
		newwin.document.writeln('</tr>');
		
		newwin.document.writeln('<tr>');
		newwin.document.writeln('<td class=alert_content>');
		newwin.document.writeln(content_alert);
		newwin.document.writeln('</td>');
		newwin.document.writeln('</tr>');
	}else{	
			newwin.document.writeln('<tr>');
			newwin.document.writeln('<td class=alert_image>');
			arr_temp = imageURL.split(".");	
			file_type = arr_temp[arr_temp.length -1].toUpperCase();	
			if(file_type!="SWF"){
				newwin.document.writeln('<img src="', imageURL, '" alt="','" border=0>');
			}else{
				newwin.document.writeln('<object id="swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" >');
				newwin.document.writeln('<param name="movie" value="'+imageURL+'">');
				newwin.document.writeln('<param name="quality" value="high">');
				newwin.document.writeln('<embed name="swf" src="'+imageURL+'"');
				newwin.document.writeln('quality="high"');
				newwin.document.writeln('pluginspage="http://www.macromedia.com/go/getflashplayer"');
				newwin.document.writeln('type="application/x-shockwave-flash" >');
				newwin.document.writeln('</embed>');
				newwin.document.writeln('</object>');
			}			
			newwin.document.writeln('</td>');
			newwin.document.writeln('</tr>');
		}
	newwin.document.writeln('</table>');
	newwin.document.writeln('</body>');
	newwin.document.writeln('</html>');
	return false;
}

// gui dang ky thue mat bang
function btn_send_premises_onclick(form,p_fuseaction){
	if (!verify(form)){
		return false;
	}
	form.fuseaction.value = p_fuseaction;
	form.submit();
}

/*--------BAT DAU PHAN GUI TIN PHAN HOI-----*/
function btn_save_article_reply_onclick(form,p_fuseaction){
	if (!verify(form)){
		return false;
	}
	// Luu cac anh duoc Upload
	if(remember_list()) {
		form.fuseaction.value = p_fuseaction;
		form.submit();
	}
}

/* get file name from the full path */
function get_filename(strPath){
	i=strPath.lastIndexOf('\\') +1;
	return strPath.substring(i,strPath.length);
}

/*to get image and asign to list*/
function assign_filename(file_element,index){
	try{
		document.all.hdn_file_attach_location[index].value=get_filename(file_element.value);
	}catch(e){;}
}
/* to remember list of document & image inserted */
function remember_list(){
	var strList="";
	// file dinh kem
	for(i=0;i<document.all.hdn_file_attach_location.length;i++){
		if(document.all.hdn_file_attach_location[i].value!=""){
			// Kiem tra dinh dang file Upload co duoc phep khong
			if (!is_valid_upload_file_type(document.all.hdn_file_attach_location[i].value,_CONST_ATTACH_FILE_TYPE_UPLOAD,"","File dinh kem khong dung dinh dang")){
				return false;
			}
			
			if (strList=="")
				strList=document.all.hdn_file_attach_location[i].value;
			else
				strList= strList + "," + document.all.hdn_file_attach_location[i].value;
		}
	}
	document.all.hdn_file_attach_list.value=strList;
	return true;
}


/*--------KET THUC PHAN GUI TIN PHAN HOI-----*/


/*--------BAT DAU XUAT BAN TIN BAI RA RSS-----*/
function rss_row_onclick(p_url,p_menu_id,p_hdn_obj,p_day_obj){
	var the_window;
	var time_type = p_hdn_obj.value;
	if (time_type=="OTHER"){
		if(!(isnum(p_day_obj.value))){
			alert('Ngay nhap vao phai la so nguyen duong!');
			return;
		}
		time_type = p_day_obj.value;
	}
	var v_url = p_url + "&menu_id=" + p_menu_id + "&time_type="+time_type;  
	the_window=window.open(v_url,null,"");
	the_window.focus();
}
function rad_time_type_onclick(p_rad_obj,p_day_obj,p_hdn_obj){
	if(p_rad_obj.value=="OTHER"){
		p_day_obj.style.display= "block";
	}else{
		p_day_obj.style.display= "none";		
	}
	p_hdn_obj.value =p_rad_obj.value;
}
function menu_onclick(p_url){
	var the_window;
	the_window=window.open(p_url,null,"");
	the_window.focus();
}
/*--------KET THUC XUAT BAN TIN BAI RA RSS-----*/


function showDialog(vLink, vWidth, vHeight)
{
return showWindow(vLink, false, true, true, false, false, false, true, true, vWidth, vHeight, 0, 0);
}

function showModalDialog(vLink, vWidth, vHeight)
{
return showWindow(vLink, false, false, false, false, false, false, true, true, vWidth, vHeight, 0, 0);
}

function showWindow(vLink, vStatus, vResizeable, vScrollbars, vToolbar, vLocation, vFullscreen, vTitlebar, vCentered, vWidth, vHeight, vTop, vLeft)
{
var sLink = (typeof(vLink.href) == 'undefined') ? vLink : vLink.href;

winDef = '';
winDef = winDef.concat('status=').concat((vStatus) ? 'yes' : 'no').concat(',');
winDef = winDef.concat('resizable=').concat((vResizeable) ? 'yes' : 'no').concat(',');
winDef = winDef.concat('scrollbars=').concat((vScrollbars) ? 'yes' : 'no').concat(',');
winDef = winDef.concat('toolbar=').concat((vToolbar) ? 'yes' : 'no').concat(',');
winDef = winDef.concat('location=').concat((vLocation) ? 'yes' : 'no').concat(',');
winDef = winDef.concat('fullscreen=').concat((vFullscreen) ? 'yes' : 'no').concat(',');
winDef = winDef.concat('titlebar=').concat((vTitlebar) ? 'yes' : 'no').concat(',');
winDef = winDef.concat('height=').concat(vHeight).concat(',');
winDef = winDef.concat('width=').concat(vWidth).concat(',');

if (vCentered)
{
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
}
else
{
	winDef = winDef.concat('top=').concat(vTop).concat(',');
	winDef = winDef.concat('left=').concat(vLeft);
}

open(sLink, '_blank', winDef);

if (typeof(vLink.href) != 'undefined')
{
	return false;
}
}

//function show_hide_menu(p_menu_id,p_parent_menu_id){
//	//try{
//		// hien thi cac chuyen muc con
//		//document.getElementById("tr_child_menu"+p_parent_menu_id).style.display = "block";
//	//}catch(e){;}
//	try{
//		// cho active chuyen muc cha
//		document.getElementById("left_menu_"+p_parent_menu_id).className="menu_level_1_active";
//		if(p_menu_id !=p_parent_menu_id ){
//			// cho active chuyen muc con
//			document.getElementById("left_menu_"+p_menu_id).className = "menu_level_2_active";
//		}
//	}catch(e){;}
//	
//}

function show_hide_menu(p_menu_id,p_parent_menu_id){
	try{
		// hien thi cac chuyen muc con
		//document.getElementById("tr_child_menu"+p_parent_menu_id).style.display = "block";
	}catch(e){;}
	
	try{
		// cho active chuyen muc cha
		document.getElementById("below_banner_menu_"+p_parent_menu_id).className = "below_banner_menu_active";		
	}catch(e){;}
	
	try{
		// khi show chuyen muc con thi khong show menu drop nua
		//document.getElementById("menu"+p_parent_menu_id).value = 1;		
	}catch(e){;}
	
	try{
		// cho active chuyen muc cha		
		document.getElementById("menu"+p_parent_menu_id).className = "menu_level_1_active";

		if(p_menu_id !=p_parent_menu_id ){
			// cho active chuyen muc con
			document.getElementById("menu"+p_menu_id).className = "menu_level_2_active";
		}
	}catch(e){;}
}


var curBanner1;
var BannerLnk1;
function ChangeBanner1(arBanner, strLnk, strImg)
{
	if (arBanner.length==0)
		return;
	curBanner1++;
	if (curBanner1 >= arBanner.length)
	{
		curBanner1=0;
	}
	document.links[BannerLnk1].href= arBanner[curBanner1][1];
	document.images[strImg].src = arBanner[curBanner1][0];
	document.images[strImg].width = arBanner[curBanner1][2];
	document.images[strImg].height = arBanner[curBanner1][3];
}
function DisplayBanner1(strAr, arBanner, strLnk, strImg,strClickTarget)
{
	curBanner1=Math.floor(Math.random()*12321) % arBanner.length;
	BannerLnk1=document.links.length;
	if(arBanner[curBanner1][1] !=""){
		document.write('<a name="',strLnk,'" href="', arBanner[curBanner1][1], '" target="',strClickTarget,'"><img name="',strImg,'" src="', arBanner[curBanner1][0], '" width=', arBanner[curBanner1][2], ' height=',arBanner[curBanner1][3], ' border=0></a>');
	}else{
		document.write('<img name="',strImg,'" src="', arBanner[curBanner1][0], '" width=', arBanner[curBanner1][2], ' height=',arBanner[curBanner1][3], ' border=0>');
	}
	setInterval('ChangeBanner1('+strAr+', \''+strLnk+'\', \''+strImg+'\')', 7000);
}


/*
Tao object XmlHttpRequest. Vi trinh duyet IE va Mozilla ap dung ky thuat nay theo 2 cach khac nhau,
de dam bao tinh tuong thich, chung ta se can phai kiem tra xem nguoi dung dang su dung trinh duyet nao
va tao doi tuong XmlHttpRequest theo phuong thuc ho tro boi trinh duyet do.
*/
var req;
/*
Ham (function) processReqChange la ham chiu trach nhiem chinh xu ly viec goi du lieu va nhan du lieu.
Cac buoc ma ham nay thuc hien:
1. Doi cho den khi may chu gui phan hoi thong bao la no da xu ly xong
2. Doc thong bao tu may chu (may chu se gui status=200 nen xu ly thanh cong, 404 neu file khong tim thay,...).
Neu may chu noi la xu ly thanh cong, tiep tuc buoc tiep theo
3. Nhan du lieu ve duoi dang XML. Su dung DOM de phan tich du lieu XML.
File XML nhan ve se cung cap cac thong tin:
	a) Ten ham goi ban dau (giua 2 the <method> va </method>)
	b) Gia tri thong bao ket qua thuc hien ham do (giua 2 the <result> va </result>)
Biet duoc 2 thong tin tren, goi lai ham do (eval) voi gia tri tra ve de cap nhap giao dien
Vi du, ham checkName() goi thong tin len may chu hoi, may chu tra ve ten ham la checkName va ket qua la 1. Ta se goi:
	checkName('',1);
*/
function processReqChange()
{
	if (req.readyState == 4) { // Complete
	  if (req.status == 200) { // OK response
		try{
			document.getElementById("table_other_info").innerHTML = req.responseText;
		}catch(e){;}
	  } else {
		alert("Problem: " + req.statusText);
	  }
	}
}

function show_hide_other_info(p_other_info_obj){
	try{
		if(document.getElementById(p_other_info_obj).className == "show"){
			document.getElementById(p_other_info_obj).className = "hide";
		}else{
			document.getElementById(p_other_info_obj).className = "show";
		}
	} catch (e) {;}
}	

function process_other_info()
{
	if (req_other_info.readyState == 4) { // Complete
	  if (req_other_info.status == 200) { // OK response
		try{
			document.getElementById("table_other_info").innerHTML = req_other_info.responseText;
		}catch(e){;}
	  } else{
		  try{			
			document.getElementById("table_other_info").innerHTML = "<img src=\"../images/loading.gif\">";
		  } catch(e){;}
	  }
	}
}

function show_other_info(p_goto_url) {
	try{
		// branch for native XMLHttpreq_other_infouest object
		if (window.XMLHttpRequest) {
			req_other_info = new XMLHttpRequest();
			req_other_info.onreadystatechange = process_other_info;
			req_other_info.open("GET", p_goto_url, true);
			req_other_info.send(null);
		// branch for IE/Windows ActiveX version
		} else if (window.ActiveXObject) {
			req_other_info = new ActiveXObject("Microsoft.XMLHTTP");
			if (req_other_info) {
				req_other_info.onreadystatechange = process_other_info;
				req_other_info.open("GET", p_goto_url, true);
				req_other_info.send();
			}
		}
	} catch(e){;}	
}

