function getLoginData(data_source,divID)
{
	
	if(window.XMLHttpRequest)
	{
		
		l_xmlHttp = new XMLHttpRequest();
		
	}else if(window.ActiveXObject)
	{
		
		l_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
		
	}
	
	if(checkLoginForm() == true)
	{
	
		if(l_xmlHttp)
		{
			
			var obj = document.getElementById(divID);
				
			l_xmlHttp.open("POST",data_source);
				
			l_xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				
			l_xmlHttp.onreadystatechange = function()
			{
				
				if(l_xmlHttp.readyState == 1)
				{
					
					obj.innerHTML = '<div style="color:#000; width:100%; text-align:center;">Loading...</div>';
					
				}
					
				if(l_xmlHttp.readyState == 4 && l_xmlHttp.status == 200)
				{
					
					/*alert("123");
					alert(l_xmlHttp.responseText);*/
					//alert(l_xmlHttp.responseText.search(/Login_Success/));
					
					
					
					if(l_xmlHttp.responseText.search(/Login_Success/) != -1)
					{
						//alert('123');
						window.location.href="http://www.diaocgiare.com/thanh-vien/";
					}
					else if(l_xmlHttp.responseText.search(/Insert_Success/) != -1)
					{
						document.getElementById('coneiner_favorites').style.display = 'block';
				
						document.getElementById('conteiner_dangnhap').style.display = 'none';
						
						addFavoriteHouse('http://www.diaocgiare.com/includes/boxes/san_dia_oc/realestate_favorite_process.php','coneiner_favorites',0,'log');
						
						getLoginTxt('http://www.diaocgiare.com/includes/boxes/home/login_txt.php','login_test');
						
						//getLoginTxt('http://www.diaocgiare.com/includes/boxes/home/login_txt.php','login_test');
												
					}
					else
					
						obj.innerHTML = l_xmlHttp.responseText;
				
										
				}
				
			}
				
			l_xmlHttp.send("Submit=LOGIN&username="+document.login_form.username.value+"&password="+document.login_form.password.value);
			
		}
			
	}
	
}


function endLoginData(data_source,divID)
{
	
	hideLoginBox();

	if(window.XMLHttpRequest)
	{
		
		e_xmlHttp = new XMLHttpRequest();
		
	}else if(window.ActiveXObject)
	{
		
		e_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
		
	}

	if(e_xmlHttp)
	{
		
		var obj = document.getElementById(divID);
			
		e_xmlHttp.open("POST",data_source);
				
		e_xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			
		e_xmlHttp.onreadystatechange = function()
		{
			
			
			
			if(e_xmlHttp.readyState == 1)
			{
					
				obj.innerHTML = '<a style="color:#fff;">Loading...</a>';
					
			}
					
			if(e_xmlHttp.readyState == 4 && e_xmlHttp.status == 200)
			{
					
				
				
				obj.innerHTML = e_xmlHttp.responseText;
			}
			
		}
			
		e_xmlHttp.send("Submit=END");
		
	}
	
}


function getLoginTxt(data_source,divID)
{

	if(window.XMLHttpRequest)
	{
		
		t_xmlHttp = new XMLHttpRequest();
		
	}else if(window.ActiveXObject)
	{
		
		t_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
		
	}
	
	if(t_xmlHttp)
	{
		
		var obj = document.getElementById(divID);
			
		t_xmlHttp.open("GET",data_source);
			
		t_xmlHttp.onreadystatechange = function()
		{
			
			if(t_xmlHttp.readyState == 1)
			{
					
				obj.innerHTML = '<a style="color:#fff;">Loading...</a>';
					
			}
					
			if(t_xmlHttp.readyState == 4 && t_xmlHttp.status == 200)
			{
					
				obj.innerHTML = t_xmlHttp.responseText;
					
			}
			
		}
			
		t_xmlHttp.send("");
		
	}
	
}



function getEmailData(data_source,divID)
{
	
	if(checkEmailForm() == true)
	{
	
		if(xmlHttp)
		{
			
			var obj = document.getElementById(divID);
				
			xmlHttp.open("POST",data_source);
				
			xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				
			xmlHttp.onreadystatechange = function()
			{
				
				if(xmlHttp.readyState == 1)
				{
					
					obj.innerHTML = '<p align="center" style="color:#990000;">Loading...</p>';
					
				}
					
				if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
				{
				
					obj.innerHTML = xmlHttp.responseText;
										
				}
				
			}
				
			xmlHttp.send("Submit=SEND&sender_name="+document.email_box_form.sender_name.value+"&sender_email="+document.email_box_form.sender_email.value+"&receiver_name="+document.email_box_form.receiver_name.value+"&receiver_email="+document.email_box_form.receiver_email.value+"&comment="+document.email_box_form.comment.value);
			
		}
			
	}
	
}


