
function printWindow()
{
    var mac = (navigator.userAgent.indexOf("Mac") != -1);   
    if (!mac)
        window.print();
    else
        alert("Your browser does not support direct printing from this page.  To print this page, click on the File menubar item and then Print.");
}



function cancelForm()
{
    submitPropertyForm('cancel');
}

function setActionForForm(action)
{
  document.forms[0].action = action;
}

function submitActionForm(action)
{
    document.forms[0].action = action;
    document.forms[0].submit();
}
function submitPropertyForm(prop)
{
    action = document.forms[0].action;
    nIndex = action.indexOf("?");    
    if (nIndex > -1)
        action += '&'+prop+'=1';
    else
        action += '?'+prop+'=1';
    document.forms[0].action = action;
}
    
// used by the reports in QR
function setActiveStudentValue(){  
  if (document.reportSelectionForm.active.checked)
    document.reportSelectionForm.studentStatus.value="active";
  else
    document.reportSelectionForm.studentStatus.value="all";
}
function setMonitorProgressOnlyValue()
{
	if (document.reportSelectionForm.mp.checked)
		document.reportSelectionForm.monitorProgressOnly.value="1";
	else
		document.reportSelectionForm.monitorProgressOnly.value="0";	
}


//------------------------moveItemsSortingByValue--------------------------------
// Moves items from one list box to another, keeping the target list box sorted by value.
// This is not the same as sorting by the actual text strings; doing it this way allows us
// to correctly sort items such as times in 12-hour format, where sorting by the actual
// text strings would result in an incorrectly sorted list.  In the interest of performance,
// this method assumes both list boxes were already sorted correctly to begin with.
//-----------------------------------------------------------------------------------
function moveItemsSortingByValue (fromBox, toBox)
{
     // Variables we'll need throughout this method
    var i = 0;
    
    // Get options to be moved in ascending order, deleting them from the "from" box as we go
    var movedOptionTexts = new Array();
    var movedOptionValues = new Array();
    for (i = 0; i < fromBox.length; i++)
    {
        if (fromBox.options[i].selected)
        {
            // Save the data for this item
            movedOptionTexts[movedOptionTexts.length] = fromBox.options[i].text;            
            movedOptionValues[movedOptionValues.length] = fromBox.options[i].value;

            // Delete item from "from" box
            fromBox.options[i] = null;
            
            // Adjust index to compensate for deleted item
            i--;
        }
    }
        
    // If there were no items to be moved, just exit
    if (movedOptionValues.length <= 0)
    {
        return false;
    }
        
    // Find the first option in the "to" box which isn't where we want it
    for (i = 0; i < toBox.length; i++)
    {
        // If this "to" box item should be sorted after the first option
        // we need to move, we've found the "first bad index".  Break out
        // of the loop.        
        //if (toBox.options[i].value > movedOptionValues[0])
        {
            break;
        }
        
        // Also deselect items in the "to" box as we go
        toBox.options[i].selected = false;
    }
    
    var firstBadIndex = i;
    
    // Save data from all "to" box options from the "first bad index"
    // to the end of the list, because we're about to move them
    var existingOptionTexts = new Array();
    var existingOptionValues = new Array();
    for (i = firstBadIndex; i < toBox.length; ++i)
    {
        // Save the data for this item
        existingOptionTexts[i - firstBadIndex] = toBox.options[i].text;
        existingOptionValues[i - firstBadIndex] = toBox.options[i].value;

        // Also deselect items in the "to" box as we go
        toBox.options[i].selected = false;
    }
    
    // Now repopulate the "to" box from the "first bad index" to the end
    // of the list with a mix of the moved and originally existing options
    var movedIndex = 0;
    var existingIndex = 0;
    var haveMoreMovedItems = (movedIndex < movedOptionValues.length);
    var haveMoreExistingItems = (existingIndex < existingOptionValues.length);
    var originalToBoxLength = toBox.length;
    i = firstBadIndex;
    while (haveMoreMovedItems || haveMoreExistingItems)
    {
        // Pick either one of the moved options or one of the existing options,
        // depending on which one is "lower" in the sorting order.  This is of
        // course subject to the availability of items in either list; if one
        // of the lists is empty, we always pick from the other one.
        var useMoved = false;
        if (haveMoreMovedItems && haveMoreExistingItems)
        {
            useMoved = (movedOptionValues[movedIndex] < existingOptionValues[existingIndex]);
        }
        else if (haveMoreMovedItems)
        {
            useMoved = true; 
        }
        else if (haveMoreExistingItems)
        {
            useMoved = false;
        }
        else
        {
            // This case should never happen; if it does, stop the loop immediately since we're done anyway.
            break;
        }
        
        var text = null;
        var value = null;
        var selected = false;
        if (useMoved)
        {
            text = movedOptionTexts[movedIndex];
            value = movedOptionValues[movedIndex];
            selected = true;    // Items that are being moved to the "to" box should be selected when they get there
            movedIndex++;
        }
        else
        {
            text = existingOptionTexts[existingIndex];
            value = existingOptionValues[existingIndex];
            selected = false;   // Items that were already in the "to" box should be deselected
            existingIndex++;
        }
        
        // Either change one of the existing entries in or add a new entry to the "to" box,
        // depending on whether or not we've already changed the last of the existing entries
        if (i < originalToBoxLength)
        {
            toBox.options[i].text = text;
            toBox.options[i].value = value;
            toBox.options[i].selected = selected;
        }
        else
        {
            toBox.options[i] = new Option(text, value, false, false);
            toBox.options[i].selected = selected;
        }
        
        i++;
        haveMoreMovedItems = (movedIndex < movedOptionValues.length);
        haveMoreExistingItems = (existingIndex < existingOptionValues.length);
    }
    
    return true;
}


