var searchSource = 'site';
var intCalMonth;
var intCalYear;

function openWindow(strName, strURL, intWidth, intHeight, strWindowName, strScrollBars, intOffsetLeft, intOffsetTop, strFeatures)
{
	if (typeof(strWindowName) == 'undefined') strWindowName = strName;
	if (typeof(strScrollBars) == 'undefined') strScrollBars = "1";

	var intLeft = (((screen.width - intWidth) / 2));
	var intTop = (((screen.height - intHeight) / 2) - 25);

	if (typeof(intOffsetLeft) != 'undefined') intLeft += intOffsetLeft;
	if (typeof(intOffsetTop) != 'undefined') intTop += intOffsetTop;

	// Added to allow override of window features/options
	if (typeof(strFeatures) == 'undefined')
	{
		strFeatures = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=" + strScrollBars + ",resizable=1";
	}
	
	strFeatures += ",left=" + intLeft + ",top=" + intTop;
	strFeatures += ",width=" + intWidth + ",height=" + intHeight;			

	winPopUp = window.open(strURL, strWindowName, strFeatures);
	setTimeout("winPopUp.focus()", 50);

	return winPopUp;
}

function getMap()
{
   var strMapURL;

   //Yahoo Maps
   //strMapURL = 'http://maps.yahoo.com/py/maps.py?BFCat=&Pyt=Tmap&newFL=Use+Address+Below&addr=2+Plymouth+St.&csz=Holbrookn%2C+MA+02343&country=us&Get%A0Map=Get+Map';
   //Google Maps
   strMapURL = 'http://maps.google.com/maps?q=2%20Plymouth%20St%2C%20Holbrook%2C%20Ma%2C%2002343&spn=0.017944%2C0.027408';


   openWindow('MapWindow', strMapURL, 750, 500 );
}

function openCatalogWindow()
{
   openWindow('CatalogWindow', 'http://navigator.ocln.org', 750, 500);
}

function mouseOver(strPage)
{
	eval('document.' + strPage + '.src = "images/' + strPage + '_over_button.gif"');
	//alert('document.' + strPage + '.src = ' + strPage + '_over_button.gif');
}

function mouseOut(strPage)
{
	eval('document.' + strPage + '.src = "images/' + strPage + 'button.gif"');
}

function underDevel()
{
	alert('This page is currently under development');	
}

function showCalDetail(strEventName, strEventDesc, strEventTime)
{
	openWindow('DetailWindow', 'calDetail.asp?desc=' + strEventDesc + '&name=' + strEventName + '&time=' + strEventTime, 400, 250);
}

function setSearchSource(objRadio)
{
	searchSource = objRadio.value;
}

function submitSearch()
{
	var strURL = '';
	if(!document.frm_search.searchText.value == '')
	{
		switch(searchSource)
		{
			case 'web':
				strURL = 'http://www.google.com/search?hl=en&lr=&q=' + document.frm_search.searchText.value;
				break;
			case 'site':
				strURL = 'http://www.google.com/search?hl=en&lr=&q=' + document.frm_search.searchText.value + '+site%3Awww.holbrookpubliclibrary.org';
				break;
			default:
				strURL = 'http://www.google.com/search?hl=en&lr=&q=' + document.frm_search.searchText.value + '+site%3Awww.holbrookpubliclibrary.org';
				break;	
		}	
		window.open(strURL, 'Google', '');
	}
	else
	{
		alert("Please enter search criteria");
		document.frm_search.searchText.focus();
		return false;
	}
}

function submitForm(objForm)
{
	/*if(checkForm(objForm))
	{
		//objForm.action = "http://www.google.com/search";
		document.frm_search.submit();
	} */
	objForm.submit();
}

/*function checkForm(objForm) 
{ 
	if(objForm.searchText.value == '' )
	{ 
		alert('You must enter seach words'); 
		objForm.q.focus(); 
		return false; 
	} 
	objForm.q.value = objForm.searchText.value;
	if (searchSource == 'site')
	{
		 objForm.q.value += " site:www.holbrookpubliclibrary.org";
	}
	return true; 
} */

function bodyLoad()
{
	document.frm_search.searchText.value = '';
}

function quickSearch()
{
	var srchfield1 = document.all.srchfield1[document.all.srchfield1.selectedIndex].value;
	var searchdata1 = document.all.searchdata1.value;
	var user_id = document.all.user_id.value;
	var password = document.all.password.value;
	var library = document.all.library.value;

	var searchURL = "http://qa.holbrookpubliclibrary.org/quickSearch.php?srchfield1=" + srchfield1 + "&searchdata1=" + searchdata1 + "&user_id=" + user_id + "&password=" + password + "&library=" + library;

	openWindow('QuickSearchWindow', searchURL, 750, 500 );
}
