// jQuery newWin Plugin 1.0.1 (20100315)
// By John Terenzio | http://plugins.jquery.com/project/newwin | MIT License
(function($){$.fn.newWin=function(){return this.each(function(){if(this.protocol=='http:'&&this.hostname!=location.hostname){$(this).click(function(){open(this.href);return false;});}});};})(jQuery);

/*
 * jQuery hashchange event - v1.2 - 2/11/2010
 * http://benalman.com/projects/jquery-hashchange-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);

// Minus Ned JS
(function(){
	// external links open in a new window
	$('a').newWin();

	// ajax navigation
	$(window).bind('hashchange',function(){
		$('a').each(function(){
			if (this.hostname == location.hostname && (this.hash == location.hash || (!this.hash && location.hash == '#'))) {
				$(this).addClass('active');
			} else {
				$(this).removeClass('active');
			}
		});
		$.hashCache = $.hashCache || $('#content').html();
		var file = location.hash.substring(1);
		if (file) {
			$('#content').load('/pages/'+file+'.html', function(){
				$('#content a').newWin();
			});
		} else {
			$('#content').html($.hashCache);
			$('#content a').newWin();
		}
	});
	$(window).trigger('hashchange');

	// join mailing list form
	var ph = 'Your email. Our mailing list.';
	$('#signup input').click(function(){
		if ($(this).val() == ph) {
			$(this).val('').css('color', '#000');
		}
	});
	$('#signup input').blur(function(){
		if (!$(this).val()) {
			$(this).val(ph).css('color', '#aaa');
		}
	});
	$('#signup input').trigger('blur').css('color', '#aaa');
	$('#signup img').click(function(){
		var email = $('#signup input').val();
		if (/^(([a-z0-9\-_.])+@(([a-z0-9\-])+\.)+([a-z0-9]{2,6}))+$/i.test(email)) {
			$.get('http://minusned.com/mail.php?action=signup&email='+encodeURI(email), function(data){
				alert(data);
				$('#signup input').val('').trigger('blur');
			});
		} else {
			alert('Please enter a valid email address!');
		}
	});
})();

