function getreport(reportrequested)
{

// this puts the the end time into the querystring in the format 01-January-2007
// this is actually the beginning of the month which forms the end month. The end of
// the month is found in downloadreport view by adding a month and subtracting a
// day. This avoids the different number of days in the month.
// the itineraryformat and airlinesortfield MUST be the same as the fields in 
// the MySQL database as they are passed directly to the SLQ instruction.
// version 3.0.5

 var monthnames = new Array("dummy", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
 var count;
 var locationofmonth;
 var airlinesortfield;
 var itineraryformat;
 var spaceplace = top.document.forms[0].MRViewSideTable$ddlistEndMonth[top.document.forms[0].MRViewSideTable$ddlistEndMonth.selectedIndex].value.indexOf(" ");
 var datelength = top.document.forms[0].MRViewSideTable$ddlistEndMonth[top.document.forms[0].MRViewSideTable$ddlistEndMonth.selectedIndex].value.length;
 var year = top.document.forms[0].MRViewSideTable$ddlistEndMonth[top.document.forms[0].MRViewSideTable$ddlistEndMonth.selectedIndex].value.substring(spaceplace + 1, datelength);
 var month = top.document.forms[0].MRViewSideTable$ddlistEndMonth[top.document.forms[0].MRViewSideTable$ddlistEndMonth.selectedIndex].value.substring(0, spaceplace);
 
 spaceplace = top.document.forms[0].MRViewSideTable$ddlistStartMonth[top.document.forms[0].MRViewSideTable$ddlistStartMonth.selectedIndex].value.indexOf(" ");
 datelength = top.document.forms[0].MRViewSideTable$ddlistStartMonth[top.document.forms[0].MRViewSideTable$ddlistStartMonth.selectedIndex].value.length;
 var startyear = top.document.forms[0].MRViewSideTable$ddlistStartMonth[top.document.forms[0].MRViewSideTable$ddlistStartMonth.selectedIndex].value.substring(spaceplace + 1, datelength);
 var startmonth = top.document.forms[0].MRViewSideTable$ddlistStartMonth[top.document.forms[0].MRViewSideTable$ddlistStartMonth.selectedIndex].value.substring(0, spaceplace);

//the following could better be coded to take the name from the radio button
if (top.document.forms[0].MRViewSideTable$AirlineChoice[0].checked == true)
 {airlinesortfield = "First_international";}
if (top.document.forms[0].MRViewSideTable$AirlineChoice[1].checked == true)
 {airlinesortfield = "Start_time";}
if (top.document.forms[0].MRViewSideTable$AirlineChoice[2].checked == true)
 {airlinesortfield = "Total_flight_time";}

if (top.document.forms[0].MRViewSideTable$ItineraryChoice[0].checked == true)
 {itineraryformat = "Itinerary_short";}
 else
 {itineraryformat = "Itinerary_long";}

if (reportrequested == "XL/report_M1.aspx")
 {window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat + "&Report=M1";return;}

if (reportrequested == "XL/report_M2.aspx")
 {window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat + "&Report=M2";return;}

if (reportrequested == "XL/report_E1.aspx")
 {window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat + "&Report=E1";return;}

if (reportrequested == "XL/report_E2.aspx")
 {window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat + "&Report=E2";return;}

if (reportrequested == "XL/report_T1.aspx")
 {window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat + "&Report=T1";return;}

if (reportrequested == "XL/report_T2.aspx")
 {window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat + "&Report=T2";return;}

if (reportrequested == "XL/report_H1.aspx")
 {window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&Report=H1";return;}

//all the following use the G1 template

if (reportrequested == "XL/report_Q1.aspx")
 {
// find the start month - problem if it overlaps a year
 startyear = year;
 for (count = 1; count<=12; count++)
  {if (monthnames[count]==month){locationofmonth = count - 2;}}
  {if (locationofmonth < 1){locationofmonth = locationofmonth + 12;startyear=startyear-1}}
   window.location = "XL/report_G1.aspx" + "?endtime=01-" + month + "-" + year + "&starttime=01-" + monthnames[locationofmonth] + "-" + startyear + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat + "&Report=Q1";return;
 }

if (reportrequested == "XL/report_Q2.aspx")
 {
// find the start month - problem if it overlaps a year
 startyear = year;
 for (count = 1; count<=12; count++)
  {if (monthnames[count]==month){locationofmonth = count - 2;}}
  {if (locationofmonth < 1){locationofmonth = locationofmonth + 12;startyear=startyear-1}}
   window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&starttime=01-" + monthnames[locationofmonth] + "-" + startyear + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat + "&Report=Q2";return;
 }

if (reportrequested == "XL/report_A1.aspx")
 {
// find the start month - problem if December chosen as the year will be the same
 for (count = 1; count<=12; count++)
  {if (monthnames[count]==month){locationofmonth = count;}}
 if (month=="December")
 {startyear = year;
  locationofmonth = 1}
 else
 {startyear = year - 1
  locationofmonth = locationofmonth + 1};
  window.location = "XL/report_G1.aspx" + "?endtime=01-" + month + "-" + year + "&starttime=01-" + monthnames[locationofmonth] + "-" + startyear + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat + "&Report=A1";return;
 }

if (reportrequested == "XL/report_YTD1.aspx")
 {window.location = "XL/report_G1.aspx" + "?endtime=01-" + month + "-" + year + "&starttime=01-January-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat + "&Report=YTD1";return;}

if (reportrequested == "XL/report_G1.aspx")
  {
   if(top.document.forms[0].MRViewSideTable$ddlistStartMonth.selectedIndex == 0) // no start date has been selected
    {alert("Please select a START month from the drop down list on the left.");return;}
   if(top.document.forms[0].MRViewSideTable$ddlistStartMonth.selectedIndex <= top.document.forms[0].MRViewSideTable$ddlistEndMonth.selectedIndex) // the start date is after the end date
    {alert("The chosen start date is after the chosen end date. Please reselect the months required from the drop downlists on the left.");return;}
 // all test passed
    spaceplace = top.document.forms[0].MRViewSideTable$ddlistStartMonth[top.document.forms[0].MRViewSideTable$ddlistStartMonth.selectedIndex].value.indexOf(" ");
    datelength = top.document.forms[0].MRViewSideTable$ddlistStartMonth[top.document.forms[0].MRViewSideTable$ddlistStartMonth.selectedIndex].value.length;
    var startyear = top.document.forms[0].MRViewSideTable$ddlistStartMonth[top.document.forms[0].MRViewSideTable$ddlistStartMonth.selectedIndex].value.substring(spaceplace + 1, datelength);
    var startmonth = top.document.forms[0].MRViewSideTable$ddlistStartMonth[top.document.forms[0].MRViewSideTable$ddlistStartMonth.selectedIndex].value.substring(0, spaceplace);
    window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&starttime=01-" + startmonth + "-" + startyear + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat+ "&Report=G1";return;
  }
}

function getstaffreport(reportrequested)
{
 var monthnames = new Array("dummy", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
 var count;
 var locationofmonth;
 var airlinesortfield;
 var itineraryformat;
 var spaceplace = top.document.forms[0].StaffGatewayTable$ddlistEndMonth[top.document.forms[0].StaffGatewayTable$ddlistEndMonth.selectedIndex].value.indexOf(" ");
 var datelength = top.document.forms[0].StaffGatewayTable$ddlistEndMonth[top.document.forms[0].StaffGatewayTable$ddlistEndMonth.selectedIndex].value.length;
 var year = top.document.forms[0].StaffGatewayTable$ddlistEndMonth[top.document.forms[0].StaffGatewayTable$ddlistEndMonth.selectedIndex].value.substring(spaceplace + 1, datelength);
 var month = top.document.forms[0].StaffGatewayTable$ddlistEndMonth[top.document.forms[0].StaffGatewayTable$ddlistEndMonth.selectedIndex].value.substring(0, spaceplace);
 
 spaceplace = top.document.forms[0].StaffGatewayTable$ddlistStartMonth[top.document.forms[0].StaffGatewayTable$ddlistStartMonth.selectedIndex].value.indexOf(" ");
 datelength = top.document.forms[0].StaffGatewayTable$ddlistStartMonth[top.document.forms[0].StaffGatewayTable$ddlistStartMonth.selectedIndex].value.length;
 var startyear = top.document.forms[0].StaffGatewayTable$ddlistStartMonth[top.document.forms[0].StaffGatewayTable$ddlistStartMonth.selectedIndex].value.substring(spaceplace + 1, datelength);
 var startmonth = top.document.forms[0].StaffGatewayTable$ddlistStartMonth[top.document.forms[0].StaffGatewayTable$ddlistStartMonth.selectedIndex].value.substring(0, spaceplace);

//the following could better be coded to take the name from the radio button
if (top.document.forms[0].StaffGatewayTable$AirlineChoice[0].checked == true)
 {airlinesortfield = "First_international";}
if (top.document.forms[0].StaffGatewayTable$AirlineChoice[1].checked == true)
 {airlinesortfield = "Start_time";}
if (top.document.forms[0].StaffGatewayTable$AirlineChoice[2].checked == true)
 {airlinesortfield = "Total_flight_time";}

if (top.document.forms[0].StaffGatewayTable$ItineraryChoice[0].checked == true)
 {itineraryformat = "Itinerary_short";}
 else
 {itineraryformat = "Itinerary_long";}


if (reportrequested == "XL/report_M1.aspx")
 {window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat;return;}

if (reportrequested == "XL/report_M2.aspx")
 {window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat;return;}

if (reportrequested == "XL/report_E1.aspx")
 {window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat;return;}

if (reportrequested == "XL/report_T1.aspx")
 {window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat;return;}

//all the following use the G1 template

if (reportrequested == "XL/report_Q1.aspx")
 {
// find the start month - problem if it overlaps a year
 startyear = year;
 for (count = 1; count<=12; count++)
  {if (monthnames[count]==month){locationofmonth = count - 2;}}
  {if (locationofmonth < 1){locationofmonth = locationofmonth + 12;startyear=startyear-1}}
   window.location = "XL/report_G1.aspx" + "?endtime=01-" + month + "-" + year + "&starttime=01-" + monthnames[locationofmonth] + "-" + startyear + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat;return;
 }

if (reportrequested == "XL/report_Q2.aspx")
 {
// find the start month - problem if it overlaps a year
 startyear = year;
 for (count = 1; count<=12; count++)
  {if (monthnames[count]==month){locationofmonth = count - 2;}}
  {if (locationofmonth < 1){locationofmonth = locationofmonth + 12;startyear=startyear-1}}
   window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&starttime=01-" + monthnames[locationofmonth] + "-" + startyear + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat;return;
 }

if (reportrequested == "XL/report_A1.aspx")
 {
// find the start month - problem if December chosen as the year will be the same
 for (count = 1; count<=12; count++)
  {if (monthnames[count]==month){locationofmonth = count;}}
 if (month=="December")
 {startyear = year;
  locationofmonth = 1}
 else
 {startyear = year - 1
  locationofmonth = locationofmonth + 1};
  window.location = "XL/report_G1.aspx" + "?endtime=01-" + month + "-" + year + "&starttime=01-" + monthnames[locationofmonth] + "-" + startyear + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat;return;
 }

if (reportrequested == "XL/report_YTD1.aspx")
 {window.location = "XL/report_G1.aspx" + "?endtime=01-" + month + "-" + year + "&starttime=01-January-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat;return;}

if (reportrequested == "XL/report_G1.aspx")
  {
   if(top.document.forms[0].StaffGatewayTable$ddlistStartMonth.selectedIndex == 0) // no start date has been selected
    {alert("Please select a START month from the drop down list on the left.");return;}
   if(top.document.forms[0].StaffGatewayTable$ddlistStartMonth.selectedIndex <= top.document.forms[0].StaffGatewayTable$ddlistEndMonth.selectedIndex) // the start date is after the end date
    {alert("The chosen start date is after the chosen end date. Please reselect the months required from the drop downlists on the left.");return;}
 // all test passed
    spaceplace = top.document.forms[0].StaffGatewayTable$ddlistStartMonth[top.document.forms[0].StaffGatewayTable$ddlistStartMonth.selectedIndex].value.indexOf(" ");
    datelength = top.document.forms[0].StaffGatewayTable$ddlistStartMonth[top.document.forms[0].StaffGatewayTable$ddlistStartMonth.selectedIndex].value.length;
    var startyear = top.document.forms[0].StaffGatewayTable$ddlistStartMonth[top.document.forms[0].StaffGatewayTable$ddlistStartMonth.selectedIndex].value.substring(spaceplace + 1, datelength);
    var startmonth = top.document.forms[0].StaffGatewayTable$ddlistStartMonth[top.document.forms[0].StaffGatewayTable$ddlistStartMonth.selectedIndex].value.substring(0, spaceplace);
    window.location = reportrequested + "?endtime=01-" + month + "-" + year + "&starttime=01-" + startmonth + "-" + startyear + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat;
  }
}

