var body=document.body,agent=navigator.userAgent
var isIE,isIE4,isIE5,isIE6,isOpr,isMoz
window.onerror=function(){ return false;} 
String.prototype.inc=function(k1,k2){
	return k2==null?this.indexOf(k1)>-1?true:false:(k2+this+k2).indexOf(k2+k1+k2)>-1?true:false}
isIE6=agent.inc("IE 6");
isIE7=agent.inc("IE 7");
isIE8=agent.inc("IE 8");
//---------------------------------------------------------------------------------------
String.prototype.trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, "");} //清除空格

var $=function (str)
{
	return document.getElementById(str);
}

var GetName=function (str)
{
	return document.getElementsByName(str);
}

var $$=function(node){
	return document.getElementsByTagName(node);
}

var $$$=function(node1,node2){
	return document.getElementById(node1).getElementsByTagName(node2);
}

function oo(obj)
{
	return document.getElementById(obj)//typeof返回数据类型
}

function num_select(obj,f,t,n){
	if(obj != null){
		for(i=f;i<=t;i++){
			obj.options[obj.options.length]=new Option(i,i);
			obj.options[obj.options.length-1].selected=n==i?true:false;
		}
	}
}

function num_select2(obj,f,t,n,q){
	if(obj != null){
		for(i=f;i<=t;i++){
			obj.options[obj.options.length]=new Option(i-q,i-q);
			obj.options[obj.options.length-1].selected=n==i?true:false;
		}
	}
}

function num_Option(obj,f,t,n){
	if(obj != null){
		var m;
		for(i=f;i<=t;i++){ 
			m=((i<10)?'0':null)+i;
			obj.options[obj.options.length]=new Option(m,m);
			// new Option(m,n);m是页面中看到的描述,而n是这一项的值;
			obj.options[obj.options.length-1].selected=n==m?true:false;
		}
	}
}

function change_option(number,index,head_name,content_name)
{
	for (var i = 1; i <= number; i++)
	{
		$(head_name + i).className = '';
		$(content_name + i).style.display = 'none';
	}
	$(head_name + index).className = 'current';
	$(content_name + index).style.display = 'block';
}

//number表示标签总数,index表示当前标签,head_name表示标签id前部分,
//content_name表示内容id前部分,css表示当前标签css类名,
function ChangTab(number,index,head_name,content_name,css)
{
	for (var i = 1; i <= number; i++)
	{
		$(head_name + i).className = '';
		$(content_name + i).style.display = 'none';
	}
	$(head_name + index).className = css;
	$(content_name + index).style.display = 'block';
}

//排行榜轮换展示
var indexPhi=1;
function ChangTabTimer()
{
    if(indexPhi == 1)
        indexPhi = 2;
    else
        indexPhi = 1;
    ChangTab(2,indexPhi,'jo','jr','sebg');
}

//经济适用房源搜索
function CheapProSearch(){
      var DistrictName,Price,Area,EstateName,url;
	  DistrictName=$("DistrictName").value;
	  Price=$("Price").value;
	  Area=$("Area").value;
	  EstateName=$("Address").value;
	  
	  var Para="";
	  if(DistrictName !="") Para+="&DistrictName="+DistrictName;
	  if(Price !="") Para+=Price;
	  if(Area !="") Para+=Area;
	  if(EstateName !="") Para+="&EstateName="+EstateName;
	  Para = Para.substr(1,Para.length-1);

	  url = "/ZhuanTi/Cheap/?"+Para;
	  window.location = url;
}
function ShowMonth(id,FullMonth){
	obj = $(id);
	obj.options.length = 1;
	if(FullMonth == true){
		var month = 12;
	}else{
		var month = new Date().getMonth();
		month += 1;
	}
	for(var i=1;i<=month;i++){ 
		n = i + "月份";
		obj.options[obj.options.length]=new Option(n,i);
		// new Option(m,n);m是页面中看到的描述,而n是这一项的值;
	}
}

