<!--

function loadYP(city_id){
	if (city_id > 0){
		ajaxLoadURL('index.php?act=ajax_yp&city_id='+ city_id, 'Div_YP');
	}
}

function gotoYP(city_id){
	if (city_id > 0){
		window.location = 'yp.php?scity_id='+ city_id;
	}
}

function limitLength(the_input, limit_chars){
	var content = the_input.value;
    if ( content.length > limit_chars ){
        the_input.value = content.substr(0, limit_chars);
	}
	if ( document.getElementById('limitDesc').innerText ){
     	document.getElementById('limitDesc').innerText		= "(Số ký tự còn hiệu lực: "+ (limit_chars - content.length) +")";
	}
	else{
        document.getElementById('limitDesc').textContent	= "(Số ký tự còn hiệu lực: "+ (limit_chars - content.length) +")";
	}
}

function changeMenu(the_menu){
	document.getElementById(the_menu).style.backgroundImage = 'url(images/bgtopmenu-ac.gif)';
}

function restoreMenu(the_menu){
	document.getElementById(the_menu).style.backgroundImage = 'url(images/bgtopmenu.gif)';
}

function check_all_box(status) {
	for (i = 0; i < the_form.length; i++) {
		the_form.elements[i].checked = status;
	}
}

function check_login_form(the_form){
	if ( (the_form.email.value == "") || (the_form.password.value == "") ){
		alert('Vui lòng nhập Email và Mật khẩu');
		return false;
	}
	return true;
}

function bookmark(title, url){
	if (document.all){
		window.external.AddFavorite(url, title);
	}
	else if (window.sidebar){
		window.sidebar.addPanel(title, url, "");
	}
}

function search_all_modules(the_form){
	var module_url	= the_form.smodule.options[the_form.smodule.selectedIndex].value;
	if ( module_url != ""){
		the_form.action	= module_url;
		return true;
	}
	alert("Vui lòng chọn trang cần tìm !");
	return false;
}

//Open normal popup
function open_popup(the_url, the_width, the_height, the_menu) {
	if ( the_width == 0 ){
		the_width	= screen.width;
	}
	if ( the_height == 0 ){
		the_height	= screen.height;
	}

	left_val	= (the_width > 0) ? (screen.width - the_width)/2 : 0;
	top_val		= (the_height > 0) ? (screen.height - the_height)/2 - 30 : 0;
	if (top_val < 0){ top_val	= 0; }
	if (the_menu == ""){ the_menu	= "no";	}

	window.open(the_url, "", "menubar="+ the_menu +", toolbar="+ the_menu +", scrollbars=yes, resizable=yes, width="+ the_width +", height="+ the_height +", top="+ top_val +", left="+ left_val);
}

//Open popup when users submit form
function open_popup_form(the_url, targetName, the_width, the_height){
	left_val	= (the_width > 0) ? (screen.width - the_width)/2 : 0;
	top_val		= (the_height > 0) ? (screen.height - the_height)/2 - 30 : 0;
	if (top_val < 0){ top_val	= 0; }

	window.open(the_url, targetName, "menubar=no, toolbar=no, scrollbars=yes, resizable=yes, width="+ the_width +", height="+ the_height +", top="+ top_val +", left="+ left_val);
}

//Check and open popup when use chose web links
function weblink_openURL(the_url){
	if ( the_url != "" ){
		window.open(the_url);
	}
}

function select_list(the_value, the_list){
	var option_count = the_list.options.length;
	for (i=0; i<option_count; i++){
		if (the_value == the_list.options[i].value){
			the_list.options[i].selected	= true;
			break;
		}
	}
}

function radio_list(the_value,the_list){
	var name_count = the_list.length;
	for (i=0; i<name_count; i++){
		if (the_value == the_list[i].value){
			the_list[i].checked	= true;
			break;
		}
	}
}

function openImage(the_img, the_width, the_height)
{
	winDef = 'status=no,resizable=yes,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes, width='+ the_width +'px, height='+ the_height +'px';
	winDef = winDef.concat(',top=').concat((screen.height - the_height)/2 - 30);
	winDef = winDef.concat(',left=').concat((screen.width - the_width)/2);
	newwin = open('', '_blank', winDef);

	newwin.document.writeln('<html><title>Picture</title><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<center><a href="" onClick="window.close(); return false;"><img src="', the_img, '" alt="Close" border=0 align="center"></a></center>');
	newwin.document.writeln('</body></html>');

	return false;
}

function delete_list(the_url) {
	if (check_selected_items()){
		question = confirm(msg_del_confirm);
		if (question != "0"){
			the_form.action = the_url;
			the_form.submit();
		}
	}
}

function del_confirm() {
	question = confirm(msg_del_confirm);
	if (question != "0"){
		return true;
	}
	return false;
}

function check_selected_items(){
	var name_count = the_form.length;

	for (i=0;i<name_count;i++){
		if (the_form.elements[i].checked){
			return true;
		}
	}

	alert(msg_choose_record);
	return false;
}

-->