// set the colour variable
var colour = "<?= $logo_colour ?>";


// search function
	function validateSearchForm() {
        if (!document.search_form.q.value) {

            alert('Please enter a keyword to seach for.');
            return false;
        }

        if (document.search_form.q.value.length<3) {

            alert('Sorry that keyword is too short.');
            return false;
        }

        return true;
    }


// search function
	function submitSearch() {
  	  return validateSearchForm();
 
      }



// login linting
	function errorCheck () {
		
		var errors='';
		var email = /^.+\@.+\..+$/;			

		if (document.loginbox.email.value == '' || email.test(document.loginbox.email.value) == false) {
			errors+='The email address you entered is not in the correct format. Please check.\n';
		}

		if (document.loginbox.password.value == '') {
			errors+='Please enter your password.\n';
		}
			
		if (errors) {
			alert('The following error(s) occurred:\n'+errors);
			return false;
		}
			
		return true;	
	} // end errorCheck
		
	function submitLogin() {

		if (errorCheck()) {
			document.loginbox.submit();
		}
			return false;
	}
	

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
else 
	countfield.value = maxlimit - field.value.length;
}

