function prepare_search_form(selector, default_string, search_term) {

  // what should the default label text be?
  var default_term = 'search...'
  if (default_string && default_string != '') {
    default_term = default_string;
  }

  // lets make sure we are starting fresh
  $(selector).unbind();

  // set the label text to either the default, or the search string
  if (search_term != '') {
    $(selector).val(search_term);
  } else {
    $(selector).val(default_term);
  }

  // add the click on, click off behavior
  $(selector).focus(
    function() {
     if ($(selector).val() == default_term) {
       $(selector).val('');
     }
    });
  $(selector).blur(
    function() {
     if ($(selector).val() == '') {
       $(selector).val(default_term);
     }
    });
}

function popup_helpres()
{windowOpener('/help/popup-helpres.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_libsog()
{windowOpener('/help/popup-lib-sog.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_aboutcensus1841()
{windowOpener('/help/popup-aboutbo-census1841.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_aboutcensus1841accuracy()
{windowOpener('/help/popup-aboutbo-census1841-accuracy.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_faqbopc()
{windowOpener('http://www.originsnetwork.com/help/popup-faqbo-pc.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_gallerygotopageemploy()
{windowOpener('http://www.originsnetwork.com/help/popup-gallerygotopage-employ.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_gallerygotopage()
{windowOpener('http://www.originsnetwork.com/help/popup-gallerygotopage.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_wildcards()
{windowOpener('http://www.originsnetwork.com/help/popup-helpwildcards.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_helpnamex()
{windowOpener('http://www.originsnetwork.com/help/popup-helpnamex.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_oldnewdates()
{windowOpener('http://www.originsnetwork.com/help/popup-helpoldnewdates.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_narrowing()
{windowOpener('http://www.originsnetwork.com/help/popup-helpnarrowing.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_afterdate()
{windowOpener('http://www.originsnetwork.com/help/popup-helpafterdate.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_sorting()
{windowOpener('http://www.originsnetwork.com/help/popup-helpsorting.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_abouteo()
{windowOpener('http://www.originsnetwork.com/help/popup-aboutbo.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_aboutio()
{windowOpener('http://www.originsnetwork.com/help/popup-aboutio.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_aboutota()
{windowOpener('http://www.originsnetwork.com/help/popup-aboutota.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_aboutso()
{windowOpener('http://www.originsnetwork.com/help/popup-aboutso.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_aboutcoll()
{windowOpener('http://www.originsnetwork.com/help/popup-about.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_sog()
{windowOpener('http://www.originsnetwork.com/help/popup-aboutbo-sog.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_abouton()
{windowOpener('http://www.originsnetwork.com/help/popup-abouton.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_privacy()
{windowOpener('http://www.originsnetwork.com/help/popup-termsofservice.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_termsofservice()
{windowOpener('http://www.originsnetwork.com/help/popup-termsofservice.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_cart()
{windowOpener('http://www.originsnetwork.com/help/popup-cart.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_demo()
{windowOpener('http://www.originsnetwork.com/demo/gettingstarted.htm','demo','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=600,height=430,left=40,top=30')}

function popup_newson()
{windowOpener('http://www.originsnetwork.com/help/popup-newson.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_contact()
{windowOpener('http://www.originsnetwork.com/help/popup-contact.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_faq()
{windowOpener('http://www.originsnetwork.com/help/popup-faq.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_archives()
{windowOpener('http://www.originsnetwork.com/help/popup-resarchives.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_helpsearching()
{windowOpener('http://www.originsnetwork.com/help/popup-help.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_articles()
{windowOpener('http://www.originsnetwork.com/help/popup-resarticles.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_newsletter()
{windowOpener('http://www.originsnetwork.com/help/popup-newsletter.htm','help','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function popup_search(site)
{
var url = "/popup-freesearch.aspx?site=" + site;

windowOpener(url,'freesearch','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=700,height=430,left=40,top=30')}

function StatusShow( msgStr )
{
	status=msgStr;
}

function NoAccessWebsite(WebsiteID)
{

var url = "";
if (WebsiteID == 1)
{

url = "/BritishOrigins/BONoSub.aspx";
}
if (WebsiteID == 2)
{

url = "/IrishOrigins/IONoSub.aspx";
}
if (WebsiteID == 4)
{

url = "/OriginSearch/OSNoSub.aspx";
}


location.href = url;
}

function NoAccessDataSet(DataSetID)
{
var url = "/pop_upNoAccessDataSet.aspx?DataSetID=" + DataSetID;

windowOpener(url,'NoAccessDataSet','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=500,height=350,left=40,top=30')
}


function popup_NoAccessWebsite(WebsiteID)
{
var url = "/pop_upNoAccessWebsite.aspx?WebsiteID=" + WebsiteID;

windowOpener(url,'NoAccessWebsite','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=500,height=350,left=40,top=30')
}

function popup_NoAccessDataSet(DataSetID)
{
var url = "/pop_upNoAccessDataSet.aspx?DataSetID=" + DataSetID;

windowOpener(url,'NoAccessDataSet','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=500,height=350,left=40,top=30')
}

function SaveSearchTest( strPageName )
{
var strURL = "http://" + location.hostname + "/popup-SavedSearches.aspx?PageName=" + strPageName;

window.open(strURL,'SaveSearch','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=500,height=200,left=40,top=30');
}


function SaveSearch( strPageName )
{
var strURL = "http://" + location.hostname + "/popup-SavedSearches.aspx?PageName=" + strPageName;

window.open(strURL,'SaveSearch','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=500,height=200,left=40,top=30');
}

function GoToLocalSavedSearch( WebsiteID )
{
	var strSavedSearchPage = "";

	if (WebsiteID == 1)
	{
		strSavedSearchPage = "/BritishOrigins/Users/SavedSearches/BOSavedSearches.aspx";
	}
	if (WebsiteID == 2)
	{
		strSavedSearchPage = "/IrishOrigins/Users/SavedSearches/IOSavedSearches.aspx";
	}
	if (WebsiteID == 3)
	{
		strSavedSearchPage = "/OriginSearch/OSUserHome.aspx";
	}

	document.location = strSavedSearchPage;
}

function popup_EditVariants(type,name,precision)
{

var strURL = "";


//strURL = "http://" + location.hostname + "/NameX/NameXSelect.aspx?Name=" + name + "&NameXLevel=" + precision  + "&Type=" + type;

strURL = "/NameX/NameXDisplay.aspx?Name=" + name + "&NameXLevel=" + precision  + "&Type=" + type;

//alert(strURL);
popupWin = window.open(strURL,'NameXEdit','toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=400,height=430,left=40,top=30');

//window.open(strURL);
}

function OpenAddAlertsPopUp(strURLPart)
{
var strURL = "http://" + location.hostname + "/Alerts/" + strURLPart;

windowOpener(strURL,"AddAlert",'toolbar=yes,status=no,scrollbars=yes,location=yes,menubar=no,resizable=1,directories=no,width=500,height=250,left=40,top=30')
}

//DO NOT DELETE
//INCLUDE IN ALL JSSource Pages
function windowOpener(url, name, args)
{
	if (typeof(popupWin) != "object")
	{
//alert("got here 1");
		popupWin = window.open(url,name,args);
		popupWin.focus();
	}
	else 
	{
		
		//alert("got here 2");
		//alert("newname: " + name);
			
		if (!popupWin.closed)
		{ 
		
		//alert("got here 3");
			
			
			if (!popupWin.name == name)
			{
				popupWin.location.href = url;
				popupWin.focus();
			}
			else
			{

				popupWin2 = window.open(url, name,args);
				popupWin2.focus();
			}
			
		} 
		else
		{
		
//		alert("got here 4");
			popupWin = window.open(url, name,args);
			popupWin.focus();
		}
			
		
	}

	
}