var modulesList = '*';

//banner
getBlock('container-banner', 'banner');

//lang
getBlock('container-language', 'lang');

//menu
getBlock('container-menu', 'disaled-menu');
getBlock('top-menu', 'top-menu');

//calendar
autoloadcalendar=function(){setTimeout("autoloadcalendar()",10000);loadModuleEX('calendar','','calendar');};autoloadcalendar();autowritetwodotscalendar=function(){setTimeout("autowritetwodotscalendar()",500);var s=getContainerID('calendar').innerHTML;s=s.replace(String.fromCharCode(10),'');s=s.replace(String.fromCharCode(13),'');var l=s.substring(0,2),d=s.substring(2,3),r=s.substring(3);d=(d==':')?' ':':';getContainerID('calendar').innerHTML=l+d+r;};autowritetwodotscalendar();

//right
//getBlock('container-RIGHT', 'col_right');


//form search
loadModuleEX('taoformsearch', '0', 'container-CENTER-1');

//thong tin TTBDS
//loadModule('getcatnewsintro', '0', 'container-CENTER-2', '', true);

//rao vat
//loadModule('listraovatintro', '0', 'container-CENTER-3', '', true);

//hit
//getBlock('so_nguoi_online_title','so_nguoi_online_title');
//getBlock('so_luot_truy_cap_title','so_luot_truy_cap_title');
whoonline();
visitor();

//hotline-tuvan
getBlock('hotline-tuvan', 'hotline-tuvan');

/* col lef new */
//san giao dich
getBlock('container-LEFT-COL-SAN-GIAO-DICH-TITLE','container-LEFT-COL-SAN-GIAO-DICH-TITLE');
getContainerID('container-LEFT-COL-SAN-GIAO-DICH-DATA').innerHTML = ' ';
//loadModuleEX('getsangiaodichbdscat','left-link','container-LEFT-COL-SAN-GIAO-DICH-DATA');

//dich vu
getBlock('container-LEFT-COL-DICH-VU-TITLE','container-LEFT-COL-DICH-VU-TITLE');
loadModuleEX('getcatdichvuintro','left-link-dich-vu-cat','container-LEFT-COL-DICH-VU-DATA');

//dang tin qua san
getBlock('container-LEFT-COL-DANG-TIN-QUA-SAN-TITLE','container-LEFT-COL-DANG-TIN-QUA-SAN-TITLE');

//dang tin mien phi
getBlock('container-LEFT-COL-DANG-TIN-MIEN-PHI-TITLE','container-LEFT-COL-DANG-TIN-MIEN-PHI-TITLE');

//tra cuu p.thuy
getBlock('container-LEFT-COL-TRA-CUU-PHONG-THUY-TITLE','container-LEFT-COL-TRA-CUU-PHONG-THUY-TITLE');

//tra cuu ban do
getBlock('container-LEFT-COL-TRA-CUU-BAN-DO-TITLE','container-LEFT-COL-TRA-CUU-BAN-DO-TITLE');

//van ban phap luat
getBlock('container-LEFT-COL-VAN-BAN-PHAP-LUAT-TITLE','container-LEFT-COL-VAN-BAN-PHAP-LUAT-TITLE');
loadModuleEX('getcatvanbanphapluatintro','left-link-vbpl-cat','container-LEFT-COL-VAN-BAN-PHAP-LUAT-DATA');

//thamdoykien_top
getBlock('thamdoykien_top','thamdoykien_top');
//tham do 1
//loadModuleEX('vote','getcattitle|3','thamdoykien_title');
//loadModuleEX('vote','showlist|thamdoykien_template|3','thamdoykien_content');
//loadModuleEX('vote','filltemplate|thamdoykien_button_template|catid:3','thamdoykien_button');
//usage: loadModuleEX('vote','autolistall|HTMLTemplateCode|<bodyBlockID>|<footerBlockID>','<containerID>');
loadModuleEX('vote','autolistall|'+getContainerID('thamdoykien_boxall').innerHTML+'|thamdoykien_template|thamdoykien_button_template','thamdoykien_boxall');

//thamdoykien 1
var whndvoteviewresult = null;
function vote_viewresult(mode, catid) //mode{"view"|"vote"}
{
	if (whndvoteviewresult)
	{
		whndvoteviewresult.close();
	}
	
	var param = '?template=thamdoykien_result&catid='+catid;
	
	if (mode == 'vote')
	{
		var voteoptions = document.getElementsByName('voteoption'+catid);
		for (var i=0; i<voteoptions.length; i++)
		{
			if (voteoptions[i].checked)
			{
				param += '&id=' + voteoptions[i].value;
				break;
			}
		}
	}
	
	var w = 600;
	var h = 350;
	var l = (screen.width - w)/2;
	var t = (screen.height - h)/2;
	whndvoteviewresult = window.open('voteresult.php'+param, 'whndvoteviewresult', 'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width='+w+',height='+h+',left='+l+',top='+t+',status');
	whndvoteviewresult.focus();
}

