/* Jquery for gallery page 
	Copyright 2008 Ambient Age
	www.ambientage.com
*/

$(document).ready(function()
{	
// gallery page mouseovers & captions
	$('.photo a span').css({visibility: 'hidden'});
	
	$('.photo').mouseover(function(){
		$(this).find('img').css({opacity: '0.4', filter: 'alpha(opacity=60)'});		
		$(this).find('span').css({color: '#000', textAlign: 'center', fontSize: '0.8em', display: 'block', paddingBottom: '0px', visibility: 'visible'});
		});
	$('.photo').mouseout(function(){
		$(this).find('img').css({filter: 'alpha(opacity=100)', opacity: '1.0', marginTop: '10px'});
		$(this).find('span').show().css({paddingBottom: '0px', visibility: 'hidden'});
	});
	
});	// end document.ready(function)

// validate contact form inputs
function contactValidate()
{
	var n = document.getElementById("cname");
	var e = document.getElementById("cemail");
	var c = document.getElementById("ccomment");
	
	if(n.value == "" || !isNaN(n.value))
	{
		doFormError("cname", "Please Enter a Name");
		return false;
	}
	else if(e.value == "" || e.value.indexOf("@") == -1 || e.value.indexOf("@") != e.value.lastIndexOf("@"))
	{
		doFormError("cemail", "Please Enter a Valid Email");
		return false;
	}
	else if(e.value.indexOf(".") == -1)
	{
		doFormError("cemail", "Please Enter a Valid Email");
		return false;
	}
	else if(c.value == "")
	{
		doFormError("ccomment", "Please Enter a Message");
		return false;
	}
	return true;	
}

/*
	Provide Contact Form Feedback on
	validation failure
*/
function doFormError(errField, msg)
{
	$(".form_error").hide().empty();
	var ef = errField + "_err";
	$("#"+ ef).append(document.createTextNode(msg)).fadeIn("slow");
	
	return;
}