function top(ownerid) {
  return '<table cellpadding="1" cellspacing="0" class="default_01"> <tr> <td width=100% colspan=4 bgcolor=#000000 ><span class="title"  ><a href="/public/jp/click?ownerid=65008b&userid='+ownerid+'" target=_blank><font color=#00ff00>■人気ランキングはこちら </font></a></span></td></tr></td></tr><tr><td bgwidth=100% color=#000000>';
}


function toprank(ownerid) {
  return '<table cellpadding="2" cellspacing="5" class=default_01 bgcolor=#000000 ><tr><td colspan="4"><a href="/public/jp/click?ownerid=65008b&userid='+ownerid+'" target=_blank>■人気ランキングはこちら</a></td></tr>';
}

function bottom(ownerid, title, link) {
    // Do not show title and link if did not get passed all args
   if ( !title && !link ) 	
  	return '<tr bgcolor=#000000> <td colspan="4" bgcolor=#000000> <span class="title"><font color=#00ff00>ID:'+ownerid+'</font><br /> <a href="/public/jp/category?ownerid='+ownerid+'" target=_blank class=homeurl><font color=#00ff00>ランキングに参加する</font></a></span><br /> <span class="title"><a href="http://www.dti-ranker.com/" target="_blank"><font class="title"><font color=#00ff00>Powered by DTI ランカー </font></font></a></span></td></tr> </table>';

  return '<tr bgcolor=#000000> <td colspan="4" bgcolor=#000000> <span class="title"><a href="'+link+'" target=_blank><font color=#00ff00>'+title+'</font></a><font color=#00ff00>ID:'+ownerid+'</font><br /> <a href="/public/jp/category?ownerid='+ownerid+'" target=_blank class=homeurl><font color=#00ff00>ランキングに参加する</font></a></span><br /> <span class="title"><a href="http://www.dti-ranker.com/" target="_blank"><font class="title"><font color=#00ff00>Powered by DTI ランカー </font></font></a></span></td></tr> </table>';
}


function limitlength(p,len) {
        if (p) {
                if (p.length > len) {

    /* Truncate the content of the P, then go back to the end of the
       previous word to ensure that we don't truncate in the middle of
       a word */
                        p = p.substring(0, len);
                        p = p.replace(/\w+$/, '');
			
				p = p+'・・・ ';
			
                }
        }

        return p;
}

function write_ad(item) {
  var prioritystring = "";
  arrowpath='';
  item.description = limitlength(item.description,50);
  item.title       = limitlength(item.title,30);
  var html = '    <td class=tdmiddle align=left valign=top>'+'<table cellpadding=0 cellspacing=0 width=100% border=0><tr><tr><td align=left class=rank><font color=#00ff00>PR</font></td><td class=title><a target=_blank href="'+item.link+'"><font color=#00ff00>'+item.title+'</a>';
  if (item.priority=='true')
    html += prioritystring;
  html += '</font></td></tr><tr><td colspan=2 class=description>'+item.description+'</td></tr></tr></table>'+'</td>';
  return html;
}


function middle(ownerid, arrowpath, prioritystring, item) {
  item.description = limitlength(item.description,50);
  item.title       = limitlength(item.title,30);
  var html = ''+'<table cellpadding=0 cellspacing=0 width=100% border=0><tr><tr><td align=left class=rank><font color=#00ff00>'+item.rank+'位 </font></td><td class=title><a target=_blank href="'+item.link+'"><font color=#00ff00>'+item.title+'</a>';
  if (item.priority=='true')
    html += prioritystring;
  html += '</font></td></tr><tr><td colspan=2 class=description>'+item.description+'</td></tr></tr></table>'+'';
  return html;
}

