// JavaScript Document
//<![CDATA[

//following are just for demonstration.
//Demonstration functions for dynamic changes, not required for running fleXcroll.
//This is esp. useful for injecting dynamic content using AJAX.
function insertRemoveP(reMove) {
	var targetEl = document.getElementById('dynamictest');
	var scrollDiv = document.getElementById('test1');
	if (targetEl == null || scrollDiv == null) return;

	if (typeof(targetEl.parS) == 'undefined') targetEl.parS = new Array();
	if (!reMove) {
		targetEl.parS[targetEl.parS.length] = document.createElement('p');
		targetEl.parS[targetEl.parS.length-1].appendChild(document.createTextNode('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque ultrices facilisis risus. Aenean sollicitudin imperdiet justo.'));
		targetEl.appendChild(targetEl.parS[targetEl.parS.length-1]);
		} else if (targetEl.parS.length > 0) {
		targetEl.parS[targetEl.parS.length-1].parentNode.removeChild(targetEl.parS[targetEl.parS.length-1]);
		targetEl.parS.length = targetEl.parS.length - 1;
		}

	//Following is the method to tell fleXcrolled div to update itself
	if(scrollDiv.scrollUpdate) scrollDiv.scrollUpdate();
	//Notice that it is best to check the method first, otherwise your javascript will throw an
	//error on browsers that are blocked.

}

function makeWideNarrow() {
	var targetEl = document.getElementById('dynamictest');
	var scrollDiv = document.getElementById('test1');
	if (targetEl == null || scrollDiv == null) return;
	if (targetEl.parentNode.className=='dynamic') targetEl.parentNode.className = 'fixedsize';
	else targetEl.parentNode.className='dynamic';
	//Following is the method to tell fleXcrolled div to update itself
	if(scrollDiv.scrollUpdate) scrollDiv.scrollUpdate();
}

function cleanTestDiv() {
	var targetEl = document.getElementById('dynamictest');
	var scrollDiv = document.getElementById('test1');
	if (targetEl != null) targetEl.innerHTML = '';
	if (typeof(targetEl.parS) != 'undefined') targetEl.parS = new Array();
	targetEl.parentNode.className = 'dynamic';
	//Following is the method to tell fleXcrolled div to update itself
	if(scrollDiv.scrollUpdate) scrollDiv.scrollUpdate();
}

//a basic example external module to control scroll from outside
//NOT required for fleXcroll to run, and user do NOT need to
//know what this is for standard operation.
function fleXcrollTo(id,x,y,relative) {
	var scrollDiv = document.getElementById(id);
	//Return if the target is null
	if (scrollDiv == null) return;
	//Do the scroll by using custom method attached by fleXcroll
	//but first check if the method exists.
	if(scrollDiv.contentScroll) scrollDiv.contentScroll(x,y,relative);
	/*
	Following is the method to commit a scroll by defining
	relative or absolute values:
		element.contentScroll(x,y,relative);
	*x and y values are horizontal and vertical
	positions of content and can be set to false if we don't
	require any one of them to be scrolled.
	*x and y should be sent as string, between quotation marks.
	*x and y can take three different units:
	px, s, p
	where px is pixels, s is a single step, p is a page scroll.
	*relative can be either true or false. If true,
	x and y is used as relative scrolling.
	*x and y refer to content position
	*e.g. To scroll one page down, you can:
	element.contentScroll(false,"1p",true);
	*e.g. To scroll 3 steps to left, you can:
	element.contentScroll("-3s",false,true);
	*e.g. To set the content at 30px right, and 20px down:
	element.contentScroll("30px","20px",false);
	*e.g. To scroll down 100px relatively,
	element.contentScroll(false,"100px",true);
	*/
}

//]]>
