// JavaScript Document
/*关闭页面不提示*/
function closepage()
{
window.opener=null;
window.open('','_self');
window.close();
}
/*跳转到另外的页面*/
function link_to_other_page(url)
{  
    var length=arguments.length;
	<!--alert(length);-->

<!--由于一开始没有考虑到弹出窗口在各个地方有不同的要求，所以到用的时候，只好增加一个参数来处理不同的需求-->
	if(length==2)
	{
		/*alert("2 arguments");*/
	
	    window.open(url,"_blank","width="+screen.width+",height="+screen.height+",top=0,left=0,toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes");
	}
	else
	{
		/*alert("1 arguments");*/
		window.location.href=url;
	}


}

	/*在静态页面直接用ajxa函数*/
	function InitAjax()
	{
	　var ajax=false; 
	　try { 
	　　ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
	　} catch (e) { 
	　　try { 
	　　　ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
	　　} catch (e) { 
	　　　ajax = false; 
	　　} 
	　}
	　if (!ajax && typeof XMLHttpRequest!='undefined') { 
	　　ajax = new XMLHttpRequest(); 
	　} 
	　return ajax;
	}
	/*第二版本的看房日志部分用到的函数*/
	function SetSession(FromStaticPage,TheNameOfTranscatPhp,TheNameOfFromStaticPage,url_link)
	{
	　//获取接受返回信息层
	
	<!--由于一开始没有考虑到弹出窗口在各个地方有不同的要求，所以到用的时候，只好增加一个参数来处理不同的需求-->
	var length=arguments.length;
	
	　var msg = document.getElementById("msg");
	　var msg = document.getElementById("msg_before");
	　//获取表单对象和用户信息值
	//　var f = document.user_info;
	//　var userName = f.city_pri.value;
//	　var userAge = f.user_age.value;
	//　var userSex = f.user_sex.value;
	//　var userLink = f.user_link.value;
	// 　var userCeshi = f.user_ceshi.value;
	// var room = f.room.value;
	//alert("运行到这里");
	
	　//接收表单的URL地址
	　var url = "/"+TheNameOfTranscatPhp+".php";
	
	　//需要POST的值，把每个变量都通过&来联接
	　var postStr = "ParameterFromStaticPage="+ FromStaticPage+"&TheNameOfFromStaticPage="+TheNameOfFromStaticPage ;
	/*alert(postStr);*/
	
	　//实例化Ajax
	　var ajax = InitAjax();
	　//通过Post方式打开连接
	　ajax.open("POST", url, true); 
	　//定义传输的文件HTTP头信息
	　ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	　//发送POST数据
	　ajax.send(postStr);
	　//获取执行状态
	//xajax_getAddassignTest (document.getElementById('result6').value,document.getElementById('result6').value);
	
	　ajax.onreadystatechange = function() { 
	　　//如果执行状态成功，那么就把返回信息写到指定的层里
	　　if (ajax.readyState == 4 && ajax.status == 200) { 
	　　//　msg.innerHTML = ajax.responseText; 
/*	     msg_before.style.display="none";
		document.getElementById('msg_before').style.display="none";
		document.getElementById('msg').style.display="block";*/
		//window.location.reload();
		
		if(length==5)
		{
		    
			link_to_other_page(url_link,arguments[4]);
		}
		else
		{   
			link_to_other_page(url_link);
		}
		
	     
	
	　　} 
	　} 
	}
	/*第二版本的看房日志部分用到的函数*/
	function transform(ToBeClosed,ToBeOpend)
	{
		/*alert("transform sucess");*/
		if(document.getElementById('customer_name_cn').value=='' && document.getElementById('customer_email').value=='' && document.getElementById('base_information_id').value=='')
		{
		document.getElementById(ToBeClosed).style.display="none";
		document.getElementById(ToBeOpend).style.display="block";
		}
		
	}
	
	/*第二版本的看房日志部分用到的函数*/
	function get_value_and_transform_customer(customer_name_cn,customer_email,base_information_id)
	{   
	/*alert("运行了获得客户资料的函数");*/
		if(customer_name_cn && !customer_email && !base_information_id)
		{  /* alert("只有客户姓名存在");*/
			SetSession(customer_name_cn,'set_session_for_customer_log_add','customer_name_cn')
			
		}
		if(customer_email && !customer_name_cn && !base_information_id)
		{ /* alert("只有客户邮箱存在");*/
			SetSession(customer_email,'set_session_for_customer_log_add','customer_email')
		}
		if(base_information_id && customer_name_cn && customer_email)
		{   /* alert("三者都存在");*/
			SetSession(base_information_id,'set_session_for_customer_log_add','base_information_id_antinomy')
		}
		if(base_information_id && customer_name_cn && !customer_email)
		{  /*  alert("客户姓名和ID存在");*/
			SetSession(base_information_id,'set_session_for_customer_log_add','base_information_id_antinomy')
		}
		if(base_information_id && !customer_name_cn && customer_email)
		{   /*alert("客户ID和邮箱存在");*/
			SetSession(base_information_id,'set_session_for_customer_log_add','base_information_id_antinomy')
		}
		if(base_information_id && !customer_name_cn && !customer_email)
		{  /* alert("只有客户姓名存在");*/
			SetSession(base_information_id,'set_session_for_customer_log_add','base_information_id_antinomy')
		}
		if(!base_information_id && customer_name_cn && customer_email)
		{  /* alert("客户姓名和邮箱存在");*/
			SetSession(customer_email,'set_session_for_customer_log_add','customer_email')
		}
		
		
	}
	/*第二版本的看房日志部分用到的函数*/
	function get_value_and_transform_property(unit_id,additional_id)
	{
		if(unit_id && additional_id)
		{   /*alert("房源编号和自定义编号存在");*/
			SetSession(unit_id,'set_session_for_customer_log_add','unit_id_antinomy')
		}
		if(unit_id && !additional_id)
		{  /* alert("房源编号存在");*/
			SetSession(unit_id,'set_session_for_customer_log_add','unit_id_antinomy')
		}
		if(!unit_id && additional_id)
		{  /* alert("自定义编号存在");*/
			SetSession(additional_id,'set_session_for_customer_log_add','additional_id')
		}		
	}
	
	/*发送推荐房源时候，如果选择了发送邮件，则询问是否需要自主编辑邮件*/
	function edit_confirm(url,id){
             document.getElementById(id).style.display="none";
			 link_to_other_page(url);

}
	
	function display_button(id,email,url){
		if(email)
		{
		document.getElementById(id).style.display="block";
		}
		else
		{
			link_to_other_page(url);
		}
		
	}