function ShowYear(id){
	obj = $(id);
    var Year = new Date().getFullYear();
	var m;
	for(var i=2007;i<=Year;i++){ 
		n = i + "年";
		obj.options[obj.options.length]=new Option(n,i);
	}
}


function zhu_shou(op,id)
{
	var el,danwei
	el = document.getElementById(op);
	if(el != null && el != undefined){
	    if(!(el.value))
	       danwei='&nbsp;&nbsp;';
	    if(el.value=='出售') {//选择出售选项
	       danwei='万元';
	    }else{
	       danwei='<font style=\"font-size:9px;\">元/月</font>';
	    }
	    $(id).innerHTML= danwei;//改变单位
	}
}

function OrderByChange(UrlId,Oid){
   var url1,url2,OrderId;
   url1=$(UrlId).value;
   OrderId=$(Oid).value;
   if(url1!=""){
	   if((url1.indexOf("OrderId="))!=-1){
		   url2 = url1.replace(/OrderId=[0-9]/g,'OrderId='+OrderId);
	   }else{
		   url2 = url1+"&OrderId="+OrderId;
	   }
   }else{
	   url2 = url1+"OrderId="+OrderId;
   }	   
   document.location = "Search.aspx?"+url2;
}

// 通过CSS类名获取对象
function getElementsByClass(searchClass,node,tag) {
        var classElements = new Array();
        if ( node == null )
                node = document;
        if ( tag == null )
                tag = '*';
        var els = node.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
        for (i = 0, j = 0; i < elsLen; i++) {
                if ( pattern.test(els[i].className) ) {
                        classElements[j] = els[i];
                        j++;
                }
        }
        return classElements;
}

//打开新窗口
function OpenUrl(url){
  if(url!=""){
      window.open(url);
  }
}

//模拟A效果
function Go(ev){
	ev  =  ev  ||  window.event; // 事件     
	var  target    =  ev.target  ||  ev.srcElement; // 获得事件源 
	var url=target.title;
    if(url!=""){
       window.open(url);
    }
}

function aTab(ev)
{
	ev  =  ev  ||  window.event; // 事件     
	var  target    =  ev.target  ||  ev.srcElement; // 获得事件源 
	var url=target.title;
	if(ev.type=="mouseover"){
	    window.status=url;
	}else{
	    window.status="";
	}
}

//批量选中
function sltAll(name,botId)
{
	var nn = document.getElementsByName(name);
	var bot=document.getElementById(botId);
	if(bot.value=="全 选"){
	    bot.value="清 空";
		for(var j=0;j<nn.length;j++)
		{  
			nn[j].checked = true;
		}
	}
	else{
	    bot.value="全 选";
		for(var j=0;j<nn.length;j++)
		{  
			nn[j].checked = false;
		}
	}
	
}

//新闻评论
function NewsCommand()
{
	if(document.NewsComForm.content.value=="") {
		alert("请填写评论内容");
		document.NewsComForm.content.focus();
		return false;
	}
	if(document.NewsComForm.otherpwd.value=="") {
		alert("请填写确认码");
		document.NewsComForm.otherpwd.focus();
		return false;
	}
	return true;
}

//在线问答
function WenDa()
{
	if(document.WenDaForm.Lname.value=="") {
		alert("请填写您的称呼");
		document.WenDaForm.Lname.focus();
		return false;
	}
	if(document.WenDaForm.Caption.value=="") {
		alert("请填写您的问题");
		document.WenDaForm.Caption.focus();
		return false;
	}
	return true;
}

function MasterSearch()
{
   document.MasterSearchForm.action="/Search/";
 //   document.MasterSearchForm.target="_blank";
  document.MasterSearchForm.submit();
}

function CzMasterSearch()
{
   document.MasterSearchForm.action="/zhulin/CzProperty.aspx";
 //   document.MasterSearchForm.target="_blank";
  document.MasterSearchForm.submit();
}