//------------------------moveItemsSortingByText--------------------------------
// Moves items from one list box to another, keeping the target list box sorted by text.
//-------------------------------------------------------------------------------
function moveItemsSortingByText (fromBox, toBox)
{

    // Variables we'll need throughout this method
    var i = 0;
    
    // Get options to be moved in ascending order, deleting them from the "from" box as we go
    var movedOptionTexts = new Array();
    var movedOptionValues = new Array();

    for (i = 0; i < fromBox.length; i++)
    {
        if (fromBox.options[i].selected) {
            // Save the data for this item
            movedOptionTexts[movedOptionTexts.length] = fromBox.options[i].text;                        
            movedOptionValues[movedOptionValues.length] = fromBox.options[i].value;

            // Delete item from "from" box
            fromBox.options[i] = null;
            
            // Adjust index to compensate for deleted item
            i--;
        }
    }
        
    // If there were no items to be moved, just exit
    if (movedOptionTexts.length <= 0)    
        return false;
            
    // Find the first option in the "to" box which isn't where we want it
    for (i = 0; i < toBox.length; i++) {
        // If this "to" box item should be sorted after the first option
        // we need to move, we've found the "first bad index".  Break out
        // of the loop.        
        if (toBox.options[i].text > movedOptionTexts[0])        
            break;        
        
        // Also deselect items in the "to" box as we go
        toBox.options[i].selected = false;
    }
    
    var firstBadIndex = i;
    
    // Save data from all "to" box options from the "first bad index"
    // to the end of the list, because we're about to move them
    var existingOptionTexts = new Array();    
    var existingOptionValues= new Array();
    for (i = firstBadIndex; i < toBox.length; ++i) {
        // Save the data for this item
        existingOptionTexts[i - firstBadIndex] = toBox.options[i].text;        
        existingOptionValues[i - firstBadIndex] = toBox.options[i].value;
        // Also deselect items in the "to" box as we go
        toBox.options[i].selected = false;
    }
    
    // Now repopulate the "to" box from the "first bad index" to the end
    // of the list with a mix of the moved and originally existing options
    var movedIndex = 0;
    var existingIndex = 0;
    var haveMoreMovedItems = (movedIndex < movedOptionTexts.length);
    var haveMoreExistingItems = (existingIndex < existingOptionTexts.length);
    var originalToBoxLength = toBox.length;
    i = firstBadIndex;
    while (haveMoreMovedItems || haveMoreExistingItems) {
        // Pick either one of the moved options or one of the existing options,
        // depending on which one is "lower" in the sorting order.  This is of
        // course subject to the availability of items in either list; if one
        // of the lists is empty, we always pick from the other one.
        var useMoved = false;
        if (haveMoreMovedItems && haveMoreExistingItems) {
            useMoved = (movedOptionTexts[movedIndex] < existingOptionTexts[existingIndex]);
        }
        else if (haveMoreMovedItems)
        {
            useMoved = true; 
        }
        else if (haveMoreExistingItems)
        {
            useMoved = false;
        }
        else
        {
            // This case should never happen; if it does, stop the loop immediately since we're done anyway.
            break;
        }
        
        var text = null;
        var value = null;
        var selected = false;
        if (useMoved)
        {
            text = movedOptionTexts[movedIndex];
            value = movedOptionValues[movedIndex];
            selected = true;    // Items that are being moved to the "to" box should be selected when they get there
            movedIndex++;
        }
        else
        {
            text = existingOptionTexts[existingIndex];
            value = existingOptionValues[existingIndex];
            selected = false;   // Items that were already in the "to" box should be deselected
            existingIndex++;
        }
        
        // Either change one of the existing entries in or add a new entry to the "to" box,
        // depending on whether or not we've already changed the last of the existing entries
        if (i < originalToBoxLength)
        {
            toBox.options[i].text = text;
            toBox.options[i].value = value;
            toBox.options[i].selected = selected;
        }
        else
        {
            toBox.options[i] = new Option(text, value, false, false);
            toBox.options[i].selected = selected;
        }
        
        i++;
        haveMoreMovedItems = (movedIndex < movedOptionTexts.length);
        haveMoreExistingItems = (existingIndex < existingOptionTexts.length);
    }
    
    return true;
}