//tuyen dung
getBlock('container-LEFT-COL-TUYEN-DUNG-TITLE','container-LEFT-COL-TUYEN-DUNG-TITLE');

//quang cao left
getBlock('QCL','QCL');
/* end col left new */

/* right */
//usage: loadModuleEX('listlinkvideoclip','getlastedupdateclip|<rows>','<containerID>');
//loadModuleEX('listlinkvideoclip','getlastedupdateclip|6','VIDEO-CLIP');//usage: loadModuleEX('listlinkvideoclip','<id>|<page>','<containerID>'); <id> null to default, <page> null to 1
loadModuleEX('listlinkvideoclip','','VIDEO-CLIP');

/* tin tuc ben phai */
//HELP: loadModuleEX('getcatnewsintroex','<containerID>,<ColsPerRow>','container-danh-muc-tin-tuc-intro');
loadModuleEX('getcatnewsintroex','container-LEFT,2','container-danh-muc-tin-tuc-intro');

//slide BDS
var lSLIDE = new Array();
var idSLIDE = new Array();
var loaibds_idSLIDE = new Array();
var iSLIDE = 0;
var imgSLIDE = getContainerID('imgSLIDE');
var imgSrcSLIDE;
var delaySLIDE = 5000;
function playSlideShowSLIDE()
{
	if (lSLIDE.length > 0)
	{
		imgSrcSLIDE = lSLIDE[iSLIDE].src;
 

		if (navigator.appName == 'Microsoft Internet Explorer') 
		{
			//IE 
			if (document.all) 
			{
				imgSLIDE.style.filter="blendTrans(duration=1);"; //0 --> 11
				imgSLIDE.filters.blendTrans.Apply(); 
				imgSLIDE.src = imgSrcSLIDE;
imgSLIDE.style.width='350px';
imgSLIDE.style.height='280px';
	imgSLIDE.filters.blendTrans.Play();
			}
		} 
		else 
		{
			imgSLIDE.src = imgSrcSLIDE;
imgSLIDE.style.width='350px';
imgSLIDE.style.height='280px';

		}	
						
		if (iSLIDE<lSLIDE.length-1) 
		{
			iSLIDE++;
		} 
		else 
		{
			iSLIDE=0;
		}
	}
	setTimeout("playSlideShowSLIDE()", delaySLIDE);
}
function showBDS()
{
	loadModuleEX('xemchittietnhadat',idSLIDE[iSLIDE]+'|'+loaibds_idSLIDE[iSLIDE],'container-LEFT');
}
//usage: loadModuleEX('slidebds','<OTC>|<ExtImage>|<record limit>','<containerID>');
//<OTC>: all, 0 or 1
//<ExtImage>: 0 or 1
//<record limit>: number or null
loadModuleEX('slidebds','0|1','SLIDEJS');

function sss()
{
	var o = getContainerID('SLIDEJS');
	if (!o)
	{
		setTimeout("sss()", 1000);
	}
	else
	{
		var s = o.innerHTML;
		if (s == '{JS}')
		{
			setTimeout("sss()", 1000);
		}
		else if (s != '')
		{
			try
			{
				eval(s);
				playSlideShowSLIDE();
			}
			catch(e)
			{
				setTimeout("sss()", 1000);
			}
		}
	}
}
//sss();

//quang cao right
getBlock('QCR','QCR');
/* end right */

/* footer */
getBlock('container-FOOTER-TIM-KIEM-THEO-DIA-BAN','container-FOOTER-TIM-KIEM-THEO-DIA-BAN');

//search by dia ban (huyen)
loadModuleEX('fillsearchbydiaban','','container-FOOTER-LIST-TIM-KIEM-THEO-DIA-BAN');
function dosearchtheodiaban(tinh, huyen)
{
	var frm = getContainerID('formsearchbds');
	frm.tinh.value = tinh;
	
	frm.huyen.name = 'h';
	
	frm.thehuyen.name = 'huyen';
	frm.huyen.value = huyen;
	
	checksubmitsearchbds('');
}

//footer
getBlock('container-footer', 'footer');
/* end footer */

