﻿	// +--------------------------------------------------------+ 
	// | js version .x														 | 
	// +--------------------------------------------------------+ 
	// | Copyright : heo woong <comefeel.com>            | 
	// +--------------------------------------------------------+ 
	// | License  : GPLv3												| 
	// +--------------------------------------------------------+ 
	
	
	var roll = {

			__constructor : function( init ){

				this.cycle = 0;
				this.floor = true;
				this.fireopen = false;
				this.graduation = 'px';
				this.exec = 'curtain';
				this.foundIt( init , this );
				this.variable = new Object();
				this.error = new Array();
				this.events = this.bind( this.beginning , this );
				this.eventElement = this.eventElement ? this.eventElement : this.spear;
				this.eventCatch ( this.eventElement , this.eventID , this.events );
			},

			fire : function( flag ){

				this.fireopen = true;
				this.floor = flag;
				this.eventFire( this.eventElement , this.eventID , this.eventArgs );
			},

			beginning : function( Event ){

						//alert( (typeof this.repeatedly != this.ty.not) +' , '+ (this.fireopen != true) +' , '+ (this.repeatedly != this.floor ));

					if( this.intervalID || ( typeof this.repeatedly != this.ty.not && this.fireopen != true && this.repeatedly != this.floor )) return this.error.push( 1000 );
				return this.intervalID = setInterval( this.moving() , this.sec );
			},

			moving : function(){

					var clearPoint = this.clearPoint;
					var point = typeof this.firstPoint === this.ty.not ? 0 : this.firstPoint;
					var tempoint;

					if( this.floor != true ){

						tempoint = point;
						point = clearPoint;
						clearPoint = tempoint;
					}

					this.point = point;
					this.lastPoint = clearPoint;

				return this.bind( this[this.exec] , this );
			},

			bright : function(){


					// first Move
					if( this.cycle == 0 ){

						var percent , app;

						if( this.clearPoint == this.lastPoint ){

							percent = 0;
							app = 1;

							this.spear.style[this.move] = this.lastPoint + this.graduation;
						}
						else {

							percent = 100;
							app = -1;							
						}

						this.point = percent;
						this.app = app;

					} else if( this.cycle >= 10 ){

						this.stop( this.lastPoint );
						return;
					}

					this.spear.style.filter = 'Alpha(opacity=' + this.point + ')';
					this.spear.style.opacity = this.point / 100;
					this.point += this.app * 10;
					this.cycle++;

			},

			curtain : function(){

					var impact = ( this.lastPoint - this.point ) / this.sec;

					if( Math.abs( impact ) < .1 ){

						void( this.stop( this.lastPoint ));
						return;
					}

					var point = Math.round( this.point );
					var roundPoint = Math.round( this.point += impact );

					if( point == roundPoint ) return;

					this.spear.style[this.move] = roundPoint + this.graduation;
			},

			stop : function( clearPoint ){

				if( typeof clearPoint == this.ty.num ) this.spear.style[this.move] = clearPoint + this.graduation;

				void( clearInterval( this.intervalID ));

				this.cycle = 0;
				this.fireopen = false;
				this.floor = !this.floor;
				this.intervalID = false;
			}
		};