//------------------insertItemSortingByText----------------------------------

function insertItemSortingByText (text, value, toBox)
{

    // Variables we'll need throughout this method
    var i = 0;
    
    // Get options to be moved in ascending order, deleting them from the "from" box as we go
    var movedOptionTexts = new Array();
    var movedOptionValues = new Array();

    // Save the data for this item
    movedOptionTexts[movedOptionTexts.length] = text;                        
    movedOptionValues[movedOptionValues.length] = value;
       
    // If there were no items to be moved, just exit
    if (movedOptionTexts.length <= 0)    
        return false;
            
    // Find the first option in the "to" box which isn't where we want it
    for (i = 0; i < toBox.length; i++) {
        // If this "to" box item should be sorted after the first option
        // we need to move, we've found the "first bad index".  Break out
        // of the loop.        
        if (toBox.options[i].text > movedOptionTexts[0])        
            break;        
        
        // Also deselect items in the "to" box as we go
        toBox.options[i].selected = false;
    }
    
    var firstBadIndex = i;
    
    // Save data from all "to" box options from the "first bad index"
    // to the end of the list, because we're about to move them
    var existingOptionTexts = new Array();    
    var existingOptionValues= new Array();
    for (i = firstBadIndex; i < toBox.length; ++i) {
        // Save the data for this item
        existingOptionTexts[i - firstBadIndex] = toBox.options[i].text;        
        existingOptionValues[i - firstBadIndex] = toBox.options[i].value;
        // Also deselect items in the "to" box as we go
        toBox.options[i].selected = false;
    }
    
    // Now repopulate the "to" box from the "first bad index" to the end
    // of the list with a mix of the moved and originally existing options
    var movedIndex = 0;
    var existingIndex = 0;
    var haveMoreMovedItems = (movedIndex < movedOptionTexts.length);
    var haveMoreExistingItems = (existingIndex < existingOptionTexts.length);
    var originalToBoxLength = toBox.length;
    i = firstBadIndex;
    while (haveMoreMovedItems || haveMoreExistingItems) {
        // Pick either one of the moved options or one of the existing options,
        // depending on which one is "lower" in the sorting order.  This is of
        // course subject to the availability of items in either list; if one
        // of the lists is empty, we always pick from the other one.
        var useMoved = false;
        if (haveMoreMovedItems && haveMoreExistingItems) {
            useMoved = (movedOptionTexts[movedIndex] < existingOptionTexts[existingIndex]);
        }
        else if (haveMoreMovedItems)
        {
            useMoved = true; 
        }
        else if (haveMoreExistingItems)
        {
            useMoved = false;
        }
        else
        {
            // This case should never happen; if it does, stop the loop immediately since we're done anyway.
            break;
        }
        
        var text = null;
        var value = null;
        var selected = false;
        if (useMoved)
        {
            text = movedOptionTexts[movedIndex];
            value = movedOptionValues[movedIndex];
            selected = true;    // Items that are being moved to the "to" box should be selected when they get there
            movedIndex++;
        }
        else
        {
            text = existingOptionTexts[existingIndex];
            value = existingOptionValues[existingIndex];
            selected = false;   // Items that were already in the "to" box should be deselected
            existingIndex++;
        }
        
        // Either change one of the existing entries in or add a new entry to the "to" box,
        // depending on whether or not we've already changed the last of the existing entries
        if (i < originalToBoxLength)
        {
            toBox.options[i].text = text;
            toBox.options[i].value = value;
            toBox.options[i].selected = selected;
        }
        else
        {
            toBox.options[i] = new Option(text, value, false, false);
            toBox.options[i].selected = selected;
        }
        
        i++;
        haveMoreMovedItems = (movedIndex < movedOptionTexts.length);
        haveMoreExistingItems = (existingIndex < existingOptionTexts.length);
    }
    
    return true;
}
//----------------------------moveItems-----------------------------------------

