(function($){
	var formats = {
		'%': function(val) {return '%';},
		'b': function(val) {return  parseInt(val, 10).toString(2);},
		'c': function(val) {return  String.fromCharCode(parseInt(val, 10));},
		'd': function(val) {return  parseInt(val, 10) ? parseInt(val, 10) : 0;},
		'u': function(val) {return  Math.abs(val);},
		'f': function(val, p) {return  (p > -1) ? Math.round(parseFloat(val) * Math.pow(10, p)) / Math.pow(10, p): parseFloat(val);},
		'o': function(val) {return  parseInt(val, 10).toString(8);},
		's': function(val) {return  val;},
		'x': function(val) {return  ('' + parseInt(val, 10).toString(16)).toLowerCase();},
		'X': function(val) {return  ('' + parseInt(val, 10).toString(16)).toUpperCase();}
	};

	var re = /%(?:(\d+)?(?:\.(\d+))?|\(([^)]+)\))([%bcdufosxX])/g;

	var dispatch = function(data){
		if(data.length == 1 && typeof data[0] == 'object') { //python-style printf
			data = data[0];
			return function(match, w, p, lbl, fmt, off, str) {
				return formats[fmt](data[lbl]);
			};
		} else { // regular, somewhat incomplete, printf
			var idx = 0; // oh, the beauty of closures :D
			return function(match, w, p, lbl, fmt, off, str) {
				return formats[fmt](data[idx++], p);
			};
		}
	};

	$.extend({
		sprintf: function(format) {
			var argv = Array.apply(null, arguments).slice(1);
			return format.replace(re, dispatch(argv));
		},
		vsprintf: function(format, data) {
			return format.replace(re, dispatch(data));
		}
	});
})(jQuery);

	(function($){
	    if(!$.sus){
	        $.sus = new Object();
	    }		
	    $.sus.AquaCaption = function(el, options){
	        var base = this;
	        base.$el = $(el);
	        base.el = el; 
	        base.$el.data("sus.AquaCaption", base);
	        
	        base.init = function(){
	            base.options = $.extend({},$.sus.AquaCaption.defaultOptions, options);
	        	base.$el.hover(
	        		function(e){
	        			base.$el.find(base.options.sel).show()
	        		},function(e){
	        			base.$el.find(base.options.sel).hide()
	        		}
	        	);
	        }
	        base.init();
	    }
	    $.sus.AquaCaption.defaultOptions = {
	        sel: ".caption"
	    }
	    $.fn.sus_AquaCaption = function(options){
	        return this.each(function(){
	            (new $.sus.AquaCaption(this, options));
	        });
	    }
	    $.fn.getsus_AquaCaption = function(){
	        return this.data("sus.AquaCaption");
	    }
		/*********   onload here  ************/
		$(function(){
		
			$('.sd-item').live('mouseover',function(e){$(this).find('.bd-left-item-title').show()}).live('mouseout',function(e){$(this).find('.bd-left-item-title').hide()})
				.click(function(e){location.href=$(this).find('a:first').attr('href')})

/*
			$('.widget-title').toggle(function(e){
				$(this).closest('.widget').siblings().height(25)
				$(this).closest('.widget').height('auto');
			}, function(e){
				$(this).closest('.widget').height(25);
			})
*/			

			
			$('div.wp-caption').hover(
				function(e){
					$(this).find('p').show();
				},function(e){
					$(this).find('p').hide();
				}
			);
			$('#sidebarsearch, #cfct-search-input').focus(function(){
				if($(this).val() == 'SEARCH'){
					$(this).val('').css({backgroundColor:'aqua',color:'black'})
				}
			}).blur(function(){
				if($(this).val() == ''){
					$(this).val('SEARCH').css({backgroundColor:'black',color:'#e0e0d7'})
				}
			})
		
			$('.widget_links a, .widget_twitter a').mousedown(function(e){
				$(this).attr('target','_new')
				}
			)

		$('#primary-sidebar img').hover(
			function(){
				this.src=$(this).attr('src').replace(/a\.png$/,'b.png');;
			},
			function(){
				this.src=$(this).attr('src').replace(/b\.png$/,'a.png');
			}
		).load(
			function(){
				$(this).load(function(){}); 
				this._i = (new Image(188,30)).src = $(this).attr('src').replace(/a\.png$/,'b.png')
			}
		);

			$('x\\:ts').each(function(){
				$(this).html('<div class="ts-env">\
		<div class="ts-img"><a href="' +$(this).attr('url')+ '" target="_external"><img width="457" height="104" src="' +$(this).attr('img')+ '"/></a></div>\
		<div class="ts-msg">\
			<h2 class="caslon">Today\'s Sponsor: ' +$(this).attr('who')+ '</h2>\
			<p>' +$(this).attr('msg')+ '</p>\
		</div>\
				</div>\
				').hover(function(){$(this).find('.ts-msg').toggle()})
				Cufon.refresh();
			})
		})
		
	})(jQuery)

