$(document).ready(function() {
	
	//$('.imageBox a').live('click', lightBox());
	
	// we may already have a #id, if so
	// we should activate it
	var address = location + "";
	
	var lastIndex = address.lastIndexOf('#');
	
	if (lastIndex != -1) {
		// we do have an #id
		var id = address.substring(lastIndex + 1, address.length);
		//$('div#entryBox').load('/clarkdave.net/portfolio/loader.php?id=' + id);
		
		if (id) {
			
			$.get('/portfolio/loader.php?id=' + id, function(data) {
				entryHTML = data;
				$('div#entryBox').show();
				//$('div#entryBox').html(entryHTML + "<div class='closeBox'><a href='#'>close</a></div>");
				
				$('div#entryBox').html(entryHTML);
				
				
				$('div#entryBox div.closeBox a').click(function() {
					$('div#entryBox').hide();
				});
			});
			
		}
	}
	
	// we need to iterate our portfolioLinks
	// and build a list of their IDs
	$('a.portfolioLink').each(function() {
		
		// get the href
		var href = $(this).attr('href');
		
		// get the index of the preceeding '/'
		var lastIndex = (href.lastIndexOf('/', href.length - 2));
		
		// get the id
		var id = href.substring(lastIndex + 1, href.length - 1);
		
		$(this).attr('href', '#' + id);
		
		$(this).click(function() {
			//$('div#entryBox').load('/clarkdave.net/portfolio/loader.php?id=' + id);
			$.get('/portfolio/loader.php?id=' + id, function(data) {
			entryHTML = data;
				$('div#entryBox').show();
				//$('div#entryBox').html(entryHTML + "<div class='closeBox'><a href='#'>close</a></div>");
				$('div#entryBox').html(entryHTML);
				$('div#entryBox div.closeBox a').click(function() {
					$('div#entryBox').hide();
				});
			});
		});
		
	});
});