﻿
function login_val(){
	document.getElementById("login_form").onSubmit=function(){
		var name_val=document.getElementById("username").value;
		var pwd_val=document.getElementById("userpassword").value;
		document.getElementById("u_name").value=encodeURIComponent(name_val);
		document.getElementById("u_pwd").value=encodeURIComponent(pwd_val);
	}
}

function combinateUrl(obj){
	switch(obj.name){
		case "newhouse":
			window.open("http://house.fclm.cn/newhouse/"+encodeURIComponent((obj.newhouse_skey.value=='楼盘关键字')?"":obj.newhouse_skey.value)+"s__"+obj.sZone.value+"_"+obj.sBuildType.value+"_"+obj.sItemType.value+"_"+((obj.sPrice.value)==''?'_':obj.sPrice.value)+"_____/");
			return false;
		case "s_sell":
			window.open("http://house.fclm.cn/sell/"+encodeURIComponent((obj.f3_key.value=='楼盘关键字')?'':obj.f3_key.value)+"s__"+obj.f3_zone.value+"_"+(obj.f3_price.value==''?'_':obj.f3_price.value)+"_"+(obj.f3_area.value==''?'_':obj.f3_area.value)+"_"+obj.f3_Shi.value+"_"+obj.f3_type.value+"_______/");
			return false;
		case "s_rent":
			window.open("http://house.fclm.cn/rent/"+obj.f4_zone.value+"_"+encodeURIComponent((obj.f4_price.value=='楼盘关键字')?'':obj.f4_price.value)+"_"+obj.shi_tin.value+"_"+obj.f4_type.value+"__"+obj.f4_fment.value+"_____/");
			return false;
	}
}

function fclm_tab(ary_obj){
	for(var o=0;o<ary_obj.length;o++)
	{
		tab(ary_obj[o],true);
	}
	
	function tab(id,bool,obj){
		var ele=document.getElementById(id);
		var children=ele.getElementsByTagName("li");
		var o;
		if(bool){
			for(var i=0;i<children.length;i++)
			{
				o=children[i].getElementsByTagName("a")[0].href;
				if(o.indexOf("#")==-1)
				{
					continue;
				}
				else{
					children[i].onclick=function(){
						tab(id,false,this);
					};
					children[i].getElementsByTagName("a")[0].onclick=function(){return false};
				}
				if(i==0){//默认第一个为选中
					var att=children[i].className;
					if(att!=null&&att.indexOf("selected")==-1){
						att=att+' '+'selected';
					}
					else if(att.indexOf("selected")!=-1){
						att=att;
					}
					else{
						att='selected';
					}
					/* children[i].setAttribute("class",att); */
					children[i].className=att;
				}
			}
		}
		else{
			for(var j=0;j<children.length;j++)
				{
					/* var c=children[j].getAttribute("class"); */
					var c=children[j].className;
					if(c!=null){
						if(c.indexOf("selected")!=-1){
							c=c.replace("selected","");
							/* children[j].setAttribute("class",c); *///这句ie6，ie7不支持
							children[j].className=c;
						}
					}
					val=getString(children[j].getElementsByTagName("a")[0].href);
					if(val==null){
						alert("没有指向的区块可以显示！");
						return false;
					}
					else if(val.indexOf("#")==-1){
						continue;
					}
					else{
						document.getElementById(val.substring(1,val.length)).style.display="none";
					}
				}
				value=getString(obj.getElementsByTagName("a")[0].href);
				if(value==null){
					alert("没有指向的区块可以显示！");
					return false;
				}
				else{
					if(value.charAt(0)!="#"){
						alert("暂不支持非ID指定的元素！");
						return false;
					}
					else{
						/* var s=obj.getAttribute("class"); */ //这句ie6，ie7不支持
						var s=obj.className;
						if(s!=null){
							s='selected'+' '+s;
						}
						else{
							s='selected';
						}
						/* obj.setAttribute("class",s); */ //这句ie6，ie7不支持
						obj.className=s;
						document.getElementById(value.substring(1,value.length)).style.display="block";
					}
				}
			}
		}
		
		function getString(str){
			var i=str.search("#");
			var s=str.substring(i,str.length);
			return s;
		}
	}
	
	
    function house_show(e_array){
		for(var o=0;o<e_array.length;o++)
		{
			showIt(e_array[o],true);
		}
		
		function showIt(id,bool,obj){
			var e=document.getElementById(id);
			var children=e.getElementsByTagName("li");
			if(bool){
				for(var i=0;i<children.length;i++)
				{
					children[i].onmouseover=function(){
					showIt(id,false,this)
					};
					if(i==0)
					{
						/* var s=children[i].getAttribute("class"); */
						var s=children[i].className;
						if(s!=null&&s.indexOf('selected')==-1){
							s=s+' '+'selected';
						}
						else{
							s='selected';
						}
						/* children[i].setAttribute("class",s); */
						children[i].className=s;
					}
				}
			}
			else{
				for(var j=0;j<children.length;j++)
				{
					/* var c=children[j].getAttribute("class"); */
					var c=children[j].className;
					if(c!=null){
						if(c.indexOf("selected")!=-1){
							c=c.replace("selected","");
							/* children[j].setAttribute("class",c); */
							children[j].className=c;
						}
					}
				}
				var str=obj.getAttribute("class");
				if(str!=null){
					str=str+' '+'selected';
				}
				else{
					str='selected';
				}
				/* obj.setAttribute("class",str); */
				obj.className=str;
			}
		}
	}
	
	
	function AutoScroll(obj){
		jquery(obj).find("ul:first").animate({
				marginTop:"-160px"
		},1500,function(){
		jquery(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
	});
}