function getNewsletterData(data_source,divID,type)
{
	
	if(checkNewsletterForm() == true)
	{
	
		if(xmlHttp)
		{
			
			var obj = document.getElementById(divID);
				
			xmlHttp.open("POST",data_source);
				
			xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				
			xmlHttp.onreadystatechange = function()
			{
				
				if(xmlHttp.readyState == 1)
				{
					
					document.getElementById('loading_image').style.display='block';
					
					obj.innerHTML = "";
					
				
					
				}
					
				if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
				{
				
					document.getElementById('loading_image').style.display='none';
				
					obj.innerHTML = xmlHttp.responseText;
										
				}
				
			}
				
			xmlHttp.send("Submit="+type+"&newsletter_email="+document.newsletter_form.newsletter_email.value);
			
		}
			
	}
	
}


function getUsernameData(data_source,divID,type)
{
	
		if(xmlHttp)
		{
			
			var obj = document.getElementById(divID);
				
			xmlHttp.open("POST",data_source);
				
			xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				
			xmlHttp.onreadystatechange = function()
			{
				
				if(xmlHttp.readyState == 1)
				{
					
				
					
					obj.innerHTML = 'Loading...';
				
					
				}
					
				if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
				{
				
					
				
					obj.innerHTML = xmlHttp.responseText;
										
				}
				
			}
				
			if(type=='username')
			{	
				xmlHttp.send("Submit=CHECK&member_username="+document.register_form.username.value+"&type="+type);
			}
			
			if(type == 'email')
			{
				
				xmlHttp.send("Submit=CHECK&member_email="+document.register_form.email.value+"&type="+type);
				
			}
		}
			

	
}


function removeImages(data_source,divID)
{

	if(xmlHttp)
	{
		
		var obj = document.getElementById(divID);
			
		xmlHttp.open("GET",data_source);
			
		xmlHttp.onreadystatechange = function()
		{
			
			if(xmlHttp.readyState == 1)
			{
					
				obj.innerHTML = '<p align="center" style="color:#000000;">Loading...</p>';
					
			}
					
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
			{
					
				obj.innerHTML = xmlHttp.responseText;
					
			}
			
		}
			
		xmlHttp.send("");
		
	}
	
}


function updateMainImage(data_source,divID,img_id)
{

	if(xmlHttp)
	{
		
		var obj = document.getElementById(divID);
			
		xmlHttp.open("POST",data_source);
				
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			
		xmlHttp.onreadystatechange = function()
		{
			
			if(xmlHttp.readyState == 1)
			{
					
				obj.innerHTML = '<p align="center" style="color:#000000;">Loading...</p>';
					
			}
					
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
			{
					
				obj.innerHTML = xmlHttp.responseText;
					
			}
			
		}
			
		xmlHttp.send("Submit=UPDATE_MAIN&img_id="+img_id);
		
	}
	
}


function updateMainImageEdit(data_source,divID,img_id,home_id)
{

	if(xmlHttp)
	{
		
		var obj = document.getElementById(divID);
			
		xmlHttp.open("POST",data_source);
				
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			
		xmlHttp.onreadystatechange = function()
		{
			
			if(xmlHttp.readyState == 1)
			{
					
				obj.innerHTML = '<p align="center" style="color:#000000;">Loading...</p>';
					
			}
					
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
			{
					
				obj.innerHTML = xmlHttp.responseText;
					
			}
			
		}
			
		xmlHttp.send("Submit=UPDATE_MAIN&img_id="+img_id+"&home_id="+home_id);
		
	}
	
}


function getHousesData(data_source,divID,keyword,conditions,pages)
{

	window.scrollTo(0,10);

	if(xmlHttp)
	{
		
		var obj = document.getElementById(divID);
			
		xmlHttp.open("POST",data_source);
				
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			
		xmlHttp.onreadystatechange = function()
		{
			
			if(xmlHttp.readyState == 1 && divID== "houses_list" )
			{
					
				document.getElementById('loading_image').style.display='block';
			
					
				obj.innerHTML = "";
					
			}
					
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
			{
					
				document.getElementById('loading_image').style.display='none';
				
			
					
				obj.innerHTML = xmlHttp.responseText;
				
				
			}
			
		}
		
		
			
		xmlHttp.send("SUBMIT=LOAD&keyword="+keyword+"&cons="+conditions+"&pages="+pages);
		
	}
	
}



