/*Original Design by Nettuts.com
**
** Modified by Patrick Eisenmann for support for lightbox.
** peisenmann@gmail.com
**
** To get it to work, your call to this file (as well as jquery.js and jquery.history.js) should be:
** <script type="text/javascript" src="js.js">var $j = jQuery.noConflict();</script>
** Change src="js.js" to whichever file you are calling.
**
**
** Modified by Andre Bluehs for support for .php.
**	contagious@gatech.edu
*/


$j(document).ready(function() {
					   
	$j('#content').wrap('<div id="content-wrapper"></div>');
						   
	function pageload(hash) {
		if(hash.substr(hash.length-3, hash.length) == "php") {
			$j("#content-wrapper").load(hash.substr(0,hash.length-3) + ".php #content",'',function(){
				$j('#content-wrapper').show('normal');
				$j('#load').fadeOut('normal');												   
			});
	}
		
/*		To add support for more file types, uncomment below, and change ...HERE...
**		to whatever you want to support. Also change ...NUMBER... to the length of
**		the name of the file type. i.e. php = 3, html = 4.
** 
**		else if(hash.substr(hash.length-...NUMBER..., hash.length) == "...HERE...") {
**			$j("#content-wrapper").load(hash.substr(0,hash.length-...NUMBER...) + "...HERE... #content",'',function(){
**				$j('#content-wrapper').show('normal');
**				$j('#load').fadeOut('normal');												   
**			});
**	}
*/

		else if(hash) {
			$j("#content-wrapper").load(hash + ".html #content",'',function(){
			
				$j('#content-wrapper').show('normal');
				$j('#load').fadeOut('normal');												   
			});
		} 
		
		else {
			$j("#content-wrapper").load("index.html #content", '', function(){}); //default
		}
	}
	
	$j.historyInit(pageload);			   

	$j('#nav li a').click(function(){
								  
		var hash = $j(this).attr('href');
		hash = hash.replace(/^.*#/, '');
		
		if (hash.substr(hash.length-3, hash.length) == "php") {
			hash = hash.substr(0, hash.length-4) + "php";
		}
/*		To add support for more file types uncomment below and change ...HERE...
**		to whatever you wish to support. also change ...NUMBER... to the length of 
** 		the name of the file type. i.e. php = 3, html = 4.
**
**		else if (hash.substr(hash.length-...NUMBER..., hash.length) == "...HERE...") {
**			hash = hash.substr(0, hash.length-...NUMBER...+1) + "...HERE...";
**		}
*/		
		else {
			hash = hash.substr(0,hash.length-5);
		}

		$j('#content-wrapper').hide('fast',function(){$j.historyLoad(hash)});
		$j('#load').remove();
		$j('#wrapper').append('<span id="load">LOADING...</span>');
		$j('#load').fadeIn('normal');
		return false;
		
	});

});
