$(function() {
	$('a[rel=external]').each(function(indx) {
		this.target = "_blank";
	});
});
Number.prototype.times = function(fn) {
	if (fn instanceof Function) {
		for (var i=0; i < this; i++) {
			fn(i+1);
		};
	};
};
Function.prototype.delay = function(ms) {
	setTimeout(this,ms);
};

/**
 * Nav
 */
$(function() {
	var duration = 225;
	$("#nav > ul > li").each(function() {
		var fn = this;
		var ul = $(this).find("> ul");
		if (ul.length == 0)
			return;
		var a = $(this).find("> a");
		var isOverSubnav = false;
		var closeFunc = function() {
			if (!isOverSubnav) {
				$(ul).stop();
				$(ul).animate({
					height: 0
				},duration,function() {
					$(a).removeClass("over");
				});
			};
		};
		$(ul).bind("mouseout",function(evt) {
			isOverSubnav = false;
			closeFunc.delay(100);
		});
		$(this).bind("mouseout",function(evt) {
			isOverSubnav = false;
			closeFunc.delay(100);
		});
		$(ul).bind("mouseover",function(evt) {
			isOverSubnav = true;
			$(a).addClass("over");
		});
		$(this).bind("mouseover",function(evt) {
			isOverSubnav = true;
			$(ul).stop();
			$(ul).animate({
				height: ul[0].scrollHeight
			},duration);
		});
	});
});
$.tablesorter.addParser({ 
	// set a unique id 
	id: 'financial_currency', 
	is: function(s) { 
		// return false so this parser is not auto detected 
		return false; 
	}, 
	format: function(s) { 
		// format your data for normalization 
		return s.replace(/\(/,"-").replace(/[^0-9\-\.]/g,"");
	}, 
	// set type, either numeric or text 
	type: 'numeric' 
});