//cache test
//ffx_swap unaltered. Will add the html to the innerHTML of the defined div

function fixStr(str){
return str.toUpperCase().replace(/[\/\-\\\&]/gi,"").replace(/[ +]/,"_");
}

  function ffx_swap(elName, html) {
      var d = document;
      if (!d.getElementById) {
          return;
      }
      var el = d.getElementById(elName);
      if (!el) {
          return;
      }
      var remove = false;
      if (typeof ffxAdExclusionList != "undefined") {
        var thisPage = window.location.pathname;
        for (var i=0; i<ffxAdExclusionList.length; i++) {
          var current = ffxAdExclusionList[i];
          if (current == 'remove_all_ads'){
            return;
          }
          else if (current == 'remove_article_ads'){
            if (thisPage.match(/\/news\/[a-zA-Z0-9-]+\/[a-zA-Z0-9-]+\/[0-9]{4}\/[0-9]{2}\/[0-9]{2}\/[0-9]+.html/) || thisPage.match(/\/articles\/.*?/)){
              remove = true;
            }
          }
          else if (current == 'remove_index_ads'){
            if  (thisPage.match(/\/index.html$/) || !thisPage.match(/.html$/)){
              remove = true;
            }
          }
          else if (current == thisPage) {
            return;
          }
        }
      }
      if (remove == true) {return;}
      el.innerHTML = html;
  }

var ad, x = 0;
thedomain = document.domain+"";
rightdomain = false;

if(thedomain.indexOf("australianstockreport.com.au")==true){
 rightdomain = true;
 document.domain = "australianstockreport.com.au";
}

while(ad = ffxAds[x]) {

ran = Math.floor(Math.random*99999999999);

if(typeof(ad.height) == "undefined")
	hei = "1";
else
   hei=ad.height;
if(typeof(ad.width) == "undefined")
	wid = "1";
else
   wid=ad.width;

  var call = "http://www.australianstockreport.com.au/ffxd/intermediatoryV2.html?w="+wid+"&h="+hei+"&ad=http://direct.fairfax.com.au/jserver/acc_random="+ran+"/";
  if(ad.adtype == null || ad.adtype!="panorama")
   call = "http://direct.fairfax.com.au/hserver/acc_random="+ran+"/";
  var pageString = "SITE=ONL.CH.AUSTRALIANSTOCKREPORT.FINANCE/AREA=FINANCE.ASR.OTHER/";
  var adString = "";
  for(i in ad)
  if(i!="height"&&i!="width")
    adString += fixStr(i)+"="+fixStr(ad[i])+"/";

  if(adString.indexOf("adspace")==-1)
  	adString += "AAMSZ="+wid+"X"+hei+"/";
  var adspace = wid+"x"+hei;

  for(i in ffxpageVars){
	pageString+= fixStr(i)+"="+fixStr(ffxpageVars[i])+"/";
	}
  if(adString.length>0)
  	adString = adString.substring(0,adString.length-1);
  var targetString = escape(pageString+adString+"/acc_random="+Math.floor(Math.random()*100000000000000000));
  if(ad.adtype == null || ad.adtype!="panorama")
      targetString=unescape(targetString);
  if(adspace=="468x60"){
  wid="728";
  hei="90";
  }
  var iFrame = "<iframe id='ffxadiframe"+x+"' name='ffxadiframe"+x+"' allowtransparency='true' width="+wid+" height="+hei+" marginwidth=0 marginheight=0 hspace=0 VSPACE=0 frameborder=0 scrolling=no bordercolor='#000000' src='"+call+targetString+"'></iframe>";
  var holderDivId = "ffxad"+(x + 1);
  ffx_swap(holderDivId, iFrame);
  x++;
}



