function movingDiv( divId, startPos, endPos, movementType, currWidth, currHeight, currTop )
{
	this.divId = divId;
	this.endPos = endPos;
	this.moveType = "horizontal";
	this.backgroundImage = "";
	this.backgroundColor = "";
	this.currWidth = currWidth;
	this.currHeight = currHeight;
	this.currTop = 0;
	this.widthBuffer = 20;
	this.heightBuffer = 34;
	
	this.startPos = ( startPos - currWidth - this.widthBuffer );
	this.xMoveDelay = ( parseFloat( this.endPos ) - parseFloat( startPos ) )/(parseFloat( this.endPos )/20);
	this.yMoveDelay = ( this.endPos - startPos )/(this.endPos/20);
	this.currLeft = this.startPos;
	this.currTop = currTop;
	this.maxYPos = ( 0 - currHeight - this.heightBuffer );
	
	// position values
	this.xMousePos = 0;
    this.yMousePos = 0;
    this.xMousePosMin = 0;
    this.yMousePosMin = 0;
}

movingDiv.prototype.setSitAndWait = function( currVal ) 
{ 
	this.sitAndWait = currVal; 
}

movingDiv.prototype.setBackgroundColor = function( currBgColor ) 
{ 
	this.backgroundColor = currBgColor; 
}

movingDiv.prototype.setBackgroundImage = function( currImagePath ) 
{ 
	var img = new Image();
	img.src = currImagePath;
	this.backgroundImage = currImagePath; 
}

movingDiv.prototype.drawDiv = function() 
{

    if( document.getElementById( this.divId ) ) 
    {
        document.getElementById( this.divId ).style.position = "absolute";
        document.getElementById( this.divId ).style.visibility = "visible";
        document.getElementById( this.divId ).style.top = this.currTop + "px";
        document.getElementById( this.divId ).style.left = this.startPos + "px";
        document.getElementById( this.divId ).style.width = this.currWidth + "px";
        document.getElementById( this.divId ).style.height = this.currHeight + "px";
        
        if( this.backgroundColor != "" ) {
	    	document.getElementById( this.divId ).style.background = this.backgroundColor;
	    }
	    
	    if( this.backgroundImage != "" ) {
	        document.getElementById( this.divId ).innerHTML = '<img src="' + this.backgroundImage + '">';
	    }
    }
    else
    {
	    var currDivText = '<div class="divOverlay" id="' + this.divId + '" style="'
	    				+ 'position: absolute;'
	    				+ 'visibility: hidden;'
	    				+ 'top: ' + this.currTop + 'px;'
	    				+ 'left: ' + this.startPos + 'px;'
	    				+ 'width:' + this.currWidth + 'px;'
	    				+ 'height: ' + this.currHeight + 'px;'
	    
	    if( this.backgroundColor != "" ) {
	    	currDivText += 'background:' + this.backgroundColor + ';';
	    }
	    
	    currDivText += '" onclick="javascript:'+ this.divId + '.hideDiv();">';
	    
	    if( this.backgroundImage != "" ) {
	    	currDivText += '<img src="' + this.backgroundImage + '">';
	    }
	    
	    currDivText += '</div>';
	    document.write( currDivText );
    }
}

movingDiv.prototype.doAnimate = function() 
{
	currElement = document.getElementById( this.divId );
	if( this.moveType == "horizontal" ) 
	{
		this.getScreenPosition();
		currElement.style.top = ( this.yMousePosMin + this.heightBuffer + this.currTop ) + "px";
		currElement.style.visibility = "visible";
		this.moveDiv();
	}
}

movingDiv.prototype.moveDiv = function()
{
	currElement = document.getElementById( this.divId );
	currElement.style.left = this.currLeft + "px";
	this.currLeft += this.xMoveDelay;
	if( this.currLeft <= this.endPos ) 
	{ 
		var self = this;
    	var funcRef = function() { self.moveDiv(); }
    	setTimeout( funcRef, 0  );
	}
	else 
	{
		var self = this;
    	var funcRef = function() { self.sendDivAway(); }
	   	setTimeout( funcRef, this.sitAndWait  );
	}	   			
}	

movingDiv.prototype.sendDivAway = function()
{
	currElement = document.getElementById( this.divId );
	if( this.currTop >= this.maxYPos ) 
	{ 
		this.currTop -= this.yMoveDelay;
		currElement.style.top = this.currTop + "px";
		var self = this;
    	var funcRef = function() { self.sendDivAway(); }
    	setTimeout( funcRef, 0  );
	}
	else {
		this.hideDiv();
	}
}

movingDiv.prototype.hideDiv = function()
{
	currElement = document.getElementById( this.divId );
	currElement.style.top = "-400px";
	currElement.style.left = "-400px";
	currElement.style.visibility = "hidden";
}

movingDiv.prototype.getScreenPosition = function() {
    if (document.layers) {
        this.xMousePosMin = window.pageXOffset;
        this.yMousePosMin = window.pageYOffset;
    } else if (document.all) {
        this.xMousePosMin = document.body.scrollLeft;
        this.yMousePosMin = document.body.scrollTop;
    } else if (document.getElementById) {
        this.xMousePosMin = window.pageXOffset;
        this.yMousePosMin = window.pageYOffset;
    }
}