function addFavoriteHouse(data_source,divID,h_id,keyword)
{

		
	if(window.XMLHttpRequest)
	{
		
		n_xmlHttp = new XMLHttpRequest();
		
	}else if(window.ActiveXObject)
	{
		
		n_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
		
	}

	if(n_xmlHttp)
	{
		
		var obj = document.getElementById(divID);
			
		n_xmlHttp.open("POST",data_source);
				
		n_xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			
		n_xmlHttp.onreadystatechange = function()
		{
			
			if(n_xmlHttp.readyState == 1)
			{
				
				obj.innerHTML = '<p align="center" style="color:#fff;">Loading...</p>';
				//document.getElementById('loading_image').style.display='none';
				//document.getElementById('houses_list').style.display='block';
					
			}
					
			if(n_xmlHttp.readyState == 4 && n_xmlHttp.status == 200)
			{
					
				if(n_xmlHttp.responseText.search(/LOGIN_REQUEST/) != -1)
				{
					
					//alert("123");
					
					document.getElementById('coneiner_favorites').style.display = 'none';
				
					document.getElementById('conteiner_dangnhap').style.display = 'block';
					//document.getElementById('loading_image').style.display='none';
					//document.getElementById('houses_list').style.display='block';
				
				}else{
					
					obj.innerHTML = n_xmlHttp.responseText;
					//document.getElementById('loading_image').style.display='none';
					//document.getElementById('houses_list').style.display='block';
					
				}
					
			}
			
		}
			
		n_xmlHttp.send("Submit=ADD_FAVORITE&home_id="+h_id+"&keyword="+keyword);
		
	}
	
}


function changeJSImg_01(data_source,divID,h_id,end,id)
{

		
	if(window.XMLHttpRequest)
	{
		
		i_xmlHttp = new XMLHttpRequest();
		
	}else if(window.ActiveXObject)
	{
		
		i_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
		
	}

	if(i_xmlHttp)
	{
		
		var obj = document.getElementById(divID);
			
		i_xmlHttp.open("POST",data_source);
				
		i_xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			
		i_xmlHttp.onreadystatechange = function()
		{
			
			if(i_xmlHttp.readyState == 1)
			{
				
				//obj.innerHTML = '<p align="center" style="color:#fff;">Loading...</p>';
				
					
			}
					
			if(i_xmlHttp.readyState == 4 && i_xmlHttp.status == 200)
			{
					
					
					obj.innerHTML = i_xmlHttp.responseText;
				
			}
			
		}
			
		i_xmlHttp.send("Submit=CHANGE_DETAIL_IMG&home_id="+h_id+"&end="+end+"&img_id="+id);
		
	}
	
}


function changeJSImg_02(data_source,divID,h_id,start,id)
{

		
	if(window.XMLHttpRequest)
	{
		
		j_xmlHttp = new XMLHttpRequest();
		
	}else if(window.ActiveXObject)
	{
		
		j_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
		
	}

	if(j_xmlHttp)
	{
		
		var obj = document.getElementById(divID);
			
		j_xmlHttp.open("POST",data_source);
				
		j_xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			
		j_xmlHttp.onreadystatechange = function()
		{
			
			if(j_xmlHttp.readyState == 1)
			{
				
				//obj.innerHTML = '<p align="center" style="color:#fff;">Loading...</p>';
				
					
			}
					
			if(j_xmlHttp.readyState == 4 && j_xmlHttp.status == 200)
			{
					
					
					obj.innerHTML = j_xmlHttp.responseText;
				
			}
			
		}
			
		j_xmlHttp.send("Submit=CHANGE_DETAIL_IMG&home_id="+h_id+"&start="+start+"&img_id="+id);
		
	}
	
}


