
function checkbox(boxname)
{
var str=document.getElementsByName(boxname);
var objarray=str.length;
var chestr="";
for (var i=0;i<objarray;i++)
{
  if(str[i].checked == true)
  {
   chestr+=str[i].id;
  }
}
return chestr;
}


//搜索条件字符
function settitle(index,titlestr,num)
{
	return;
	$(index+"title").innerHTML = titlestr;

	if($(index+"titlename"))
	{
		$(index+"titlename").className = "name";
	}
	for(var i=0;i<100;i++)
	{
		if($(index+"titlename"+i))
		{
			$(index+"titlename"+i).className = "name";
		}
	}
	if($(index+"titlename"+num))
	{
		$(index+"titlename"+num).className = "name_on";
	}
	if(index=="districts")
	{
		getcenter(titlestr,"");
	}
	if(index=="params")
	{
		getcenter(searchcondition['districts'],titlestr);
	}
	//setbox1height();
	
}
//设置开始时间面板
function openmenu(index)
{
	if($(index+"menu").style.display == "none")
	{
		$(index+"menu").style.display = "block";
	}
	else
	{
		$(index+"menu").style.display = "none";
	}
	
}
//搜索条件字符 时间样式
function settimetitle(index){
	closetip();
	var titlestr = "";
	var syear = $(index+"syear").value;
	var smonth = $(index+"smonth").value;
	var eyear = $(index+"eyear").value;
	var emonth = $(index+"emonth").value;
	var searchdate = "[";
	if(smonth == "" && syear == "" && emonth == "" && eyear == ""){
		$(index+"menu").style.display = "none";
		if(index == "intime"){
			$(index+"title").innerHTML = "入住时间";
		}
		else
		{
			$(index+"title").innerHTML = "开盘时间";
		}
		searchcondition[index] = "";
		searchresult();
		return;
	}
	if(smonth != "" && syear == "")
	{
		alert("输入开始年份");
		return false;
	}
	if(emonth != "" && eyear== "")
	{
		alert("输入结束年份");
		return false;
	}
	if(syear >= eyear){
		if(((parseInt(syear+smonth) > parseInt(eyear+emonth)) && (parseInt(eyear+emonth) != 0))){
			alert("结束时间必须大于开始时间");
			return false;
		}
	}
	
	
	if(smonth != "")
	{
		
		titlestr += syear+"."+smonth.substring(0,2);
		searchdate += syear+smonth;
	}
	else
	{
		if(syear != "")
		{
			titlestr += syear;
			searchdate += syear+"0101";
		}
		else
		{
			searchdate += "";
		}
	}
	searchdate += ",";
	if(emonth != "" && !(eyear == syear && emonth == smonth))
	{
		titlestr += "-"+eyear+"."+emonth.substring(0,2);
		searchdate += eyear+emonth;
	}
	else
	{
		if(eyear != "" && eyear!=syear)
		{
			titlestr += "-"+eyear;
			searchdate += eyear+"1231";
		}
		else if(eyear != "")
		{
			searchdate += eyear+"1231";
		}
	}
	searchdate += "]";
	$(index+"title").innerHTML = titlestr;
	$(index+"menu").style.display = "none";
	searchcondition[index] = searchdate;
	c();
}
//设置搜索条件并搜索
function setsearch(index,searchvalue)
{
	if(searchurl == "")
	{
		return;
	}
	$("resultList").innerHTML = "";
	$("newmapObj").style.display = "block";
	var url = searchurl;
	var pars = searchurlpars;
	if(index == "page")
	{
		pars +=  '&page='+searchvalue;
		pars +=  '&sort='+$('sort').value;
	}
	else if(index == "sort")
	{
		pars +=  '&page=0';
		pars +=  '&sort='+searchvalue;
	}
	
	var myAjax = new Ajax.Request
	(
         url,
         {method: 'post', postBody: pars,onFailure:showFailure, onComplete: showSearchResult}
    );
	//searchresult();
}

var searchbustype = "1";
function setsearchbustype(type)
{
	searchbustype = type;
	for(var j =0;j < 10;j++)
	{
		if($("bustype"+j))
		{
			$("bustype"+j).style.display = "none";
		}
	}
	$("bustype"+type).style.display = "block";
}
function getdistance(le){//得到里程
	if(le<=1000){
		var s = le;
		return s+"米";
	}else{
		var s = Math.round(le/1000);
		return "约"+s+"公里";
	}
}
//显示周边搜索右边栏
function filltempsearch(cname,num)
{
	house_near_num = num;
	showmenu(2,1);
	$("tempnearname").value = cname;
}


