function addHover()
{
	var menu = document.getElementById('menu');
	menu.className='hover';
}

function undoHover()
{
	var menu = document.getElementById('menu');
	menu.className='';
}

function clearSearch()
{
	var search = document.getElementById('s');
	if (search.value == 'Search')
	{
		search.value='';
	}
}

/**
 *
 * @access public
 * @return void
 **/


function regionArea(TheValue) {
        document.getElementById('region').value = TheValue;
     	document.search.submit()
}

/**
 *
 * @access public
 * @return void
 **/
function postCodeEnter(){
	usePointFromPostcode(document.getElementById('postcode').value,
    function (point) {
      	document.search.lat.value=point.lat();
    	document.search.lon.value=point.lng();
    	document.forms['search'].postcode.style.border = '1px solid #00cc00';
      });
}

function clearText(field){

    if (field.defaultValue == field.value)
    {
    	field.value = '';
    }
	else if (field.value == '')
	{
		field.value = field.defaultValue;
		document.search.lat.value=0;
    	document.search.lon.value=0;
	}

}

function clearTextNewsletter(field){

    if ('Your email address here' == field.value)
    {
    	field.value = '';
    }
	else if (field.value == '')
	{
		field.value = field.defaultValue;
		document.search.lat.value=0;
    	document.search.lon.value=0;
	}

}

jQuery(document).ready(function(){

	jQuery("#postcode").bind("keyup change click", function(){
		usePointFromPostcode(jQuery(this).val(),
    	function (point) {
	      	jQuery("#lat").val(point.lat());
	    	jQuery("#lon").val(point.lng());
	    	jQuery("#postcode").css("border", "1px solid #00cc00");
      	});
	});

	jQuery("#provider_postcode").bind("keyup change click", function(){
		usePointFromPostcode2(jQuery(this).val(),
    	function (point) {
	      	jQuery("#provider_lat").val(point.lat());
	    	jQuery("#provider_lon").val(point.lng());
	    	jQuery("#provider_postcode").css("border", "1px solid #00cc00");
      	});
	});

	jQuery("#seeker_postcode").bind("keyup change click", function(){
		usePointFromPostcode3(jQuery(this).val(),
    	function (point) {
	      	jQuery("#seeker_lat").val(point.lat());
	    	jQuery("#seeker_lon").val(point.lng());
	    	jQuery("#seeker_postcode").css("border", "1px solid #00cc00");
      	});
	});

	jQuery("#location_provider_postcode").bind("keyup change click", function(){
		usePointFromPostcode3(jQuery(this).val(),
    	function (point) {
	      	jQuery("#location_provider_lat").val(point.lat());
	    	jQuery("#location_provider_lon").val(point.lng());
	    	jQuery("#location_provider_postcode").css("border", "1px solid #00cc00");
      	});
	});

	jQuery("#signUpButton").bind("mouseover", function(){
		usePointFromPostcode3(jQuery("#seeker_postcode").val(),
    	function (point) {
	      	jQuery("#seeker_lat").val(point.lat());
	    	jQuery("#seeker_lon").val(point.lng());
	    	jQuery("#seeker_postcode").css("border", "1px solid #00cc00");
      	});
	});
});

String.prototype.toTitleCase = function() {
    return this.replace(/([\w&`'‘’"“.@:\/\{\(\[<>_]+-? *)/g, function(match, p1, index, title) {
        if (index > 0 && title.charAt(index - 2) !== ":" &&
        	match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\.?|via)[ \-]/i) > -1)
            return match.toLowerCase();
        if (title.substring(index - 1, index + 1).search(/['"_{(\[]/) > -1)
            return match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2);
        if (match.substr(1).search(/[A-Z]+|&|[\w]+[._][\w]+/) > -1 ||
        	title.substring(index - 1, index + 1).search(/[\])}]/) > -1)
            return match;
        return match.charAt(0).toUpperCase() + match.substr(1);
    });
};