//check search bds
var Nhap_Ma_So_vn = '--- Nhập Mã Số ---';
var Nhap_Ma_So_en = '--- Code ---';
function checksubmitsearchbds(msg)
{
return getContainerID('formsearchbds').submit();
   var err = '';
   
   err += getContainerID('tinh').value;
   err += getContainerID('huong').value;
   err += getContainerID('tien').value;
   err += getContainerID('loaibds').value;
   err += getContainerID('loaitinraobds').value;
   err += (getContainerID('code').value == '') ? '' : 'ok';

if (err == '') {
       alert(msg);
       return false;
   } else {
       return getContainerID('formsearchbds').submit();
   }
}

//rao vat
var vn = 'Ban can phai nhap thong tin day du';
var en = 'Please fill value in the form...';
function checkvalue(id)
{
	var o =  getContainerID(id);
	if (o) {
		return (o.value != '') ? 0 : 1;
	} else {
		return 0;
	}
}
function check(msg)
{
	var err = 0;
	
	err += checkvalue('name');
	err += checkvalue('loairaovat_id');
	err += checkvalue('title_vn');
	err += checkvalue('content_vn');
	
	if (err) {
		alert(msg);
		return false;
	}
	
	return document.getElementById('form-raovat').submit();
}

//dat cau hoi
var vnfaq = 'Ban can phai nhap thong tin day du'; //sua tieng viet
var enfaq = 'Please fill value in the form...'; 
function checkvaluefaq(id)
{
	var o =  getContainerID(id);
	if (o) {
		return (o.value != '') ? 0 : 1;
	} else {
		return 0;
	}
}
function checkfaq(msg)
{
	var err = 0;
	
	err += checkvaluefaq('name');
	err += checkvaluefaq('content');
	
	if (err) {
		alert(msg);
		return false;
	}
	
	return document.getElementById('form-faq').submit();
}

var camonmuabds_vn = 'Chúng tôi đã nhận được thông tin bất động sản cần mua/thuê của Quý khách. Chúng tôi sẽ liên lạc với Quý khách trong thời gian sớm nhất. Cảm ơn Quý khách đã sử dụng dịch vụ của chúng tôi.';
var camonmuabds_en = 'Chung toi da nhan duoc thong tin bat dong san can mua/thue cua Quy khach. Chung toi se lien lac voi Quy khach trong thoi gian som nhat. Cam on Quy khach da su dung dich vu cua chung toi.';
function checkformdangkymuabds_vn() //phan danh cho tieng Viet
{
if (document.getElementById('hoten').value=='') {alert('Xin vui lòng nhập họ và tên'); document.getElementById('hoten').select(); return false;}
if (document.getElementById('dtdd').value=='') {alert('Xin vui lòng nhập số điện thoại di động'); document.getElementById('dtdd').select(); return false;}
if (document.getElementById('dtcd').value=='') {alert('Xin vui lòng nhập số điện thoại cố định'); document.getElementById('dtcd').select(); return false;}

return true;
}
function checkformdangkymuabds_en() //phan danh cho tieng Anh
{
if (document.getElementById('hoten').value=='') {alert('Xin vui long nhap ho va ten'); document.getElementById('hoten').select(); return false;}
if (document.getElementById('dtdd').value=='') {alert('Xin vui long nhap so dien thoai di dong'); document.getElementById('dtdd').select(); return false;}
if (document.getElementById('dtcd').value=='') {alert('Xin vui long nhap so dien thoai co dinh'); document.getElementById('dtcd').select(); return false;}

return true;
}

//trim all
function trimAll(sString) 
         {
            while (sString.substring(0,1) == ' ')
          {
             sString = sString.substring(1, sString.length);
          }
           while (sString.substring(sString.length-1, sString.length) == ' ')
          {
             sString = sString.substring(0,sString.length-1);
          }
           return sString;
         }


//for search BDS video
getBlock('dsvd','bsvd');function svd(){return getContainerID('fsvd').submit();}