function changeJSImgTmp_01(data_source,divID,end,id)
{

		
	if(window.XMLHttpRequest)
	{
		
		i_xmlHttp = new XMLHttpRequest();
		
	}else if(window.ActiveXObject)
	{
		
		i_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
		
	}

	if(i_xmlHttp)
	{
		
		var obj = document.getElementById(divID);
			
		i_xmlHttp.open("POST",data_source);
				
		i_xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			
		i_xmlHttp.onreadystatechange = function()
		{
			
			if(i_xmlHttp.readyState == 1)
			{
				
				//obj.innerHTML = '<p align="center" style="color:#fff;">Loading...</p>';
				
					
			}
					
			if(i_xmlHttp.readyState == 4 && i_xmlHttp.status == 200)
			{
					
					
					obj.innerHTML = i_xmlHttp.responseText;
				
			}
			
		}
			
		i_xmlHttp.send("Submit=CHANGE_DETAIL_IMG&end="+end+"&img_id="+id);
		
	}
	
}


function changeJSImgTmp_02(data_source,divID,start,id)
{

		
	if(window.XMLHttpRequest)
	{
		
		j_xmlHttp = new XMLHttpRequest();
		
	}else if(window.ActiveXObject)
	{
		
		j_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
		
	}

	if(j_xmlHttp)
	{
		
		var obj = document.getElementById(divID);
			
		j_xmlHttp.open("POST",data_source);
				
		j_xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			
		j_xmlHttp.onreadystatechange = function()
		{
			
			if(j_xmlHttp.readyState == 1)
			{
				
				//obj.innerHTML = '<p align="center" style="color:#fff;">Loading...</p>';
				
					
			}
					
			if(j_xmlHttp.readyState == 4 && j_xmlHttp.status == 200)
			{
					
					
					obj.innerHTML = j_xmlHttp.responseText;
				
			}
			
		}
			
		j_xmlHttp.send("Submit=CHANGE_DETAIL_IMG&start="+start+"&img_id="+id);
		
	}
	
}

function editMemberInfo(data_source,divID)
{

	if(checkEditForm() == true)
	{
		if(xmlHttp)
		{
			
			var obj = document.getElementById(divID);
				
			xmlHttp.open("POST",data_source);
					
			xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				
			xmlHttp.onreadystatechange = function()
			{
				
				if(xmlHttp.readyState == 1)
				{
						
					document.getElementById('loading_img_1').style.display='block';
					
					obj.innerHTML = "";
					
				}
						
				if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
				{
						
					document.getElementById('loading_img_1').style.display='none';	
					
					obj.innerHTML = xmlHttp.responseText;
						
				}
				
			}
				
			xmlHttp.send("Submit=EDIT_INFO&fullname="+document.edit_info_form.fullname.value+"&phone_number="+document.edit_info_form.phone_number.value+"&company="+document.edit_info_form.company.value+"&address="+document.edit_info_form.address.value+"&website="+document.edit_info_form.website.value);
			
		}
		
	}
	
}

function changeMemberPass(data_source,divID)
{

	if(checkChangePassForm() == true)
	{
		if(xmlHttp)
		{
			
			var obj = document.getElementById(divID);
				
			xmlHttp.open("POST",data_source);
					
			xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				
			xmlHttp.onreadystatechange = function()
			{
				
				if(xmlHttp.readyState == 1)
				{
						
					document.getElementById('loading_img_2').style.display='block';
					
					obj.innerHTML = "";
					
				}
						
				if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
				{
						
					document.getElementById('loading_img_2').style.display='none';	
					
					obj.innerHTML = xmlHttp.responseText;
						
				}
				
			}
				
			xmlHttp.send("Submit=CHANGE&newpassword="+document.change_pass_form.newpassword.value);
			
		}
		
	}
	
}

function addImageAlt(data_source,divID,img_id,alt_id)
{
	
	//alert(document.getElementById(alt_id).value);
	
	if(window.XMLHttpRequest)
	{
		
		xmlHttp = new XMLHttpRequest();
		
	}else if(window.ActiveXObject)
	{
		
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
		
	}
	
	if(xmlHttp)
	{
		
		var obj = document.getElementById(divID);
				
		xmlHttp.open("POST",data_source);
					
		xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				
		xmlHttp.onreadystatechange = function()
		{
				
			if(xmlHttp.readyState == 1)
			{
						
				
					
				obj.innerHTML = '<p align="center" style="color:#000000;">Loading...</p>';
					
			}
						
			if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
			{
						
			
					
				obj.innerHTML = xmlHttp.responseText;
						
			}
				
		}
				
		xmlHttp.send("Submit=ADD_ALT&img_id="+img_id+"&alt="+document.getElementById(alt_id).value);
			
	}
	
}