function MonthText (MonthNumber) {
   var Month = new Array();
       Month[1]="January";
       Month[2]="February";
       Month[3]="March";
       Month[4]="April";
       Month[5]="May";
       Month[6]="June";
       Month[7]="July";
       Month[8]="August";
       Month[9]="September";
       Month[10]="October";
       Month[11]="November";
       Month[12]="December";

return Month[MonthNumber];
}



function setTimeDateStuff () {
	
  var Today=new Date();

  var ThisDay=Today.getDate();
  var paddedThisDay = leadingZero(ThisDay);

  var ThisMonthminus1 = Today.getMonth();
  var paddedThisMonthminus1 = leadingZero(ThisMonthminus1);

  var ThisMonth=Today.getMonth()+1;
  var paddedThisMonth = leadingZero(ThisMonth);

  var ThisMonthplus1=Today.getMonth()+2;
  var paddedThisMonthplus1 = leadingZero(ThisMonthplus1);

  var ThisMonthplus3=Today.getMonth()+4;

  var ThisYear=Today.getFullYear();

if (ThisMonthminus1 == 0) {
ThisMonthminus1 = 12;
var TodayDateStringAusLessMonth = paddedThisDay+"/"+ThisMonthminus1+"/"+ThisYear;
}

if (ThisMonthplus1 > 12) {
ThisMonthplus1 = ThisMonthplus1 - 12;
var TodayDateStringAusPlusMonth = paddedThisDay+"/"+ThisMonthplus1+"/"+ThisYear;
}

if (ThisMonthplus3 > 12) {
ThisMonthplus3 = ThisMonthplus3 - 12;
}


  var TodayDateStringUS = ThisYear+"-"+paddedThisMonth+"-"+paddedThisDay;
  var TodayDateStringAus = paddedThisDay+"/"+paddedThisMonth+"/"+ThisYear;

  var TodayDateStringAusLessMonth = paddedThisDay+"/"+paddedThisMonthminus1+"/"+ThisYear;
  var TodayDateStringAusPlusMonth = paddedThisDay+"/"+paddedThisMonthplus1+"/"+ThisYear;


// The following three lines used in unused input part of form

  var outputThis = MonthText(ThisMonthplus3);


  document.getElementById('monthsortfield').value = ThisMonthplus3;

  document.getElementById('month').value = outputThis;


// The above three lines used in unused input part of form



document.getElementById('search1_gbdate_from').value = TodayDateStringAus;
document.getElementById('search2_gbdate_from').value = TodayDateStringAus;
document.getElementById('search3_gbdate_from').value = TodayDateStringAus;

document.getElementById('search1_gbdate_to').value = TodayDateStringAusPlusMonth;
document.getElementById('search2_gbdate_to').value = TodayDateStringAusPlusMonth;
document.getElementById('search3_gbdate_to').value = TodayDateStringAusPlusMonth;

document.getElementById('search1_rodate_from').value = TodayDateStringAus;
document.getElementById('search2_rodate_from').value = TodayDateStringAus;
document.getElementById('search3_rodate_from').value = TodayDateStringAus;

document.getElementById('search1_rodate_to').value = TodayDateStringAusPlusMonth;
document.getElementById('search2_rodate_to').value = TodayDateStringAusPlusMonth;
document.getElementById('search3_rodate_to').value = TodayDateStringAusPlusMonth;

document.getElementById('search1_dateupdated_from').value = TodayDateStringAusLessMonth;
document.getElementById('search2_dateupdated_from').value = TodayDateStringAusLessMonth;
document.getElementById('search3_dateupdated_from').value = TodayDateStringAusLessMonth;

document.getElementById('search1_dateupdated_to').value = TodayDateStringAus;
document.getElementById('search2_dateupdated_to').value = TodayDateStringAus;
document.getElementById('search3_dateupdated_to').value = TodayDateStringAus;

}


function leadingZero(x){
   y=(x>9)?x:'0'+x;

//   e.g. to add zero padding to four digits:
//   y=(x>9)?x:'000'+x;
//   y=(x>99)?x:'00'+x;
//   y=(x>999)?x:'0'+x;
   return y;
}



function pickQuery(callingElement, n) {

var i = 0;

var queryTypes = new Array();
queryTypes[0] = "NULL" + n;
queryTypes[1] = "hiddenbyforcode" + n;
queryTypes[2] = "hiddenbykeywords" + n;
queryTypes[3] = "hiddenbyu_amount" + n;
queryTypes[4] = "hiddenbygrantor" + n;
queryTypes[5] = "hiddenbyschemename" + n;
queryTypes[6] = "hiddenbyrodate" + n;
queryTypes[7] = "hiddenbygbdate" + n;
queryTypes[8] = "hiddenbymonthsortfield" + n;
queryTypes[9] = "hiddenbyschemecategorynumber" + n;
queryTypes[10] = "hiddenbyschemecategorydescription" + n;
queryTypes[11] = "hiddenbywebaccessexternal" + n;
queryTypes[12] = "hiddenbyacgrlist" + n;
queryTypes[13] = "hiddenbyacgrportfolio" + n;
queryTypes[14] = "hiddenbyrcname" + n;
queryTypes[15] = "hiddenbydateupdated" + n;

var queryIndex = document.getElementById(callingElement).selectedIndex;

//  Hide or display if called from a search criterion:

if(queryIndex == 0) {

  for(i=1;i<queryTypes.length;i++) {
    document.getElementById(queryTypes[i]).style.display='none';
  }
    document.getElementById('hiddensubmit').style.display='none';
}
else {

  for(i=1;i<queryTypes.length;i++) {
    document.getElementById(queryTypes[i]).style.display='none';

  } // end for


document.getElementById(queryTypes[queryIndex]).style.display='';
document.getElementById('hiddensubmit').style.display='';

 } // end else

}


function startagain () {

window.location = "/researchoffice/fod";

}


function showNextCriterion(n) {

var criterion = "criterion" + n;

if(n==0 || n==1) {alert('Bizarre! There is no criterion 0! \n\n...and criterion 1 should always be visible!');}
else {
    document.getElementById(criterion).style.display='';
 } // end else

}



