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;
	}
}

// khaitn them doan ham nay
// ngay them 07/08/2007
//noi dung: width="', vWidth ,'" tai vi tri dong so 39.
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>ISA-WEB 7.0 - C&#244;ng ty CNTH ISA</title><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<title>HAI TUYEN. CO. L.T.D</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 width="', vWidth ,'"></a>');
	newwin.document.writeln('</body>');

	if (typeof(vLink.href) != 'undefined')
	{
		return false;
	}
}

function goto_url(p_url,p_open_new_win)
{
	if (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){
		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;
		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 * 40) + 50;
	if (v_height < 250){
		v_height = 250;
	}
	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=500,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('&lt;', '<');
	content_alert = content_alert.replace('&gt;', '>');
	content_alert = content_alert.replace('"','\"');
	content_alert = content_alert.replace("'","\'");
		
	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;
}

/*--------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 đính kèm không đúng định dạng")){
				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_tr_menu_obj){
	try{	
		var v_count = p_tr_menu_obj.length*1;
		if (v_count>0){
			for (var i=0; i<v_count; i++){
				p_tr_menu_obj[i].style.display = "block";
			}
		}else{
			p_tr_menu_obj.style.display = "block";
		}
	}catch(e){;}
}

//khaitn them ham nay de su ly cho viet dang ky tai khaon cua thanh vien tren mang. ngay 19-07-2007
// kiem tra longin tai khoan vao
function btn_login_onclick(p_form_name,p_fuseaction){
	if(trim(p_form_name.txt_user_name.value) ==""){
		alert('Ten dang nhap khong duoc bo trong');
		p_form_name.txt_user_name.focus();
		return;
	}
	if(trim(p_form_name.txt_password.value) ==""){
		alert('Mat khau khong duoc bo trong');
		p_form_name.txt_password.focus();
		return;
	}
	<!--Luu lai url cua trang hien thoi de quay lai-->
	v_url = window.location.href;
	p_form_name.fuseaction.value = p_fuseaction;
	p_form_name.url_back.value = v_url;
	p_form_name.submit();
}
// ham dang ky tai khoan thanh vien tren mang
function btn_customer_register_onclick(p_goto_url,p_fuseaction){
	v_url = p_goto_url + "&fuseaction=" + p_fuseaction;
	window.location = v_url;
}
// ham kiem tra check cac field dang nhap vao
function btn_save_customer_onclick(p_form_name,p_fuseaction){
	var v_date_of_birth;	
	// kiem tra ho va ten 
	if(p_form_name.txt_name.value==""){
		alert("Ho va ten khong duoc bo trong");
		p_form_name.txt_name.focus();
		return;
	}
	// kiem tra ngay sinh
	if(p_form_name.sel_birth_day.value==""){
		alert("Ngay sinh khong duoc bo trong");
		p_form_name.sel_birth_day.focus();
		return;
	}
	// kiem tra thang sinh
	if(p_form_name.sel_birth_month.value==""){
		alert("Thang sinh khong duoc bo trong");
		p_form_name.sel_birth_month.focus();
		return;
	}
	// kiem tra nam sinh
	if(p_form_name.sel_birth_year.value==""){
		alert("Nam sinh khong duoc bo trong");
		p_form_name.sel_birth_year.focus();
		return;
	}
	// kiem tra ngay sinh da hop le chua
	v_date_of_birth = p_form_name.sel_birth_day.value + "/" + p_form_name.sel_birth_month.value + "/" + p_form_name.sel_birth_year.value;
	if(!isdate(v_date_of_birth)){
		alert("Ngay sinh khong hop le");
		p_form_name.sel_birth_day.focus();
		return;
	}
	// kiem tra dia chi email
	if((p_form_name.txt_email.value=="") || (!isemail(p_form_name.txt_email.value))){
		alert("Dia chi email bi bo trong hoac khong hop le");
		p_form_name.txt_email.focus();
		return;
	}
	// kiem tra dia chi
	if(p_form_name.txt_address.value==""){
		alert("Dia chi khong duoc bo trong");
		p_form_name.txt_address.focus();
		return;
	}
	
	// kiem tra thanh pho
	if(p_form_name.txt_city.value==""){
		alert("Tinh/ Thanh pho khong duoc bo trong");
		p_form_name.txt_city.focus();
		return;
	}
	// kiem tra dien thoai
	if(p_form_name.txt_tel.value==""){
		alert("Dien thoai co dinh khong duoc bo trong");
		p_form_name.txt_tel.focus();
		return;
	}
	// kiem tra so tai khoan
	/*
	if(p_form_name.txt_account.value==""){
		alert("So tai khoan khong duoc bo trong");
		p_form_name.txt_account.focus();
		return;
	}
	if(!isnum(p_form_name.txt_account.value)){
		alert("So tai khoan phai la cac so tu 0 den 9");
		p_form_name.txt_account.focus();
		return;
	}
	*/
	// kiem tra ngan hang dang ky tai khoan
	/*
	if(p_form_name.txt_bank.value==""){
		alert("Ngan hang dang ky tai khoan khong duoc bo trong");
		p_form_name.txt_bank.focus();
		return;
	}*/
	// kiem tra ten truy cap
	if(p_form_name.txt_login_name.value==""){
		alert("Ten truy cap khong duoc bo trong");
		p_form_name.txt_login_name.focus();
		return;
	}
	// kiem tra mat khau
	if(p_form_name.txt_password.value==""){
		alert("Mat khau khong duoc bo trong");
		p_form_name.txt_password.focus();
		return;
	}
	// kiem tra mat khau go lai da chinh xac chua
	if(p_form_name.txt_password.value != p_form_name.txt_retype_password.value){
		alert("Mat khau nhap lai khong chinh xac");
		p_form_name.txt_retype_password.focus();
		return;
	}
	// kiem tra ma so xac nhan
	if(p_form_name.txt_serect_number.value == ""){
		alert("Ma so xac nhan khong duoc bo trong");
		p_form_name.txt_serect_number.focus();
		return;
	}
	p_form_name.fuseaction.value = p_fuseaction;
	p_form_name.submit();
	
}
// doi mat khau. khaitn them
function btn_change_password_onclick(p_form_name,p_fuseaction){
	<!--Luu lai url cua trang hien thoi de quay lai-->
	v_url = window.location.href;
	p_form_name.fuseaction.value = p_fuseaction;
	p_form_name.url_back.value = v_url;
	p_form_name.submit();
}
// kiem tra khi nahn nut doi mat khau tren form doi mat khau. khaitn them
function btn_agree_change_password_onclick(p_form_name,p_fuseaction){
	// kiem tra ten dang nhap
	if(p_form_name.txt_user_name.value==""){
		alert("Ten dang nhap khong duoc bo trong");
		p_form_name.txt_user_name.focus();
		return;
	}
	// kiem tra mat khau cu
	if(p_form_name.txt_old_password.value==""){
		alert("Mat khau cu khong duoc bo trong");
		p_form_name.txt_old_password.focus();
		return;
	}
	// kiem tra mat khau moi
	if(p_form_name.txt_new_password.value==""){
		alert("Mat khau moi khong duoc bo trong");
		p_form_name.txt_new_password.focus();
		return;
	}
	// kiem tra mat khau go lai da chinh xac chua
	if(p_form_name.txt_new_password.value != p_form_name.txt_retype_new_password.value){
		alert("Mat khau moi nhap lai khong chinh xac");
		p_form_name.txt_retype_new_password.focus();
		return;
	}
	
	p_form_name.fuseaction.value = p_fuseaction;
	p_form_name.submit();
}
// ham xu ly khi nhan nut thoat khi dang ky xong. khaitn them
function btn_logout_onclick(p_form_name,p_fuseaction){
	<!--Luu lai url cua trang hien thoi de quay lai-->
	v_url = window.location.href;
	p_form_name.fuseaction.value = p_fuseaction;
	p_form_name.url_back.value = v_url;
	p_form_name.submit();
}
// khaitn . het phan dang ky thanh vien qua mang