
  function calendarPicker(strField)
  {
    window.open('DatePicker.aspx?field=' + strField, 'calendarPopup', 'top=200,left=200,width=250,height=190,resizable=yes');
  }
  
  function CalendarFrame(strField)
  {                  
    document.getElementById(strField).style.display='block';
  }
  
  function ContainerQuickInfo(ContainerID)
  {
    openDialog('ContainerQuickInfo.aspx?ContainerID=' + ContainerID, 460, 470);
  }

  function ContainerJobQuickInfo(FindJobNo)
  {
    openDialog('ContainerQuickInfo.aspx?FindJobNo=' + FindJobNo, 460, 470);
  }
  
  function TruckVisitQuickInfo(TruckVisitID, RegoNo)
  {
    openDialog('VBSTruckVisitQuickInfo.aspx?TruckVisitID=' + TruckVisitID, 460, 470);
  }

  function DisplayEstimateDetails(EstimateID)
  {
    openDialog('DepotEstimateDetails.aspx?EstimateID=' + EstimateID, 700, 500, RefreshDepot);
  }
  
  function DisplayTransportJobSegmentDetails(JobSegmentID)
  {
    openDialog('TransportSegmentDetails.aspx?JobSegmentID=' + JobSegmentID, 400, 450);
  }

  function DisplayApproveEstimateEntry(EstimateID)
  {
    openDialog('DepotEstimateApprovalEntry.aspx?EstimateID=' + EstimateID, 400, 200, RefreshEstimate);
  }
  
  function RefreshEstimate() {
    window.location = window.location
  }
  

  function DisplayContainerSummaryList(ContainerSize, ContainerType, ContainerHeight, GradeCode, StatusCode, OperatorCode, ContainerRate) 
  {
    window.open('DepotContainerSummaryList.aspx?Size=' + ContainerSize + '&Type=' + ContainerType + '&Height=' + ContainerHeight + '&GradeCode=' + GradeCode + '&StatusCode=' + StatusCode + '&LineOp=' + OperatorCode + '&ContainerRate=' + ContainerRate, null, "width=720,height=400,scrollbars=yes,resizable=yes,left=" + (screen.width - 720) / 2 + ",top=" + (screen.height - 400) / 2);
  }
   
  function ViewPDFFile(PRAID)
  {
    window.open('PRAViewPDF.aspx?PRAID=' + PRAID);
  } 

  function PRASearch()  {
    var el = document.getElementById('PRASearchFrame');
      el.src = "PRASearchPopup.aspx";
      el.style.visibility = "visible";
  }
  
  function HidePRAPopup()  {
    parent.document.getElementById('PRASearchFrame').style.visibility="hidden"
  }


  function ProcessContainerImportReleasePinChange(ContID, newPinNo) {
    if (ContID > 0) { 
      var url = "TMSUtils.aspx?ContainerPinChangeID=" + ContID + "&PinNo=" + newPinNo; 
      xmlHttp = GetXmlHttpObject(DefaultAjaxChangeHandler); 
      xmlHttp_Get(xmlHttp, url); 
    }           
  }

  function DefaultAjaxChangeHandler() 
  { 
      //readyState of 4 or 'complete' represents that data has been returned 
      if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){ 
        var TmpVal = 0;
      } 
  } 
  
/////////////////////////////////////////////////////
//  Below is code for switching wigets on and off
/////////////////////////////////////////////////////
  
function switchMenu(obj) {
  var url = ""
  var el = document.getElementById(obj);
  if ( el.className != 'closed' ) {
    //Append the name to search for to the requestURL 
    url = "Control_ChangeView.aspx?ControlID=" + obj + "&State=0"; 
    xmlHttp = GetXmlHttpObject(ControlChangeHandler); 
    xmlHttp_Get(xmlHttp, url); 
    el.className = 'closed';
  }
  else {
    //Append the name to search for to the requestURL 
    url = "Control_ChangeView.aspx?ControlID=" + obj + "&State=1"; 
    xmlHttp = GetXmlHttpObject(ControlChangeHandler); 
    xmlHttp_Get(xmlHttp, url); 
    el.className = '';
  }
}

function goAway(obj) {
  var el = document.getElementById(obj);
  el.className = 'gone';
}

function ControlChangeHandler() {
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){ 
    var TmpVal = 0;
  }
}

/////////////////////////////////////////////////////
//  Below is code for highlighting table rows on mouse over 
/////////////////////////////////////////////////////

// These variables are for saving the original background colors
var savedStates=new Array();
var savedStateCount=0;

/////////////////////////////////////////////////////
// This function takes an element as a parameter and 
//   returns an object which contain the saved state
//   of the element's background color.
/////////////////////////////////////////////////////
function saveBackgroundStyle(myElement)
{
  saved=new Object();
  saved.element=myElement;
  saved.className=myElement.className;
  saved.backgroundColor=myElement.style["backgroundColor"];
  return saved;   
}

/////////////////////////////////////////////////////
// This function takes an element as a parameter and 
//   returns an object which contain the saved state
//   of the element's background color.
/////////////////////////////////////////////////////
function restoreBackgroundStyle(savedState)
{
  savedState.element.style["backgroundColor"]=savedState.backgroundColor;
  if (savedState.className)
  {
    savedState.element.className=savedState.className;    
  }
}

