function encode(data)
{
	var i=0
	 while (i<=data.length)
	 {
		 i=i+1;
		data=data.replace('&','__lol__');
	 }
	return data
}
 function gotolink(url)
{
	window.location=url;
}

function search()
{
	data='search_sring='+encode(document.getElementById("search_text_box").value);
	//data=data+'&danhmuctimkiem='+encode(document.getElementById("danhmuctimkiem").value);
	LoadXmlDocPost('modules/search/xml_search.php',data,'search');
}

function login()
{	
	data='u='+encode(document.getElementById("login_user").value);
	data=data+'&p='+encode(document.getElementById("login_pass").value);
	if(data=='u=&p=')
	{	
		alert('Ban lam on nhap tai khoan')
	}else
	{
		LoadXmlDocPost('modules/users/xml_lg.php',data,'login_echo');
	}
	}
function logout()
{	
	LoadXmlDoc('modules/users/xml_logout.php','login_echo');
}
function dangky()
{	
	data='u='+encode(document.getElementById("ru").value);
	data=data+'&p='+encode(document.getElementById("rp").value);
	data=data+'&pa='+encode(document.getElementById("rpa").value);
	data=data+'&email='+encode(document.getElementById("remail").value);
	data=data+'&address='+encode(document.getElementById("raddress").value);
	data=data+'&birthday='+encode(document.getElementById("rbirthday").value);
	data=data+'&telephone='+encode(document.getElementById("rtelephone").value);
	LoadXmlDocPost('modules/users/xml_dangky.php',data,'thongbao_dangky');
}

///////////////////////////////////////quickview///////////////////////////////////////
var is_load;
var mytime=0;
var myInterval;

function quick_view(id)
{	
    document.getElementById("danhmuctimkiem").style.display="none";
	myInterval=window.setInterval ("show_quick_view("+id+")", 100);

	//window.setInterval("myNumber++;",100);
	//if(myNumber>1000)show_quick_view(id);
}
function show_quick_view(id)
{	
	mytime=mytime+100;
	if(mytime>300)
	{
		document.getElementById("quick_view").style.display="block";
		LoadXmlDoc('modules/quickview/xml_quick_view.php?id='+id,'quick_view');
	 	clearInterval(myInterval);
	}
}
function close_quick_view()
{		
	mytime=0;
	clearInterval(myInterval);
	document.getElementById("quick_view").style.display="none";
    document.getElementById("danhmuctimkiem").style.display="block";
}

function move_it(event){
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) {
	posx = e.pageX;
	posy = e.pageY;
	}
	else if (e.clientX || e.clientY) {
	posx = e.clientX ;
	posy = e.clientY;
	}
	if(posy<=150)
	{
   	 document.getElementById("quick_view").style.top = (posy+document.documentElement.scrollTop);
	}

	if(posy>=150 && posy<400)
	{
   	 document.getElementById("quick_view").style.top = (posy+document.documentElement.scrollTop-100);
	}
	if(posy>=400)
	{
   	 document.getElementById("quick_view").style.top = (posy/2+document.documentElement.scrollTop);
	}
    document.getElementById("quick_view").style.left = (posx+10) ;
	
}//////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////dang tin///////////////////////////////////////

function dangtin()
{
    document.getElementById("danhmuctimkiem").style.display="none";
document.getElementById("root").style.display="block";
var theHandle = document.getElementById("handle");
var theRoot   = document.getElementById("root");
Drag.init(theHandle, theRoot);
LoadXmlDoc('modules/dangtin/xml_dangtin.php','noidungdangtin');
}

function close_root()
{
	document.getElementById("root").style.display="none";
    document.getElementById("danhmuctimkiem").style.display="block";
}


function add_new_topic(id)
{
	data='id='+id;
	data=data+'&topic_name='+document.getElementById("topic_name").value;
	var edit_value;
	edit_value=document.getElementById('content').contentWindow.document.body.innerHTML;
	var i=0
	 while (i<=edit_value.length)
	 {
		 i=i+1;
		edit_value=edit_value.replace('&nbsp;','__nbsp__');
		edit_value=edit_value.replace('&quot;','__quot__');
		edit_value=edit_value.replace('&amp;','__amp__');
		edit_value=edit_value.replace('&lt;','__lt__');
		edit_value=edit_value.replace('&gt;','__gt__');
		edit_value=edit_value.replace('&#39;','___39__');
	 }


	data=data+'&data='+edit_value;
	//document.write(data);
	show_echo();
	LoadXmlDocPost('modules/forum/xml_add_new_topic.php',data,'otc_echo');
}

function dongydangtin()
{	
	data='ndot_lvl2='+encode(document.getElementById("ndot_lvl2").value);
	data=data+'&ndot_city='+encode(document.getElementById("ndot_city").value);
	data=data+'&name_v='+encode(document.getElementById("name_v").value);
	data=data+'&des='+encode(document.getElementById("des").value);
	LoadXmlDocPost('modules/dangtin/xml_dongydangtin.php',data,'thongbaodangtin');
}
function laylaimk()
{	
	data='ndot_lvl2='+encode(document.getElementById("ndot_lvl2").value);
	data=data+'&ndot_city='+encode(document.getElementById("ndot_city").value);
	LoadXmlDocPost('modules/dangtin/xml_dongydangtin.php',data,'thongbaodangtin');
}

function doimien(mien)
{	
	LoadXmlDoc('modules/doimien/xml_doimien.php?mien='+mien,'chonmien');
}