function KickerPages() { this.value = 0; } 

var mySlide = new Array(
						new Array(	'http://c.americanapparel.net/storefront/headers/accessories/mainpage/rsa0513.jpg',
										new Array (	'<a href="search.html?s=rsa0513">Stripe Satin Charmeuse Bow Headband</a>' ) ),
						
						new Array(	'http://c.americanapparel.net/storefront/headers/accessories/mainpage/nailpolish.jpg',
										new Array (	'<a href="nailpolsh.html">Nail Polish</a>' ) ),
						
						new Array(	'http://c.americanapparel.net/storefront/headers/accessories/mainpage/BUTTTWL_01.jpg',
										new Array (	'<a href="butttwl.html">BUTT Magazine Towel</a>' ) ),
						
						new Array(	'http://c.americanapparel.net/storefront/headers/accessories/mainpage/rsa0507_navyredstripe.jpg' , 
										new Array (	'<a href="RSA0507.html">Cinch Rope Tote</a>' ) ),
						
						new Array(	'http://c.americanapparel.net/storefront/headers/accessories/mainpage/floppyhat_04.jpg' , 
										new Array (	'<a href="floppyhat.html">Wool Floppy Hat</a>' ) ),
						
						new Array(	'http://www.americanapparel.net/storefront/headers/accessories/mainpage/rsawbt2_red.jpg',
										new Array (	'<a href="accessories-belts---ties.html">Belts &amp; Ties</a>' ) ),
						
						new Array(	'http://c.americanapparel.net/storefront/headers/accessories/mainpage/bedding2.jpg',
										new Array (	'<a href="accessories-bedding.html">Bedding</a>' ) ),
						
						new Array(	'http://c.americanapparel.net/storefront/headers/accessories/mainpage/shoes.jpg' , 
										new Array (	'<a href="accessories-shoes.html">Shoes</a>' ) )
						);

var myInterval = 0; 
var myIntervalPause = 0; 
var myTimeout = 0; 
var myAPI;

function ScrollThroughmyPages(){ myAPI.next(500); RestartmyInterval(); }

function AutoScroll() {
	
	if ( document.getElementById('TheNewStandards') != null ) document.getElementById('TheNewStandards').style.display = '';

	randArray(mySlide);
	
	for(var x = 0; x < mySlide.length; x++)
		document.getElementById('myItems').innerHTML += '<span><img id="myItem'+x+'" src="http://c.americanapparel.net/inc/HomepageScroller/NavImages/Blank.gif" /><div class="myText" id="myLink'+x+'"></div></span>';

	$(function() {
		$("#myScrollable").myScrollable({horizontal:true});
	});

    if (document.getElementById('myScrollable') != null) {
        myAPI = $("#myScrollable").myScrollable();
	    myTotal = myAPI.getStatus().total;
	    if (myTotal <= 1) {
	        $('DIV.myNext').hide();
	        $('DIV.myPrev').hide();
	    }

		RestartmyInterval();
	}

}

function RestartmyInterval() {
	LoadImgs();
	myPause = 5000;
	CancelmyInterval();
	myInterval = setInterval('ScrollThroughmyPages()',myPause);
}

function PausemyInterval(){ LoadImgs(); CancelmyInterval(); clearTimeout(myTimeout); myTimeout = setTimeout('RestartmyInterval()',5000); } 

function CancelmyInterval(){ LoadImgs(); clearInterval(myInterval); } 

function LoadImgs(){
    myIndex = myAPI.getStatus().index;
	LoadImg(myIndex - 1);
	LoadImg(myIndex);
	LoadImg(myIndex + 1);
}

function LoadImg(index){
	Item = document.getElementById('myItem' + index);
	Link = document.getElementById('myLink' + index);
	if ( Item != null ){
		if (mySlide[index] != null && Item.src != mySlide[index][0])
		{
			Item.src = mySlide[index][0];

			for(var x = 0; x < mySlide[index][1].length; x++){
				if ( x == 0 )
					Link.innerHTML = mySlide[index][1][x];
				else
					Link.innerHTML += ' | ' + mySlide[index][1][x];
			}
		}
		
	}
}


function randArray(o){
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
}

window.onload=AutoScroll;

