function isMouseLeaveOrEnter(e, handler) {   
	if (e.type != 'mouseout' && e.type != 'mouseover') return false;   
	var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;   
	while (reltg && reltg != handler)   
		reltg = reltg.parentNode;   
	return (reltg != handler);   
} 

function changeSearchCase(){
	if($("searchType").value=="divInduct"){
		$("divInduct").style.display="";
		$("divSecond").style.display="none";
	}else{
		$("divSecond").style.display="";
		$("divInduct").style.display="none";
	}
}

function changImage(obj,index){//浣跨敤涓?
	$("bigImage").src = obj.src;
	ojbHouseImages = $("house_images");
	ojbHouseImage = ojbHouseImages.getElementsByTagName("img");
	$("divNumber").innerHTML = index;
	for(i=0;i<ojbHouseImage.length;i++){
		ojbHouseImage[i].parentNode.className="img_more";
	}
	obj.parentNode.className="img_more_currect";
}

var scrollCount=0;
var speed = 1;
var MyMar;
function second_image_right(){//浣跨敤涓?
	scrollCount += 104;
	MyMar = setInterval(econd_image_Marquee,speed);
}

function second_image_left(){//浣跨敤涓?
	scrollCount = scrollCount - 104;
	MyMar = setInterval(econd_image_Marquee,speed);
}

function econd_image_Marquee(){ //浣跨敤涓?
	if(scrollCount==0){
		clearInterval(MyMar);
	}
	if(scrollCount>0){
		scrollCount = scrollCount - 8;
		$("sec_house_scroll").scrollLeft = $("sec_house_scroll").scrollLeft+8;
	}else{
		scrollCount = scrollCount + 8;
		$("sec_house_scroll").scrollLeft = $("sec_house_scroll").scrollLeft-8;
	}
	
	//alert($("sec_house_scroll").scrollLeft);
}

function showLookHouse(obj){
	if(obj.checked){
		$("divLookHouse").style.display="";
	}else{
		$("divLookHouse").style.display="none";
	}
}

function showSearchHouse(obj){
	if(obj.checked){
		$("divSearchHouse").style.display="";
	}else{
		$("divSearchHouse").style.display="none";
	}
}

var fn = function(e){
	obj = e;
			imageCount = obj.getAttribute("imageCount");
			if(imageCount>0){
				Location = getObjectLocation(obj);
				
				bod=document.getElementsByTagName('body')[0];
				
				lb							=document.createElement('div');
				lb.className				="image_count";
				lb.style.top				=(Location[0]+73-19) +"px"; 
				lb.style.left				=(Location[1]+98-19) +"px"; 
				lb.style.display			="block"; 
				lb.style.position			="absolute"; 
				lb.style.zIndex				=10;
				lb.style.filter				="alpha(opacity=100)";
				//alert(text);
				lb.innerHTML 				= imageCount;
			
				bod.appendChild(lb);
			}
			
}
		
function getImageCount(obj){
	setTimeout(function(){
		//return fn(obj);
	},500)
	
}


		
function getObjectLocation(obj){
	var t=obj.offsetTop;
	var l=obj.offsetLeft;
	var objLocat = new Array();
	var e=obj;
	
	while(e=e.offsetParent){
		t+=e.offsetTop;
		l+=e.offsetLeft;
	}
	//alert("top="+t+"\nleft="+l)
	objLocat[0]=t;
	objLocat[1]=l;
	return objLocat;
}

function orderbyList(obj){
	strURL = "HouseList_"+obj.value+".html";
	window.location.href = strURL;
}

function setKeywordFouce(obj){
	if(obj.style.color=="#999999"){
		obj.value="";
		obj.style.color="#000000";
	}
}



function loginout(){
	
	strURL='loginout.php?id=' +Math.random();

	new Ajax.Request(strURL, {method: 'post', onComplete: loginoutReceive});
}

function loginoutReceive(httpObj){
	text = httpObj.responseText;
	window.location.reload();
}

function changPassword(){
	strOldPassword = $("oldPassword").value;
	strNewPassword = $("newPassword").value;
	strComPassword = $("comPassword").value;
	
	strURL='_changePassword.php?id=' 	+Math.random();
	strData = "oldPassword=" 		+ encodeURIComponent(strOldPassword);
	strData += "&newPassword=" 		+ encodeURIComponent(strNewPassword);
	strData += "&comPassword=" 		+ encodeURIComponent(strComPassword);
	new Ajax.Request(strURL, {method: 'post', parameters: strData, onComplete: changPasswordReceive});
}

