$(document).ready(function(){

	$.get(
		"news.html", {}, function(data)
		{
			$("#ajaxnewsbox").append(data).find("ul").newsTicker();
		}
	)
	
	$('.error').hide();
  
	$(".contbutton").click(function() {  
    // validate and process form here  
		$('.error').hide();
		var name = $("input#name").val();
		if (name == "") {
	    $("label#nameerror").show();
    	$("input#name").focus();
	    return false;
    }
	
	var email = $("input#email").val();
	if (email == "" || email == null || email.length == 0 || email.indexOf("@.") > -1 || email.indexOf(".@") > -1 || email.indexOf("@@") > -1 || email.indexOf("..") > -1 || email.indexOf("@") < 1 || email.lastIndexOf(".") == 0 || email.indexOf(".") == email.length) {
    $("label#emailerror").show();
    $("input#email").focus();
    return false;
    }
	
	var contactno = $("input#contactno").val();
	if (contactno == "" || contactno == null || contactno == 0 || !IsNumeric(contactno)) {
    $("label#contactnoerror").show();
    $("input#contactno").focus();
    return false;
    }

	var message = $("textarea#message").val();
	if (message == "") {
      $("label#messageerror").show();
      $("textarea#message").focus();
      return false;
    }
	
	var verification = $("select#verification").val();
	if (verification != "3") {
      $("label#verificationerror").show();
      $("select#verification").focus();
      return false;
    }
	
	var dataString = '&name='+ name + '&email=' + email + '&message=' + message;
	$.ajax({
    type: "POST",
    url: "scripts/enquiry.php",
    data: dataString,
    success: function() {
      $('#contactform').html("<div id='success'></div>");
      $('#success').html("<h3>Thank you!</h3>")
      .append("<p>We will be in touch soon.</p>")
      .hide()
      .fadeIn(1500, function() {
        $('#success');
      });
    }
  });
  return false;
});



$(".textelement, .messagearea").hover(
  function()
  {
  $(this).addClass("inputhover");
}, 
function()
{
  $(this).removeClass("inputhover");
}
);

$(".textelement, .messagearea, .selectelement").focus(
  function()
  {
  $(this).addClass("inputfocus");
}
);
$(".textelement, .messagearea, .selectelement").blur(
  function()
  {
  $(this).removeClass("inputfocus");
}
);


$(".connect a img, .button_text").hover(
 function()
 {
  this.src = this.src.replace("_off","_on");
 },
 function()
 {
  this.src = this.src.replace("_on","_off");
 }
);

});
