$().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(){}
    });

    // Show/Hide More Completed Projects
	var $moreProj = $('#moreProjects');
	var $control = $('#projViewToggleSpan');
	var height = $moreProj.height();
	$moreProj.hide().css({ height : 0 });
	$control.click(function () {
	  if ( $moreProj.is(':visible') ) {
	    $control.empty().append('<img id="moreProjsToggle" src="./images/header-viewMoreProjs.png" alt="View More Projects" />');
	    $moreProj.animate({ height: 0 }, { duration: 1500, complete: function () {
	        $moreProj.hide();
	      }
	    });
	  }
	  else
	  {
	    $moreProj.show().animate({ height : height }, { duration: 1500, complete: function () { 
	    	$control.empty().append('<img id="moreProjsToggle" src="./images/header-hideMoreProjs.png" alt="View Less Projects" />'); 
	    	}
	    });
	  }
	  return false;
	});

	
    // 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});
		}
	});

	// Expand/Contract About PRS
	var $moreAbout = $('#commentForm');
	var $expandLink = $('#moreAbout');
	var $closeLink = $('#moreAboutClose');
	$closeLink.click(function(){$moreAbout.hide('fast');})
	$expandLink.toggle(
	function()
	{
		$moreAbout.show('fast');
	},
	function()
	{
		$moreAbout.hide('fast');
	});

});

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;
    }
}

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
