function object(id,ctop,cright,cbottom,cleft) {
	if (n) {
		this.css = document.layers[id];
		this.x = this.css.left;
		this.y = this.css.top;		
	} else if (ie) {
		this.css = document.all[id].style;
		this.x = parseInt(this.css.pixelLeft);
		this.y = parseInt(this.css.pixelTop);	
	}

	this.visibility = this.css.visibility;
	this.IsShow = ObjectShow;
	this.moveBy = ObjectMoveBy;
	this.moveTo = ObjectMoveTo;

	this.obj = id + "Object";
                eval(this.obj + "=this");
	this.slideBy = ObjectSlideBy;
	this.slideTo = ObjectSlideTo;
	this.slide = ObjectSlide;

        	this.clipBy = ObjectClipBy;
                this.clipTo = ObjectClipTo;
                this.clipValues = ObjectClipValues;
                if (ie) {
                	if (ctop!=null && cright!=null && cbottom!=null && cleft!=null) 
			this.clipTo(ctop,cright,cbottom,cleft);
                               	else if (this.css.pixelWidth && this.css.pixelHeight) 
			this.clipTo(0,this.css.pixelWidth,this.css.pixelHeight,0);
	}

	this.wipeBy = ObjectWipeBy;
                this.wipeTo = ObjectWipeTo;
	this.wipe = ObjectWipe;
}

function ObjectShow(ans) {
	if (ans == "visible") {
		if (n) this.css.visibility = "show";
		else if (ie) this.css.visibility = "visible";
		else alert("Error in [ObjectShow] function in STEP 1");
	} else if (ans == "hidden") {
		if (n) this.css.visibility = "hide";
		else if (ie) this.css.visibility = "hidden";
		else alert("Error in [ObjectShow] function in STEP 2");
	} else {
		alert("Error in [ObjectShow] function");
	}
}

function ObjectMoveBy(xpos,ypos) {
	this.x += xpos;
	this.css.left = this.x;
	this.y += ypos;
	this.css.top = this.y;
}

function ObjectMoveTo(xpos,ypos) {
	this.x = xpos;
	this.css.left = this.x;
	this.y = ypos;
	this.css.top = this.y;
}

function ObjectSlideBy(distx,disty,inc,speed,fn) {
	if (!this.slideActive) {
		var endx = this.x + distx;
                             	var endy = this.y + disty;
		var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc;
                               	var dx = distx/num;
                               	var dy = disty/num;
                               	this.slideActive = 1;
                               	if (!fn) fn = null;
                               	this.slide(dx,dy,endx,endy,speed,fn);
	}
}

function ObjectSlideTo(endx,endy,inc,speed,fn) {
	if (!this.slideActive) {
		var distx = endx - this.x;
                               	var disty = endy - this.y;
                               	var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc;
                               	var dx = distx/num;
                               	var dy = disty/num;
                               	this.slideActive = 1;
                               	if (!fn) fn = null;
                               	this.slide(dx,dy,endx,endy,speed,fn);
	}
}

function ObjectSlide(dx,dy,endx,endy,speed,fn) {
	if (this.slideActive && (Math.floor(Math.abs(dx))<Math.floor(Math.abs(endx-this.x)) || Math.floor(Math.abs(dy))<Math.floor(Math.abs(endy-this.y)))) {
		this.moveBy(dx,dy);
                               	setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+speed+",\""+fn+"\")",speed);
	} else {
		this.slideActive = 0;
                               	this.moveTo(endx,endy);
                               	eval(fn);
	}
}

function ObjectClipBy(t,r,b,l) {
	if (n) {
		this.css.clip.top = this.clipValues('t') + t;
                               	this.css.clip.right = this.clipValues('r') + r;
                               	this.css.clip.bottom = this.clipValues('b') + b;
                               	this.css.clip.left = this.clipValues('l') + l;
	} 
	else if (ie) this.css.clip = "rect("+(this.clipValues('t')+t)+"px "+(this.clipValues('r')+r)+"px "+Number(this.clipValues('b')+b)+"px "+Number(this.clipValues('l')+l)+"px)";
}

