var anim_timeout;






// function moveDiv()
//   this function moves the DIV along a segment of the path
//   based on the anchor points.  It will keep calling 
//   itself with a setTimeout() until the DIV is at the end 
//   of the segment
//
function moveDiv(id, dest, type, step_size)
{
	var obj = anim_getObject(id);
	var anim_style = anim_getStyleObject(id);
	if ((type=='w' || type=='h') && dest > 0) {
		anim_style.display = 'block';
	}
  if (anim_style)
  {

    // get the first anchor
    //
    if (type=='x') {
		var this_dim = parseInt(anim_style.left);
    } else if (type=='y') {
		var this_dim = parseInt(anim_style.top);
	} else if (type=='h') {
		var this_dim = parseInt(anim_style.height);
	} else if (type=='w') {
		var this_dim = parseInt(anim_style.width);	
	}
    


    // if we don't know the step sizes to move the DIV, figure them out
    //
    if (step_size == 0) {
    	step_size = Math.round((dest - this_dim)/7);
	}
	//alert(anim_style.height);
	//alert(this_dim);
    // figure out the new coordinates
    //
    var next_dim = this_dim + step_size;

    // if we're at the end of the segment, set the coordinates to
    // move the DIV to the end
    //
	next_dim = anim_atEndOfPath(step_size, dest, next_dim);


    // add the px or don't, depending on the browser
    if (!document.layers) {
		next_dim = next_dim + "px";
    }

    if (type=='x') {
		anim_style.left = next_dim;
    } else if (type=='y') {
		anim_style.top = next_dim;
	} else if (type=='h') {
		anim_style.height = next_dim;
	} else if (type=='w') {
		anim_style.width = next_dim;
	}
    
    
    
    // if we're at the end of the segment, get new anchors
    // otherwise, call moveDiv() again with a new starting point
    // along the segment
    //
    if (parseInt(next_dim) == parseInt(dest)) {
    	if ((type=='w' || type=='h') && dest <= 0) {
    		anim_style.display = 'none';
    	}
		clearTimeout(anim_timeout);
    } else {
      var timeout_string = "moveDiv('" + id + "', " + dest + ", '" + type + "'," + step_size + ");";
      //alert(timeout_string);
      anim_timeout = setTimeout(timeout_string, 10);
    }
  }
}


// function anim_atEndOfPath()
//   if the DIV is about to be moved past the end point of
//   the segment, this will return true.  Otherwise, it will
//   return false.
//
function anim_atEndOfPath(the_step_size, dest, next) {
	if (((the_step_size > 0) && (next > dest)) || ((the_step_size < 0) && (next < dest))) {
		return dest;
	} else {
		return next;
	}
}


function anim_getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
		// W3C DOM
		return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
		// MSIE 4 DOM
		return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
		// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
    } else {
		return false;
    }
} // anim_getStyleObject



function anim_getObject(objectId) {
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // anim_getStyleObject
