// JavaScript Document
function changeHou_vch1(){
	area=$("ofi_regional").value;
	strURL="Admin/House/changeArea.php?id=" + Math.random();		
	strData = "bh=" + area; 
	new Ajax.Request(strURL, {method: 'post', parameters: strData,onComplete: changeHouReceive});	
}

function changeHouReceive(httpObj){
	FromText = httpObj.responseText;
	FromText = getConvForSafari(FromText);
	//alert(FromText);
	t = FromText.parseJSON();
	SonBank = $("ofi_regional1");
	SonBankLength = SonBank.length;
	for(var i=0;i<SonBankLength;i++){
		SonBank.options[0] = null;
	}
	SonBank.options[SonBank.length] = new Option("","");
	for(i=0;i<t.BaseCount;i++){
		SonBank.options[SonBank.length] = new Option(t.SunBaseList[i].BaseName,t.SunBaseList[i].BaseID);
	}
}

function changeHou_vch2(){
	area=$("ofi_vch1").value;
	strURL="Admin/House/changeArea.php?id=" + Math.random();		
	strData = "bh=" + area; 
	new Ajax.Request(strURL, {method: 'post', parameters: strData,onComplete: createNewFlowReceive});
}

function createNewFlowReceive(httpObj){
	FromText = httpObj.responseText;
	FromText = getConvForSafari(FromText);
	//alert(FromText);
	t = FromText.parseJSON();
	SonBank = $("ofi_vch2");
	SonBankLength = SonBank.length;
	for(var i=0;i<SonBankLength;i++){
		SonBank.options[0] = null;
	}
	SonBank.options[SonBank.length] = new Option("","");
	for(i=0;i<t.BaseCount;i++){
		SonBank.options[SonBank.length] = new Option(t.SunBaseList[i].BaseName,t.SunBaseList[i].BaseID);
	}
}

function JumpResults(){
	type=$("ofi_type").value;
	regional=$("ofi_regional").value;
	regional1=$("ofi_regional1").value;
	rent=$("ofi_rent").value;
	price=$("ofi_price").value;
	area=$("ofi_area").value;
	keyword=$("ofi_keyword").value;
	location.href='house-list_'+ type +'_'+ regional +'_'+ regional1 +'_'+ rent +'_'+ price +'_'+ area +'_'+ keyword +'_\.html';
}

function getOfiInfo(mid){
	document.location="information_"+ mid +'\.html'; 	
}

function Landing(mid){
	UserName=$("UserName").value;
	password=$("password").value;
	if(UserName==""){
		alert("用户名为空");
		return false;
	}
	if(password==""){
		alert("密码为空");
		return false;
	}
	strURL="login.php?id=" + Math.random();		
	strData = "UserName=" + UserName; 
	strData += "&password=" + password; 
	new Ajax.Request(strURL, {method: 'post', parameters: strData,onComplete: LandingReceive});	
}

function LandingReceive(httpObj){
	FromText = httpObj.responseText;
	FromText = getConvForSafari(FromText);
	if(FromText==1){
		document.location='member_1.html';
	}else if(FromText==2){
		document.location='Admin/index1.html';
	}else if(FromText==3){
		alert("密码不正确");
	}else{
		alert("用户名不存在");
	}
}

function Landing_1(mid){
	UserName=$("UserName").value;
	password=$("password").value;
	if(UserName==""){
		alert("用户名为空");
		return false;
	}
	if(password==""){
		alert("密码为空");
		return false;
	}
	strURL="login.php?id=" + Math.random();		
	strData = "UserName=" + UserName; 
	strData += "&password=" + password; 
	new Ajax.Request(strURL, {method: 'post', parameters: strData,onComplete: LandingReceive});	
	//document.location='login_1.php?UserName='+ UserName +'&password='+password; 	
}

function Login(){
	if($("name").value==""){
		alert("用户名为空");
		return false;
	}
	if($("emali").value==""){
		alert("邮箱为空");
		return false;
	}
	if($("password").value!=$("password1").value){
		alert("两次输入的密码不一致。");
		return false;
	}else{
		password=$("password").value;	
	}
	
	UserName=$("name").value;
	emali=$("emali").value;
	Mobile=$("Mobile").value;
	phone=$("Mobile").value;
	
	document.location='LoginUser.php?UserName='+ UserName +'&password='+password+'&emali='+emali+'&Mobile='+Mobile+'&phone='+phone;
}

function updpassword(){
	if($("password").value=="" || $("password_1").value==""){
		alert("密码不能为空");
		return false;
	}
	if($("password_1").value!=$("password_2").value){
		alert("新密码输入有误");
		return false;
	}
	pass = $("password").value;
	pass_1 = $("password_1").value;
	document.location='member-edit-pass1.php?password='+ pass +'&password_1='+ pass_1;
}

function changeName(){
	name=$("name").value;
	strURL="changeName.php?id=" + Math.random();		
	strData = "name=" + name; 
	new Ajax.Request(strURL, {method: 'post', parameters: strData,onComplete: changeNameReceive});	
}

function changeNameReceive(httpObj){
	FromText = httpObj.responseText;
	FromText = getConvForSafari(FromText);
	if(FromText!=""){
		alert(FromText);	
	}
}

function updData(){
	phone = $("phone").value;
	Mobile = $("Mobile").value;
	emali = $("emali").value;
	address = $("address").value;
	per_txt0 = $("per_txt0").value;
	strURL="member-edit-data1.php?id=" + Math.random();		
	strData = "phone=" + phone;
	strData += "&Mobile=" + Mobile;
	strData += "&emali=" + emali;
	strData += "&address=" + address;
	strData += "&per_txt0=" + per_txt0;
	new Ajax.Request(strURL, {method: 'post', parameters: strData,onComplete: updDataReceive});
}

function updDataReceive(httpObj){
	FromText = httpObj.responseText;
	FromText = getConvForSafari(FromText);
	alert("修改成功！");	
}