$(document).ready(function(){

$(".home-right-box .bottom").hide();

//MAIN NAVIGATION
$(".home-right-box").hover(			   
	function () {
      $(this).children(".sliderbox").children(".bottom").slideDown('slow');
    }, 
    function () {
      $(this).children(".sliderbox").children(".bottom").slideUp('slow');

    }
  );



});



Cufon.replace('h1');
Cufon.replace('h2');









// APPLICATION FORM
function applicationForm() {
	var position = $('input[name="position"]').val();
	var first_names = $('input[name="first-names"]').val();
	var surname = $('input[name="surname"]').val();
	var title = $('input[name="title"]').val();
	var telephone = $('input[name="telephone"]').val();
	
	if (position && first_names && surname && title && telephone) {
		return true;		
	} else {
		alert('Please fill out all form fields marked with *');
		return false;
	}
}


//Enquiry form
function enquiryForm(){
	var name= $("input[name='name']").val();
	var email= $("input[name='email']").val();
	var message= $("textarea").val();
	
	if(name && email && message){
		
		if(validateEmail(email) == true){
			return true;		
		}
		
		else{
			return false;
		}
	}
	
	else{
		alert('Please fill out all form fields');
		return false;
	}
	
	
}





//Validate Email Function, this returns True if correct
function validateEmail(str){
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		var error_check = false;
		
		if (str.indexOf(at)==-1){
		   error_check = true;

		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   error_check = true;

		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    error_check = true;

		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    error_check = true;
	
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    error_check = true;
	
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    error_check = true;

		 }
		
		 if (str.indexOf(" ")!=-1){
		    error_check = true;

		 }
		 
		 if(error_check == false){
			 return true;
			 
		 }
		 
		 else{
			
			if (str==null || str==""){
				alert("Please Enter your Email Address");

			}
	
			else {
				alert("'" + str + "' is not a valid email address!");
				return false;

			}
		 }	
}
