  var OCGuid = '';

  function pollFragment()
  {
    var iframe = document.getElementById("oddsFrame");
    setTimeout(function()
    {
      pollForHeight(OCGuid, iframe, 0);
    }, 200);
  }
  
  function pollForHeight(guid, iframe, retryCount)
  {
    if (retryCount < 10)
    {
      var getHeightImage = new Image();
      getHeightImage.onload = function()
      {
        iframe.style.height = getHeightImage.height + "px";
        setTimeout(pollFragment, 5000); //Start again in 5 seconds
      };
      getHeightImage.onerror = function()
      {
        setTimeout(function()
        {
          pollForHeight(guid, iframe, retryCount + 1);
        }, 200);
      };
      getHeightImage.src = "http://www.puntersparadise.com.au/api/OddsComparisonGetHeight.php?guid=" + guid + "&cacheKiller=" + Math.random().toString().substring(2);
    }
    else
    {
      iframe.src = iframe.src.substring(0, iframe.src.indexOf("#")) + "#SHOW_SCROLL";
    }
  }
  
  function generateGUID()
  {
    function G4()
    {
      return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
    }
    return G4()+G4()+"-"+G4()+"-"+G4()+"-"+G4()+"-"+G4()+G4()+G4();
  }

  function setupiFrame()
  {
    var iframe = document.getElementById("oddsFrame");
    OCGuid = generateGUID();
    iframe.src = iframe.src + "#GUID=" + OCGuid;
    pollFragment();
  }

  if (window.addEventListener) //DOM method for binding an event
    window.addEventListener("DOMContentLoaded", setupiFrame, false);
  else if (window.attachEvent) //IE exclusive method for binding an event
    window.attachEvent("onload", setupiFrame);
  else if (document.getElementById) //support older modern browsers
    window.onload=setupiFrame;