$(function(){
	$('.navHover').hover(function(){
		$this = $(this);
		hoverOver($this);
	},function(){
		$this = $(this);
		hoverOut($this);
	});
	$('input.searchbox').focus(function(){
		$(this).prev().addClass('glow');
	}).blur(function(){
		$(this).prev().removeClass('glow');
	});
	$('input.go').mouseover(function(){
		$(this).addClass('glow');
	}).mouseout(function(){
		$(this).removeClass('glow');
		$(this).removeClass('gactive');
	}).mousedown(function(){
		$(this).removeClass('glow');
		$(this).addClass('gactive');
	}).mouseup(function(){
		$(this).removeClass('gactive');
	});
	$('input#submit').mouseover(function(){
		$(this).addClass('glow');
	}).mouseout(function(){
		$(this).removeClass('glow');
		$(this).removeClass('gactive');
	}).mousedown(function(){
		$(this).removeClass('glow');
		$(this).addClass('gactive');
	}).mouseup(function(){
		$(this).removeClass('gactive');
	});
	$('textarea').before('<div class="absolute textareaBG"></div>');
	$('a[rel^=lightbox]').addClass('noborder');
});
function setActiveNav()
{
	var wloc = window.location.href;
	var photo = /\/index.php\/photographs/;
	var projects = /\/index.php\/projects/;
	var comments =  /\/index.php\/contact/;
	if(photo.test(wloc))
	{
		clearActive($('#photos'));
	}
	else if(projects.test(wloc))
	{
		clearActive($('#projects'));
	}
	else if(comments.test(wloc))
	{
		clearActive($('#comments'));
	}
	else
	{
		clearActive($('#home'));
	}
}
function clearActive($el)
{
		$el.addClass('active');
		setNavButtonImage();
}
function setNavButtonImage()
{
	$('.active').children('a').find('.absolute').addClass('active');
	$('.active').children('div:first').find('.absolute').addClass('s_active');
}
function hoverOver(el)
{
	if(!el.parent().parent().hasClass('active'))
	{
		$spot = el.parent().prev('div');
		$btn = el.children('div');
		$spot.children('div').stop().animate({opacity:0},'slow');
		$btn.stop().animate({opacity:0},'slow');
	}
}
function hoverOut(el)
{
	if(!el.hasClass('active'))
	{
		$spot = el.parent().prev('div');
		$btn = el.children('div');
		$spot.children('div').stop().animate({opacity:1},'slow');
		$btn.stop().animate({opacity:1},'slow');
	}
}