function IndexLogin()
{
	var frm=document.IndexLoginF;
    if(frm.UserName.vaule==""){alert("请填写用户名");frm.UserName.focus;return false;}
	if(frm.PassWord.value==""){alert("请填写登录密码");frm.PassWord.focus;return false;}
	if(frm.otherWord.value==""){alert("请填写验证码");frm.otherWord.focus;return false;}
	if(frm.Usertype.value==""){alert("请选择您的去向");frm.Usertype.focus;return false;}
	return true;
}

//显示商圈
function ShowSangquan(i)
{
    if(i== undefined){
        return false;
    }
    var div = $("Sangquan");
    var objs = getElementsByClass("hiddDIV",div,null);
    var titleAs = getElementsByClass("SqspanC",div,null);
    var len = objs.length;
    //alert(len);
    for(var j=0;j<len;j++){
        objs[j].style.display="none";
        titleAs[j].getElementsByTagName("a")[0].className="";
    }
    if(i>=len){
        i = len-1;
    }
    objs[i].style.display="block";
    titleAs[i].getElementsByTagName("a")[0].className="SqspanA";
}

function ShowBord1(obj)
{
	obj.style.backgroundColor="#FFF4D0";
	obj.style.borderBottom="1px solid #F9DD8A";
}

function ShowBord2(obj)
{
	obj.style.backgroundColor="";
	obj.style.borderBottom="1px solid #dddddd";
}

function ShowNewsInfor(NewsId)
{
	var HitsDiv =$('ArticleHitsDiv');
    if(NewsId != "" && NewsId != null && NewsId !='undefined'){
//	    loadPostText("/Xml/NewXml.aspx",ShowNewsHitsBack,"postion=NewsHits&Aid="+NewsId);
        XMLHttp.sendReq('POST', '/Xml/NewXml.aspx', "postion=NewsInfor&Aid="+NewsId, ShowNewsInforBack);
	}else{
	    HitsDiv.innerHTML = "id未定义";
	}
}

function ShowNewsInforBack(obj)
{
	var InforDiv =$("NewsInforDiv");
	if (obj.readyState==4)
	{
		if (obj.status==200)
		{
		    var xmlDoc=obj.responseXML.documentElement;
		    var PreUrl=xmlDoc.getElementsByTagName("Pre")[0].childNodes[0].nodeValue;
		    var PreTitle=xmlDoc.getElementsByTagName("Pre")[1].childNodes[0].nodeValue;
		    var NextUrl=xmlDoc.getElementsByTagName("Next")[0].childNodes[0].nodeValue;
		    var NextTitle=xmlDoc.getElementsByTagName("Next")[1].childNodes[0].nodeValue;
			if(PreUrl != "0" && PreUrl != null){
				InforDiv.innerHTML = "上一篇：<a href=\""+PreUrl+"\">"+ PreTitle +"</a><br>";
			}else{
				InforDiv.innerHTML = "上一篇：没有了<br>";
			}
			
			if(NextUrl != "0" && NextUrl != null){
				InforDiv.innerHTML += "下一篇：<a href=\""+NextUrl+"\">"+ NextTitle +"</a><br>";
			}else{
				InforDiv.innerHTML += "下一篇：没有了<br>";
			}
			
		}else{
			InforDiv.innerHTML = "加载失败";
		}
	}else{
		InforDiv.innerHTML = "加载中…";
	}
}

//防止重复提交
var IsFirst=true;
function SubmitTj(obj)
{
	if(IsFirst){
	   IsFirst=false;
	   obj.value="提交中……";
	   return true;
	   obj.disabled=true;
	}else{
	   obj.value="提交中，请勿重击！";
	   return false;
	   obj.disabled=true;
	}

}