function ObjectClipTo(t,r,b,l) {
	if (n) {
		this.css.clip.top = t;
                               	this.css.clip.right = r;
                               	this.css.clip.bottom = b;
                               	this.css.clip.left = l;
	}
	else if (ie) this.css.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)";
}

function ObjectClipValues(which) {
	if (n) {
		if (which=="t") return this.css.clip.top;
		if (which=="r") return this.css.clip.right;
		if (which=="b") return this.css.clip.bottom;
		if (which=="l") return this.css.clip.left;
	}
	else if (ie) {
		var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px");
		if (which=="t") return Number(clipv[0]);
		if (which=="r") return Number(clipv[1]);
		if (which=="b") return Number(clipv[2]);
		if (which=="l") return Number(clipv[3]);
	}
}

function ObjectWipeBy(dt,dr,db,dl,distt,distr,distb,distl,speed,fn) {
	if (!this.wipeActive) {
		var endt = (Math.abs(dt)>0&&distt) ? this.clipValues('t') + distt : null;
		var endr = (Math.abs(dr)>0&&distr) ? this.clipValues('r') + distr : null;
		var endb = (Math.abs(db)>0&&distb) ? this.clipValues('b') + distb : null;
		var endl = (Math.abs(dl)>0&&distl) ? this.clipValues('l') + distl : null;
		this.wipeActive = 1;
		if (!fn) fn = null;
		this.wipe(dt,dr,db,dl,endt,endr,endb,endl,speed,fn);
	}
}

function ObjectWipeTo(dt,dr,db,dl,endt,endr,endb,endl,speed,fn) {
	if (!this.wipeActive) {
		this.wipeActive = 1;
		if (!fn) fn = null;
		this.wipe(dt,dr,db,dl,endt,endr,endb,endl,speed,fn);
	}
}

function ObjectWipe(dt,dr,db,dl,endt,endr,endb,endl,speed,fn) {
	var nt = this.clipValues('t');
	var nr = this.clipValues('r');
	var nb = this.clipValues('b');
	var nl = this.clipValues('l');

	if (this.wipeActive && ((endt!=null && nt!=endt) || (endr!=null && nr!=endr) || (endb!=null && nb!=endb) || (endl!=null && nl!=endl))) {
		if (endt!=null) dt = (endt<nt) ? -1*Math.abs(dt) : Math.abs(dt);
		if (endr!=null) dr = (endr<nr) ? -1*Math.abs(dr) : Math.abs(dr);
		if (endb!=null) db = (endb<nb) ? -1*Math.abs(db) : Math.abs(db);
		if (endl!=null) dl = (endl<nl) ? -1*Math.abs(dl) : Math.abs(dl);

		if (dt!=0) {
			if (endt!=null) {
				if (Math.abs(dt)<Math.abs(endt-nt)) nt += dt;
				else nt = endt;
			} else nt += dt;
		}

		if (dr!=0) {
			if (endr!=null) {
				if (Math.abs(dr)<Math.abs(endr-nr)) nr += dr;
				else nr = endr;
			} else nr += dr;
		}

                               if (db!=0) {
                               		if (endb!=null) {
				if (Math.abs(db)<Math.abs(endb-nb)) nb += db;
				else nb = endb;
			} else nb += db;
		}

                               if (dl!=0) {
			if (endl!=null) {
				if (Math.abs(dl)<Math.abs(endl-nl)) nl += dl;
				else nl = endl;
			} else nl += dl;
		}

                               this.clipTo(nt,nr,nb,nl);
                               setTimeout(this.obj+".wipe("+dt+","+dr+","+db+","+dl+","+endt+","+endr+","+endb+","+endl+","+speed+",\""+fn+"\")",speed);
	}
	else {
		this.wipeActive = 0;
		eval(fn);
	}
}
