
   function checkSearchDates(oForm,hElements) {
			var useDefault = typeof hElements == 'undefined';
			var yearBeginName = useDefault ? 'searchTxtYearBegin' : hElements['yearBegin'];
			var yearEndName = useDefault ? 'searchTxtYearEnd' : hElements['yearEnd'];
			var monthBeginName = useDefault ? 'searchTxtMonthBegin' : hElements['monthBegin'];
			var monthEndName = useDefault ? 'searchTxtMonthEnd' : hElements['monthEnd'];
			//alert(oForm[yearBeginName]+' ' + yearBeginName); return false;
      var i;
      var j;
      var yearBegin = oForm[yearBeginName].value;
      var monthBegin = '';
      var yearEnd = oForm[yearEndName].value;
      var monthEnd = '';
      var dateBegin = '';
      var dateEnd = '';
      if (oForm[monthBeginName]) monthBegin = oForm[monthBeginName][oForm[monthBeginName].selectedIndex].value;
      if (oForm[monthEndName]) monthEnd = oForm[monthEndName][oForm[monthEndName].selectedIndex].value;

      dateBegin=yearBegin + monthBegin;
      dateEnd=yearEnd + monthEnd;
      if (isNaN(yearBegin) || (yearBegin != '' && yearBegin.length != 4)) {
         alert("Start year is invalid.  Please enter a four digit year.");
         oForm[yearBeginName].value='';
         oForm[yearBeginName].focus();
         return false;
      }
      else if (isNaN(yearEnd) || (yearEnd != '' && yearEnd.length != 4)) {
         alert("End year is invalid.  Please enter a four digit year.");
         oForm[yearEndName].value='';
         oForm[yearEndName].focus();
         return false;
      }
      else if (dateEnd < dateBegin && yearEnd != '' && !( yearBegin <= yearEnd && ( monthBegin == '' || monthEnd == '' )) ) {
         alert("End date is before start date.");
         oForm[yearEndName].focus();
         return false;
      }
      else if (yearBegin == '' && monthBegin != '') {
         alert("Start month was selected with no start year.");
         oForm[yearBeginName].focus();
         return false;
      }
      else if (yearEnd == '' && monthEnd != '') {
         alert("End month was selected with no end year.");
         oForm[yearEndName].focus();
         return false;
      }
	// Test the form without submitting: if the 'testForm' flag is in QUERY
	if (window.location.search.indexOf('testForm') >= 0) {
		alert('All is OK.'); return false; }
	return true;

	}


	function validateExport(oForm,hElements) {
		var hElementsDefault = { 'view' : 'page', 'id' : 'id' };
		if( typeof(hElements) == 'undefined' )
			hElements = {};
		for( k in hElementsDefault )
			if( typeof(hElements[k]) == 'undefined' )
				hElements[k] = hElementsDefault[k];

		if ( typeof(oForm) == 'string' )
			oForm = document.getElementsByName(oForm).length ? document.getElementsByName(oForm)[0] : document.getElementById(oForm);

		if ( typeof(oForm) == 'undefined' )
			return;

		var message = "No publications selected.\n Please select articles to include in the report by clicking on the checkbox.";
		for ( var i=0; i<oForm.elements[hElements['id']].length; i++ ) {
				if
				(
					oForm.elements[hElements['id']][i].checked &&
					typeof(oForm.elements[hElements['id']][i].value)!='undefined' &&
					oForm.elements[hElements['id']][i].value != ""
				)
				{ message = ''; break; }
		}
		if ( message ) {
			alert(message);
			return false;
		}

		//alert('Good to go');
		return true;
	}

	var exportClicked = 0;
	function getExport(oForm,hElements) {

		var hElementsDefault = { 'view' : 'page', 'id' : 'id' };
		if( typeof(hElements) == 'undefined' )
			hElements = {};
		for( k in hElementsDefault )
			if( typeof(hElements[k]) == 'undefined' )
				hElements[k] = hElementsDefault[k];

		if ( exportClicked ) return; exportClicked = 1;

		var what = '';

		if ( typeof(oForm) == 'string' )
			oForm = document.getElementsByName(oForm).length ? document.getElementsByName(oForm)[0] : document.getElementById(oForm);

		if ( typeof(oForm) == 'undefined' )
			return;

		for( i=oForm.elements[hElements['view']].length - 1; i>=0; i--)
			if ( oForm.elements[hElements['view']][i].checked ) what = oForm.elements[hElements['view']][i].value;

		var action = oForm.action;
		if ( what == 'ris' )
		oForm.action = action + '/pubs'+Math.round(Math.random()*100000)+'.ris';

		oForm.submit();
		oForm.action = action;

		exportClicked = 0;
	}
