//this stops the $ symbol shortcutting jQuery, so that it can be used with other libraries (in this case in the gallery with MooTools) 
jQuery.noConflict();

function setNav()
{
	jQuery('#nav1 li').click(function()
	{
		var id = jQuery(this).attr('id');
		var childID = jQuery(this).attr('title');
		
		if( childID == '' )	gotoPage( id );
		else				gotoPage( id + '/' + childID );
	});
	
	
	jQuery('#nav2 li').click(function()
	{
		var id = jQuery(this).attr('id');
		var childID = jQuery(this).attr('title');
		
		if( childID == '' )	gotoPage( id );
		else				gotoPage( id + '/' + childID );
	});
	
	
	jQuery('#nav3 li').click(function()
	{
		var id = jQuery(this).attr('id');
		gotoPage( id );
	});
	
	
	jQuery('#logo-hb').click(function()
	{
		if( ! isHome() ) window.location = 'http://' + window.location.hostname + '/index.php'; //isHome() is set in init-page.js
	});
}


function setProjectAssetThumbs()
{
	jQuery('.project-thumb').click(function()
	{
		var id = jQuery(this).attr('id');
		id = replaceSpecialChar( id );
		
		window.location = 'http://' + window.location.hostname + '/' + id + checkHasQuery(id);
	});
	
	jQuery('.project-thumb').mouseover(function()
	{
		jQuery(this).css('border-color', '#00b9f2') ;
	});
	
	jQuery('.project-thumb').mouseout(function()
	{
		jQuery(this).css('border-color', '#4988a4') ;
	});
}


function setDiaryH1Btns()
{
	
	jQuery('.diary-asset h1').click(function()
	{
		expandDiary( jQuery(this).parent() ); // in animate.js
	});
}


function replaceSpecialChar( str )
{
	str = str.split('-FSLASH-').join('/');
	str = str.split('-SPACE-').join(' ');
	str = str.split('-AMP-').join('&');
	str = str.split('-QUERY-').join('?');
	str = str.split('-EQUALS-').join('=');
	
	return str;
}


function gotoPage( id )
{
	id = replaceSpecialChar( id );
	//if( '/'+id != getNavName() ) 
	window.location = 'http://' + window.location.hostname + '/' + id + checkHasQuery(id);
}


function checkHasQuery( url )
{
	if( url.indexOf('?') == -1 )	return '.php';
	else							return '';
}

