var picpath='http://wh.house365.com/images/tab/';

var tab=new Array(new Array('searchnewhouse', 'searchsell', 'searchrent', 'searchhome', 'searchnews', 'searchpic', 'searchbbs', 'searchlife', 'searchzhidao'), new Array("fcjd", "jjjd"), new Array("lpsd","xwph","xwph2"), new Array("jgcx1", "jgcx2", "jgcx3", "jgcx4", "jgcx5", "jgcx6", "jgcx7"), new Array("div_rmlp", "div_zxlp"), new Array("div_bykp", "div_xykp"), new Array("div_zzl", "div_bgl", "div_syyfl"), new Array("div_sellcx", "div_rentcx"), new Array("div_sell_1", "div_sell_2", "div_sell_3"), new Array("div_rent_1", "div_rent_2", "div_rent_3"), new Array("div_officeinfo", "div_shopinfo", "div_villainfo"), new Array("div_office_1", "div_office_2"), new Array("div_shop_1", "div_shop_2"), new Array("div_villa_1", "div_villa_2"), new Array("div_top40_day", "div_top40_week", "div_top40_month"), new Array("lpsd_new", "xwph_new"), new Array("jjw16_1", "jjw16_2"),new Array("jjw17_1", "jjw17_2"),new Array("jjw18_1", "jjw18_2"));
var bgpic=new Array(new Array(), new Array(), new Array("lpsd3_bg1.jpg","lpsd3_bg2.jpg", "lpsd3_bg3.jpg"), new Array('jgcx.gif', 'jgcx1.gif', 'jgcx2.gif', 'jgcx3.gif', 'jgcx4.gif', 'jgcx5.gif', 'jgcx6.gif'), new Array("rmlp.gif", "rmlp1.gif"), new Array("bylp.gif", "bylp1.gif"), new Array("zzljjqk.gif", "zzljjqk1.gif", "zzljjqk2.gif"), new Array("tjfy.gif", "tjfy1.gif"), new Array("esftab.gif", "esftab1.gif", "esftab2.gif"), new Array("zfxx.gif", "zfxx1.gif", "zfxx2.gif"), new Array("xzl.jpg", "xzl1.jpg", "xzl2.jpg"), new Array("xzltab.gif", "xzltab1.gif"), new Array("xzltab.gif", "xzltab1.gif"), new Array("xzltab.gif", "xzltab1.gif"), new Array(), new Array("td_bg.jpg", "td_bg1.jpg"), new Array("tab.gif", "tab1.gif"), new Array("lpsd_bg.jpg", "lpsd1_bg.jpg"), new Array("lpsd_bg.jpg", "lpsd1_bg.jpg"));
var tdbgpic=new Array(new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array());
var tdpics=new Array(new Array('f2_03.gif', 'f_05.gif', 'f_07.gif', 'f_09.gif', 'f_11.gif', 'f_13.gif', 'f_15.gif', 'f_17.gif', 'f44.gif', 'f_03.gif', 'f2_05.gif', 'f2_07.gif', 'f2_09.gif', 'f2_11.gif', 'f2_13.gif', 'f2_15.gif', 'f2_17.gif', 'f44.gif'), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array());
var cls=new Array(new Array(), new Array(), new Array("w14","bblue14","w14"), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array(), new Array("sdfn_on","sdfn"), new Array("s14","sh14"), new Array("w14","bblue14"),new Array("w14","bblue14"),new Array("w14","bblue14"));
var ajaxids=new Array(new Array("newhouse", "sell", "rent", "home", "news", "pic", "bbs", "life", "zhidao"), new Array(), new Array(), new Array("1,6000","6000,8000","8000,10000","10000,15000","15000,20000","20000,-1","0,0"), new Array(), new Array(), new Array(), new Array(), new Array("1", "2", "3"), new Array("1", "2", "3"), new Array(), new Array("1", "2"), new Array("1", "2"), new Array("1", "2"), new Array("1", "2", "3"),new Array(),new Array());

