function chklogin(){
	if(frmlogin.username.value==""){
		alert("请输入用户名~");
		frmlogin.username.focus();
		return false;
	}

	if(frmlogin.password.value==""){
		alert("请输入密码~");
		frmlogin.password.focus();
		return false;
	}

	frmlogin.submit();
}
function initMarquee(_mid){
	var str=marqueeContent[_mid][0];
	document.write('<div id="marqueeBox'+_mid+'" style="overflow:hidden; display:inline; text-align:left; line-height:'+marqueelineHeight[_mid]+'px; height:'+marqueeHeight[_mid]+'px" onmouseover="clearInterval(marqueeInterval['+_mid+'][0])" onmouseout="marqueeInterval['+_mid+'][0]=setInterval(\'startMarquee('+_mid+')\',marqueeDelay['+_mid+'])"><div style="display:inline;">'+str+'</div></div>');
	marqueeId[_mid]++;
	marqueeInterval[_mid][0]=setInterval("startMarquee("+_mid+")",marqueeDelay[_mid]);
}

function startMarquee(_mid){
	var marqueeBox=$('marqueeBox'+_mid);
	var str=marqueeContent[_mid][marqueeId[_mid]];
	marqueeId[_mid]++;
	if(marqueeId[_mid]>=marqueeContent[_mid].length) marqueeId[_mid]=0;
	if(marqueeBox.childNodes.length==1){
		var nextLine=document.createElement('div');
		nextLine.innerHTML=str;
		marqueeBox.appendChild(nextLine);
	}
	else{
		marqueeBox.childNodes[0].innerHTML=str;
		marqueeBox.appendChild(marqueeBox.childNodes[0]);
		marqueeBox.scrollTop=0;
	}
	clearInterval(marqueeInterval[_mid][1]);
	marqueeInterval[_mid][1]=setInterval("scrollMarquee("+_mid+")",5);
}

function scrollMarquee(_mid){
	var marqueeBox=$('marqueeBox'+_mid);
	marqueeBox.scrollTop++;
	if(marqueeBox.scrollTop%marqueeHeight[_mid]==(marqueeHeight[_mid]-0)){
		clearInterval(marqueeInterval[_mid][1]);
	}
}
function _select(_2,_3) {
	for(i=0;i<document.getElementById(_2).length;i++){
		if (document.getElementById(_2).options[i].value == _3){
		 document.getElementById(_2).options[i].selected=true;
		}
	}
}

var ua = navigator.userAgent.toLowerCase();
	isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1));
function hideElms(elmTag) {
	for (i=0; i<document.all.tags(elmTag).length; i++){
		obj = document.all.tags(elmTag)[i];
		if (!obj || !obj.offsetParent) continue;
		obj.style.visibility = "hidden";
	}
}

function showElms(elmTag) {
	for (i=0; i<window.parent.document.all.tags(elmTag).length; i++){
		obj = window.parent.document.all.tags(elmTag)[i];
		if (!obj || !obj.offsetParent) continue;
		obj.style.visibility = "visible";
	}
}
function ltrim(s){
 return s.replace( /^\s*/, "");
}

function rtrim(s){
 return s.replace( /\s*$/, "");
}
function trim(s){
 return rtrim(ltrim(s));
}
/*function getElementsByClassName(clsName,objParent,htmlTag){
	if (!htmlTag){
		htmlTag='div';
	}
	var arr=new Array();
	var elems=objParent.getElementsByTagName(htmlTag);
	for(var cls,i=0;(elem=elems[i]);i++){
		if((" "+elem.className+" ").indexOf(" "+clsName+" ")!=-1){
			arr[arr.length]=elem;
		}
	}
	return arr;
}

function InitMoveBox(_id,_tag,_bodyClass){
	var _id=document.getElementById(_id);
	var _bodys=getElementsByClassName(_bodyClass,_id);
	_bodys[0].style.display='block';
	var _buttons=_id.getElementsByTagName(_tag)[0].getElementsByTagName('span');
	for(var i=0;i<_buttons.length;i++){
		_buttons[i].onmouseover=function(){
			for(var j=0;j<_buttons.length;j++){
				if (_buttons[j]==this){
					_buttons[j].className='current';
					_bodys[j].style.display='block';
					_id.getElementsByTagName('h3')[0].getElementsByTagName('a')[0].href=this.title;
				}else{
					_buttons[j].className='';
					_bodys[j].style.display='none';
				}
			}
		}
	}
} */
function CreateFlash(idad, swfurl, wad, had, vs){
	var str = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"" + wad + "\" height=\"" + had + "\" id=\"" + idad + "\" align=\"middle\">";
	str += "<param name=\"allowScriptAccess\" value=\"always\">";
	str += "<param name=\"quality\" value=\"high\">";
	str += "<param name=\"movie\" value=\"" + swfurl + "\">";
	str += "<param name=\"flashvars\" value=\"" + vs + "\">";
	str += "<embed src=\"" + swfurl + "\" flashvars=\"" + vs + "\" quality=\"high\" width=\"" + wad + "\" height=\"" + had + "\" name=\"" + idad + "\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">";
	str += "</object>";
	document.write(str);
}

