sfHover = function() {

	var sfEls = document.getElementById("nav").getElementsByTagName("LI");

	for (var i=0; i<sfEls.length; i++) {

		sfEls[i].onmouseover=function() {

			this.className+=" sfhover";

		}

		sfEls[i].onmouseout=function() {

			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");

		}

	}

}

if (window.attachEvent) window.attachEvent("onload", sfHover);

function clearval(txt)

			{	

				document.getElementById(txt).value ='';

			}

			

			function noinput(txt)

			{

				if(document.getElementById(txt).value =='')

				{

					document.getElementById(txt).value = txt;

				}

			}
			
$(document).ready(function(){

				//To switch directions up/down and left/right just place a "-" in front of the top/left attribute

				//Caption Sliding (Partially Hidden to Visible)

				$('.boxgrid.caption').hover(function(){

					$(".cover", this).stop().animate({top:'80px'},{queue:false,duration:160});

				}, function() {

					$(".cover", this).stop().animate({top:'220px'},{queue:false,duration:160});

				});

			}
			
				$('form#contactForm').submit(function() {
		$('form#contactForm .error').remove();
		var hasError = false;
		$('.requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '') {
				var labelText = $(this).prev('label').text();
				$(this).parent().append('<span class="error">You forgot to enter your '+labelText+'.</span>');
				hasError = true;
			} else if($(this).hasClass('email')) {
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				if(!emailReg.test(jQuery.trim($(this).val()))) {
					var labelText = $(this).prev('label').text();
					$(this).parent().append('<span class="error">You entered an invalid '+labelText+'.</span>');
					hasError = true;
				}
			}
		});
		if(!hasError) {
			$('form#contactForm li.buttons button').fadeOut('normal', function() {
				$(this).parent().append('<img src="/wp-content/themes/blueskies/loading.gif" alt="Loading&hellip;" height="31" width="31" />');
			});
			var formInput = $(this).serialize();
			$.post($(this).attr('action'),formInput, function(data){
				$('form#contactForm').slideUp("fast", function() {				   
					$(this).before('<p class="thanks"><strong>Thanks!</strong> Your email was successfully sent. I check my email all the time, so I should be in touch soon.</p>');
				});
			});
		}
		
		return false;
		
	});
			
			
			);

function validate_email(field,alerttxt)

{

with (field)

  {

  apos=value.indexOf("@");

  dotpos=value.lastIndexOf(".");

  if (apos<1||dotpos-apos<2)

    {alert(alerttxt);return false;}

  else {return true;}

  }

}

function validate_required(field,alerttxt,caption)

{

with (field)

  {

  if (value==null||value=="" || value==caption)

    {

    alert(alerttxt);return false;

    }

  else

    {

    return true;

    }

  }

}



function validate_form(thisform)

{

with (thisform)

  {

  if (validate_required(name,"Name must be filled out!","Name:")==false)

  {name.focus();return false;}

if (validate_email(email,"Email must be filled out!")==false)

  {email.focus();return false;}

if (validate_required(phone,"Phone must be filled out!","Phone:")==false)

  {phone.focus();return false;}

if (validate_required(message,"Message must be filled out!","Message:")==false)

  {message.focus();return false;}

if (validate_required(capcha,"Message must be filled out!","Capcha:")==false)

  {capcha.focus();return false;}  
  
  }



}			