function showtab(m,n,count,type){
	var tdpic, ctrbgpic;

	for(var i=1;i<=count;i++){
		if(i==n){
			getObject(tab[m][i-1]).style.display="";

			if((type&2)!=0){
				tdpic="";
				if(tdbgpic[m][i-1+count]) tdpic=picpath+tdbgpic[m][i-1+count];
				getObject("td_"+m+"_"+i).style.background="url('"+(tdpic)+"')";
			}

			if((type&4)!=0){
				getObject("td_"+m+"_"+i).className=cls[m][0];
			}

			if((type&8)!=0){
				getObject("nav_"+m+"_"+i).style.display="";
			}

			if((type&16)!=0){
				tdpic="";
				if(tdpics[m][i-1+count]) tdpic=picpath+tdpics[m][i-1+count];
				getObject("img_"+m+"_"+i).src=tdpic;
			}

			if((type&32)!=0){
				var content=getObject(tab[m][i-1]).innerHTML;
				if(content.indexOf('ÔØÈëÖÐ')!=-1||content==''){
					loaddata(m,ajaxids[m][i-1],tab[m][i-1]);
				}
			}
		}
		else{
			getObject(tab[m][i-1]).style.display="none";

			if((type&2)!=0){
				tdpic="";
				if(tdbgpic[m][i-1]) tdpic=picpath+tdbgpic[m][i-1];
				getObject("td_"+m+"_"+i).style.background="url('"+(tdpic)+"')";
			}

			if((type&4)!=0){
				getObject("td_"+m+"_"+i).className=cls[m][1];
			}

			if((type&8)!=0){
				getObject("nav_"+m+"_"+i).style.display="none";
			}

			if((type&16)!=0){
				tdpic="";
				if(tdpics[m][i-1]) tdpic=picpath+tdpics[m][i-1];
				getObject("img_"+m+"_"+i).src=tdpic;
			}
		}
	}

	if((type&1)!=0){
		ctrbgpic="";
		if(bgpic[m][n-1]) ctrbgpic=picpath+bgpic[m][n-1];
		getObject("ctr_"+m).style.background="url('"+(ctrbgpic)+"')";
	}
}

function getObject(objectId){
	if(document.getElementById && document.getElementById(objectId)){
		// W3C DOM
		return document.getElementById(objectId);
	}else if (document.all && document.all(objectId)){
		// MSIE 4 DOM
		return document.all(objectId);
	}else if (document.layers && document.layers[objectId]){
		// NN 4 DOM.. note: this won\'t find nested layers
		return document.layers[objectId];
	}else{
		return false;
	}
}

function getbodyscrolltop(){
	var scrollPos;
	if(typeof window.pageYOffset != 'undefined'){
		scrollPos = window.pageYOffset; 
	}
	else if(typeof document.compatMode!='undefined' && document.compatMode!='BackCompat'){
		scrollPos=document.documentElement.scrollTop;
	}
	else if(typeof document.body!='undefined'){
		scrollPos=document.body.scrollTop;
	}

	return scrollPos;
}

function loaddata(m,ajaxid,objid){
	switch(m){
		case 0:
			var url='http://wh.house365.com/search/js_search.php';
			var pars='type='+ajaxid;
			break;
		case 3:
			var url='http://wh.house365.com/js_loadnewhouseprice.php';
			var pars='price='+ajaxid;
			break;
		case 8:
			var url='http://wh.house365.com/js_loadsellinfo.php';
			var pars='type='+ajaxid;
			break;
		case 9:
			var url='http://wh.house365.com/js_loadrentinfo.php';
			var pars='type='+ajaxid;
			break;
		case 11:
			var url='http://wh.house365.com/js_loadofficeinfo.php';
			var pars='type='+ajaxid;
			break;
		case 12:
			var url='http://wh.house365.com/js_loadshopinfo.php';
			var pars='type='+ajaxid;
			break;
		case 13:
			var url='http://wh.house365.com/js_loadvillainfo.php';
			var pars='type='+ajaxid;
			break;
		case 14:
			var url='http://wh.house365.com/js_loadforumrank.php';
			var pars='type='+ajaxid;
			break;
	}

	if(url!=""&&pars!=""){
		var myAjax=new Ajax.Updater(objid,url,{method:'get',parameters:pars,evalScripts:true});
	}

	return false;
}

