
function openWindows( referer, url, args, redirect ) {
  if( redirect == 'true') {
    window.location = "http://www.betfair.com/?" + referer;
  }
  window.open(url + referer,"",args );
}


function loadArticle( variantId, itemId ) {

  var reply = function(report) {
    
    var item = report.object.items[0];

    // we need to loop over the item fields to find the article.
    var itemf;
    for( var j = 0; j < item.itemFields.length; j++ ) {
      if ( item.itemFields[j]["itemFieldId"] == "article" ) {
        itemf = item.itemFields[j]["value"];
        break;
      }
    }

    // try find div-tag.
    var n = document.getElementById( "helpcontents" );

    if ( !n ) {
      n = document.getElementById( "homepage" );
      if ( !n ) {
        alert( "No 'helpcontents' id, can't load contents!" );
        return true;
      } else {
        // if it is the homepage, we need to "turn" it into a normal
      // contents page.
        n.className = "helpcontents";
        n.id = "helpcontents";
        var t = document.getElementById( "contentstab" );
        t.className = "tabon";
      }
    }

    // set one link to have the 'subnavlinkon'
    var l = document.getElementById( "link"+itemId );
    l.className = "subnavlinkon";

    // reset cookie of last viewed article
    document.cookie =
    "contents=/contents/itemId/"+itemId+"/index."+variantId+".html; path=/";

    n.innerHTML =
    "<div id=\"progressholder\"><div id=\"progressbg\"><div id=\"progress\"></div></div></div>\n" +
    itemf;

  };

  var el = document.getElementById( "progressholder" );
  if ( el ) {
    el.style.display = "block";
  }

  // reset all links to not have class 'subnavlinkon'
  var links = document.getElementsByTagName("a");
  for( var i = 0; i < links.length; i++ ) {
    if ( links[i].className == "subnavlinkon" ) links[i].className = "";
  }

  // call the AJAX.
  P2Content.getArticle( variantId, itemId, reply );


  // tell link to not navigate.
  return false;

}