function moveItems (fromBox, toBox) {  
  
    for(var i=0;i < fromBox.length; ++i) {
        if (fromBox.options[i].selected) {
            
            toBox.options[toBox.length] = 
                new Option(fromBox.options[i].text, fromBox.options[i].value, false, false);
            
            fromBox.options[i] = null;
            //fromBox.length = fromBox.length - 1;
            --i;
        }
    }
}

//-------------------selectionCheck-------------------------------------------
// check to make sure selection is not empty 

function selectionCheck(list) {          
  var clist = 0;    
  if (list.length) {
    for (i = 0; i < list.length; i++){      
      if (list[i].checked)         
        clist++;        
    }
  } else {
    if (list.checked)
      clist++;
  }   
  if (clist == 0) {    
    return false;
  } else {
    return true;
  }  
}

//---------------------setAllOptions-----------------------------------------
function selectAllOptions(selectList) {   
  setAllOptions(selectList, true);
}

function deselectAllOptions(selectList) {  
  setAllOptions(selectList, false);
}

function setAllOptions(selectList, state) {  
  bCancel=false;   

  if(selectList != null){                 
    for (var i = 0; i < selectList.length; ++i) {            
      selectList.options[i].selected = state;      
    }
  }
}

//--------------------selectAllCheckBoxes---------------------------------------
function selectAllBoxes(list, state){    
  if (list != null) {
    if (list.length) {
      for (var i = 0; i < list.length; i++)
        list[i].checked = state;
    } else {
      list.checked = state;
    }
  }
}

function playAudio(filename, forward) {            
  submitActionForm(forward);  
}