function trim(str){
	for(var i=0; i<str.length&&str.charAt(i)==" "; i++);
	for(var j=str.length; j>0&&str.charAt(j-1)==" "; j--);
	if(i>j) return  "";  
	return str.substring(i,j);
}

function _showtab(isshow,_mid,count,type){
	if(isshow){
		showtab(_mid,tabid[_mid],count,type);

		tabid[_mid]=(tabid[_mid]+1)%count;
		if(tabid[_mid]==0) tabid[_mid]=count;
	}

	if(_ctrtab[_mid]) clearTimeout(_ctrtab[_mid]);
	_ctrtab[_mid]=setTimeout("_showtab(1,"+_mid+","+count+","+type+");",5000);
}

function _clearscroll(_mid){
	if(_ctrtab[_mid]) clearTimeout(_ctrtab[_mid]);
}

function ad_qp_check(){
	var qpflag=false;
	if(!ns && !ie && !w3){
		setTimeout("ad_st_deal()",1000);
		return;
	}

	if(ie && !document.all.lbplocation){
		setTimeout("ad_st_deal()",1000);
		return;
	}

	if(ns && !document.layers["lbplocation"]){
		setTimeout("ad_st_deal()",1000);
		return;
	}

	if(w3 && !document.getElementById("lbplocation")){
		setTimeout("ad_st_deal()",1000);
		return;
	}

	if(ie) adDiv=eval('document.all.lbplocation.style');
	else if(ns) adDiv=eval('document.layers["lbplocation"]');
	else if(w3) adDiv=eval('document.getElementById("lbplocation").style');

	if (ie||w3) if(adDiv.display=="none") qpflag=true; 
	else if(adDiv.visibility=="hide")  qpflag=true;

	if(qpflag==true) setTimeout("ad_st_deal()",1000);
	else setTimeout("ad_qp_check()",1000); 
}

function log_start(id,_time){
	setTimeout("real_log_start('"+id+"')",_time); 
	return false;
}

function real_log_start(id){
	$(id).style.display="none";
}

function loadsp(){
	movesp();
	setTimeout("closesp();",30000);
}

function movesp(){
	var ptop,pleft;
	
	ptop=getbodyscrolltop()+240;
	pleft=(window.screen.width-800)/2;

	document.getElementById("spad").style.top=ptop+"px";
	document.getElementById("spad").style.left=pleft+"px";
	setTimeout("movesp()",200);
}

function closesp(){
	document.getElementById('spad').style.visibility='hidden';
}

function hidegfgj(e){
	thisObj=e.target?e.target:event.srcElement;
	do{
		if(thisObj.id=="a_gfgj") return;
		if(thisObj.id=="div_gfgj") return;

		if(thisObj.tagName=="BODY"){
			$('div_gfgj').style.display='none';
			return;
		}

		thisObj=thisObj.parentNode;
	}
	while(thisObj.parentNode);
}

function hidewzsp(e){
	thisObj=e.target?e.target:event.srcElement;
	do{
		if(thisObj.id=="a_wzsp") return;
		if(thisObj.id=="div_wzsp") return;

		if(thisObj.tagName=="BODY"){
			$('div_wzsp').style.display='none';
			return;
		}

		thisObj=thisObj.parentNode;
	}
	while(thisObj.parentNode);
}

function setadfytop(){
	$('div_adfy').style.top=$('top').offsetTop+"px";
	$('div_adfy').style.visibility="visible";

	timeout_adfy=setTimeout('setadfytop()',500);
}

var _m;
var marqueeId=new Array();
var marqueeDelay=new Array();
var marqueeHeight=new Array();
var marqueelineHeight=new Array();
var marqueeInterval=new Array();
var marqueeContent=new Array();
var marqueenumber=new Array();

var tabid=new Array();
var _ctrtab=new Array();

