var noScript = {
	init: function () {
		var noScriptAnchor, noScriptParent;
		noScriptAnchor = Base.byId('noscript');
		if (noScriptAnchor) {
			noScriptParent = noScriptAnchor.parentNode;
			noScriptParent.removeChild(noScriptAnchor);
		}
	}
};
var newWindowLinks = {
	init: function () {
		var anchors, no, i;
		anchors = Base.getElementsByClass('new-window');
		no = anchors.length;
		for (i=0; i < no; i++) {
			Base.addEventListener(anchors[i], 'click', newWindowLinks.open);
			anchors[i].title += (anchors[i].title == '') ? '(N.B. external web link, opens in a new window.)' : ' (N.B. external web link, opens in a new window.)';
		}
	},
	open: function (event) {
		var return_value = true;
		if (window.open(this.href)) {
			Base.preventDefault(event);
			return_value = false;
		}
		return return_value;
	}
};
var googleSearchForm = {
	init: function () {
		var element;
		element = Base.byId('google-search-sidebar');
		if (element) {
			Base.addEventListener(element, 'submit', googleSearchForm._setSearchValues);
		}
		element = Base.byId('google-search-content');
		if (element) {
			Base.addEventListener(element, 'submit', googleSearchForm._setSearchValues);
		}
	},
	_setSearchValues: function () {
		this.q.value='site:www.aptaylortrust.org.uk ' + this.searchtermlist.value;
	}
};
var siteBookmarkIE = {
	init: function () {
		if (typeof window.external.AddFavorite !== 'undefined') {
			var element;
			element = Base.byId('IE-Bookmark-h2');
			if (element) {
				Base.addEventListener(element, 'click', siteBookmarkIE._addBookmarkIE);
				element = Base.byId('IE-Bookmark-p');
				if (element) {
					Base.addEventListener(element, 'click', siteBookmarkIE._addBookmarkIE);
				}
			}
		}
	},
	_addBookmarkIE: function (event) {
		window.external.AddFavorite('http://www.aptaylortrust.org.uk/', 'The AP Taylor Trust');
		// don't forget to cancel the default action (called from anchor href #null), irrespective of success
		Base.preventDefault(event);
		return false; 
	}
};
Base.start(noScript);
Base.start(googleSearchForm);
Base.start(siteBookmarkIE);
Base.start(newWindowLinks);
