
var trk='http://us.rd.yahoo.com/events/worldaids/carousel/';
var filepath = 'http://l.yimg.com/us.yimg.com/i/mntl/ww/events/worldaids/08/';

var arr_aids = [
{img:"story01.jpg",link:"http://us.rd.yahoo.com/SIG=137hj2jl3/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FFlorence-Ngobeni.aspx",line1:"Florence: 35, Alex: 2",line2:"South Africa",ctatxt:"Read their story"},  //story1
{img:"story02.jpg",link:"http://us.rd.yahoo.com/SIG=12r9asqq6/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FTatu.aspx",line1:"Tatu: 35, Faith: 4",line2:"Tanzania",ctatxt:"Read their story"}, //story2
{img:"story03.jpg",link:"http://us.rd.yahoo.com/SIG=1318lgcr9/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FFlorentine.aspx",line1:"Florentine: 26, Faith: 7",line2:"Cameroon",ctatxt:"Read their story"},  //story3
{img:"story04.jpg",link:"http://us.rd.yahoo.com/SIG=12s6emo5u/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FMaria.aspx",line1:"Maria: 18",line2:"Russia",ctatxt:"Read her story"}, //story4
{img:"story05.jpg",link:"http://us.rd.yahoo.com/SIG=13luru6c8/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FThe-Byaruhanga_s-Story-of-Hope.aspx",line1:"Annabella: 14",line2:"Uganda",ctatxt:"Read her story"},  //story5
{img:"story06.jpg",link:"http://us.rd.yahoo.com/SIG=1342j48sb/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FCristina-Pena.aspx",line1:"Cristina: 25",line2:"California",ctatxt:"Read her story"}, //story6
{img:"story07.jpg",link:"http://us.rd.yahoo.com/SIG=13bs2pcok/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FBillandSusanBelfiore.aspx",line1:"The Belfiore Family",line2:"New Jersey",ctatxt:"Read their story"},  //story7
{img:"story08.jpg",link:"http://us.rd.yahoo.com/SIG=12u2nfio4/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FLungile.aspx",line1:"Lungile: 33",line2:"Swaziland",ctatxt:"Read her story"}, //story8
{img:"story09.jpg",link:"http://us.rd.yahoo.com/SIG=1338hfls6/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FTanya-Torres.aspx",line1:"Tanya: 25, Damian: 3",line2:"Florida",ctatxt:"Read their story"},  //story9
{img:"story10.jpg",link:"http://us.rd.yahoo.com/SIG=138iok6od/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FMaggie-Nakasindde.aspx",line1:"Maggie: 8",line2:"Uganda",ctatxt:"Read her story"}, //story10
{img:"story11.jpg",link:"http://us.rd.yahoo.com/SIG=1390v7leb/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FMamiechou-Mahnjoku.aspx",line1:"Mamiechou: 6",line2:"Cote d'Ivoire ",ctatxt:"Read her story"},  //story11
{img:"story12.jpg",link:"http://us.rd.yahoo.com/SIG=138teve3f/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FTheMeredithFamily.aspx",line1:"The Meredith Family",line2:"Kentucky",ctatxt:"Read their story"}, //story12
{img:"story13.jpg",link:"http://us.rd.yahoo.com/SIG=12u6umbe9/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FCacilda.aspx",line1:"Cacilda: 47",line2:"Mozambique",ctatxt:"Read her story"},  //story13
{img:"story14.jpg",link:"http://us.rd.yahoo.com/SIG=12sh7eta1/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FChiku.aspx",line1:"Chiku: 16",line2:"Tanzania",ctatxt:"Read her story"}, //story14
{img:"story15.jpg",link:"http://us.rd.yahoo.com/SIG=136b7mmsp/**http%3A%2F%2Fwww.pedaids.org%2FAboutUs%2FSurvivorSpotlight%2FSurvivorArchive%2FRenatha-Kabanya.aspx",line1:"Renatha: 39",line2:"Rwanda",ctatxt:"Read her story"} //story15
];
	



var car_aids;


function loadCarousel() {
	car_aids = new gwCarousel();
	car_aids.makeThumbs();
	YAHOO.util.Event.addListener(document.getElementById("next-arrow"), "click", function(){car_aids.doNext()}); 
	YAHOO.util.Event.addListener(document.getElementById("prev-arrow"), "click", function(){car_aids.doPrev()}); 
}

//gw carousel fxns
function gwCarousel() {
	this.thumbw = 160;
	this.thumbm = 5;
	this.thumbtotal = 0;//curArr.length-1;
	this.viewable = 900;
	this.divView = 	document.getElementById("thumbsview");
	this.divView.style.width = this.viewable+"px";
	this.totalwidth = 0;//(this.thumbw+this.thumbm)*this.thumbtotal - (this.viewable/2);
	this.totalpages=0;
	this.incr = 855;//this.viewable;  //px
	this.curPos = 0;
	this.curPage = 1;
	
	this.doNext = function() {
		if(this.curPage < this.totalpages) {
			trackMisc("carousel/next");
			this.getPage(this.curPage+1);
		}
	};
	
	this.doPrev = function() {
		if(this.curPage >1) {
			trackMisc("carousel/prev");
			this.getPage(this.curPage-1);
		}
	};
	this.getPage = function(p) {
		this.curPos = 0-(this.incr*(p-1))
		var attributes = { left: { to: this.curPos } }
		var myAnim = new YAHOO.util.Anim("thumbs", attributes,.5,YAHOO.util.Easing.easeOut);
		myAnim.animate();
		this.doArrows(p);
		this.curPage = p;
		
	};
	this.doArrows = function(p) {
		if(p<=1)document.getElementById("prev-arrow").src=filepath+"carousel_prev_0.gif";
		else document.getElementById("prev-arrow").src=filepath+"carousel_prev.gif";
		
		if(p>=this.totalpages)document.getElementById("next-arrow").src=filepath+"carousel_next_0.gif";
		else document.getElementById("next-arrow").src=filepath+"carousel_next.gif";
	};
	this.reset = function() {
		this.curPos = 0;
		this.curPage =1;
		document.getElementById("thumbs").style.left = "0px";
	};
	this.makeThumbs = function() {
		var arr = arr_aids;
		
		this.thumbtotal = arr.length;
		this.totalwidth = (this.thumbw+this.thumbm)*(this.thumbtotal+1);
		this.totalpages = Math.ceil(this.totalwidth/this.viewable);
		
		var ul = document.getElementById("thumbs");
		
		ul.style.width= this.totalwidth + "px";
		
		ul.innerHTML='';
		for(var i=0;i<this.thumbtotal;i++) {
			var thumbinfo = arr[i];
			var trk2 = trk+(i+1)+"/*";
			ul.innerHTML += '<li><p class="img"><a href="'+trk2+thumbinfo.link+'"><img src="'+filepath+"stories/"+thumbinfo.img+'" height="90" width="160"></a></p><div class="txt"><p>'+thumbinfo.line1+'</p><p>'+thumbinfo.line2+'</p></div><p class="cta">&nbsp;<a href="'+trk2+thumbinfo.link+'">&#187; '+thumbinfo.ctatxt+'</a></p></li>';
		
		}
		this.reset();
		this.doArrows(this.curPage);
		
	};

	
}

