var imgCache = [];

(function($){
	// PRELOAD BANNERS
	//(function(){
//		var imgs = 'main bio shows donate booking'.split(' '),
//			i = imgs.length,
//			img = null;
//	
//		while(i--){
//			img = document.createElement('img');
//			img.src = '/images/header-' + imgs[i] + '.jpg';
//			imgCache.push(img);
//		}
//	})();
	
	// ATTACH LINK CLICKING EVENTS
	//$('#main-links > a, #footer-links > a').click((function(){
//		function linkObj(){
//			var args = arguments,
//				type = args[0],
//				url = args[1] || type;
//			
//			return {
//				cls : 'header_' + type,
//				img : '/images/header-' + type + '.jpg',
//				url : '/' + url + '.php'
//			};
//		}
//		
//		var types = {
//			index : linkObj('main', 'index'),
//			store : linkObj('main', 'store'),
//			bio : linkObj('bio'),
//			shows : linkObj('shows'),
//			donate : linkObj('donate'),
//			booking : linkObj('booking'),
//			albums : linkObj('main', 'albums')
//		};
//		
//		return function(event){
//			event.preventDefault();
//			
//			var $a = $(this),
//				type = /([a-z]*)_link/.exec($a.attr('class'))[1],
//				obj = types[type],
//				id = '#body-container';
//			
//			$(id).load(obj.url + ' ' + id, function(){
//				$a.addClass('selected')
//					.siblings().removeClass('selected');
//				$('#logo').removeClass().addClass(obj.cls);
//			});
//		}
//	})());
	
	// SHOW MUSIC PLAYER
	swfobject.embedSWF(
		'/fl/music-player.swf',
		'music-player',
		'257', '32', '10',
		false, {
			wmode : 'transparent'
		}
	);
	
	// FIX PNG ALPHA TRANSPARENCY FOR IE6
	$('#social-links').pngFix();
	
	/**
	 *  Twitter
	 */
	function twitterCallback(tweets) {
		tweets = $.map(tweets, function(tweet) {
			var /*username = tweet.user.screen_name,*/
				status = tweet.text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
					return '<a href="' + url + '">' + url + '</a>';
				}).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
					return  reply.charAt(0)+'<a href="http://twitter.com/' + reply.substring(1) + '">' + reply.substring(1) + '</a>';
				});
			
			return '<li><span>' + status + '</span></li>';
		}).join('');
		
		$('#twitter_update_list').html(tweets);
	}
	
	$.getJSON('http://twitter.com/statuses/user_timeline/CallingGlory.json?callback=?&count=10', twitterCallback);
})(jQuery);
