/* 
		dw_wipes.js		wipe methods for dynObj 
		(requires dw_core.js, dw_clip.js, and dw_util.js)
		version date: October 2002 (this.wiping prop added)
		
		This code is from Dynamic Web Coding  
		at http://www.dyn-web.com/
    Copyright 2002 by Sharon Paine 
    See Terms of Use at http://www.dyn-web.com/bus/terms.html
    Permission granted to use this code 
    as long as this entire notice is included.
		
		Idea and math for time-based animation from:
		Aaron Boodman at www.youngpup.net 
		and Mike Foster at www.cross-browser.com
*/

// wipe called can be prevented
var wipe_halt = false;	

// args: which wipe, delay, wipeTime, what next (fn)
dynObj.prototype.wipe=function(which,delay,wipeTime,fn) {
	if (wipe_halt||this.wiping) return;
	this.wipeTime=wipeTime||1000; this.delay=delay||100; this.fn=fn;
	switch (which) {
		
		// wipe into view from upper left corner to lower right
		case "in corner" :
			this.clipTo(0,0,0,0);
			this.show();
			setTimeout(this.obj+".wipe_in_corner()",this.delay);
		break;
		
		// wipe out of view from lower right to upper left
		case "out top left" :
			setTimeout(this.obj+".wipe_out_top_left()",this.delay);
		break;
		
  	default:
			alert("Oops! Check choices again.");
	}
	this.wipeStart = new Date().getTime()+this.delay;
	this.per = Math.PI/(2*this.wipeTime);
}


// wipe into view from upper left corner to lower right
dynObj.prototype.wipe_in_corner=function() {
	this.wiping = true;
	var clipVal = this.getClipValues();
	var elapsed = (new Date().getTime())-this.wipeStart;
	if (elapsed<this.wipeTime) {
	var vinc = this.height*((1/this.wipeTime)*elapsed);
	var hinc = this.width*((1/this.wipeTime)*elapsed);
	this.clipTo(0,hinc,vinc,0);
	setTimeout(this.obj+".wipe_in_corner()",35);
	} else {
		this.clipTo(0,this.width,this.height,0);
		this.wiping = false;
		if (this.fn) eval(this.fn);
	}
}

// wipe out of view from lower right to upper left
dynObj.prototype.wipe_out_top_left=function () {
	this.wiping = true;
	var clipVal = this.getClipValues();
	var elapsed = (new Date().getTime())-this.wipeStart;
	if (elapsed<this.wipeTime) {
	var vinc = -this.height*Math.cos(this.per*elapsed)+this.height;
	var hinc = -this.width*Math.cos(this.per*elapsed)+this.width;
		this.clipTo(0,this.width-hinc,this.height-vinc,0);
		setTimeout(this.obj+".wipe_out_top_left()",35);
	} else {
		this.clipTo(0,0,0,0);
		this.wiping = false;
		if (this.fn) eval(this.fn);
	}
}
