function loadPayouts(game,ddate, e, sm) {
  // don't display pobox until fully loaded
  $.ajaxSetup({ async: false });
  $("#pobox").load('/ajax/getPayouts.aspx?game=' + game + '&ddate=' + ddate);
  var top = (e.clientY - $("#rpane").offset().top + 15) + "px";
  // var top = (e.clientY + document.getElementById('bground').scrollTop - 310)  + "px";
  var left = "337px";
  if (sm === undefined) {
    // determine position of payouts based on y position and game
    if (game == 1) {
      left = "181px";
    } else if (game == 3) {
      left = "357px";
    } else if (game == 2) {
      left = "188px";
    } else if (game == 4) {
      left = "363px";
    }
  } else {
    // else site master or home page
    // var top = (e.clientY + document.getElementById('bground').scrollTop - 310)  + "px";
    var left = "360px";
    // determine position of payouts based on y position and game
    if (game == 1) {
        left = "230px";
    } else if (game == 3) {
        left = "355px";
    } else if (game == 2) {
        left = "230px";
    } else if (game == 4) {
        left = "355px";
    }

  }
  $("#pobox").css("top", top);
  $("#pobox").css("left", left);
  $("#pobox").css("display", "block");
  $("#flyout").css("top", "50px");
}

function loadGridPayouts(game,ddate, e) {

  // don't display pobox until fully loaded
  $.ajaxSetup({ async: false });
  $("#pobox").load('/ajax/getPayouts.aspx?numbers=true&game=' + game + '&ddate=' + ddate);

  // set nib top default to 50px
  var ntop = "50px";

  // determine position of payouts based on e.clientY
  // modify this code to use jquery only, instead of javascript
  // var top = (e.clientY  + document.getElementById('bground').scrollTop - 310) + "px";
  var bheight = getPayoutBoxHeight(game);
  var top = (e.clientY - $("#rpane").offset().top + 15) + "px";

  // determine position of payouts based on e.clientY
  var left =  "595px";
  if ((game == 5) || (game == 11)) {
    left = "485px";
  } else if (game == 6) {
    left = "585px";
  } else if (game == 7) {
    left = "590px";
  } else if (game == 10) {
    left = "560px";
  }

  // calculate pobox bottom in relation to bottom of rpane
  var pobottom = e.clientY - $("#rpane").offset().top - 55 + bheight;
  // alert(pobottom + " / " + $("#rpane").height());

  // if bottom rpane reached position bottom of pobox to rpane bottom and move nib
  if (pobottom > $("#rpane").height()) {
      if (($("#rpane").height() + 95 - bheight) > 0) {
        // set top of box
        top = ($("#rpane").height() + 95 - bheight) + "px";
        // set top of nib
        ntop = (e.clientY - $("#rpane").offset().top - ($("#rpane").height() + 30 - bheight)) + "px";
      }
  // else if payout to be displayed is less than 60 pixels from the top, scroll down
  } else if (e.pageY < 60) {
    $("#bground").animate({scrollTop: "-=" + (60 - e.pageY)}, 0);
  }

  $("#pobox").css("top", top);
  $("#pobox").css("left", left);
  $("#pobox").css("display", "block");
  $("#flyout").css("top", ntop);

}

function loadWinGridPayouts(game,ddate, e, shift) {
  var shiftPayoutWindow = shift  

  // don't display pobox until fully loaded
  $.ajaxSetup({ async: false });
  $("#pobox").load('/ajax/getPayouts.aspx?numbers=true&game=' + game + '&ddate=' + ddate);
  
  // set nib top default to 50px
  var ntop = "50px";

  // determine position of payouts based on e.clientY
  // modify this code to use jquery only, instead of javascript
  // var top = (e.clientY  + document.getElementById('bground').scrollTop - 310) + "px";
  var bheight = getPayoutBoxHeight(game);
  var top = (e.clientY - $("#rpane").offset().top + 15) + "px";
  var left =  "625px";
  if (game == 5) {
      if (shiftPayoutWindow == true) {
        left = "592px";     
      } else {
        left = "550px";      
      }      
  } else if (game == 11) {
    left = "555px";
  } else if (game == 6) {
    left = "615px";
  } else if (game == 7) {
    left = "620px";
  } else if (game == 10) {
    left = "587px";
  }
  // calculate pobox bottom in relation to bottom of rpane
  var pobottom = e.clientY - $("#rpane").offset().top - 55 + bheight;
  // alert(pobottom + " / " + $("#rpane").height());

  // if bottom rpane reached position bottom of pobox to rpane bottom and move nib
  if (pobottom > $("#rpane").height()) {
      if (($("#rpane").height() + 95 - bheight) > 0) {
        // set top of box
        top = ($("#rpane").height() + 95 - bheight) + "px";
        // set top of nib
        ntop = (e.clientY - $("#rpane").offset().top - ($("#rpane").height() + 30 - bheight)) + "px";
      }
  // else if payout to be displayed is less than 60 pixels from the top, scroll down
  } else if (e.pageY < 60) {
    $("#bground").animate({scrollTop: "-=" + (60 - e.pageY)}, 0);
  }

  $("#pobox").css("top", top);
  $("#pobox").css("left", left);
  $("#pobox").css("display", "block");
  $("#flyout").css("top", ntop);
}

// this function is needed since the prior to rendering the pobox for
// the first time, the jquery function does not know height
// if payout chart design is changed (when game prize structure changes)
// verify that the box height for the game is updated here
function getPayoutBoxHeight(game) {

  var bheight = 0;
  if ((game == 1) || (game == 3)) {
    bheight = 333;
  } else if ((game == 2) || (game == 4)) {
    bheight = 249;
  } else if (game == 5) {
    bheight = 548;
  } else if (game == 6) {
    bheight = 277;
  } else if (game == 7) {
    bheight = 361;
  } else if (game == 10) {
    bheight = 433;
  } else if (game == 11) {
    bheight = 548;
  }
  return bheight;
  
}

// function scrollY() {return window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;}

