var bbs_maproot="";
var bbs_domain="soufun.com";

var re = /\/[a-z]*bbs[^\.]/i;                // 创建正则表达式模式。
var arr;
if ((arr = re.exec(window.location.href)) != null)
{
	 bbs_maproot=arr[0]+"pinpai";
}
/*
if(window.location.href.toUpperCase().indexOf("/BBS/")>=0)
{
	bbs_maproot="/bbs";
}*/
if(window.location.host.toUpperCase().indexOf("JIATX.COM")>=0)
{
	bbs_domain="jiatx.com";
}

function viewPage2(ipage){
        document.frmList2.Page.value=ipage
        document.frmList2.submit()        
     }
     function viewPage1(ipage){
        document.frmList2.Page.value=ipage
        document.frmList2.submit()        
}

function ltf(b_id,a_id,t_id,sign,top,list_tid,good){

	var targetImg =$("fi"+"_"+top+"_"+ a_id);
	var targetDiv =$("f" +"_"+top+"_"+ a_id);
	
	//if (targetImg.src.indexOf("nofollow")!=-1){return false;}
	//if (targetImg.className=="nf"){return false;}
	if ("object"==typeof(targetImg)){
		if (targetDiv.className.indexOf("ddon")==-1){
			targetDiv.className=targetDiv.className.replace("ddoff","ddon");
			//targetImg.src="http://img2s.soufun.com/bbs/image/bbs/minus.gif";
			targetImg.className="ld";
			if (targetImg.getAttribute("loaded")=="no")
			{
				//targetDiv.innerHTML="正读取跟贴……";
				$("hiddenframe").src=bbs_maproot+"/soufun_forum/frm_loadtree1.aspx?boardid="+b_id+"&id="+a_id+"&tid="+t_id+"&sign="+ sign +"&top="+top+"&listTid="+list_tid+"&good="+good;
			}
		}else{
			targetDiv.className=targetDiv.className.replace("ddon","ddoff");
			//targetImg.src="http://img2s.soufun.com/bbs/image/bbs/plus.gif";
			targetImg.className="pl";
		}
	}
}
function resumeTree(rootid){
	loadThreadFollow(rootid);
}
function add(sign,bid){
	val="?bid="+bid+"&sign="+sign;
	newwindow = window.open('/asp/bbs/speak.aspx' + val,"nwl");
	if(!newwindow.opener){newwindow.opener=self};
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function jump(domain,sign,bid){
	var url;
	if(document.all.select.value != "")
	{
		url=bbs_maproot+"/soufun_forum/EquipmentForum/BBS_Equipment_HotElit.aspx?postdate="+document.all.select.value+"&domain="+domain+"&sign="+sign+"&bid="+bid;
		window.location.assign(url);
	}
}			
function pagejump(url){
var target=url+"&page="+$("txtpage").value;
window.location=target;
}
function forumjump(){
var signlist=$("mainsignlist");
if(signlist!=null){
var sign=signlist.value;
var postbox=$("post_box");
if(postbox!=null){
	postbox.innerHTML="<A href='"+bbs_maproot+"/soufun_forum/post/frm_speak.aspx/sign="+sign+"&Bid=-1' target=_blank onclick='javascript:return checksign()'}  class=\"on\">发表新帖</A>&nbsp;";
	}
	}
}
function checksign(){
	var signlist=$("mainsignlist");
	if(signlist!=null){
	var sign=signlist.value;
	if(sign==""){alert("请选择论坛");return false;}
	}
}
function jump_city()
{
	if(document.all.select2.value == "")
	{
		return;
	}
var url;
if(document.all.select2.value.length < 5)
{
	url=bbs_maproot+'/soufun_forum/equipmentforum/bbs_equipment.aspx?domain='+document.all.select2.value;
}
else
{
	url = document.all.select2.value;
}
window.location.assign(url);
}
function close_list_right(){
 $("list_1").style.visibility='hidden';
 //$("list_2").style.visibility='hidden';
}
//kejet系统发布flash广告页面
function insertFlash(elm, url, w, h, id) {
 if (!$(elm)) return;
 var str = '';
 str += '<embed width="'+ w +'" height="'+ h +'" src="'+ url +'" quality="autohigh" wmode="opaque" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" id='+id+'></embed>';
 $(elm).innerHTML = str;
}



////轮循广告用

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" : "" );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function changeAd(divname,cookiename,adname,adnum,adheight,adwidth)
{
	//debugger;
	var tdate = new Date(); // 初始化日期对象
	tdate.setHours(tdate.getHours()+ 1);

	var ad_id = Get_Cookie(cookiename);
	if (ad_id==null)
	{
		Set_Cookie(cookiename,"1",tdate,"/",bbs_domain,"");
	}
	else
	{
		ad_id=Number(ad_id)+1;
		if(ad_id>adnum)
		{
			Set_Cookie(cookiename,"1",tdate,"/",bbs_domain,"");
		}
		else
		{
			Set_Cookie(cookiename,ad_id,tdate,"/",bbs_domain,"");
		}
	}

	ad_id = Get_Cookie(cookiename);
	var cid=Number(ad_id);
	for (var i=1;i<=adnum;i++)
	{
		var tlad=$(divname+i);
		tlad.src=adname[(cid+i-1)%adnum];		
		tlad.height=adheight;
		tlad.width=adwidth;
		//alert((cid+i-1)%adnum);
		//alert(tlad.HEIGHT);
		//alert(tlad.WIDTH);
	}
}
