var betinfoPopupIsIE=document.all;
var betinfoPopupIsNN=!document.all&&document.getElementById;
var betinfoPopupDiv=betinfoPopupIsIE ? document.all.betinfoPopup : document.getElementById("betinfoPopup"); 
var betinfoPopupIsDragging = false;
var betinfoPopupMoveInterval = 0;

function betinfoPopupHide(){
  if (betinfoPopupIsIE||betinfoPopupIsNN) {
    betinfoPopupDiv.style.visibility="hidden";
    betinfoPopupDiv.style.top=200 + 'px'
  }
}

function betinfoPopupDrag(e){
if (!betinfoPopupIsDragging) return;
  betinfoPopupDiv.style.left=betinfoPopupIsIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
  betinfoPopupDiv.style.top=betinfoPopupIsIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;
}


function betinfoPopupInit()
{
 betinfoPopupDiv=betinfoPopupIsIE ? document.all.betinfoPopup : document.getElementById("betinfoPopup");
}

function betinfoPopupDragStart(e){
  var topDog=betinfoPopupIsIE ? "BODY" : "HTML";
  //var hotDog=betinfoPopupIsIE ? event.srcElement : e.target;
  var hotDog = document.getElementById('betinfoPopup');
  /*while (hotDog.id!="betinfoPopup"&&hotDog.tagName!=topDog){
    hotDog=betinfoPopupIsIE ? hotDog.parentElement : hotDog.parentNode;
  }*/
  if (hotDog.id=="betinfoPopup"){
    offsetx=betinfoPopupIsIE ? event.clientX : e.clientX;
    offsety=betinfoPopupIsIE ? event.clientY : e.clientY;
    nowX=parseInt(betinfoPopupDiv.style.left);
    nowY=parseInt(betinfoPopupDiv.style.top);
    betinfoPopupIsDragging=true;
    document.onmousemove=betinfoPopupDrag;
  }
}


function betinfoPopupShow(e,url){
  var content = document.getElementById('betinfoPopupContent');
  var width=650;
  var height=475;
  var xpos, ypos;
  /*xpos=parseInt(e.clientX - width/2);
  ypos=parseInt(e.clientY - height/2);
  if (xpos<0) xpos = 0;
  else if(xpos>(document.body.clientWidth-width-20)) xpos = document.body.clientWidth-width-20;
  if (ypos<0) ypos = 0;
  else if(ypos>(document.body.clientHeight-height-30)) ypos = document.body.clientHeight-height-30;
  */
  var windowWidth = window.innerWidth?window.innerWidth:(document.body.parentElement.clientWidth?document.body.parentElement.clientWidth:document.body.clientWidth);
  var windowHeight = window.innerHeight?window.innerHeight:(document.body.parentElement.clientHeight?document.body.parentElement.clientHeight:document.body.clientHeight);
  xpos = Math.round(windowWidth/2-width/2)
  ypos = Math.round(windowHeight/2-height/2)

  xpos += document.body.scrollLeft;
  ypos += document.body.scrollTop;
  if (xpos<0) xpos=0
  if (ypos<0) ypos=0
  content.src = url;
  if (betinfoPopupIsIE||betinfoPopupIsNN) {
  betinfoPopupDiv.style.visibility="visible";
  }
  betinfoPopupDiv.style.left=xpos + 'px'
  betinfoPopupDiv.style.top=ypos + 'px'
  var doc = content.contentDocument?content.contentDocument:content.Document;
  if (doc)
  {
    doc.body.innerHTML = '<div style="height:100%; vertical-align: middle; text-align: center">Loading...</div>'
  }
  return;
}
document.onmousedown=betinfoPopupInit;
