var $=function(id) {
   return document.getElementById(id);
}
/* 更多城市 */
function moreBoxto(numc){
	for (j=0; j<1; j++){
	 if($('moreBox' + j)){
	 $('moreBox'+j).style.display='none';

	 }
	}
	$('moreBox'+numc).style.display='block';
}
function hidden_moreBoxto(numc) {
	timeout = setTimeout(function() {$("moreBox"+numc).style.display = "none";},100);
}
function show_moreBoxto(numc){
	window.clearTimeout(timeout);
	$("moreBox"+numc).style.display = "";
}
function resizeImg(obj,width)
{
	var w = obj.width;
	var h = obj.height;
	if(w > width)
	{
		obj.width = width;
		obj.height = h * width / w;		
	}
	else
	{
		obj.width=w;
		obj.height=h;
	}
}
function Block(b,p)
{
	this.b = b;this.p = p;
}

function InitializeArea(btn,area)
{
	var btnName = btn.split(',');
	var areaName = area.split(';');
	var tmpArr; 
	
	
	var blockName;
	
	var btnObj = new Array(); 
	
	var linkObj = new Array(); 
	
	var areaObj = new Array();
	
	var block = new Array();
	 
	
	for(var i=0;i<parseInt(btnName[2]);i++)
	{
		btnObj[i] = document.getElementById(btnName[0] + '_' + (i+1));
		linkObj[i] = document.getElementById(btnName[1] + '_' + (i+1));
	}
	for(var i=0;i<areaName.length;i++)
	{
		tmpArr = areaName[i].split(':');
		areaObj[i] = document.getElementById(tmpArr[0]);
		blockName = tmpArr[1].split(',');
		for(var j=0;j<blockName.length;j++)
		{
			block[block.length] = new Block(document.getElementById(blockName[j]),areaObj[i]);
		}
	}
	
	for(var i=0;i<btnObj.length;i++)
	{
		btnObj[i].onmouseover = 
			function(ev)
			{
				if(this.className == 'noactive' || this.className == '')
				{
					
					for(var j=0;j<btnObj.length;j++)
					{
						if(btnObj[j].className == 'activetd')
						{
							btnObj[j].className = 'noactive';
							if(linkObj[j])
							{
								linkObj[j].className = 'subtitle';
								if(linkObj[j].firstChild && linkObj[j].firstChild.nodeName == 'A')
								{
									linkObj[j].firstChild.style.color = '#537E00';	
								}
							}
							
							if(block[j])
							{	
								block[j].b.style.display = 'none';
								block[j].p.style.display = 'none';
							}
							break;
						}
					}
				
					this.className = 'activetd';
					var li = parseInt(this.id.substring(this.id.lastIndexOf('_')+1)) - 1;					
					if(linkObj[li])
					{
						linkObj[li].className = 'activetitle';
						if(linkObj[li].firstChild && linkObj[li].firstChild.nodeName == 'A')
						{
							linkObj[li].firstChild.style.color = '';	
						}
					}
				
					if(block[li])
					{
						block[li].b.style.display = '';
						block[li].p.style.display = '';						
					}
					
				
					if(block[j] && block[li] && block[j].p != block[li].p)
					{
						for(var k = 0;k < block.length; k ++)
						{
							if(k != li)
							{
								if(btnObj[k])
								{
									btnObj[k].className = (block[k].p!=block[li].p?'':'noactive');
								}
							}
						}
					}
				}
			}
	}
}