function sAlert(txt,$uri){
	//var eSrc=(document.all)?window.event.srcElement:arguments[1];
	if(isIE)hideElms('select');
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = document.documentElement.clientHeight+"px";
	//((document.documentElement.clientHeight>document.documentElement.scrollHeight)?document.documentElement.clientHeight:document.documentElement.scrollHeight)+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=0)";
	shield.style.opacity = 0;
	var alertFram = document.createElement("DIV");
	alertFram.id="alertFram";
	alertFram.style.position = "absolute";
	alertFram.style.left = "50%";
	alertFram.style.top = "50%";
	alertFram.style.marginLeft = "-225px" ;
	alertFram.style.marginTop = -75+document.documentElement.scrollTop+"px";
	alertFram.style.width = "450px";
	alertFram.style.height = "150px";
	alertFram.style.background = "#ccc";
	alertFram.style.textAlign = "center";
	alertFram.style.lineHeight = "150px";
	alertFram.style.zIndex = "10001";

	strHtml  = "<div style=\"margin:0px;padding:0px;width:100%\">\n";
	strHtml += "	<div style=\"background:#FF6500;text-align:left;padding-left:20px;font-size:14px;font-weight:bold;height:25px;line-height:25px;border:1px solid #FF9E33;\">[系统提示]</div>\n";
	strHtml += "	<div style=\"background:#fff;text-align:center;font-size:12px;height:120px;line-height:120px;border-left:1px solid #FF9E33;border-right:1px solid #FF9E33;\">"+txt+"</div>\n";
	strHtml += "	<div style=\"background:#FFECDF;text-align:center;font-weight:bold;height:25px;line-height:25px; border:1px solid #FF9E33;\"><input type=\"button\" value=\"确 定\" id=\"do_OK\" onclick=\"doOk('"+$uri+"')\" /></div>\n";
	strHtml += "</div>\n";
	alertFram.innerHTML = strHtml;
	document.body.appendChild(alertFram);
	document.body.appendChild(shield);
	this.setOpacity = function(obj,opacity){
		if(opacity>=1)opacity=opacity/100;
		try{ obj.style.opacity=opacity; }catch(e){}
		try{
			if(obj.filters.length>0&&obj.filters("alpha")){
				obj.filters("alpha").opacity=opacity*100;
			}else{
				obj.style.filter="alpha(opacity=\""+(opacity*100)+"\")";
			}
		}catch(e){}
	}
	var c = 0;
	this.doAlpha = function(){
		if (++c > 20){clearInterval(ad);return 0;}
		setOpacity(shield,c);
	}
	var ad = setInterval("doAlpha()",1);
	this.doOk = function($u){
		document.body.removeChild(alertFram);
		document.body.removeChild(shield);
		//eSrc.focus();
		document.body.onselectstart = function(){return true;}
		document.body.oncontextmenu = function(){return true;}
		if(isIE)showElms_1('select');
		if ($u!='' && $u!='undefined' &&$u!='null')
		{
			document.location.href=$u;
		}
	}
	document.getElementById("do_OK").focus();
	//eSrc.blur();
	document.body.onselectstart = function(){return false;}
	document.body.oncontextmenu = function(){return false;}
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

var picpath='http://img.hz.house365.com/main/house_new/tab/';//images/

var tab=new Array(
	new Array('searchnewhouse', 'searchsell', 'searchrent', 'searchhome', 'searchnews', 'searchpic', 'searchbbs', 'searchlife', 'searchzhidao'),
	new Array("fcjd", "jjjd"),
	new Array("lpsd", "xwph"),
	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("hfsp","hdsp"),
	new Array("jgcx1", "jgcx2", "jgcx3", "jgcx4", "jgcx5", "jgcx6", "jgcx7")

);
var bgpic=new Array(
	new Array(),
	new Array(),
	new Array("lpsd_bg.jpg", "lpsd1_bg.jpg"),
	//new Array("lpsd.gif", "xwph1.gif"),
	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("lpsd.gif","xwph1.gif"),
	new Array("lpsd_bg.jpg", "lpsd1_bg.jpg"),
	new Array("price_nav.gif","price_nav1.gif","price_nav2.gif","price_nav3.gif","price_nav4.gif","price_nav5.gif","price_nav6.gif")
);
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()
);
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_16.gif', 'f_03.gif', 'f2_05.gif', 'f2_07.gif', 'f2_09.gif', 'f2_11.gif', 'f2_13.gif', 'f2_15.gif', 'f2_16.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()
);
var cls=new Array(
	new Array(),
	new Array(),
	//new Array(),
	new Array("w14","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("w14","w14"),
	//new Array(),
	new Array()
);
var ajaxids=new Array(
	new Array("newhouse", "sell", "rent", "home", "news", "pic", "bbs", "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("1,5000","5001,6000","6001,7000","7001,8000","8001,10000","10001,-1","0,0")
);
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://hz.house365.com/search/js_search.php';
			var pars='type='+ajaxid;
			break;
		case 3:
			var url='http://hz.house365.com/js_loadnewhouseprice.php';
			var pars='price='+ajaxid;
			break;
		case 8:
			var url='http://hz.house365.com/js_loadsellinfo.php';
			var pars='type='+ajaxid;
			break;
		case 9:
			var url='http://hz.house365.com/js_loadrentinfo.php';
			var pars='type='+ajaxid;
			break;
		case 11:
			var url='http://hz.house365.com/js_loadofficeinfo.php';
			var pars='type='+ajaxid;
			break;
		case 12:
			var url='http://hz.house365.com/js_loadshopinfo.php';
			var pars='type='+ajaxid;
			break;
		case 13:
			var url='http://hz.house365.com/js_loadvillainfo.php';
			var pars='type='+ajaxid;
			break;
		case 14:
			var url='http://hz.house365.com/js_loadforumrank.php';
			var pars='type='+ajaxid;
			break;
		case 16:
			var url='http://hz.house365.com/js_loadnewhouseprice.php';
			var pars='price='+ajaxid+'&area=7';
			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();",20000);
}

function movesp(){
	var ptop,pleft;

	ptop=getbodyscrolltop()+200;
	pleft=(window.screen.width-500)/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 hidegfgj1(e){
	thisObj=e.target?e.target:event.srcElement;
	do{
		if(thisObj.id=="a_gfgj1") return;
		if(thisObj.id=="div_gfgj1") return;

		if(thisObj.tagName=="BODY"){
			$('div_gfgj1').style.display='none';
			return;
		}

		thisObj=thisObj.parentNode;
	}
	while(thisObj.parentNode);
}

function hidegfgj2(e){
	thisObj=e.target?e.target:event.srcElement;
	do{
		if(thisObj.id=="a_gfgj2") return;
		if(thisObj.id=="div_gfgj2") return;

		if(thisObj.tagName=="BODY"){
			$('div_gfgj2').style.display='none';
			return;
		}

		thisObj=thisObj.parentNode;
	}
	while(thisObj.parentNode);
}

function hidegfgj3(e){
	thisObj=e.target?e.target:event.srcElement;
	do{
		if(thisObj.id=="a_gfgj3") return;
		if(thisObj.id=="div_gfgj3") return;

		if(thisObj.tagName=="BODY"){
			$('div_gfgj3').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);
}

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();
