﻿function e(objid){
	var div = document.getElementById(objid)
	return div;
}

function liSet(obj,num,class1,class2){
	for(var i=1;e(obj + i);i++){
		if(i == num){
			e(obj+i).className = class1
		}else{
			e(obj+i).className = class2
		}
	}
}

function setTab(name,cursel){
    for(i=1;document.getElementById(name+i);i++){
        
        var menu=document.getElementById(name+i);
        var con=document.getElementById("con_"+name+"_"+i);
        menu.className=i==cursel?"hover":"";
        con.style.display=i==cursel?"block":"none";
    }
}

function AddOption(obj,value,text){
   var objOption=document.createElement("OPTION");
   objOption.value=value;
   objOption.text=text;
   obj[obj.length]=objOption;
}

var hxflag = new Array(16);

hxflag[0] = "一房一厅"
hxflag[1] = "两房一厅"
hxflag[2] = "两房两厅"
hxflag[3] = "三房一厅"
hxflag[4] = "三房两厅"
hxflag[5] = "四房两厅"
hxflag[6] = "四房三厅"
hxflag[7] = "五房两厅"
hxflag[8] = "单间";
hxflag[9] = "复式";
hxflag[10] = "别墅";
hxflag[11] = "错层"
hxflag[12] = "跃式"
hxflag[13] = "厂房"
hxflag[14] = "仓库"
hxflag[15] = "车库"
hxflag[16] = "写字楼"
hxflag[17] = "商铺"

function AddHX(obj){
    for(var i = 0;i<hxflag.length;i++){
        AddOption(obj,hxflag[i],hxflag[i])
    }
}


fadeUp=function(element,red,green,blue){
    if(element.fade){
        window.clearTimeout(element.fade);
    }
    var cssValue = "rgb("+red+","+green+","+blue+")";
    element.style.backgroundColor = cssValue;
    //$(element).css("background-color",cssValue);
    if(red == 255 && green == 255 && blue == 255){
        return;
    }
    var newRed = red + Math.ceil((255-red)/10);
    var newGreen = green + Math.ceil((255-green)/10);
    var newBlue = blue + Math.ceil((255-blue)/10);
    var repeat = function(){
        fadeUp(element,newRed,newGreen,newBlue);
    };
    element.fade=window.setTimeout(repeat,100);
}

var repeat = function(){
        fadeUp(element,newRed,newGreen,newBlue);
    };
 


function MoveTextDiv(obj,obj1,action,anum){//上下移动层
	if(action=="up"){
		UpMove(obj,obj1,anum);
	}
	else{
		DownMove(obj,obj1,anum);
	}
}
function UpMove(obj,obj1,anum){
	if(obj1.offsetTop<0){
		obj1.style.pixelTop+=anum;
	}
}
function DownMove(obj,obj1,anum){
	if(obj1.offsetTop>(obj.offsetHeight-obj1.offsetHeight)){
		obj1.style.pixelTop-=anum;
	}
}

function MoveTextDiva(obj,obj1,action,anum){//左右移动层
	if(action=="left"){
		LeftMove(obj,obj1,anum);
	}
	else{
		RightMove(obj,obj1,anum);
	}
}
function LeftMove(obj, obj1, anum) {
	if(obj1.offsetLeft<0){
		obj1.style.pixelLeft+=anum;
	}
}
function RightMove(obj,obj1,anum){
	if(obj1.offsetLeft>(obj.offsetWidth-obj1.offsetWidth)){
		obj1.style.pixelLeft-=anum;

	}

}


function DrawImage(ImgD,FitWidth,FitHeight){
    DrawImage(ImgD,FitWidth,FitHeight,true)
}
function DrawImage(ImgD,FitWidth,FitHeight,flag){
    var image=new Image();

    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
        if(image.width/image.height>= FitWidth/FitHeight){
            if(image.width>FitWidth){
                ImgD.width=FitWidth;
                ImgD.height=(image.height*FitWidth)/image.width;
                if(flag){
                    ImgD.onclick = function (){
                        window.open(ImgD.src)
                    }
                }
                ImgD.onmouseover = function (){
                this.style.cursor = "hand";
                }
            }else{
               ImgD.width=image.width;
               ImgD.height=image.height;
            }
            ImgD.alt="点击查看大图";
        }else{
            if(image.height>FitHeight){
                ImgD.height=FitHeight;
                ImgD.width=(image.width*FitHeight)/image.height;
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
            ImgD.alt="点击查看大图";
        }
    }
    image.delect
}

//**************************************************************************************************************************
//**************************************************************************************************************************

//左边
//var left_img='<a href=\"http:\/\/www.53hy.com\/stat\/stat.asp?siteKey=iecool&pageNO=1&urlCode=432b8db663bf55e561683b9a830af5ad\" target=\"_blank\"><img src=\"http:\/\/www.iecool.com\/ads\/53dns_100_100.gif\" width=\"100\" height=\"100\" border=\"0\"><\/a>';

//右边
//var right_img='<a href=\"http:\/\/www.53hy.com\/stat\/stat.asp?siteKey=iecool&pageNO=1&urlCode=432b8db663bf55e561683b9a830af5ad\" target=\"_blank\"><img src=\"http:\/\/www.iecool.com\/ads\/53dns_100_100.gif\" width=\"100\" height=\"100\" border=\"0\"><\/a>';

    var delta=0.15
	var collection;
	
	function floaters() {
		this.items	= [];
		this.addItem	= function(id,y)
				  {
					var newItem				= {};
					newItem.object			= document.getElementById(id);
					newItem.y				= y;

					this.items[this.items.length]		= newItem;
				  }
		this.play	= function()
				  {
					collection				= this.items
					setInterval('play()',10);
				  }
		}
		function play()
		{

			for(var i=0;i<collection.length;i++)
			{
				var followObj		= collection[i].object;
				//var followObj_x		= (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
				var followObj_y		= (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);

//				if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {
//					var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
//					dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
//					followObj.style.left=followObj.offsetLeft+dx;
//					}

				if(followObj.offsetTop!=(document.documentElement.scrollTop+followObj_y)) {
					var dy=(document.documentElement.scrollTop+followObj_y-followObj.offsetTop)*delta;
					dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
					followObj.style.top=followObj.offsetTop+dy;
					}
				followObj.style.display	= '';
			}
		}	



