currentPosScroll = new Array();
currentAdmin = false;

function scrollL( name ) {
	if( typeof currentPosScroll[name] == 'undefined' ) {
		currentPosScroll[name] = 0;
	}
	
	var pTags = document.getElementById( 'content_productsBy'+name ).getElementsByTagName( 'p' );
	noElements = pTags.length;
   
	if( currentPosScroll[name] > 0 ) {
		currentPosScroll[name]--;
	}
	
	var attributes = {
		scroll: { to: [ currentPosScroll[name]*83, 0 ] }
	};
   
	if( currentAdmin && currentAdmin.isAnimated() ) {
		currentAdmin.stop();
		delete currentAdmin;
	}
	currentAdmin = new YAHOO.util.Scroll('scroll_productsBy'+name, attributes, 1, YAHOO.util.Easing.easeBothStrong );
	currentAdmin.animate();
}

function scrollR( name ) {
	if( typeof currentPosScroll[name] == 'undefined' ) {
		currentPosScroll[name] = 0;
	}
	
	var pTags = document.getElementById( 'content_productsBy'+name ).getElementsByTagName( 'p' );
	noElements = pTags.length;
   
	if( currentPosScroll[name]+5 < noElements ) {
		currentPosScroll[name]++;
	}
	
	var attributes = {
		scroll: { to: [ currentPosScroll[name]*83, 0 ] }
	};
	
	if( currentAdmin && currentAdmin.isAnimated() ) {
		currentAdmin.stop();
		delete currentAdmin;
	}
	currentAdmin = new YAHOO.util.Scroll('scroll_productsBy'+name, attributes, 1, YAHOO.util.Easing.easeBothStrong );
	currentAdmin.animate();
}

var currentPosScrollAdvert = 0;
var currentAdvertAnim = false;
function scrollLAdvert( ) {

	if( currentPosScrollAdvert > 0 ) {
		scrollToAdvert( currentPosScrollAdvert-1 );
	}
}

function scrollRAdvert( ) {
	if( currentPosScrollAdvert < 3 ) {
		scrollToAdvert( currentPosScrollAdvert+1 );
	}
}

function scrollToAdvert(n, stopAutoScroll){

	if( typeof(stopAutoScroll) == 'undefined' ) {
		stopAutoScroll = true; //default to true
	}

	if (typeof(scrollRAdvertInterval) != 'undefined' && stopAutoScroll ) {
		clearInterval(scrollRAdvertInterval);
		delete scrollRAdvertInterval;
	}
	
	YAHOO.util.Dom.removeClass( 'advertControlsPage'+currentPosScrollAdvert, 'advertControlsPageOn' );
	currentPosScrollAdvert = n;
	YAHOO.util.Dom.addClass( 'advertControlsPage'+currentPosScrollAdvert, 'advertControlsPageOn' );
	
	var attributes = {
		scroll: { to: [ currentPosScrollAdvert*500, 0 ] }
	};
   
	if( currentAdvertAnim && currentAdvertAnim.isAnimated() ) {
		currentAdvertAnim.stop();
		delete currentAdvertAnim;
	}
	currentAdvertAnim = new YAHOO.util.Scroll('homeAdvertSliderWindow', attributes, 2, YAHOO.util.Easing.easeBothStrong );
	currentAdvertAnim.animate();
}

var scrollPause = false;
function scrollPauseAdvert() {
	scrollPause = true;
}

function scrollPlayAdvert() {
	scrollPause = false;
}

function scrollAutoAdvert( ) {
	if( scrollPause ) {
		return;
	}
	
	if( currentPosScrollAdvert < 3 ) {
		scrollToAdvert( currentPosScrollAdvert+1, false );
	} else {
		scrollToAdvert( 0, false );
	}
	
}

var scrollRAdvertInterval = setInterval( scrollAutoAdvert, 6000 );
