function Node ( options ) {
	options = options || {};
	
	for ( o in options ) {
		this[o] = options[o];
	}
	var defaults = {
		id : (""+Math.random()).substring(2),
		location : { x : 0, y : 0 },
		exits : {}
	}
	for ( d in defaults ) {
		if ( this[d] == null ) {
			this[d] = defaults[d];
		}
	}

	this.location.x = this.location.x;/* + Math.randomInt(-5,5);*/
	this.location.y = this.location.y;/* + Math.randomInt(-5,5);*/

	this.title = options.title || "Chapter " + this.id;

	this.visit = function ( ) {
		var ns = MAP.getNodes();
		for ( var i = 0, n; n = ns[i]; i ++ ) {
			if ( n.className.match ( /^node( |$)/ ) ) {
				n.className = n.className.replace(/\bactive\b/,"").replace(/^\s*|\s*$/,"");
			}
		}
		this.show();
		if ( !visited ) {
			node.className += " visited";
		}
		node.className += " active";
		visited = true;
		if ( this.exits == null ) this.exits = {};
		for ( e in this.exits ) {
		    if ( this.directionOption( e ) ) {
                MAP.join ( NODES[this.id], NODES[this.exits[e].id] );   
		    }
		}
	}
	this.show = function ( ) {
		node.innerHTML = this.title;
		node.title = this.title;
		MAP.appendChild ( node );
	}
	this.directionOption = function ( direction, visited ) {
	    var exit = this.exits[direction];
	    if (exit && exit.prereq) {
	        if (("."+MAP.visited+".").indexOf("."+exit.prereq+".") > -1) {
	            return exit;
	        } else {
	            return null;
	        }
        } else {
            return exit;
        }
	}

	var visited = false;
	var node = document.createElement('li');
	node.className = "node";
	node.id = "node_chapter" + this.id;
	node.style.left = ( this.location.x - 5 ) + "px";
	node.style.top = ( this.location.y - 5 ) + "px";
};