/*当鼠标点击进入文本框的时候，清除默认值*/	
function clearText(thefield){
		if(thefield.defaultValue==thefield.value)
		thefield.value="";
}	



/*当用户提交表单时，过滤提示语*/
function filter_key(key_id,filter_str)
{ 
	if(document.getElementById(key_id).value==filter_str)
	{
		document.getElementById(key_id).value='';
	}
}


/*搜索项目处理关键字部分*/
var OnKeyRequestBuffer = 
 {
 	bufferText: false,
 	bufferTime: 500,
 	modified : function(strId,exc_id,asking_type)
 	{
 		setTimeout('OnKeyRequestBuffer.compareBuffer("'+strId+'","'+exc_id+'","'+asking_type+'","'+xajax.$(strId).value+'");', this.bufferTime);
 	},
 	compareBuffer : function(strId,exc_id,asking_type,strText)
 	{
		//alert('strtext:'+strText);
		//alert('buffertext:'+this.bufferText);
		//alert('strtext:'+strText);
		//alert('strid_value:'+xajax.$(strId).value);
 		if (strText == xajax.$(strId).value)
 		{
 			this.bufferText = strText;
 			OnKeyRequestBuffer.makeRequest(strId,exc_id,asking_type);
 		}
 	},
 	makeRequest : function(strId,exc_id,asking_type)
 	{
		if(xajax.$(strId).value)
		{
		hs_searchProperty(xajax.$(strId).value,exc_id,strId,asking_type);
		}
	}
}	
/*搜索房源处理关键字部分*/
var OnKeyRequestBuffer_1 = 
 {
 	bufferText: false,
 	bufferTime: 500,
 	modified : function(strId,exc_id,asking_type)
 	{
 		setTimeout('OnKeyRequestBuffer_1.compareBuffer("'+strId+'","'+exc_id+'","'+asking_type+'","'+xajax.$(strId).value+'");', this.bufferTime);
 	},
 	compareBuffer : function(strId,exc_id,asking_type,strText)
 	{
		//alert('strtext:'+strText);
		//alert('buffertext:'+this.bufferText);
		//alert('strtext:'+strText);
		//alert('strid_value:'+xajax.$(strId).value);
 		if (strText == xajax.$(strId).value)
 		{
 			this.bufferText = strText;
 			OnKeyRequestBuffer_1.makeRequest(strId,exc_id,asking_type);
 		}
 	},
 	makeRequest : function(strId,exc_id,asking_type)
 	{
		if(xajax.$(strId).value)
		{
		hs_searchunit(xajax.$(strId).value,exc_id,strId,asking_type);
		}
	}
}
/*顾问主页处理关键字搜索部分*/
var OnKeyRequestBuffer_2 = 
 {
 	bufferText: false,
 	bufferTime: 500,
 	modified : function(strId,exc_id,asking_type)
 	{
 		setTimeout('OnKeyRequestBuffer_2.compareBuffer("'+strId+'","'+exc_id+'","'+asking_type+'","'+xajax.$(strId).value+'");', this.bufferTime);
 	},
 	compareBuffer : function(strId,exc_id,asking_type,strText)
 	{
		//alert('strtext:'+strText);
		//alert('buffertext:'+this.bufferText);
		//alert('strtext:'+strText);
		//alert('strid_value:'+xajax.$(strId).value);
 		if (strText == xajax.$(strId).value)
 		{
 			this.bufferText = strText;
 			OnKeyRequestBuffer_2.makeRequest(strId,exc_id,asking_type);
 		}
 	},
 	makeRequest : function(strId,exc_id,asking_type)
 	{
		if(xajax.$(strId).value)
		{ 
		hs_searchProperty_1(xajax.$(strId).value,exc_id,strId,asking_type);
		}
	}
}