function getElement(id) {
return document.getElementById ? document.getElementById(id) :
document.all ? document.all(id) : null;
}

var CSAg = window.navigator.userAgent; 
var CSBVers = parseInt(CSAg.charAt(CSAg.indexOf("/")+1),10);
var CSIsW3CDOM = ((document.getElementById) && !(IsIE()&&CSBVers<6)) ? true : false;
function IsIE() { return CSAg.indexOf("MSIE") > 0;}
var boxes=[];
function MoveAble(name,obj,slideSpeed,stay) {
	this.stay= (stay==true) ? true : false;
	this.name=name;
	this.slideSpeed=slideSpeed;
	this.moveIt=b_moveIt;
	this.slideOut=b_slideOut;
	this.slideIn=b_slideIn;
	this.slideUpdate=b_slideUpdate;
	this.hideIt=b_hideIt;
	this.obj=obj;
	this.css=this.obj.style;
	this.x=this.obj.offsetLeft;
	this.y=this.obj.offsetTop;
	this.ox=this.x;
	this.oy=this.y;
	this.no=boxes.length;
	boxes[boxes.length]=(this);

	var obj=this;
	boxes.push(this);
	window.onscroll=function() {
		if (obj.done!=true) {
			obj.slideUpdate()
		}
	}
}
function b_slideUpdate() {
	var _dy,_dx;
		clearTimeout(this.initTimer)
		var e=this.obj;
		if (e!=null) {
			_dy=(document.body.scrollTop+document.body.clientHeight-e.offsetHeight);
			if (this.no>0) {
				var pobj=boxes[this.no].obj;
				_dy-=pobj.offsetHeight;
			}
			if (IsIE()) {
				_dx=(document.body.scrollLeft+document.body.clientWidth-e.offsetWidth);
			} else {
				_dx=(document.body.scrollLeft+document.body.clientWidth-e.offsetWidth);
			}
				this.ox=_dx;
				this.oy=_dy+e.offsetHeight;
		}
		if (this.done!=true) {
			this.obj.style.visibility="visible";
			clearTimeout(this.scrollTimer)
			this.slideIn(_dx,_dy);
		}


}
function b_moveIt(x,y){this.css.left=this.x; this.css.top=this.y;}
function b_hideIt() {

//mx.apply(mx, [4,3]);
	//this.sildeIn(454,34);
	
	this.css.visibility='hidden';
	this.css.top=0;
	this.css.left=0;

}
function b_slideIn(x,y){
	if (this.done) {
	}		
	clearTimeout(this.scrollTimer)
	 if (Math.round(this.x) == Math.round(x) && Math.round(this.y) == Math.round(y)) {
			if (this.done!=true) {
			if (this.stay && boxes.length==2) {
			} else {
				this.scrollTimer=setTimeout(this.name+".slideOut("+this.ox+","+this.oy+")",6000);
			}}
	 } else {
		this.x -= (this.x-x)/this.slideSpeed;   
        this.y -= (this.y-y)/this.slideSpeed;
 		this.moveIt(this.x , this.y);
 	
 		this.scrollTimer=setTimeout(this.name+".slideIn("+x+","+y+")",this.slideSpeed);
	}
}
function b_slideOut(x,y) {
	clearTimeout(this.scrollTimer)
	 if (Math.round(this.x) == Math.round(x) && Math.round(this.y) == Math.round(y)) {
				if (!this.stay) 
					setTimeout(this.name+".hideIt()",10);
				this.done=true;
	 } else {
		this.x -= (this.x-x)/this.slideSpeed;   
        this.y -= (this.y-y)/this.slideSpeed;
 		this.moveIt(this.x , this.y); 
		this.scrollTimer=setTimeout(this.name+".slideOut("+x+","+y+")",this.slideSpeed)
	}
}
var elementTimer=[];
var _strElement
function focusElement(str) {
	var xstr;
	if (str==null) {
		xstr=_strElement
	} else {
		xstr=str;
	}
	/*if (mx!=null) {
		mx.slideUpdate();
	}*/
	var e=getElement(xstr);
	if (e!=null) {
		e.scrollIntoView();
		//e.focus();
	//	alert(e.style.posTop)
		//window.scrollTo(0,e.offsetTop+e.offsetHeight);
		
    }
    if (str!=null) {
		_strElement=xstr;
		window.onload = focusElement;
	}
}

function findElement(e,i,execute) {	
	if (i==null && e!=null) {
		var ltimer;
		i=elementTimer.length;
		var tobj=new Object();
		tobj.timer=ltimer;
		tobj.elementname=e;
		tobj.finished=false;
		tobj.execute=execute;
		tobj.testTimes=0;
		elementTimer[i]=tobj;
	} 

	for (var j=0;j<elementTimer.length;j++) {
		if ((!elementTimer[j].finished) && (elementTimer[j].testTimes<5)) {
			elementTimer[j].testTimes+=1;
			clearTimeout(elementTimer[j].ltimer);
			var obj=getElement(elementTimer[j].elementname);
			if (obj==null) {
					elementTimer[j].ltimer=setTimeout("findElement()",500);
			} else {	
				elementTimer[j].finished=true;
				elementTimer[j].execute.call(this,obj);
			}
		}
	}
}