function addProvider() {

	//Set Variables
	var width = 345;
	var height = 120;
	var URL = '/provider_service/pop.php';
	var version = new Array();

	//Browser Version
	str = navigator.appVersion;
	if (str.match("MSIE ([0-9])")) version = str.match("MSIE ([0-9])");
	//else version = 0;

	//alert(version.length);

	var indentLeft = (screen.width - width) / 2;
	var indentTop = (screen.height - height) / 2;

	//IE Support
	if (version['1'] && (typeof window.external == "object") && (typeof window.external.AddSearchProvider != "undefined")) {

		if (version['1'] < 7){
			//alert("Using version below MSIE 7 (" + version[0] + "), height + 30, width + 6.");
			height = height + 30;
			width = width + 6;
			indentLeft = (screen.width - width) / 2;
			indentTop = (screen.height - height) / 2;
		}

		//IE Modal
		//window.showModalDialog(URL,'','dialogHeight:' + height +'px;dialogWidth:' + width +'px;center:yes;resizable:no;scroll:no;status:no;');

		//Open Popup
		day = new Date();
		id = 'provider';
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ", left=" + indentLeft + ", top=" + indentTop + "');");

		return true;

	//Mozilla Support
	} else if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
		
		//Open Popup
		day = new Date();
		id = 'provider';
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ", left=" + indentLeft + ", top=" + indentTop + "');");

		return true;

	} else {
		return false;
	}

}

function doAddProvider() {

	//Browser Version
	str = navigator.appVersion;
	if (str.match("MSIE ([0-9])")) version = str.match("MSIE ([0-9])");

	//Mozilla Support
    if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
        window.sidebar.addSearchEngine(
            "http://stthomaskendal.easysearch.org.uk/Provider.src",  /* engine URL */
            "http://stthomaskendal.easysearch.org.uk/images/provider.gif",  /* icon URL */
            "stthomaskendal.easysearch.org.uk",                                         /* engine name */
            "Web" );                                               /* category name */
		return true;

	//IE Support
	} else if ((typeof window.external == "object") && version['1'] >= 7) {
		
		window.external.AddSearchProvider('http://stthomaskendal.easysearch.org.uk/Provider.xml');
		return true;

	} else {
		document.location.href = '/provider_service/';
		return false;
	}

}

var type_selected = "web";
function changeType(type) {

	elS = document.getElementById('type_'+type_selected);
	elU = document.getElementById('type_'+type);
	searchString = document.getElementById('searchString');

	//region_us
	//region_uk

	//alert(document.getElementById('region_us').checked);


	if (searchString.value.length>0) {
		//Replace s=query with new query
		elU.href = elU.href.replace(new RegExp("s=[^&$]*"),"s="+encodeURI(searchString.value));
		elU.href = elU.href.replace(new RegExp("r=[^&$]*"),"r="+(document.getElementById('region_uk').checked ? document.getElementById('region_uk').value : document.getElementById('region_us').value));
		return true;
	} else {
		//Change Existing
		if (elS) elS.className = "type_unselected";

		el = document.getElementById('search_t');
		if (el) el.value = type;
		if (elU) elU.className = "type_selected";
		type_selected = type;

		return false;
	}

}

function addToFavorites() { 
	var urlAddress = "http://stthomaskendal.easysearch.org.uk";
	var pageName = "easysearch (St Thomas' Church - Kendal)";
	if (window.sidebar) { //FireFox
		window.sidebar.addPanel(pageName, urlAddress, "");
	} else if (window.external) { //IE
		window.external.AddFavorite(urlAddress, pageName);
	}
}


function makeHomepage(obj) {

	var urlAddress = "http://stthomaskendal.easysearch.org.uk";
	var pageName = "easysearch (St Thomas' Church - Kendal)";
	var clientVersion = navigator.appVersion;

	if (clientVersion.indexOf('MSIE') != -1) {
		obj.style.behavior = "url(#default#homepage)";
		obj.setHomePage(urlAddress);
	} else {
		alert("Please set http://stthomaskendal.easysearch.org.uk \nas your home page using your browser settings.");
	}

}