// /prod/webdocs/htdocs/amednews/scripts/amnehs.js
// amednews e-HS ad processing routines



// specific specialty extractor for e-HS targeting
function getSpecialty(cookieStr) {
  var index1 = cookieStr.indexOf("s:");
  if (index1 == -1) {
    return "";
  }
  var index2 = cookieStr.indexOf(":", index1+2);
  if (index2 == -1) {
    return "";
  }
  return(cookieStr.substring(index1+2, index2));
}

// e-HS unchanging vars
var oas='http://ads.digitalhealthcare.com/RealMedia/ads/';
var RN = new String (Math.random());
var RNS = RN.substring (2, 11);

// callout to DisplayAds at ea ad position 
// *** NOTE the sitepage is hardcoded on ea page but this function is in a central script file 
// "query" is the filter var
function DisplayAds (position, width, height) {
  var oaspage= sitepage + '/1' + RNS + '@' + position;
  if (_version < 11) {
    document.write ('<A HREF="' + oas + 'click_nx.ads/'+ oaspage + '" TARGET="_top" ><IMG SRC="' + oas + 'adstream_nx.ads/' + oaspage + query + '" BORDER="0" WIDTH="' + width + '" HEIGHT="' + height + '"></A>');
  } else {
    document.write ('<SCRIPT LANGUAGE="JavaScript1.1" SRC="' + oas + 'adstream_jx.ads/' + oaspage + query + '">');
    document.write ('\<\!-- --\>');
    document.write ('\<\/SCRIPT\>');
    document.write ('\<\!-- --\>');
  }
}

// callout to display Interstitial ad 
function Interstitial () {
   var allcookies=document.cookie;
   var pos=allcookies.indexOf("EHSinterstitial=served");
   if (pos==-1) {
   	var date = new Date();
   	date.setTime(date.getTime()+(12*60*60*1000));
   	document.cookie="EHSinterstitial=served; expires=" + date.toGMTString() + "; path=/"; 
   	document.write('<script LANGUAGE="JavaScript1.1" SRC="http://ads.digitalhealthcare.com/RealMedia/ads/adstream_jx.ads/www.amednews.com/@Interstitial"><\/script>');
   	if (parseFloat(navigator.appVersion) == 0){ 
   	document.write('<IFRAME WIDTH=120 HEIGHT=600 MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" SRC="http://ads.digitalhealthcare.com/RealMedia/ads/adstream_sx.ads/www.amednews.com/@Interstitial"></IFRAME>');
   	}
   }
}
