function checkForm()

{

  var valid = true;

	for (i=0; i < this.length; i++)

	{

		if ($(this[i]).hasClass("compulsory"))

		{

			var type = this[i].type.toLowerCase();

			if (type == "textarea" || type == "text" || type == "password"){

				if (this[i].value == this[i].defaultValue || this[i].value == "")

				{

				  $(this[i]).addClass("errorField");	

				 	valid = false;

				}

				else

				{

				  $(this[i]).removeClass("errorField");				

				}

			}

			else 

			{

				if (type == "checkbox" && !this[i].checked)

				{

				 	valid = false;

				}

			}

		}

	}

	if(!valid)

	{

		alert('Please fill in required fields.')

	}

	else

	{

		for (i=0; i < this.length; i++)

		{

			var type = this[i].type.toLowerCase();

			if (type == "textarea" || type == "text" || type == "password")

			{

				if(this[i].value == this[i].defaultValue)

				{

					this[i].value = '';

				}

			}

		}		

	}

	return valid;

}



function checkValue ()

{

	if(this.value == this.defaultValue)

	{

		this.value = "";

	}

	else if(this.value=="")

	{

		this.value = this.defaultValue;

	}

}



$(document).ready(function(){
  
  $('#billboard').crossSlide({
    //speed: 25,
    sleep: 5,
    fade: 1
  }, [
    { src: '/images/header/4.jpg'/*, dir: 'up'*/ },
    { src: '/images/header/2.jpg' },
    { src: '/images/header/3.jpg' },
 
    { src: '/images/header/5.jpg' },
    { src: '/images/header/6.jpg' },
    { src: '/images/header/7.jpg' }
  ]);

  $("#contactForm").bind("submit", checkForm);

  $("#contactForm textarea, #contactForm input[type='text']").each(function(){

    $(this).bind("focus", checkValue);

    $(this).bind("blur", checkValue);

  });

});
