$().ready(function() 
{ 
	// prettyWindow
	$("a[rel^='prettyPhoto']").prettyPhoto({
        animationSpeed: 'fast', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
        opacity: 0.35, /* Value betwee 0 and 1 */
        showTitle: true, /* true/false */
        allowresize: true, /* true/false */
        counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
        theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
        callback: function(){}
    });
	
	var $csabrams = $('#cs_abrams');
	var $cs360    = $('#cs_360');
	
	$('#cs_button_abrams').click(function ()
	{
		$csabrams.toggle('fast');	
	});
	
	$('#cs_button_360').click(function ()
	{
		$cs360.toggle('fast');	
	});


	// Raise/Lower Contact Bar
	$('.contactjq, #contactArrow').click(function(event) {
		var $footer = $('#footerwrap');
		var $arrow = $('#contactArrow');
		if ($footer.height() < 160)
		{
			$arrow.attr('src','./images/arrowDown.png');
			$footer.animate({'height':250},{duration:'slow',queue:false});
		}
		else
		{
			$arrow.attr('src','./images/arrowUp.png');
			$footer.animate({'height':70},{duration:'slow',queue:false});
		}
	});

	// Submit the contact form via AJAX
	$('#sendnow').click(function() {
		//Form Validation
		var fromname = $('#fromname').val();
		var fromemail = $('#fromemail').val();
		var message = $('#message').val();
		if (fromname == '')
		{
			alert('Please include your name with your email...');
			$('#fromname').addClass('error').focus();
			return false;
		}
		if (isValidEmail(fromemail) == false)
		{
			alert('Please include your email address so that we may get back to you...');
			$('#fromemail').addClass('error').select();
			return false;
		}
		if (message == '')
		{
			alert('Please include a message with your email...');
			$('#message').addClass('error').focus();
			return false;
		}

		// Good submit, run the process
		$('#contact').append('<div id="removeme" >Sending email...</div>');

		$.post('./',{'ajax':1,'operation':'contactSubmit','fromname':fromname,'fromemail':fromemail,'message':message},function(data){$('#removeme').remove();$('#contact').append(data);});
	});
});

function isValidEmail(e)
{
	var email  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (email.test(e) == false)
	{
      return false;
    }
    else
    {
      return true;
    }
}