var NODES = {
    1 : new Node ( {
    	id : 1,
    	title : '1',
    	location : { x : 200, y : 50 },
    	contentUrl : '/stories/week6/text/1/',
    	exits : {
    	    
    	    
    	    S : { id : 2, text : 'Begin reading the story' }
    	    
    	}
    } ),
    2 : new Node ( {
    	id : 2,
    	title : '2',
    	location : { x : 200, y : 120 },
    	contentUrl : '/stories/week6/text/2/',
    	exits : {
    	    N : { id : 1, text : 'Return to instructions' },
    	    E : { id : 3, text : 'Leave your office' },
    	    S : { id : 13, text : 'Listen to Shaan Azad\&#39;s tale' },
    	    W : { id : 21, text : 'Reminisce about your childhood' }
    	}
    } ),
    3 : new Node ( {
    	id : 3,
    	title : '3',
    	location : { x : 300, y : 120 },
    	contentUrl : '/stories/week6/text/3/',
    	exits : {
    	    N : { id : 9, text : 'Proceed to your recording studio' },
    	    E : { id : 8, text : 'Leave the hallway', prereq : 8 },
    	    S : { id : 4, text : 'Proceed to your meeting' },
    	    W : { id : 2, text : 'Return to your office' }
    	}
    } ),
    4 : new Node ( {
    	id : 4,
    	title : '4',
    	location : { x : 275, y : 155 },
    	contentUrl : '/stories/week6/text/4/',
    	exits : {
    	    N : { id : 3, text : 'Leave the meeting' },
    	    
    	    S : { id : 5, text : 'Greet the other guest' }
    	    
    	}
    } ),
    5 : new Node ( {
    	id : 5,
    	title : '5',
    	location : { x : 300, y : 185 },
    	contentUrl : '/stories/week6/text/5/',
    	exits : {
    	    N : { id : 4, text : 'Greet the other guest' },
    	    E : { id : 6, text : 'Turn to the windows' }
    	    
    	    
    	}
    } ),
    6 : new Node ( {
    	id : 6,
    	title : '6',
    	location : { x : 350, y : 185 },
    	contentUrl : '/stories/week6/text/6/',
    	exits : {
    	    N : { id : 7, text : 'Ask about the agenda' },
    	    
    	    
    	    W : { id : 5, text : 'Turn to your first guest' }
    	}
    } ),
    7 : new Node ( {
    	id : 7,
    	title : '7',
    	location : { x : 375, y : 155 },
    	contentUrl : '/stories/week6/text/7/',
    	exits : {
    	    N : { id : 8, text : 'Leave the meeting' },
    	    
    	    S : { id : 6, text : 'Turn to the windows' }
    	    
    	}
    } ),
    8 : new Node ( {
    	id : 8,
    	title : '8',
    	location : { x : 350, y : 120 },
    	contentUrl : '/stories/week6/text/8/',
    	exits : {
    	    N : { id : 12, text : 'Proceed to your recording studio' },
    	    
    	    S : { id : 7, text : 'Proceed to your meeting' },
    	    W : { id : 3, text : 'Return to the hallway' }
    	}
    } ),
    9 : new Node ( {
    	id : 9,
    	title : '9',
    	location : { x : 275, y : 85 },
    	contentUrl : '/stories/week6/text/9/',
    	exits : {
    	    N : { id : 10, text : 'Speak to the producer' },
    	    
    	    S : { id : 3, text : 'Leave the studio' }
    	    
    	}
    } ),
    10 : new Node ( {
    	id : 10,
    	title : '10',
    	location : { x : 300, y : 50 },
    	contentUrl : '/stories/week6/text/10/',
    	exits : {
    	    
    	    E : { id : 11, text : 'Glance at Shaan Azad' },
    	    S : { id : 9, text : 'Examine the studio' }
    	    
    	}
    } ),
    11 : new Node ( {
    	id : 11,
    	title : '11',
    	location : { x : 350, y : 50 },
    	contentUrl : '/stories/week6/text/11/',
    	exits : {
    	    
    	    
    	    S : { id : 12, text : 'Examine the studio' },
    	    W : { id : 10, text : 'Speak to the producer' }
    	}
    } ),
    12 : new Node ( {
    	id : 12,
    	title : '12',
    	location : { x : 375, y : 85 },
    	contentUrl : '/stories/week6/text/12/',
    	exits : {
    	    N : { id : 11, text : 'Glance at Shaan Azad' },
    	    
    	    S : { id : 8, text : 'Leave the studio' }
    	    
    	}
    } ),
    13 : new Node ( {
    	id : 13,
    	title : '13',
    	location : { x : 200, y : 185 },
    	contentUrl : '/stories/week6/text/13/',
    	exits : {
    	    N : { id : 2, text : 'Turn your attention to your office' },
    	    E : { id : 14, text : 'Say, \&quot;Tell it one way.\&quot;' },
    	    
    	    W : { id : 20, text : 'Say, \&quot;Tell it the other way\&quot;' }
    	}
    } ),
    14 : new Node ( {
    	id : 14,
    	title : '14',
    	location : { x : 250, y : 185 },
    	contentUrl : '/stories/week6/text/14/',
    	exits : {
    	    
    	    
    	    S : { id : 15, text : 'Continue the story one way' },
    	    W : { id : 13, text : 'Continue it the other way' }
    	}
    } ),
    15 : new Node ( {
    	id : 15,
    	title : '15',
    	location : { x : 275, y : 210 },
    	contentUrl : '/stories/week6/text/15/',
    	exits : {
    	    N : { id : 14, text : 'Continue it the other way' },
    	    
    	    S : { id : 16, text : 'Continue the story one way' }
    	    
    	}
    } ),
    16 : new Node ( {
    	id : 16,
    	title : '16',
    	location : { x : 250, y : 245 },
    	contentUrl : '/stories/week6/text/16/',
    	exits : {
    	    N : { id : 15, text : 'Continue it the other way' },
    	    
    	    
    	    W : { id : 17, text : 'Continue the story one way' }
    	}
    } ),
    17 : new Node ( {
    	id : 17,
    	title : '17',
    	location : { x : 200, y : 245 },
    	contentUrl : '/stories/week6/text/17/',
    	exits : {
    	    
    	    E : { id : 16, text : 'Continue it the other way' },
    	    
    	    W : { id : 18, text : 'Continue the story one way' }
    	}
    } ),
    18 : new Node ( {
    	id : 18,
    	title : '18',
    	location : { x : 150, y : 245 },
    	contentUrl : '/stories/week6/text/18/',
    	exits : {
    	    N : { id : 19, text : 'Continue the story one way' },
    	    E : { id : 17, text : 'Continue it the other way' }
    	    
    	    
    	}
    } ),
    19 : new Node ( {
    	id : 19,
    	title : '19',
    	location : { x : 125, y : 210 },
    	contentUrl : '/stories/week6/text/19/',
    	exits : {
    	    N : { id : 20, text : 'Continue the story one way' },
    	    
    	    S : { id : 18, text : 'Continue it the other way' }
    	    
    	}
    } ),
    20 : new Node ( {
    	id : 20,
    	title : '20',
    	location : { x : 150, y : 185 },
    	contentUrl : '/stories/week6/text/20/',
    	exits : {
    	    
    	    E : { id : 13, text : 'Continue the story one way' },
    	    S : { id : 19, text : 'Continue it the other way' }
    	    
    	}
    } ),
    21 : new Node ( {
    	id : 21,
    	title : '21',
    	location : { x : 150, y : 120 },
    	contentUrl : '/stories/week6/text/21/',
    	exits : {
    	    N : { id : 22, text : 'Reflect upon your first fight' },
    	    E : { id : 2, text : 'Turn your attention to your office' },
    	    S : { id : 26, text : 'Reflect upon your rooftop' },
    	    W : { id : 24, text : 'Reflect upon your schoolwork' }
    	}
    } ),
    22 : new Node ( {
    	id : 22,
    	title : '22',
    	location : { x : 125, y : 85 },
    	contentUrl : '/stories/week6/text/22/',
    	exits : {
    	    N : { id : 23, text : 'Recall that morning\&#39;s events' },
    	    
    	    S : { id : 21, text : 'Reminisce about your childhood' }
    	    
    	}
    } ),
    23 : new Node ( {
    	id : 23,
    	title : '23',
    	location : { x : 100, y : 50 },
    	contentUrl : '/stories/week6/text/23/',
    	exits : {
    	    
    	    
    	    S : { id : 22, text : 'Reflect upon your first fight' }
    	    
    	}
    } ),
    24 : new Node ( {
    	id : 24,
    	title : '24',
    	location : { x : 100, y : 120 },
    	contentUrl : '/stories/week6/text/24/',
    	exits : {
    	    
    	    E : { id : 21, text : 'Reminisce about your childhood' },
    	    
    	    W : { id : 25, text : 'Recall that night\&#39;s events' }
    	}
    } ),
    25 : new Node ( {
    	id : 25,
    	title : '25',
    	location : { x : 50, y : 120 },
    	contentUrl : '/stories/week6/text/25/',
    	exits : {
    	    
    	    E : { id : 24, text : 'Reflect upon your schoolwork' }
    	    
    	    
    	}
    } ),
    26 : new Node ( {
    	id : 26,
    	title : '26',
    	location : { x : 125, y : 155 },
    	contentUrl : '/stories/week6/text/26/',
    	exits : {
    	    N : { id : 21, text : 'Reminisce about your childhood' },
    	    
    	    S : { id : 27, text : 'Recall that evening\&#39;s events' }
    	    
    	}
    } ),
    27 : new Node ( {
    	id : 27,
    	title : '27',
    	location : { x : 100, y : 185 },
    	contentUrl : '/stories/week6/text/27/',
    	exits : {
    	    N : { id : 26, text : 'Reflect upon your rooftop' }
    	    
    	    
    	    
    	}
    } )
    
}