//首页焦点图片
function ShowFocusPic()
{
    var nums = [], timer, n = $$("idSlider2").getElementsByTagName("li").length,
        st = new SlideTrans("idContainer2", "idSlider2", n, {
            onStart: function(){//设置按钮样式
                forEach(nums, function(o, i){ o.className = st.Index == i ? "on" : ""; })
            }
        });
    for(var i = 1; i <= n; AddNum(i++)){};
    function AddNum(i){
        var num = $$("idNum").appendChild(document.createElement("li"));
        num.innerHTML = i--;
        num.onmouseover = function(){
            timer = setTimeout(function(){ num.className = "on"; st.Auto = false; st.Run(i); }, 200);
        }
        num.onmouseout = function(){ clearTimeout(timer); num.className = ""; st.Auto = true; st.Run(); }
        nums[i] = num;
    }
    st.Run();
}

//行业焦点图片
function ShowFocus(files,texts,links,swf_width,swf_height)
{
	files=files.substr(1,files.length-1); 
	texts=texts.substr(1,texts.length-1);
	links=links.substr(1,links.length-1);
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">');
	document.write('<param name="movie" value="/swf/bcastr.swf"><param name="quality" value="high">');
	document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
	document.write('<param name="FlashVars" value="bcastr_file='+files+'&bcastr_link='+links+'&TitleBgColor=6699FF">');
	document.write('<embed src="/swf/bcastr.swf" wmode="opaque" FlashVars="bcastr_file='+files+'&bcastr_link='+links+'&TitleBgColor=6699FF& menu="false" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>');
	//&bcastr_title='+texts+'
}

function SelectAgent()
{
	var pas = document.getElementsByName("username");
	var va = null;
	for(var i=0;i<pas.length;i++)
	{
		if(pas[i].checked == true)
		{
			va = pas[i].value;
		}
	}
	if(va != null)
	{
		showPopWin('/ShowMessage.aspx?lei=zx&UserType=1&passname='+va, 400, 270, null);
	}else{
		alert("请选中一个置业专家，才能提问。谢谢");
	}
}

var iExp = 0;
function HomeExpertScroll()
{
	var HeDiv = $("HomeExpertDiv");
	var Childs = HeDiv.getElementsByTagName("div");
//	if(iExp >= Childs.length){
//		iExp = 0;
//	}
	if(Childs.length > 0){
		for(var i=0; i< Childs.length; i++)
		{
			if(Childs[i].style.display != "none")
			    Childs[i].style.display ="none";
			else
			    Childs[i].style.display ="block";
		}
//		Childs[iExp].style.display ="block";
//		Childs[iExp+1].style.display ="block";
	}
//	iExp = iExp+3;
	setTimeout("HomeExpertScroll()",5000);
}

function ChangeBorderColor(obj,action){
	if(action == true){
//        obj.style.border = '1px solid #ff6600';
		obj.style.backgroundColor = "#F1FF83";

	}else{
//		obj.style.border = 'none';
		obj.style.backgroundColor = "";
	}
}

//广告调用
var ShowMasterAd =true;
function ShowIndexAd(pagename,NoShowID){
    var para = "";
    if(pagename != "" && pagename != null && pagename != undefined)
        para += "PageName="+pagename;
    if(NoShowID != "" && NoShowID != null && NoShowID != undefined)
        para += "&NoShowID="+NoShowID;
	XMLHttp.sendReq('POST', '/Xml/GgLoding.aspx',para, ShowIndexAdBack);
}

function ShowIndexAdById(DivID){
	XMLHttp.sendReq('POST', '/Xml/GgLoding.aspx', 'DivID='+DivID, ShowIndexAdBack);
}