<!---------- BTDate Date Control scripts -------------------->
function BTDate_changeNewDate(numb,dayobj,monthobj,yearobj,newdate) {

 mth = monthobj.selectedIndex;
 sel = yearobj.selectedIndex;
 yr = yearobj.options[sel].text;
 if (numb != 1) {
  numDays = BTDate_numDaysIn(mth,yr);
  if (numDays > dayobj.selectedIndex) 
       {remember = dayobj.selectedIndex;}
  else {remember = numDays-1;}
  dayobj.options.length = numDays;
  for (i=27;i<numDays;i++) {
   dayobj.options[i].text = i+1;
  }
  dayobj.selectedIndex = remember;
 }
 day = dayobj.selectedIndex;

 var m = parseInt(monthobj.options[mth].value)
 var d = parseInt(dayobj.options[day].text)
 var y = parseInt(yearobj.options[sel].text)
 newdate.value = m+"/"+d+"/"+y;
<!--- Hack!!! if the date range button exists make sure it is checked ---->
 if (document.forms[0].timeFrame)
 {
    document.forms[0].timeFrame[4].checked=true;
 }

<!-- Another hack, dws -->
if (document.forms[0].schoolYearTimeFrame)
{
	document.forms[0].schoolYearTimeFrame[1].checked = true;
}	 
}
function BTDate_numDaysIn(mth,yr) {
 if (mth==3 || mth==5 || mth==8 || mth==10) return 30;
 else if ((mth==1) && BTDate_leapYear(yr)) return 29;
 else if (mth==1) return 28;
 else return 31;
}
function BTDate_leapYear(yr) {
 if (((yr % 4 == 0) && yr % 100 != 0) || yr % 400 == 0)
  return true;
 else
  return false;
}

<!-- update using a string MM/DD/YYYY -->
function BTDate_updateWithString(newdate, form, name)
{	
      var m = newdate.slice(0,2);
      var d = newdate.slice(3,5);
      var y = newdate.slice(6);
      BTDate_updateControls(m, d, y, form, name)
}

function BTDate_updateControls(month, day, year, form, name)
{
      var m = BTDate_findElement(form, "BTmonth4"+name);
      var y = BTDate_findElement(form, "BTyear4"+name);
      var d = BTDate_findElement(form, "BTday4"+name);
      m.selectedIndex = BTDate_getIndex(parseInt(month, 10),m)  //ksaxton 2/9/01 #73D2CD
      d.selectedIndex = BTDate_getIndex(parseInt(day, 10),d)    //added 10 so number is 
      y.selectedIndex = BTDate_getIndex(parseInt(year, 10),y)   //parsed base 10
      BTDate_changeNewDate(0,d,m,y,BTDate_findElement(form, name));
}

function BTDate_findElement(form, name)
{
      var len = form.elements.length;
      for (var i=0; i<len; i++) {
      if (form.elements[i].name == name)
      return form.elements[i]
      }
}

function BTDate_getIndex(value, selobj)
{
      var len = selobj.options.length;
      for (var i=0; i<len; i++) {
      if (selobj.options[i].value == value)
      return i;
      }
}

// Report Selection functions

