  function drawPage(data){
    //alert("drawPage="+data);
    document.getElementById("page").innerHTML = data; 
    DoTH();
  }
 
  function drawErrorPage(xhr,status){
    var errorHtml = '<div id="stacktrace" style="padding: 15px; margin-left:25px; margin-right:25px; margin-top:50px; margin-bottom:400px;">';
      if (xhr.status==200){
        errorHtml  += '<div class="titleBlock titleOrangeBold14">'+xhr.status+' - '+status+'</div>';
      } else {
        errorHtml  += '<div class="titleBlock titleOrangeBold14">'+xhr.status+' - '+xhr.statusText+'</div>';
      }
      errorHtml  += '<p style="width: 500px;">';
      errorHtml  += 'Sorry, we are not able to process your request at this time.';
      errorHtml  += '</p></div>';
    document.getElementById("page").innerHTML=errorHtml;
  }

  function drawPageHeader(headerPath){
    try{
      $.get(headerPath, function(response){ 
          document.getElementById("static_header").innerHTML = response; 
          $(".TopNav_div").mouseover(function (){
              $(this).toggleClass("TopNav_div_over");
              $(this).find("div:first").css({'display':'block','top':($(this).position().top +24 )+'px','left':($(this).position().left )+'px'})
              $(this).find("div:first").append('<div class="TopNav_shadow"></div>');
              $(this).find("div.TopNav_shadow").css({'width':$(this).find("div:first").width(),'height':$(this).find("div:first").height(),'top':(3)+'px','left':(3)+'px',opacity:0.4})
            }
          ); 
          $(".TopNav_div").mouseout(function (){
            $(this).toggleClass("TopNav_div_over");
            $(this).find("div:first").css('display','none');
            $(this).find("div.TopNav_shadow").remove();
          });           

          var selectedTopNavDiv = document.getElementById(selectedTab);
          if (selectedTopNavDiv){
            selectedTopNavDiv.style.fontWeight='bold';
            selectedTopNavDiv.style.color='#0575b9'; //CME font color
          }           
      }, "html");
    } catch(e){}
  }

  function makeCellsWhite(){
    var page = document.getElementById('page');
    var cellCount = page.getElementsByTagName('td').length;
    for(var j=0;j<cellCount;j++){
      var cell = page.getElementsByTagName('td')[j];
      if(cell.getAttribute("rel") == 'refresh'){
        cell.style.background = '#FFFFFF';
      }
    }
  }

  function gup( name ){
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );

    if( results == null ) return "";
    else return results[1];
  }

  function getAbsX(elt) { return(elt.x) ? elt.x : getAbsPos(elt, 'offsetLeft');}
  function getAbsY(elt) { return(elt.y) ? elt.y : getAbsPos(elt, 'offsetTop');}
  function getAbsPos(elt, which) {
    var iPos = 0;
    while (elt != null) {
      iPos += elt[which];
      elt = elt.offsetParent;
    }
    return iPos;
  }
  
  function DoTH(){
    //if DIV table headers present
    if ( $("div.fix_table_header").length > 0 ){
      var DivsCount = document.getElementsByTagName('div').length;
      for (var i=0;i < DivsCount;i++) {

        var div = document.getElementsByTagName('div')[i];
        if (div.className == 'fix_table_header') {
          var firstChild = div.getElementsByTagName('div')[0];
          var secondChild = div.getElementsByTagName('tr')[0];

          if (firstChild && secondChild) {
            var columns_count = firstChild.getElementsByTagName('div').length;
            for (var ii=0;ii < columns_count;ii++) {
              var firstChild_ans = firstChild.getElementsByTagName('div')[ii];
              var secondChild_ans = secondChild.getElementsByTagName('td')[ii];

              firstChild_ans.style.width = (secondChild_ans.clientWidth)+'px';
              firstChild_ans.style.left = getAbsX(secondChild_ans)+'px';
              firstChild_ans.style.top = (getAbsY(secondChild_ans)-(18))+'px';
              secondChild_ans.style.borderTop = '0px';
              firstChild_ans.style.display = 'block';
            }
          }
        }
      }
    } 
    //if DIV table headers present - this is for Options page which has
    // a custom span across the top for CALLS / PUTS
    else if ( $("div.fix_options_table_header").length > 0 ){
      var DivsCount = document.getElementsByTagName('div').length;
      for (var i=0;i < DivsCount;i++) {

        var div = document.getElementsByTagName('div')[i];
        if (div.className == 'fix_options_table_header') {
          //
          // DO NOT CHANGE THIS UNLESS YOU TEST THE OPTIONS PAGE IN MULTIPLE
          // BROWSERS WITH THE NEW CODE FIRST (CLEAR BROWSER CACHE TOO)!!!
          //
          var firstChild = div.getElementsByTagName('div')[0];
          var secondChild = div.getElementsByTagName('tr')[0];

          if (firstChild && secondChild) {
            var columns_count = firstChild.getElementsByTagName('div').length;
            for (var ii=0;ii < columns_count;ii++) {
              var firstChild_ans = firstChild.getElementsByTagName('div')[ii];
              var secondChild_ans = secondChild.getElementsByTagName('td')[ii];

              if ($.browser.msie){ 
                firstChild_ans.style.top = (getAbsY(secondChild_ans)-32)+'px';
                firstChild_ans.style.width = ((secondChild_ans.clientWidth)+1)+'px';
              } else {
                firstChild_ans.style.top = (getAbsY(secondChild_ans)-32)+'px';
                firstChild_ans.style.width = (secondChild_ans.clientWidth)+'px';
              }
              firstChild_ans.style.left = getAbsX(secondChild_ans)+'px';
              secondChild_ans.style.borderTop = '0px';
              firstChild_ans.style.display = 'block';
            }
          }
        }
      }
    }
  }
  
  function updateSortable(elementId){
    //For some reason I have to call this on updates
    $(document).ready(function(){
      $(elementId).tablesorter(); });
      
    //For some reason this was not needed, it is here for referrence   
    //$("elementId").trigger("update"); 
    //var sorting = [[2,1],[0,0]]; 
    // sort on the first column 
    //$("#example").trigger("sorton",[sorting]);
 
  }

  //Clear Any List
  function clearList(elementId){
    var list = document.getElementById(elementId);
    // clear the country list 
    if ( list != null ){
      for (var count = list.options.length-1; count > -1; count--)
        list.options[count] = null;
    }
  }
  
  function colorTransition(cell, tmp){
    if ( cell.innerHTML != tmp ){
      cell.innerHTML = tmp;
      //cell.style.backgroundColor = 'd8e6ee';
      //colorFade('testdiv','background','ffffff','d8e6ee');
    }
  }
 
  //helper method that resets the values of table to default value = '-'
  function clearTable(maxRowsPerPage, maxColumns, rowPrefix, emptyChar){
    for ( i = 0; i < maxRowsPerPage; ++i){
      var row = document.getElementById(rowPrefix+i); 
      for ( j = 0; row!=null && j < maxColumns; ++j)
        row.cells[j].innerHTML = emptyChar;
    }
  }
  
  //Helper method to extract values from drop downs 
  function getSelectedValue(elementId){
    var ndx = document.getElementById(elementId).selectedIndex;    
    return document.getElementById(elementId).options[ndx].text;
  }
  
  function appendParamToURL(url, param1Name, param1value){
    if (url.indexOf('?') > -1){ 
      url += "&" + param1Name + "=" + param1value;
    } else {
      url += "?" + param1Name + "=" + param1value;
    }
    return url;
  }
 
  function getXmlFromResponse(response){
    var xmlString
    
    if (window.ActiveXObject) {
      //for IE
      xmlString = response.xml;
    } else if (document.implementation && document.implementation.createDocument) {
      //for Mozila
      xmlString = (new XMLSerializer()).serializeToString(response);
    }
  
    return xmlString
  }