/////////////////////////////////////////////////////
// This function is used by highlightTableRow() to find table cells (TD) node
/////////////////////////////////////////////////////
function findNode(startingNode, tagName)
{
  // on Firefox, the TD node might not be the firstChild node of the TR node
  myElement=startingNode;
  var i=0;
  while (myElement && (!myElement.tagName || (myElement.tagName && myElement.tagName!=tagName)))
  {
    myElement=startingNode.childNodes[i];
    i++;
  }  
  if (myElement && myElement.tagName && myElement.tagName==tagName)
  {
    return myElement;
  }
  // on IE, the TD node might be the firstChild node of the TR node  
  else if (startingNode.firstChild)
    return findNode(startingNode.firstChild, tagName);
  return 0;
}

/////////////////////////////////////////////////////
// Highlight table row.
// newElement could be any element nested inside the table
// highlightColor is the color of the highlight
/////////////////////////////////////////////////////
function highlightTableRow(myElement, highlightColor)
{
  var i=0;
  // Restore color of the previously highlighted row
  for (i; i<savedStateCount; i++)
  {
    restoreBackgroundStyle(savedStates[i]);          
  }
  savedStateCount=0;

  // To get the node to the row (ie: the <TR> element), 
  // we need to traverse the parent nodes until we get a row element (TR)
  // Netscape has a weird node (if the mouse is over a text object, then there's no tagName
  while (myElement && ((myElement.tagName && myElement.tagName!="TR") || !myElement.tagName))
  {
    myElement=myElement.parentNode;
  }

  // If you don't want a particular row to be highlighted, set it's id to "header"
  // If you don't want a particular row to be highlighted, set it's id to "header"
  if (!myElement || (myElement && myElement.id && myElement.id=="header") )
    return;
		  
  // Highlight every cell on the row
  if (myElement)
  {
    var tableRow=myElement;
    
    // Save the backgroundColor style OR the style class of the row (if defined)
    if (tableRow)
    {
	  savedStates[savedStateCount]=saveBackgroundStyle(tableRow);
      savedStateCount++;
    }

    // myElement is a <TR>, then find the first TD
    var tableCell=findNode(myElement, "TD");    

    var i=0;
    // Loop through every sibling (a sibling of a cell should be a cell)
    // We then highlight every siblings
    while (tableCell)
    {
      // Make sure it's actually a cell (a TD)
      if (tableCell.tagName=="TD")
      {
        // If no style has been assigned, assign it, otherwise Netscape will 
        // behave weird.
        if (!tableCell.style)
        {
          tableCell.style={};
        }
        else
        {
          savedStates[savedStateCount]=saveBackgroundStyle(tableCell);        
          savedStateCount++;
        }
        // Assign the highlight color
        tableCell.style["backgroundColor"]=highlightColor;

        // Optional: alter cursor
        tableCell.style.cursor='default';
        i++;
      }
      // Go to the next cell in the row
      tableCell=tableCell.nextSibling;
    }
  }
}

/////////////////////////////////////////////////////
// This function is to be assigned to a <table> mouse event handler.
// If the element that fired the event is within a table row,
//   this function will highlight the row.
/////////////////////////////////////////////////////
function trackTableHighlight(mEvent, highlightColor)
{
  if (!mEvent)
    mEvent=window.event;
		
  // Internet Explorer
  if (mEvent.srcElement)
  {
    highlightTableRow( mEvent.srcElement, highlightColor);
  }
  // Netscape and Firefox
  else if (mEvent.target)
  {
    highlightTableRow( mEvent.target, highlightColor);		
  }
}

/////////////////////////////////////////////////////
// Highlight table row.
// newElement could be any element nested inside the table
// highlightColor is the color of the highlight
/////////////////////////////////////////////////////
function highlightTableRowVersionA(myElement, highlightColor)
{
  var i=0;
  // Restore color of the previously highlighted row
  for (i; i<savedStateCount; i++)
  {
    restoreBackgroundStyle(savedStates[i]);          
  }
  savedStateCount=0;

  // If you don't want a particular row to be highlighted, set it's id to "header"
  if (!myElement || (myElement && myElement.id && myElement.id=="header") )
    return;
		  
  // Highlight every cell on the row
  if (myElement)
  {
    var tableRow=myElement;
    
    // Save the backgroundColor style OR the style class of the row (if defined)
    if (tableRow)
    {
	  savedStates[savedStateCount]=saveBackgroundStyle(tableRow);
      savedStateCount++;
    }

    // myElement is a <TR>, then find the first TD
    var tableCell=findNode(myElement, "TD");    

    var i=0;
    // Loop through every sibling (a sibling of a cell should be a cell)
    // We then highlight every siblings
    while (tableCell)
    {
      // Make sure it's actually a cell (a TD)
      if (tableCell.tagName=="TD")
      {
        // If no style has been assigned, assign it, otherwise Netscape will 
        // behave weird.
        if (!tableCell.style)
        {
          tableCell.style={};
        }
        else
        {
          savedStates[savedStateCount]=saveBackgroundStyle(tableCell);        
          savedStateCount++;
        }
        // Assign the highlight color
        tableCell.style["backgroundColor"]=highlightColor;

        // Optional: alter cursor
        tableCell.style.cursor='default';
        i++;
      }
      // Go to the next cell in the row
      tableCell=tableCell.nextSibling;
    }
  }
}