function InitializeSingelArea(btn,blk,hideclassname,showclassname)
{
	var buttonS = btn.split(',');
	var blockS = blk.split(',');
	var btnObjS = new Array();
	var blkObjS = new Array();
	for(var i=0;i<buttonS.length;i++)
	{
		btnObjS[i] = document.getElementById(buttonS[i]);
		blkObjS[i] = document.getElementById(blockS[i]);
	}
	for(var i=0;i<btnObjS.length;i++)
	{
		btnObjS[i].onmouseover = 
			function()
			{
				for(var j=0;j<btnObjS.length;j++)
				{				    
					if(btnObjS[j].className != hideclassname)
					{
						btnObjS[j].className = hideclassname;
						if(blkObjS[j])
						{
							blkObjS[j].style.display = 'none';
						}		
						break;
					}
				}
				
				this.className = showclassname;				
				var bi = parseInt(this.id.substring(this.id.lastIndexOf('_')+1)) - 1;
				if(blkObjS[bi])
				{
					blkObjS[bi].style.display = '';
				}
			}
	}
}
window.onload = 
	function()
	{
	    if(document.getElementById('RButton_1')!=null)
	    {
		    InitializeSingelArea('RButton_1,RButton_2','RBlock_1,RBlock_2','ranking02','ranking01');//房地产博文推荐、全国博客推荐		
		}
		 if(document.getElementById('AButton_1')!=null)
	    {
		    InitializeSingelArea('AButton_1,AButton_2','ABlock_1,ABlock_2','ranking02','ranking01');//房地产博文排行榜、房地产博文评论榜
		}
		 if(document.getElementById('UButton_1')!=null)
	    {
		    InitializeSingelArea('UButton_1,UButton_2,UButton_3','UBlock_1,UBlock_2,UBlock_3','weekfire','weekblog');//一周博文榜、一周人气榜、人气总榜
		}
		 if(document.getElementById('IButton_1')!=null)
	    {
		    InitializeSingelArea('IButton_1,IButton_2,IButton_3,IButton_4','IBlock_1,IBlock_2,IBlock_3,IBlock_4','ssblogss_b','ssblog_b');//搜房地产博客搜索		
		}
	}

//----------------120_80-----------------
function resizeM_124_98(el)
{

 if(el.runtimeStyle)
 {
	el.runtimeStyle.behavior="none";
 }

 var tempM = new Image();
 tempM.src = el.src ;
 tempM.el = el;
 tempM.onload = resizeMonLoad_124_98;
 tempM.doload = resizeMonLoad_124_98;
 if(el.fileSize && (el.fileSize>0)){; tempM.doload();};
}

function resizeMonLoad_124_98()
{
     var el = this.el;
	 var maxW = 124;
	 var maxH = 98;
	 el.style.visibility="visible";

	 if(this.width < maxW)
	 {
		el.style.width = this.width + "px";
	 }

	 if(this.height < maxH)
	 {
		el.style.height = this.height + "px";
	 }
	 
	 if(this.width>this.height)
	 {
		  if(this.width >= maxW)
		  {; 
			  var r = maxW / this.width;
			  el.style.height = (this.height * r ) + "px";
			  el.style.width = maxW + "px";
		  }
	 }
	 else
	 {
		if(this.height >= maxH)
		{
			var r = maxH / this.height;
			el.style.width = (this.width * r )+ "px";
			el.style.height = maxH + "px";
		}
	 }
}
//----------------105_83-----------------
function resizeM_100_75(el)
{

 if(el.runtimeStyle)
 {
	el.runtimeStyle.behavior="none";
 }

 var tempM = new Image();
 tempM.src = el.src ;
 tempM.el = el;
 tempM.onload = resizeMonLoad_100_75;
 tempM.doload = resizeMonLoad_100_75;
 if(el.fileSize && (el.fileSize>0)){; tempM.doload();};
}

function resizeMonLoad_100_75()
{
     var el = this.el;
	 var maxW = 100;
	 var maxH = 75;
	 el.style.visibility="visible";

	 if(this.width < maxW)
	 {
		el.style.width = this.width + "px";
	 }

	 if(this.height < maxH)
	 {
		el.style.height = this.height + "px";
	 }
	 
	 if(this.width>this.height)
	 {
		  if(this.width >= maxW)
		  {; 
			  var r = maxW / this.width;
			  el.style.height = (this.height * r ) + "px";
			  el.style.width = maxW + "px";
		  }
	 }
	 else
	 {
		if(this.height >= maxH)
		{
			var r = maxH / this.height;
			el.style.width = (this.width * r )+ "px";
			el.style.height = maxH + "px";
		}
	 }
}