function ShowIndexAdBack(obj){
  if (obj.readyState==4)
  {
		if(obj.status==200)
		{
			var xmlDoc=obj.responseXML.documentElement;
			var AdverObj=xmlDoc.getElementsByTagName("adver");
			if(AdverObj && AdverObj.length >0){
				for(var i=0;i<AdverObj.length;i++)
				{
					var File = AdverObj[i].childNodes[0].childNodes[0].nodeValue;
					var Url = AdverObj[i].childNodes[1].childNodes[0].nodeValue;
					var Summary = AdverObj[i].childNodes[2].childNodes[0].nodeValue;
					var Width = AdverObj[i].childNodes[3].childNodes[0].nodeValue;
					var Height = AdverObj[i].childNodes[4].childNodes[0].nodeValue;
					var DivId = AdverObj[i].childNodes[5].childNodes[0].nodeValue;
					
					var FileClass =File.substring(File.indexOf(".")+1).toLowerCase();
					var str = "";
										
					if(FileClass == "swf"){
					   str =  "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+Width+"\" height=\""+Height+"\">"+
							"   <param name=\"movie\" value=\"/UpFiles/"+File+"\" />"+
							"   <param name=\"quality\" value=\"high\" />"+
							"   <embed src=\"/UpFiles/"+File+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+Width+"\" height=\""+Height+"\"></embed>"+
							"  </object>";
					}
					else if(FileClass == "jpg" || FileClass == "gif" || FileClass == "bmp" ||FileClass == "jpeg")
					{
					    str ="<a href=\""+Url+"\" title=\""+Summary+"\" target=\"_blank\"><img src=\"/UpFiles/"+File+"\" border=\"0\" width=\""+Width+"\" height=\""+Height+"\"  alt=\""+Summary+"\" /></a>";
					}
					if($(DivId)){
						$(DivId).style.display = "block";
						$(DivId).innerHTML = str;
					}
				}
			}
		}
   }
}
//___________________
//函数功能:判断输入的字符串是不是中文*  
function ischinese(name)  
{  
	if(name.length  ==  0)
    return  false;
    for(i  =  0;  i  <  name.length;  i++)  { 
    if(name.charCodeAt(i)  >  128)
    return  true;
    }
    return  false;

}

function SubmitQianJin(){
	var frm=document.QianJinForm;
    if(!ischinese(frm.name.value)){alert("请重新输入中文");frm.name.focus(); return false;}    
	if(frm.phone.value=="" || frm.phone.value.length<11){alert("请输入电话号码");frm.phone.focus();return false;}
	if(frm.idno.value==""){alert("请输入身份证号");frm.idno.focus();return false;}
	if(frm.note.value==""){alert("请输入内容");frm.note.focus();return false;}
	if(frm.otherCode.value==""){alert("请输入验证码");frm.otherCode.focus();return false;}
	return true;

}

function closeBan(id)
{
	$(id).style.display= 'none';
	if(id == "FlashDlTop"){
		$("FlashDlImg").style.display= 'none';
	}
}

//图片自动调整的模式，1为按比例调整 ，2 按大小调整。
var resizemode=2;
function imgresize(o){
	if (resizemode==2 || o.onmousewheel){
		if(o.width > 500 ){
			o.style.width='500px';
		}
		if(o.height > 800){
			o.style.height='800px';
		}
	}
	else{
		var parentNode=o.parentNode.parentNode
		if (parentNode){
			if (o.offsetWidth>=parentNode.offsetWidth) o.style.width='98%';
		}
		else{
			var parentNode=o.parentNode
			if (parentNode){
				if (o.offsetWidth>=parentNode.offsetWidth) o.style.width='98%';
			}
		}
	}
}

//兼容IE、火狐的本地图片预览效果
function getPath(obj)  
{  
    if(obj)  
    {  
        if (window.navigator.userAgent.indexOf("MSIE")>=1)  
        {  
            obj.select();  
            return document.selection.createRange().text;  
        }  
        else if(window.navigator.userAgent.indexOf("Firefox")>=1)  
        {  
            if(obj.files)  
            {  
                return obj.files.item(0).getAsDataURL();  
            }  
            return obj.value;  
        }  
        return obj.value;  
    }  
} 