function compReport(userType,brand)
{
    thisAction = "displayReport.do?";
    thisAction += "reportType=C";
    if (userType == 'D')
    {
        if (document.reportSelectionForm.studentType.value != "-1")
             thisAction += "&xaxis=cfv.field1";
        else if (document.reportSelectionForm.schoolID.value != "-1" && document.reportSelectionForm.gradeID.value != "-1")
            thisAction += "&xaxis=class.id";
        else if (document.reportSelectionForm.schoolID.value != "-1")
            thisAction += "&xaxis=user.grade"; 
       else
            thisAction += "&xaxis=school.id";
    }
    else if (userType == 'T')
    {
        if (document.reportSelectionForm.storyID.value != "-1" && document.reportSelectionForm.studentID.value != "-1")
            thisAction += "&xaxis=reading.id";
        else if (document.reportSelectionForm.studentID.value != "-1")
            thisAction += "&xaxis=story.id";
 
        else if (document.reportSelectionForm.classID.value != "-1")
            thisAction += "&xaxis=student.id";
        else
            thisAction += "&xaxis=class.id";
        if (document.reportSelectionForm.storyID.value == "-1")
            thisAction += "&storyID=-1";
        thisAction += "&studentType=-1";
    }
    else if (userType == 'B')
    {
        if (document.reportSelectionForm.studentType.value != "-1")
            thisAction += "&xaxis=cfv.field1";
       else if (document.reportSelectionForm.classID.value != "-1")
            thisAction += "&xaxis=student.id";       
        else if (document.reportSelectionForm.gradeID.value != "-1")
            thisAction += "&xaxis=class.id";
 
        else
            thisAction += "&xaxis=user.grade";    
    }
    if (document.reportSelectionForm.storyID.value == "-1")
            thisAction += "&storyID=-1";
    thisAction += "&yaxis=percent_correct";
    thisAction += "&dataTable=num_students";
    thisAction += "&dataTable=last_session";
    thisAction += "&dataTable=completed_titles";
    if (brand != 'QR')
        thisAction += "&dataTable=completed_quizzes";
    if (brand != 'QR')
        thisAction += "&dataTable=average_text_level";
    thisAction += "&dataTable=quiz_available";
    thisAction += "&dataTable=quiz_attempted";
    thisAction += "&loseSort=1";

    thisAction += "&dataTable=quiz_correct";
    thisAction += "&dataTable=percent_correct";
    thisAction += "&yaxislabel=report.percent_correct";
    thisAction += "&graphType=bar";
    thisAction += "&barType=verticalBar"; 
    thisAction += "&fromReport=1";
    thisAction += "&drillLevel=-1";
    thisAction += "&noTable=0";


    // thisAction += "&dataTable=lastReadingDate";
    document.reportSelectionForm.action=thisAction;
//    document.reportSelectionForm.submit();
}
function fluencyAgainstGoalReport(userType,brand)
{
    thisAction = "displayReport.do?";
    thisAction += "reportType=FG"; 

    if (userType == 'D')
    {
        if (document.reportSelectionForm.studentType.value != "-1")
            thisAction += "&xaxis=cfv.field1";
        else if (document.reportSelectionForm.schoolID.value != "-1" && document.reportSelectionForm.gradeID.value != "-1")
            thisAction += "&xaxis=class.id";
        else if (document.reportSelectionForm.schoolID.value != "-1")
            thisAction += "&xaxis=user.grade";

        else
            thisAction += "&xaxis=school.id";

    }
    else if (userType == 'T')
    {
        if (document.reportSelectionForm.storyID.value != "-1" && document.reportSelectionForm.studentID.value != "-1")
            thisAction += "&xaxis=reading.id";
        else if (document.reportSelectionForm.studentID.value != "-1")
            thisAction += "&xaxis=story.id";
        else if (document.reportSelectionForm.classID.value != "-1")
            thisAction += "&xaxis=student.id";
        else
            thisAction += "&xaxis=class.id";
        if (document.reportSelectionForm.storyID.value == "-1")
            thisAction += "&storyID=-1";
        thisAction += "&studentType=-1";

    }    
    else if (userType == 'B')
    {
        if (document.reportSelectionForm.studentType.value != "-1")
            thisAction += "&xaxis=cfv.field1";
        else if (document.reportSelectionForm.classID.value != "-1")
            thisAction += "&xaxis=student.id";
        else if (document.reportSelectionForm.gradeID.value != "-1")
            thisAction += "&xaxis=class.id";
        else
            thisAction += "&xaxis=user.grade";    
    }

    thisAction += "&xaxis=month";
    thisAction += "&yaxis=month";
    thisAction += "&loseSort=1";
    thisAction += "&dataTable=month";
    thisAction += "&dataTable=num_students2";
    thisAction += "&dataTable=completed_titles2";
    thisAction += "&dataTable=average_text_level2";
    thisAction += "&dataTable=below_goal";
    thisAction += "&dataTable=at_above_goal";
/*
    thisAction += "&dataTable=trend_point";
    thisAction += "&dataTable=goal";
    thisAction += "&dataTable=ten_below_goal";
*/ 
    thisAction += "&dataTable=average_wpm";
    thisAction += "&yaxislabel=report.wpm";
    thisAction += "&graphType=goal";
    thisAction += "&barType=verticalBar";
    thisAction += "&fromReport=1";
    thisAction += "&drillLevel=-1";
    thisAction += "&noTable=0";



    document.reportSelectionForm.action=thisAction;
//    document.reportSelectionForm.submit();
}
function fluencyReport(userType,brand)
{
    thisAction = "displayReport.do?";
    thisAction += "reportType=F";  
    if (userType == 'D')
    {
        if (document.reportSelectionForm.studentType.value != "-1")
            thisAction += "&xaxis=cfv.field1";
        else if (document.reportSelectionForm.schoolID.value != "-1" && document.reportSelectionForm.gradeID.value != "-1")
            thisAction += "&xaxis=class.id";
        else if (document.reportSelectionForm.schoolID.value != "-1")
            thisAction += "&xaxis=user.grade";

        else
            thisAction += "&xaxis=school.id";

    }
    else if (userType == 'T')
    {
        if (document.reportSelectionForm.storyID.value != "-1" && document.reportSelectionForm.studentID.value != "-1")
            thisAction += "&xaxis=reading.id";
        else if (document.reportSelectionForm.studentID.value != "-1")
            thisAction += "&xaxis=story.id";
        else if (document.reportSelectionForm.classID.value != "-1")
            thisAction += "&xaxis=student.id";
        else
            thisAction += "&xaxis=class.id";
        if (document.reportSelectionForm.storyID.value == "-1")
            thisAction += "&storyID=-1";
        thisAction += "&studentType=-1";

    }    
    else if (userType == 'B')
    {
        if (document.reportSelectionForm.studentType.value != "-1")
            thisAction += "&xaxis=cfv.field1";
        else if (document.reportSelectionForm.classID.value != "-1")
            thisAction += "&xaxis=student.id";
        else if (document.reportSelectionForm.gradeID.value != "-1")
            thisAction += "&xaxis=class.id";
        else
            thisAction += "&xaxis=user.grade";    
    }
    thisAction += "&yaxis=wpm";
    thisAction += "&loseSort=1";
    thisAction += "&dataTable=num_students";
    thisAction += "&dataTable=last_session";
    thisAction += "&dataTable=completed_titles";
    if (brand != 'QR')
        thisAction += "&dataTable=average_text_level";
    thisAction += "&dataTable=num_readings";
    if (brand == 'QR')
        thisAction += "&dataTable=total_words";
    thisAction += "&dataTable=firstwpm";
    thisAction += "&dataTable=lastwpm";
    if (brand != 'QR')
        thisAction += "&dataTable=amount_read";
    thisAction += "&dataTable=wpm_goal";
    if (brand == 'QR')
        thisAction += "&dataTable=accuracy";
    thisAction += "&dataTable=wpm";
    thisAction += "&yaxislabel=report.wpm";
    thisAction += "&graphType=bar";
    thisAction += "&barType=verticalBar";
    thisAction += "&fromReport=1";
    thisAction += "&drillLevel=-1";
    thisAction += "&noTable=0";



    document.reportSelectionForm.action=thisAction;
//    document.reportSelectionForm.submit();
}
function usageReport(userType,brand)
{
    thisAction = "displayReport.do?";
    thisAction += "reportType=U";  

   if (userType == 'D')
    {
        if (document.reportSelectionForm.studentType.value != "-1")
            thisAction += "&xaxis=cfv.field1";
        else if (document.reportSelectionForm.schoolID.value != "-1" && document.reportSelectionForm.gradeID.value != "-1")
            thisAction += "&xaxis=class.id";
        else if (document.reportSelectionForm.schoolID.value != "-1")
            thisAction += "&xaxis=user.grade";
 
        else
            thisAction += "&xaxis=school.id";
 
    }
    else if (userType == 'T')
    {
        if (document.reportSelectionForm.storyID.value != "-1" && document.reportSelectionForm.studentID.value != "-1")
            thisAction += "&xaxis=reading.id";
        else if (document.reportSelectionForm.studentID.value != "-1")
            thisAction += "&xaxis=story.id";
 
        else if (document.reportSelectionForm.classID.value != "-1")
            thisAction += "&xaxis=student.id";

        else
            thisAction += "&xaxis=class.id";

        if (document.reportSelectionForm.storyID.value == "-1")
            thisAction += "&storyID=-1";
        thisAction += "&studentType=-1";

    }    
    else if (userType == 'B')
    {
        if (document.reportSelectionForm.studentType.value != "-1")
             thisAction += "&xaxis=cfv.field1";
        else if (document.reportSelectionForm.classID.value != "-1")
            thisAction += "&xaxis=student.id";
        else if (document.reportSelectionForm.gradeID.value != "-1")
            thisAction += "&xaxis=class.id";
        else
            thisAction += "&xaxis=user.grade";    
    }
    if (document.reportSelectionForm.storyID.value == "-1")
            thisAction += "&storyID=-1";
    thisAction += "&loseSort=1";

    thisAction += "&yaxislabel=report.totalUsageGraph";
    thisAction += "&dataTable=num_students";
    thisAction += "&dataTable=reading_time";
    thisAction += "&dataTable=listening_time";
    thisAction += "&dataTable=quiz_time";
    thisAction += "&dataTable=total_usage";
    thisAction += "&dataTable=completed_titles";
    thisAction += "&dataTable=readings_per_title";
    thisAction += "&dataTable=last_session";
    thisAction += "&dataTable=total_sessions";
    thisAction += "&graphType=bar";
    thisAction += "&barType=verticalBar";
    thisAction += "&yaxis=total_usage_time_min";
    thisAction += "&fromReport=1";
    thisAction += "&drillLevel=-1";
    thisAction += "&noTable=0";
    document.reportSelectionForm.action=thisAction;
//    document.reportSelectionForm.submit();
}

