
function startLayer(){
	fixedLayer('sideDataDetail',10)
}

function fixedLayer(layName,offSetY){

	if(!window.fixedLayer[layName]){
		if(document.getElementById){
			if( !document.getElementById(layName) ) return;
		}else if(document.all){
			if( !document.all(layName) ) return;
		}
	
		this.ie    = !!document.all
		this.n4    = !!document.layers
		this.w3c   = !!document.getElementById
		this.ua    = navigator.userAgent
        this.mac45 = ua.indexOf('MSIE 4.5; Mac_PowerPC') != -1
		this.mac5  = ua.indexOf('MSIE5.0;Mac_PowerPC')   != -1
        this.macie = ua.indexOf('Mac_PowerPC')  !=-1 && ie
		this.moz   = ua.indexOf('Gecko') !=-1
		this.opr   = !!window.opera
		if(this.n4)
			window.onresize = function(){ location.reload() }
		window.fixedLayer[layName] = true
	}

    offSetY = parseInt(offSetY,10)
	offTop  = offSetY
    offTop  = parseInt(offTop,10)
	
    if(document.all&&!this.opr){
		var iHeight= document.body.clientHeight
		var iWidth = document.body.clientWidth
		var mx = iWidth / 2
		if (self.pageYOffset){
			var my = self.pageYOffset + offTop
		}else{
			var my = document.documentElement.scrollTop + offTop
		}
	} else {
		var iHeight= window.innerHeight
		var iWidth = window.innerWidth
		var mx = iWidth / 2
		if (self.pageYOffset){
			var my = self.pageYOffset + offTop
		}else{
			var my = document.documentElement.scrollTop + offTop
		}
	}
	
	if( mx < 400 ) mx = 400
	
	if(document.getElementById){
		max = document.getElementById('footer').offsetTop-500
		if( max < my ) my = max
		min = document.getElementById('sideTop').offsetTop
		if( min > my ) my = min
        document.getElementById(layName).style.top  = my+"px"
		document.getElementById(layName).style.width = (mx - 50)+"px"
    } else if(document.all){
		max = document.all.footer.offsetTop-500;
		if( max < my ) my = max
		min = document.all.sideTop.offsetTop
		if( min > my ) my = min
        document.all(layName).style.pixelTop  = my+"px"
		document.all(layName).style.pixelWidth = (mx - 50)+"px"
	} else if(document.layers){
		document.layers[layName].moveTo(mx,my)
	}
	
    if(!(this.ie&&!this.mac45) || this.opr){
//		clearTimeout(fixedLayer[layName])
//        fixedLayer[layName]=setTimeout("fixedLayer('"+layName+"','"+offSetY+"')",100)
	}
}

addEvent(window, "load", startLayer);
addEvent(window, "scroll", startLayer);
