//<![CDATA[
    
function $(_id) {
	return document.getElementById(_id);
}
function trim(_str) {
	return _str.replace(/^\s+|\s+$/g, "");
}

function checkGuestBook() {
	if (trim($('signer').value) == '') {
		alert("Please provide a name");
		$('signer').focus();
		return false;
	}

	if (trim($('email').value) == '') {
		alert("Please provide an email");
		$('email').focus();
		return false;
	}

	if (trim($('comments').value) == '') {
		alert("Please provide your comments for the guestbook");
		$('comments').focus();
		return false;
	}
	
	return true;
}

function updateDateSels(_pre) {
	var datestr = $(_pre).value;
	
	return false;	
}

function setdefault(_elem, _onoff, _msg, _class) {
	var bg_class = "bg-msg";

	if (_onoff) {
		if (trim(_elem.value) == _msg) {
			_elem.value = '';
			_elem.className = _class;
		}
	}
	else if (trim(_elem.value) == '') {
		_elem.value = _msg;
		_elem.className = _class + " " + bg_class;
	}
}

function checkContact() {
	if (trim($('customer').value) == '') {
		alert("Please provide a name");
		$('customer').focus();
		return false;
	}
	else if (trim($('email').value) == '') {
		alert("Please provide an email");
		$('email').focus();
		return false;
	}
	else if (trim($('request').value) == '') {
		alert("Please give details of why you are contacting us.");
		$('request').focus();
		return false;
	}
	
	if (document.getElementsByName('ctype')[0].checked == true && trim($('phone').value) == '') {
		alert("Please provide a phone number by which to contact you at.");
		$('phone').focus();
		return false;
	}

	return true;
}

function change_search() {
	var radios = document.getElementsByName('search_by');
	var which = (radios[0].checked != true ? ['none','block'] : ['block','none']);
	
	$('search_by_name').style.display = which[0];
	$('search_by_date').style.display = which[1];
}
	

window.onload = function() {
	if ($('map')) { load(); }
	if ($('customer')) { $('customer').focus(); }	
	if ($('signer')) { $('signer').focus(); }	
	var links = document.getElementsByTagName('a');
	for(var i=0; i<links.length; i++) {
		if (links[i].getAttribute("rel") && links[i].getAttribute("rel") == 'external') {
			links[i].setAttribute("target", "_new");
		}
	}
};

window.onunload = function() {
	if ($('map')) { GUnload(); }
};



//]]>