/**
 * Submits the form containing the given field, when the given event is
 * an Enter key press.
 * In the following example, if the focus is in the searchTerm field and the user
 * presses the Enter key, mySearchForm will be submitted:
 *
 * <form name="mySearchForm" action="...">
 *    ...
 *    <input name="searchTerm" onkeypress="return submitOnEnterKeyPress(this, event)" />
 *
 */
function submitOnEnterKeyPress(field, event) {
   var keycode;
   if (window.event) keycode = window.event.keyCode;
   else if (event) keycode = event.which;
   else return true;
   if (keycode == 13) {
      field.form.submit();
      return false;
   }
   else return true;
}

/**
 * Calls a function when the Enter key is pressed. Pass in the function name as an unquoted
 * string without parentheses.
 *
 * In the following example, if the focus is in the searchTerm field and the user
 * presses the Enter key, doSearch() will be called:
 *
 * <input name="searchTerm" onkeypress="return callFunctionOnEnterKeyPress("doSearch", event)" />
 */
function callFunctionOnEnterKeyPress(functionPtr, event) {
   var keycode;
   if (window.event) keycode = window.event.keyCode;
   else if (event) keycode = event.which;
   else return true;
   if (keycode == 13) {
      functionPtr();
      return false;
   }
   else return true;
}
