function doSlide(direction,id,startPosition,endPosition,millisec)
{

	obj = document.getElementById(id);	
	
	if(direction=='up')
	{
	obj.style.height=startPosition;
	pxPerLoop = (startPosition-endPosition)/millisec;
	slideUp(obj,startPosition,endPosition,pxPerLoop);
	}
	else if(direction=='right')
	{
	obj.style.right=startPosition;
	pxPerLoop = (endPosition-startPosition)/millisec;
	slideRight(obj,startPosition,endPosition,pxPerLoop);
	}
	else if(direction=='left')
	{
	obj.style.right=startPosition;
	pxPerLoop = (startPosition-endPosition)/millisec;
	slideLeft(obj,startPosition,endPosition,pxPerLoop);
	}
	else
	{
	obj.style.height=startPosition;
	pxPerLoop = (endPosition-startPosition)/millisec;
	slideDown(obj,startPosition,endPosition,pxPerLoop);
	}
}

function slideDown(obj,offset,full,px)
{
	if(offset < full)
	{
		obj.style.height = offset+"px";
		offset=offset+px;
		setTimeout((function(){slideDown(obj,offset,full,px);}),50);
	}
	else
	{
		obj.style.height = full+"px";
	}
}

function slideUp(obj,offset,full,px)
{
	if(offset > full)
	{
		obj.style.height = offset+"px";
		offset=offset-px;
		setTimeout((function(){slideUp(obj,offset,full,px);}),50);
	}
	else
	{
		obj.style.height = full+"px";
	}
}

function slideRight(obj,offset,full,px)
{
	if(offset < full)
	{
		obj.style.right = offset+"px";
		offset=offset+px;
		setTimeout((function(){slideRight(obj,offset,full,px);}),1);
	}
	else
	{
		obj.style.right = full+"px";
	}
}

function slideLeft(obj,offset,full,px)
{
	if(offset > full)
	{
		obj.style.right = offset+"px";
		offset=offset-px;
		setTimeout((function(){slideLeft(obj,offset,full,px);}),1);
	}
	else
	{
		obj.style.right = full+"px";
	}
}

/*Custom Function that creates a sliding set of divs. Currently programmed to display 2 items at a time. You Must generate the first and last promo twice so they rotate through seemlessly.*/
function slideIt(id,direction,count,width,speed)
{
obj = document.getElementById(id);

var current_pos=parseInt(obj.style.right);
var new_pos=0;
	if(direction=='left')
	{
		if(current_pos<=0)
		{
			obj.style.right = ((count)*width)+"px";
			current_pos=parseInt(obj.style.right);
		}
		new_pos=current_pos-width;
		doSlide(direction,id,current_pos,new_pos,speed);

	}
	else if(direction=='right')
	{
		if((current_pos+width)>=((count+1)*width))
		{
			obj.style.right = 0+"px";
			current_pos=parseInt(obj.style.right);
		}
		new_pos=current_pos+width;
		doSlide(direction,id,current_pos,new_pos,speed);
		
	}

}

/*A Ghetto little function that puts the slidding promo on a timer. The nicest feature is the slide_skipabeat with you can use to keep the script from trying to run to close to mouseclicks.*/
function slideTimer(mseconds,id,slide_dir,slide_promo_count,slide_promo_width,speed)
{
	if(!slide_skipabeat)
	{
		slideIt(id,slide_dir,slide_promo_count,slide_promo_width,speed);
	}
	else
	{
		slide_skipabeat=false;
	}
setTimeout(function(){slideTimer(mseconds,id,slide_dir,slide_promo_count,slide_promo_width,speed)},mseconds);
}
