/*
CoreEffects Div Slider .5

About: CoreEffects DivSlider Created By Quixjote's Computers and Services
Your Support is Welcome!  To See Future Develpment of this JSApp, please
consider a PP donation to quixjote@quixjote.net

Features:
* Ability to choose which div you are sliding.
* Slide Up, Down, Left or Right
* Recognizes zero-point with Offset.
Changelist:

Bugs:

Compatibility and Testing:

*/


/*Things that we need:
div1 = Primary Div ***ID*** Name that we want to be able to control
direction = The Direction that we want to slide "div1".  Accepted Values: Up, Down, Left, Right
slideAmt = The Amount (In Pixels) that we want to slide "div1"
speed = The Speed at which to get to "slideAmt"
stopPosition = The furthest you want the panel to end.  Left with not activate if it would go lower than 80px.
dirLimit = if location is more/less than the limit based on direction, do not move.
*/

function stoRight(end, amount, speed, divName){
	end = parseInt(end);
  if (amount>=end){
    theDiv = document.getElementById(divName);
    theDiv.style.left = amount + "px";
    amount=amount-speed;
    setTimeout("stoRight("+end+","+amount+","+speed+",'"+divName+"')", speed);
  }}
function stoLeft(end, amount, speed, divName){
	end = parseInt(end);
  if (amount<=end){
    theDiv = document.getElementById(divName);
    theDiv.style.left = amount + "px";
    amount=amount+speed;
    setTimeout("stoLeft("+end+","+amount+","+speed+",'"+divName+"')", speed);
  } }
function stoDown(end, amount, speed, divName){
	end = parseInt(end);
  if (amount>=end){
    theDiv = document.getElementById(divName);
    theDiv.style.top = amount + "px";
    amount=amount-speed;
    setTimeout("stoDown("+end+","+amount+","+speed+",'"+divName+"')", speed);
  } }
function stoUp(end, amount, speed, divName){
	end = parseInt(end);
  if (amount<=end){
    theDiv = document.getElementById(divName);
    theDiv.style.top = amount + "px";
    amount=amount+speed;
    setTimeout("stoUp("+end+","+amount+","+speed+",'"+divName+"')", speed);
  } 
  }

function divSlide(div1, direction, slideAmt, speed, stopPosition){ //Eventually Add dirL and dirU Limits
	var obj = document.getElementById(div1);
	var startPosition = obj.offsetWidth+obj.offsetWidth;
	var slideAmt = parseInt(slideAmt);
	dirLLimit = typeof(dirLLimit) != 'undefined' ? dirLLimit : 'NO LIMIT'; //Check if dirLLimit is set, if not, set to no Limit
	dirULimit = typeof(dirULimit) != 'undefined' ? dirULimit : 'NO LIMIT'; //Check if dirULimit is set, if not, set to no Limit

	if (direction=="Left"){
		var startAmt = parseInt(obj.style.left);
		var finalAmt = startAmt + slideAmt;
		if (finalAmt <= 0 + stopPosition){
		setTimeout("stoLeft("+finalAmt+","+startAmt+","+speed+",'"+div1+"')", speed);
		} else {
		finalAmt = 0;
		setTimeout("stoLeft("+finalAmt+","+startAmt+","+speed+",'"+div1+"')", speed);
		}
	} else if (direction=="Right"){
		var startAmt = parseInt(obj.style.left);
		var finalAmt = startAmt - slideAmt;
		if (finalAmt <= 0 + stopPosition){
		setTimeout("stoRight("+parseInt(finalAmt)+","+startAmt+","+speed+",'"+div1+"')", speed);
		} else {
		finalAmt = 0;
		setTimeout("stoRight("+parseInt(finalAmt)+","+startAmt+","+speed+",'"+div1+"')", speed);
		}
	} else if (direction=="Up"){
		var startAmt = parseInt(obj.style.top);
		var finalAmt = startAmt + slideAmt;
		if (finalAmt <= 0 + stopPosition){
		setTimeout("stoUp("+finalAmt+","+startAmt+","+speed+",'"+div1+"')", speed);
		} else {
		finalAmt = 0;
		setTimeout("stoUp("+finalAmt+","+startAmt+","+speed+",'"+div1+"')", speed);
		}
	} else if (direction=="Down"){
		var startAmt = parseInt(obj.style.top);
		var finalAmt = startAmt - slideAmt;
		if (finalAmt <= 0 + stopPosition){
		setTimeout("stoDown("+finalAmt+","+startAmt+","+speed+",'"+div1+"')", speed);
		} else {
		finalAmt = 0;
		setTimeout("stoDown("+finalAmt+","+startAmt+","+speed+",'"+div1+"')", speed);
		}
	} 
	
}


