<!--

var mntimer, mnflag, mndiv;

function check_price_deal(){
	if ( document.getElementById('price_deal').checked == true ){
		//document.getElementById('price').value		= '';
		document.getElementById('price').disabled	= true;
	}
	else{
		document.getElementById('price').disabled	= false;
	}
}

function menu_open(div_id){
	document.getElementById(div_id).style.display	= '';
	mndiv	= div_id;
	mnflag	= 1;
}

function menu_close(){
	mnflag		= 0;
	mntimer		= setTimeout('menu_close_finish()', 500);
}

function menu_close_finish(){
	if ( !mnflag ){
		document.getElementById(mndiv).style.display	= 'none';
	}
}

function menu_close_cancel(){
	mnflag		= 1;
}

function load_district(city_id, district_id, box_name, div_id){
	if ( city_id > 0 ){
		ajaxLoadURL("ajax.php?act=load_district&city_id="+ city_id +"&boxname="+ box_name +"&selected_id="+ district_id +"&css=is&s_all=1", div_id);
	}
	else{
		document.getElementById(div_id).innerHTML	= '<select class="is" name="sdistrict_id"><option value="0">-- Quận / Huyện --</option></select>';
	}
}

function change_search_form(search_type){
	if ( search_type != '' ){
		document.MENUFORM.search_type.value		= search_type;
	}
	else{
		search_type		= document.MENUFORM.search_type.value ? document.MENUFORM.search_type.value : 'estate';
	}
	var search_list		= new Array('estate', 'project', 'company', 'news');
	var search_text		= new Array('Bất động sản', 'Dự án', 'Doanh nghiệp', 'Thông tin');

	var flag	= -1;
	for (i=0; i<search_list.length; i++){
		if ( search_list[i] == search_type ){
			document.getElementById('Div_'+ search_list[i]).style.display	= '';
			flag	= i;
		}
		else{
			document.getElementById('Div_'+ search_list[i]).style.display	= 'none';
		}
	}

	if ( flag != -1 ){
		document.getElementById('Div_sTitle').innerHTML		= search_text[flag];
	}
}

function goTop(){
	var url			= window.location + "";
	if ( url.indexOf('#top') == -1 ){
		url			+= '#top';
	}
	window.location		= url;
}

function checkSearchForm(the_form, default_text){
	if ( (the_form.skeyword.value == "") || (the_form.skeyword.value == default_text) ){
		alert('Vui lòng nhập từ khóa cần tìm');
		the_form.skeyword.focus();
		return false;
	}
	return true;
}

function checkDateForm(the_date){
	var date_str	= the_date.value;
	if ( date_str.indexOf('-') != -1 ){
		var date_info	= date_str.split('-');
		if ( date_info.length == 3 ){
			return true;
		}
	}
	alert('Vui lòng chọn ngày');
	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 - 50 : 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){
	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; }

	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 get_radio_value(the_list){
	for (i=0; i<the_list.length; i++){
		if ( the_list[i].checked == true ){
			return the_list[i].value;
		}
	}
	return "";
}

function gotoTop(){
	var url		= window.location + "";
	if ( url.indexOf('#') == -1 ){
		window.location		= window.location +"#";
	}
	else{
		window.location		= window.location;
	}
}

function set_homepage(obj, site_url){
	var the_browser		= navigator.userAgent.toLowerCase();
	var browser_ie		= ((the_browser.indexOf("msie") != -1) && (the_browser.indexOf("opera") == -1));

	if ( browser_ie ){
		obj.style.behavior		= 'url(#default#homepage)';
		obj.setHomePage(site_url);
	}
	else{
		alert('Trình duyệt bạn đang sử dụng không hỗ trợ chức năng này!');
	}
	return false
}

function renew_list(the_url) {
	if (check_selected_items()){
		question = confirm(msg_renew_confirm);
		if (question != "0"){
			the_form.action = the_url;
			the_form.submit();
		}
	}
}

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;
}

function submit_list_form(flag) {
	if (check_selected_items()){
		the_form.factive.value = flag;
		the_form.submit();
	}
}

function check_all_box(status) {
	for (i = 0; i < the_form.length; i++) {
		the_form.elements[i].checked = status;
	}
}

function show_hide(div_id){
	if ( document.getElementById(div_id).style.display == '' ){
		document.getElementById(div_id).style.display = 'none';
	}
	else{
		document.getElementById(div_id).style.display = '';
	}
}

function mycarousel_initCallback(carousel){
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
 
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
 
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });

    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });

    jQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });
};

function mycarousel_initCallback3(carousel){
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};
 
function mycarousel_initCallback5(carousel){
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
 
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
 
    // Pause autoscrolling if the user moves with the cursor over the clip.
    /*
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
    */

    jQuery('#mycarousel-prev5').bind('click', function() {
        carousel.prev();
        return false;
    });

    jQuery('#mycarousel-next5').bind('click', function() {
        carousel.next();
        return false;
    });
};

function mycarousel_initCallback6(carousel){
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
 
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
 
    // Pause autoscrolling if the user moves with the cursor over the clip.
    /*
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
    */

    jQuery('#mycarousel-prev6').bind('click', function() {
        carousel.prev();
        return false;
    });

    jQuery('#mycarousel-next6').bind('click', function() {
        carousel.next();
        return false;
    });
};

-->	
