// Search Toggler	
function toggleSearch()
{
	if(document.getElementById("search-box").style.display == 'block')
	{
		hideSearch();
	}
	else
	{
		showSearch();
	}
}

function hideSearch() {
		document.getElementById("search-box").style.display = 'none';
	
}
function showSearch(e) {
	document.getElementById("search-box").style.display = 'block';
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	return false;
}

function hideEnews() {
	document.getElementById("newsletter-dropdown").style.display = 'none';	
}

function showEnews(e) {
	document.getElementById("newsletter-dropdown").style.display = 'block';
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
		
	if(targ.type == 'checkbox' || targ.id == 'ceng' || targ.id == 'cenm' || targ.id == 'cenb')
	{	
		//targ.checked = true;
	}
	else
	{
		return false;
	}	
}

// Search postcode-to-coords
function processAddress(form, address) {
	var geocoder = null;
	if (GBrowserIsCompatible()) {
		geocoder = new GClientGeocoder();			
		geocoder.getLatLng(address+',UK', function(point) {
			
			if (!point) {
				alert("Postcode Not Found");
			} 
			else {
				document.getElementById('lat').value = point.lat();
				document.getElementById('long').value = point.lng();						
				
				document.getElementById('search_postcode').submit();

			}
		});				
	}		
	
	return false;
}

// Map location animator
function animate(nlat, nlong, title)
{
	map.panTo(new GLatLng(nlat, nlong));
	map.openInfoWindow(new GLatLng(nlat, nlong), document.createTextNode(title));
}

// Toggle event tables
function toggleTable(id)
{
	if(document.getElementById(id+'-t').style.display != 'block')
	{
		document.getElementById(id+'-t').style.display = 'block';
		document.getElementById(id+'-a').innerHTML = 'hide';
	}
	else
	{
		document.getElementById(id+'-t').style.display = 'none';
		document.getElementById(id+'-a').innerHTML = 'show';
	}
}

// Delete a forum post
function deleteReply(id)
{
	if(confirm('Are you sure you wish to delete this reply?')) window.location = '/members/forum/delete/'+id;
	else return false;
}

// Delete a whole thread
function deleteThread(id)
{
	if(confirm('Are you sure you wish to delete this entire thread?')) window.location = '/members/forum/delete/'+id;
	else return false;
}