function formatText(index, panel) {
	return index + "";
}

$(function () {
	$('.anythingSlider').anythingSlider({
		easing: "easeInOutExpo",
        autoPlay: true,
        delay: 10000,
        startStopped: false,
        animationTime: 1000,
        hashTags: true,
        buildNavigation: true,
    	pauseOnHover: true,
    	startText: "",
		stopText: "",
		navigationFormatter: formatText
	});
	$("#slide-jump").click(function(){
		$('.anythingSlider').anythingSlider(6);
	});
});

haccordion.setup({
	accordionid: 'hc1',
	paneldimensions: {peekw:'40px', fullw:'480px', h:'240px'},
	selectedli: [0, true],
	speed: 250,
	collapsecurrent: false
});

function showTweets(json, uList) {
	uList.innerHTML = '';
    for (var i=0; i<json.length; i++) {
        uList.innerHTML = uList.innerHTML + "<li>" + linkify(json[i].text) + "</li>";
    }
}

function showLPATweets(json) {
    showTweets(json, document.getElementById("LPAssociation"));
}

function showChesterTweets(json) {
    showTweets(json, document.getElementById("ChesterBe"));
}

function showMikeTweets(json) {
    showTweets(json, document.getElementById("m_shinoda"));
}

function showPhoenixTweets(json) {
    showTweets(json, document.getElementById("phoenixlp"));
}

function showJoeTweets(json) {
    showTweets(json, document.getElementById("joehahnlp"));
}

function linkify(text){
    if (text) {
        text = text.replace(/((https?\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi,
            function(url){
                var full_url = url;
                if (!full_url.match('^https?:\/\/')) {
                    full_url = 'http://' + full_url;
                }
                return '<a href="' + full_url + '" target="_blank">' + url + '</a>';
            }
        );
    }
    return text;
}

window.onload=function() { 
	var feeds = new Array();
	feeds[0] = 'http://twitter.com/statuses/user_timeline/lpassociation.json?count=5&callback=showLPATweets';
	feeds[1] = 'http://twitter.com/statuses/user_timeline/m_shinoda.json?count=5&callback=showMikeTweets';
	feeds[2] = 'http://twitter.com/statuses/user_timeline/ChesterBe.json?count=5&callback=showChesterTweets';
	feeds[3] = 'http://twitter.com/statuses/user_timeline/phoenixlp.json?count=5&callback=showPhoenixTweets';
	feeds[4] = 'http://twitter.com/statuses/user_timeline/joehahnlp.json?count=5&callback=showJoeTweets';
	
	for (var i = 0; i < feeds.length; i++) {
		var script = document.createElement('script');
		script.setAttribute('src', feeds[i]);
		document.body.appendChild(script);
	}
}