function changPasswordReceive(httpObj){
	text = httpObj.responseText;
	t = text.parseJSON();
	if(t.errorType==0){
		alert("淇濆瓨鎴愬姛");
	}else{
		alert(t.errorMessage);
	}
	
}

function saveUser(){
	str_usr_cn_name		= $("usr_cn_name").value;
	str_usr_en_name		= $("usr_en_name").value;
	str_usr_sex			= $("usr_sex").value;
	str_usr_marriage	= $("usr_marriage").value;
	str_usr_brithday	= $("usr_brithday").value;
	str_usr_tel			= $("usr_tel").value;
	str_usr_Email		= $("usr_Email").value;
	
	strURL='_saveUser.php?id=' 		+Math.random();
	strData = "usr_cn_name=" 		+ encodeURIComponent(str_usr_cn_name);
	strData += "&usr_en_name=" 		+ encodeURIComponent(str_usr_en_name);
	strData += "&usr_sex=" 			+ encodeURIComponent(str_usr_sex);
	strData += "&usr_marriage=" 	+ encodeURIComponent(str_usr_marriage);
	strData += "&usr_brithday=" 	+ encodeURIComponent(str_usr_brithday);
	strData += "&usr_tel=" 			+ encodeURIComponent(str_usr_tel);
	strData += "&usr_Email=" 		+ encodeURIComponent(str_usr_Email);
	new Ajax.Request(strURL, {method: 'post', parameters: strData, onComplete: saveUserReceive});
}

function saveUserReceive(httpObj){
	text = httpObj.responseText;
	t = text.parseJSON();
	if(t.errorType==0){
		alert("淇濆瓨鎴愬姛");
	}else{
		alert(t.errorMessage);
	}
}

function saveRequest(){
	str_req_time			= $("req_time").value;
	str_req_target			= $("req_target").value;
	str_req_badroom			= $("req_badroom").value;
	str_req_toilet			= $("req_toilet").value;
	str_req_area			= $("req_area").value;
	str_req_year			= $("req_year").value;
	str_req_local			= $("req_local").value;
	str_req_price_begin		= $("req_price_begin").value;
	str_req_price_end		= $("req_price_end").value;
	str_req_memo			= $("req_memo").value;
	
	strURL='_saveRequest.php?id=' 			+ Math.random();
	strData = "str_req_time=" 			+ encodeURIComponent(str_req_time);
	strData += "&str_req_target=" 		+ encodeURIComponent(str_req_target);
	strData += "&str_req_badroom=" 		+ encodeURIComponent(str_req_badroom);
	strData += "&str_req_toilet=" 		+ encodeURIComponent(str_req_toilet);
	strData += "&str_req_area=" 		+ encodeURIComponent(str_req_area);
	strData += "&str_req_year=" 		+ encodeURIComponent(str_req_year);
	strData += "&str_req_local=" 		+ encodeURIComponent(str_req_local);
	strData += "&str_req_price_begin=" 	+ encodeURIComponent(str_req_price_begin);
	strData += "&str_req_price_end=" 	+ encodeURIComponent(str_req_price_end);
	strData += "&str_req_memo=" 		+ encodeURIComponent(str_req_memo);
	new Ajax.Request(strURL, {method: 'post', parameters: strData, onComplete: saveRequestReceive});
}

function saveRequestReceive(httpObj){
	text = httpObj.responseText;
	t = text.parseJSON();
	if(t.errorType==0){
		alert("淇濆瓨鎴愬姛");
	}else{
		alert(t.errorMessage);
	}
}

function favoritesHouse(sco_mid){
	strURL='_favorites.php?id=' 			+ Math.random();
	strData = "sco_mid=" 			+ encodeURIComponent(sco_mid);
	
	new Ajax.Request(strURL, {method: 'post', parameters: strData, onComplete: favoritesHouseReceive});
}

function favoritesHouseReceive(httpObj){
	text = httpObj.responseText;
	t = text.parseJSON();
	if(t.errorType==0){
		alert("淇濆瓨鎴愬姛");
	}else{
		alert(t.errorMessage);
	}
}

function listKeywordFocus(obj){
	if(obj.style.color=="#818181"){
		obj.value = "";
		obj.style.color="#000";
	}else{
		
	}
}

function listKeywordBlur(obj){
	if(obj.value==""){
		obj.style.color="#818181";
		obj.value = "璇疯緭鍏ュ叧閿瓧";
	}
}