/* get, set, and delete cookies */
function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
	
function Set_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires.toGMTString() : "" ) + //expires.toGMTString()
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
	
function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


//获取大小，用于页面自适应
function getScreenSize()
{
	var theWidth,theHeight;
	if (window.innerWidth) 
	{ 
		theWidth = window.innerWidth ;
		theHeight = window.innerHeight;
	} 
	else if (document.compatMode=='CSS1Compat') 
	{ 
		theWidth = document.documentElement.clientWidth ;
		theHeight = document.documentElement.clientHeight ;
	
	} 
	else if (document.body) 
	{ 
		theWidth = document.body.clientWidth ;
		theHeight = document.body.clientHeight ;

	} 
	var result = [theWidth,theHeight];
	return result;
}
function hideRightMenu()
{
	if($('map_result_main').style.display == 'none')
	{
		$('map_result_main').style.display='block';
		$('map_body_box').style.paddingRight = '214px';
		$('map_result_barimg_open').style.display = "none";
		$('map_result_barimg_hide').style.display = "block";
	}
	else
	{
		$('map_result_main').style.display='none';
		$('map_body_box').style.paddingRight = '4px';
		$('map_result_barimg_hide').style.display = "none";
		$('map_result_barimg_open').style.display = "block";
	}
	map.checkResize();
}
function hideLeftMenu()
{
	if($('map_left_container').style.display == 'none')
	{
		$('map_left_container').style.display='block';
		$('pagebodyRight1').style.marginLeft = '180px';
		$('map_result_barimg_open2').style.display = "none";
		$('map_result_barimg_hide2').style.display = "block";
	}
	else
	{
		$('map_left_container').style.display='none';
		$('pagebodyRight1').style.marginLeft = '6px';
		$('map_result_barimg_hide2').style.display = "none";
		$('map_result_barimg_open2').style.display = "block";
	}
	map.checkResize();
}
//清空检索项
function clearitem(index)
{
	if($(index+"title"))
	{
		$(index+"title").innerHTML = "";
	}
	//$(index+"font").innerHTML = "";
	//$('cityname').innerHTML = searchcondition['cityname']+"全部楼盘";	
	if($(index+"titlename"))
	{
		$(index+"titlename").className = "name";
	}
	for(var i=0;i<100;i++)
	{
		if($(index+"titlename"+i))
		{
			$(index+"titlename"+i).className = "name";
		}
	}
}
function cleartimeitem(index)
{
	$(index+"title").innerHTML = "";
	//$(index+"font").innerHTML = "";
	//$('cityname').innerHTML = searchcondition['cityname']+"全部楼盘";	
	$(index+"syear").value = "";
	$(index+"smonth").value = "";
	$(index+"eyear").value = "";
	$(index+"emonth").value = "";
}
function setbox1height()
{
	var str = $('box1Listsearch').innerHTML;
	var exp = /\"/g;
	str = str.replace(exp,"");
	var len = str.length;
	if(len > 338 && len <= 354)
	{
		$("box1List").style.height =  (85 + 15) + "px";
	}
	else if(len > 354 && len <= 370)
	{
		$("box1List").style.height =  (85 + 30) + "px";
	}
	else if(len > 370 && len <= 386)
	{
		$("box1List").style.height =  (85 + 50) + "px";
	}
	else if(len > 386)
	{
		$("box1List").style.height =  (85 + 65) + "px";
	}
	else
	{
		$("box1List").style.height =  "85px";
	}
	$("map_menu_container").style.height =  ($("map_left_container").offsetHeight - $("box1Listup").offsetHeight - 30) + "px";
}
function checkFirefoxOrIE(){
userAgent=window.navigator.userAgent.toLowerCase();
if(userAgent.indexOf("firefox")>=1){
return 1;
}
else {
	return 0;
}
}

function changeround(round)
{
	isdragend = 0;
	searchtype = 1;
	searchrsstatrt = 1;
	searchresult();
}
function changesubway(subway)
{
	isdragend = 0;
	searchtype = 1;
	searchrsstatrt = 1;
	searchresult();
}

function gotoorder(index,city)
{
	if(city=="bj")
	{
		window.location='http://'+city+index+'.test.soufun.com/map/';
	}
	else
	{
		window.location='http://'+index+city+'.test.soufun.com/map/';
	}
}
