function getRefToDiv(divID,oDoc)
{
if (document.getElementById)
{return document.getElementById(divID);}
if (document.all)
{return document.all[divID];}
if(!oDoc)
{oDoc = document;}
if(document.layers)
{
if(oDoc.layers[divID])
  {return oDoc.layers[divID];}
else
  {
  for( var x = 0, y; !y && x < oDoc.layers.length; x++ )
  {
y = getRefToDiv(divID,oDoc.layers[x].document);
  }
  return y;
  }
}
return false;
}

function toggleDiv(divID)
{
<!-- the image buttons must be called imgbut and then the name of the table without tbl -->
var myReference = getRefToDiv(divID);
if (!myReference){return;}
if(myReference.style)
{
if (myReference.style.display == 'none')
{expand(divID);
MM_swapImage('imgbut' + divID.substring(3, divID.length),'','../newlookimages/minus.gif',1);}
else
{collapse(divID);
MM_swapImage('imgbut' + divID.substring(3, divID.length),'','../newlookimages/plus.gif',1);}
}
else
{
if (myReference.display == 'hide')
{expand(divID);}
else
{collapse(divID);}
}
}

function collapse_all(NumberOfTables)
{
for (var i = 0; i <= NumberOfTables - 1; i++)
 {
  collapse('tbldetails'+i);
 }
return;
}

function expand(divID)
{
 myReference = getRefToDiv(divID);
 if (!myReference){return;}
 if(myReference.style)
 {myReference.style.display = ''}
 else
 {myReference.display = 'show';}
}

function collapse(divID)
{
 myReference = getRefToDiv(divID);
 if (!myReference){return;}
 if(myReference.style)
 {myReference.style.display = 'none'}
 else
 {myReference.display = 'hide';}
}

function getreport(reportrequested)
{

// this puts the the end time into the querystring in the format 01/01/2007
// this is actually the beginning of the month which forms the end. 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.

 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)

 if (top.document.forms[0].MRViewSideTable$AirlineChoice[top.document.forms[0].MRViewSideTable_rdbFlightStartTime.checked] == true)
 {airlinesortfield = "Start_time"}
 else
 {airlinesortfield = "Total_flight_time"}
 if (top.document.forms[0].MRViewSideTable$ItineraryChoice[top.document.forms[0].MRViewSideTable_rdbShortItinerary.checked] == true)
 {itineraryformat = "Short"}
 else
 {itineraryformat = "Long"}
 window.location = reportrequested + "?pseudoendtime=01-" + month + "-" + year + "&airlinesortfield=" + airlinesortfield + "&itineraryformat=" + itineraryformat
}
