// mSlide
// By Mark Willis - www.MarkWillis.co.uk

function mSlide(mTarget, mStart, mGoal, mIncrement, mReps, mDir, mAjax, mContentLoad)
{
	/* PLEASE CALL THE mSlideToggle FUNCTION (BELOW) IN YOUR HTML */
	
	if(mDir == 1)
	{
		// OPENING
		if((mStart + (mIncrement * mReps)) <= mGoal)
		{
			// Not reached goal yet...
			document.getElementById(mTarget).style.height = (mStart + (mIncrement * mReps)) + "px";
			document.getElementById(mTarget).style.display = "block";
			var st = setTimeout('mSlide(\'' + mTarget + '\', ' + mStart + ', ' + mGoal + ', ' + mIncrement + ', ' + (mReps + 1) + ', 1, \''+ mAjax +'\', \''+ mContentLoad +'\')', 1);
		}else{
			// Reached goal
			if(mAjax == 1){mAjaxQuery(mTarget, mContentLoad, '');}
			mSlideable = 1;
			mSlideOpen = 1;
		}
	}else{
		// CLOSING
		if((mStart - (mIncrement * mReps)) >= mGoal)
		{
			// Not reached goal yet...
			document.getElementById(mTarget).style.height = (mStart - (mIncrement * mReps)) + "px";
			var st = setTimeout('mSlide(\'' + mTarget + '\', ' + mStart + ', ' + mGoal + ', ' + mIncrement + ', ' + (mReps + 1) + ', 2, 0, \'\')', 1);
		}else{
			// Reached goal
			document.getElementById(mTarget).style.display = "none";
			mSlideable = 1;
			mSlideOpen = 0;
		}
	}
	
	return false;
}

function mSlideToggle(slideWindow, slideTarget, slideStartHeight, slideGoalHeight, callAjax, contentLoad)
{
	/* Guide
	
		slideWindow			YOUR ID for the slider's content. This controls multi-windowed slider content. Set to 1 if you are not using AJAX.
		slideTarget			The Element ID that you wish the slide open and close.
		slideStartHeight	The starting height of the element that you wish to open/close.
		slideStartHeight	The goal height of the element that you wish to open/close.
		callAjax			If you wish to use AJAX Method to load data into the sliding area. 0 = No, 1 = Yes.
		contentLoad			Relative URL for the page you wish to load into the sliding area once it opens (given callAjax == 1)
		
	*/
	
	
	if(mSlideable == 1)
	{
	
	if(mSlideWindow == slideWindow || mSlideWindow == 0)
	{
	
	if(mSlideOpen == 0)
	{
		// Open
		// Populate with loader.
		//clearBubble();
		//alert("sliding open...");
		if(callAjax == 1){document.getElementById(slideTarget).innerHTML = '<div class="mSlideAreaLoading"><!-- --></div>';}
		mSlide(slideTarget, slideStartHeight, slideGoalHeight, 10, 0, 1, callAjax, contentLoad);
		mSlideable = 0;
		mSlideWindow = slideWindow;
	}else if(mSlideOpen == 1)
	{
		// Close
		//clearBubble();
		//alert("sliding close...");
		
		mSlide(slideTarget, slideGoalHeight, 0, 10, 0, 2, 0, '');
		mSlideable = 0;
		mSlideWindow = 0;
	}
	
	}else{
		// Bypass sliding, just change content.
		if(callAjax == 1)
		{
			document.getElementById(slideTarget).innerHTML = '<div class="mSlideAreaLoading"><!-- --></div>';
			mAjaxQuery(slideTarget, contentLoad, '');
		}
		mSlideWindow = slideWindow;
	}
	
	
	
	}
		
	return false;
}