    var _SERVER = 'www.addiply.com/';
    
    function addiply_media(adtype, p1, p2, p3)
    {
      if(adtype==1){
        //Text Ads
        isvertical=p1;
        inventory=p2;
        count = p3;
        ad_b(isvertical, inventory, count);
      } else if(adtype==2){
        //Banner Ads
        loc_id=p1;
        pheight=p2;
        pwidth = p3;
        ad_c(loc_id, pheight, pwidth);
      }
    }
    
    function ad_a(loc_id, pheight, pwidth)
    {
      twa_server = _SERVER;
      twa_rn = '001234567890'; twa_rns = '1234567890';
      twa_rn = new String (Math.random()); twa_rns = twa_rn.substring (2, 11);
      twa_url = 'http://'+twa_server+'redirect.php?i=' + twa_rns;
      twa_image ='http://'+twa_server+'renderimage.php?i=' + twa_rns + '&p=' + loc_id;
      twa_code = '<a href=\"' + twa_url + '\" target="_blank">';
      twa_code = twa_code + '<img border=0 height=' + pheight + ' width=' + pwidth + ' src=\"' + twa_image + '\"></a>';
      document.write(twa_code);
    }
  
    function ad_b(isvertical, inventory, count)
    {	
      var singleheight=110, singlewidth=146, height=0, width=0;
      if(isvertical==1){
        height=count*singleheight+65; width=singlewidth+10;
      } else {
        height=singleheight+45; width=count*singlewidth;
      }
      document.write("<iframe height="+height+" width="+width+" frameborder=0 marginwidth=0 marginheight=0 vspace=0 hspace=0 scrolling=no src=\"http://"+_SERVER+"gettextads.php?i="+inventory+"&v="+isvertical+"\"></iframe>");
    }
  
    function ad_c(loc_id, pheight, pwidth)
    {      
      twa_server = _SERVER;
      twa_rn = '001234567890'; twa_rns = '1234567890';
      twa_rn = new String (Math.random()); twa_rns = twa_rn.substring (2, 11);
      document.write("<iframe height="+pheight+" width="+pwidth+" frameborder=0 marginwidth=0 marginheight=0 vspace=0 hspace=0 scrolling=no src=\"http://"+_SERVER+"renderimage.php?i=" + twa_rns + "&p="+loc_id+"\"></iframe>");
    } 