//for form search-by-keyword
var textbox_search_by_keyword_defaultvalue_0 = 'Nhập từ khóa tìm kiếm --------------------------';
var textbox_search_by_keyword_defaultvalue_1 = 'Search by keyword ------------------------------';
getBlock('search-by-keyword','search-by-keyword');
all_reset_textbox_search_by_keyword();
function clear_textbox_search_by_keyword(lang)
{
var textbox_search_by_keyword_defaultvalue = (lang == 0) ? textbox_search_by_keyword_defaultvalue_0 : textbox_search_by_keyword_defaultvalue_1;
var o = getContainerID('textbox_search_by_keyword');
	if (o)
	{
		if (o.value == textbox_search_by_keyword_defaultvalue)
		o.value = '';
	}
}
function reset_textbox_search_by_keyword(lang)
{
var textbox_search_by_keyword_defaultvalue = (lang == 0) ? textbox_search_by_keyword_defaultvalue_0 : textbox_search_by_keyword_defaultvalue_1;
	var o = getContainerID('textbox_search_by_keyword');
	if (o)
	{
		if (trimAll(o.value) == '')
		o.value = textbox_search_by_keyword_defaultvalue;
	}
}
function all_reset_textbox_search_by_keyword()
{
var lang = 0;
//aj get lang
if (document.getElementById) var e = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	
if (!e) 
{
setTimeout("all_reset_textbox_search_by_keyword()",100);
return;
}

if (e) 
{
  e.onreadystatechange = function()
  {
      if (e.readyState == 4 && e.status == 200) 
      {
	 if (e.responseText == 'vn') lang = 0;
	 else lang = 1;

         var o = getContainerID('textbox_search_by_keyword');
	 if (o) reset_textbox_search_by_keyword(lang);
	 else setTimeout("all_reset_textbox_search_by_keyword()",100);
      }								
   }
}
e.open("POST", 'getcurrentlang.php', true);
e.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
e.send('');
//end aj
}
function do_search_by_keyword(lang)
{
var textbox_search_by_keyword_defaultvalue = (lang == 0) ? textbox_search_by_keyword_defaultvalue_0 : textbox_search_by_keyword_defaultvalue_1;
	var o = getContainerID('textbox_search_by_keyword');
	if (o)
	{
		var keyword = trimAll(o.value);
		if ((keyword == '') || (keyword == textbox_search_by_keyword_defaultvalue))
		{
if(lang==0){alert('Nhập từ khóa tìm kiếm!');} else {alert('Please input keyword!');
}
			o.value = '';
			o.select();
			return;
		}
		var frm = getContainerID('formsearchbds');
		frm.keyword.value = keyword;
		checksubmitsearchbds('');
	}
}

function setHomePage()  
{    
	if (document.all)       
	{           
		document.body.style.behavior='url(#default#homepage)';     
		document.body.setHomePage('http://thegioibatdongsan.vn');           
	}       
	else if (window.sidebar)       
	{       
		if(window.netscape)       
		{            
			try            
			{                 
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");              
			}              
			catch(e)              
			{     
				alert("this action was aviod by your browser，if you want to enable，please enter about:config in your address line, and change the value of signed.applets.codebase_principal_support to true");            
			}       
		}        
		var prefs = Components.classes['@mozilla.org/preferences-service;'].getService(Components.interfaces.nsIPrefBranch);       		
		prefs.setCharPref('browser.startup.homepage','http://thegioibatdongsan.vn');    
	}   	
} 

//active top menu (san GD & san OTC)
function SetActiveTopMenuSanGDOTC()
{
	var menusanGD = getContainerID('topmenusanGD');
	var menusanOTC = getContainerID('topmenusanOTC');
	
	if (!menusanGD || !menusanOTC)
	{
		setTimeout("SetActiveTopMenuSanGDOTC()", 500);
		return;
	}
	
	//get isOTC
	if (document.getElementById) 
	{
		var e = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	}
	
	if (e) 
	{
		e.onreadystatechange = function()
										{

												if (e.readyState == 4 && e.status == 200) 
												{
													if (e.responseText == '0') //san giao dich
													{
														menusanGD.className = 'menu topmenuactive';
														menusanOTC.className = 'menu';
													}
													else //san otc
													{
														menusanGD.className = 'menu';
														menusanOTC.className = 'menu topmenuactive';
													}
													loadModuleEX('getsangiaodichbdscat','left-link','container-LEFT-COL-SAN-GIAO-DICH-DATA');
												}
										}
								
	}
e.open("POST", 'getcurrentisotc.php', true);
		e.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		e.send('');
}
SetActiveTopMenuSanGDOTC();

//do not remove code...
var w=0,l1=0,l2=0,step=5,timeout=1,d='',d1=null,d2=null;function setDirection(v){d=v;}function getNum(){var o=document.getElementById("widthDIVIMGBDS");if(o){w=parseInt(o.value);}else{w=0;}}function goL(){if(l1>-w){l1-=step;}else{l1=0;}d1.style.left=l1+"px";l2=l1+w;d2.style.left=l2+"px";return null;}function goR(){if(l1<0){l1+=step;}else{l1=-w;}d1.style.left=l1+"px";l2=l1+w;d2.style.left=l2+"px";return null;}function wait(){setTimeout("wait()",timeout);getNum();if(!w){return;}d1=document.getElementById("image-list-d1");d2=document.getElementById("image-list-d2");if(!d1||!d2){return;}if(d=='left'){return goL();}if(d=='right'){return goR();}}wait();function chonHuyen(catid){loadModuleEX('chonhuyen',catid,'container-cb-huyen');}
