// JavaScript Document
var TagContent='_Content';
var TagSum=0;
function IndexTag(BarName,CurrTag,TagSum)
{
	for(i=1; i <= TagSum; i++)
	{
		if(i==CurrTag){
			document.getElementById(BarName+i).className=BarName+i+'_change';
			document.getElementById(BarName+i+TagContent).style.display='block';
		}else{
			document.getElementById(BarName+i).className='';
			document.getElementById(BarName+i+TagContent).style.display='none';
		}
	}
}

//切换背景分帧

function ItopBg(BarName,CurrTag,TagSum)
{
			document.getElementById(BarName).className='topbg'+CurrTag;
			document.getElementById(BarName+CurrTag+TagContent).style.display='block';
			document.getElementById(BarName+TagSum+TagContent).style.display='none';
    for(i=1; i <= 2; i++)
	{
		if(i==CurrTag){
			document.getElementById(BarName+i).className='cb';
		}else{
			document.getElementById(BarName+i).className='cw';
		}
	}
}

//切换标签类别相同的函数
function IndexTag1(BarName,CurrTag,TagSum)
{
	for(i=1; i <= TagSum; i++)
	{
		if(i==CurrTag){
			document.getElementById(BarName+i).className=BarName+'_ok';
			document.getElementById(BarName+i+TagContent).style.display='block';
		}else{
			document.getElementById(BarName+i).className='';
			document.getElementById(BarName+i+TagContent).style.display='none';
		}
	}
}

function IndexTag2(BarName,CurrTag,TagSum)
{
	for(i=1; i <= TagSum; i++)
	{
		if(i==CurrTag){
			document.getElementById(BarName+i+TagContent).style.display='block';
		}else{
			document.getElementById(BarName+i+TagContent).style.display='none';
		}
	}
}

function iTag(BarName,CurrTag,TagSum)
{
	for(i=1; i <= TagSum; i++)
	{
		if(i==CurrTag){
			document.getElementById(BarName+i).className='active';
			document.getElementById(BarName+i+TagContent).style.display='block';
		}else{
			document.getElementById(BarName+i).className='change';
			document.getElementById(BarName+i+TagContent).style.display='none';
		}
	}
}

/*户型检索*/
function iTag1(BarName,CurrTag,TagSum)
{
	for(i=1; i <= TagSum; i++)
	{
		if(i==CurrTag){
			document.getElementById(BarName+i).className=BarName+i+'_ok';
			document.getElementById(BarName+i+TagContent).style.display='block';
		}else{
			document.getElementById(BarName+i).className=BarName+i;
		    document.getElementById(BarName+i+TagContent).style.display='none';
		}
	}
	if(CurrTag==7){
		for(i=1; i <= TagSum-1; i++){
			document.getElementById(BarName+i+'_list').style.display='block';
			document.getElementById('others').style.display='block';
		}
	}else{
			
		for(i=1; i <= TagSum-1; i++)
	    {
			if(i==CurrTag){
				document.getElementById(BarName+i+'_list').style.display='block';
			}else{
				document.getElementById(BarName+i+'_list').style.display='none';
			}
		}
		document.getElementById('others').style.display='none';
	}
}


//显示隐藏的子类
function showSubClass(Id,Sum)
{	
	 for (i=1;i<=Sum;i++) {
	  if(i==Id){
        document.getElementById("M"+i).style.display = "block";
	  }else{ 
	   document.getElementById("M"+i).style.display = "none";
	  }
    }	
}

//批量压缩图片
function imgFix(n,w,h,t) 
{ //定义要限制的图片宽高,这个宽高要同style里面定义的相同，小于限定高宽的图片不操作 
	var widthRestriction = w; 
	var heightRestriction = h; 
	var allElements = document.getElementsByTagName('*') ;	
	for (var i = 0; i < allElements.length; i++) {
		 if (allElements[i].className.indexOf(n) >= 0){ 
		      var imgElements = allElements[i].getElementsByTagName('img'); 
		      for (var j=0; j < imgElements.length; j++){ 
					imgElements[j].style.display="";
					if ( imgElements[j].width > widthRestriction || imgElements[j].height > heightRestriction )
					{ 
							if ( imgElements[j].width >= imgElements[j].height) { 
							    imgElements[j].width = widthRestriction;
								//imgElements[j].height = imgElements[j].height*(widthRestriction/imgElements[j].width); 
								imgElements[j].removeAttribute('height');
							}else{ 
								imgElements[j].height = heightRestriction; 
								//imgElements[j].width = imgElements[j].width*(heightRestriction/imgElements[j].height); 
								imgElements[j].removeAttribute("width");
							} 
					}
					if ( t == 1){
						if ( imgElements[j].height < heightRestriction ){ 
							imgElements[j].style.marginTop = ( heightRestriction -imgElements[j].height ) /2 + "px"; 
						} 
					}
		} /*for j*/ 
		} 
	}/*for i*/ 
	}
//单处理等比缩小图片	
function changeImageSize(img,maxWid,desHei,mstyle){
	img.style.display = "";
	if(img.height >= desHei || img.width >= maxWid) {
	    if(img.height <= img.width) {
		img.width=maxWid;
		//img.removeAttribute("height");
		img.height=img.height*(maxWid/img.width);
			if (img.height>desHei)
			{
				img.removeAttribute("width");
				img.height=desHei;
				}
	    } else {
		img.height=desHei;
		//img.removeAttribute("width");
	    }
		
	}
	if(mstyle == 1){
		img.style.marginTop = ( desHei - img.height ) /2 + "px"; 	
		}
	
    }
	




