function switchMenu() {
  if(fclist){
    if(fclist.length == 0){
    } else {
      jQuery("#fc_subnavi_0").hide();
      jQuery("#fc_subnavi_1").show();
    }
  }
}

function myfcNews(flag) {
  if(flag==1){
    jQuery("#morefc").show();
    jQuery("#morenews").hide();
    jQuery("#hidenews").show();
  } else {
    jQuery("#morefc").hide();
    jQuery("#morenews").show();
    jQuery("#hidenews").hide();
  }
}

function myComment(flag) {
  if(flag==1){
    jQuery("#morecom").show();
    jQuery("#morecomments").hide();
    jQuery("#hidecomments").show();
  } else {
    jQuery("#morecom").hide();
    jQuery("#morecomments").show();
    jQuery("#hidecomments").hide();
  }
}

function showEntry(url) {
  openNewWindow(url, 'fcpreview', 'resizable=yes,toolbar=no,scrollbars=yes,personalbar=no,menubar=no,width=800,height=950'); 
}

function switchEntry(type) {
  if (type!='video' && type!='photo' && type!='diary') { type='all'; }
  document.getElementById('fctype').value = type;
  if ($('#newThumbnail_area').hasClass('thumnailAll')) { $('#newThumbnail_area').removeClass('thumnailAll'); }
  else if ($('#newThumbnail_area').hasClass('thumnailPhoto')) { $('#newThumbnail_area').removeClass('thumnailPhoto'); }
  else if ($('#newThumbnail_area').hasClass('thumnailDiary')) { $('#newThumbnail_area').removeClass('thumnailDiary'); }
  else if ($('#newThumbnail_area').hasClass('thumnailVideo')) { $('#newThumbnail_area').removeClass('thumnailVideo'); }
  className='thumnail'+type.charAt(0).toUpperCase()+type.substr(1).toLowerCase();
  $('#newThumbnail_area').addClass(className);
  xmlHttpGet('/fanclub/newEntry/'+type, 'newThumbnail_area');
}

function goTo(page) {
  type = document.getElementById('fctype').value;
  if (type!='video' && type!='photo' && type!='diary') { type='all'; }
  if (!page) page = 1;
  xmlHttpGet('/fanclub/newEntry/'+type+'?page='+page, 'newThumbnail_area');
}

function showMyFc() {
  limit = 20;
  mycount = 0;
  myfc = '';
  if ((isUser() || isVIP()) && fclist) {
    for (t in fclist) {
      if (mycount>=limit) { ++mycount;break; }
      myfc+='<div class="myFC_content"';
      if ((mycount+1)%2==0) { myfc+=' style="margin-right:0pt;"'; }
      myfc+='>';
      var online = performers.online[fclist[t]];
      if(online && online.session >= 110) { 
        myfc+='<div class="thumbnail_online"><span>ONLINE中！</span></div>';
        myfc+='<a href="javascript:openPreview(\''+fclist[t]+'\', 110)">';
      } else {
        myfc+='<a href="javascript:openFcProfile(\''+fclist[t]+'\')">';
      }      
      myfc+='<img width="123" height="92" src="'+image_url+'/WebArchive/'+fclist[t]+'/live/LinkedImage.jpg"/></a>';
      myfc+='<p class="pf_name"><a href="javascript:openFcProfile(\''+fclist[t]+'\');">'+fclist[t]+'</a></p>';
      myfc+='<p class="btnSendMail"><a href="javascript:openSendMail(\''+fclist[t]+'\');">メールする</a></p>';
      myfc+='</div>';
      ++mycount;
    }
  }
  if (myfc!='') {
    $("#btn_whatsFC").show(); 
    $("#btn_premium").hide(); 
    myfc='<h3>Myファンクラブ</h3>'+myfc;
    myfc+='<br style="clear: left;"/>';
    if (mycount>limit) { myfc+='<p id="btn_myFC_list"><a href="/fanclub/myfc">Myファンクラブ一覧へ</a></p>'; }
    $('#myFC_area').empty();
    $('#myFC_area').append(myfc); 
  } else {
    $("#btn_whatsFC").hide(); 
    $("#btn_premium").show(); 
  }
  return mycount;
}

function showOsusume(divID,noFC) {
  limit = 20;
  mycount = 0;
  if (noFC!=1) { mycount = showMyFc(); }
  limit = Math.floor((limit-mycount)/2);
  if (mycount==0) { limit = limit-2; }
  if (limit<=0) { $("#recommendFC_area").hide(); }
  num = 0;
  $(document).ready(function(){
    $.get('/json/fcRecommend','',
      function(data){
        var thumb = '';
       if(typeof fc_recommend != 'undefined'){
        eval(data);
        for (i in fc_recommend) {
           if (num>=limit) { break; }
           if ((isUser() || isVIP()) && fclist[i]) { continue; }
           pfullname = fc_recommend[i].user_name;
           pfname = fc_recommend[i].user_name.substring(0, 14);
           pfimg = image_url+'/WebArchive/'+pfullname+'/flash/LinkedImage.jpg';
           var pfonline = performers.online[pfullname];
           if (fc_recommend[i].user_name.length > 14) { pfname+='...'; }
           message = fc_recommend[i].message.substring(0, 40);
           if (fc_recommend[i].message.length > 40) { message+='...'; }
           last_style = (limit==num+1) ? ' style="border-bottom-style: none;"' : '';
           thumb+='<div class="recommendFC_content"'+last_style+'>';
           if(pfonline && pfonline.session >= 110) {
             thumb+='<div class="thumbnail_online"><span>ONLINE中！</span></div>';
             thumb+='<a href="javascript:openPreview(\''+fc_recommend[i].user_name+'\');"><img width="90" src="'+pfimg+'"></a>';
           } else {
             thumb+='<a href="javascript:openFcProfile(\''+fc_recommend[i].user_name+'\');"><img width="90" src="'+pfimg+'"></a>';
           }
           thumb+='<p class="pfName"><a href="javascript:void(0);" onClick="openFcProfile(\''+fc_recommend[i].user_name+'\');">'+pfname+'</a>ちゃん</p>';
           thumb+='<p class="contentType">';
           if (fc_recommend[i].diary>0) { thumb+='<img src="/img/fanclub/icon_pencil.gif"/>'; }
           if (fc_recommend[i].image>0) { thumb+='<img src="/img/fanclub/icon_camera.gif"/>'; }
           if (fc_recommend[i].video>0) { thumb+='<img width="16" height="16" src="/img/fanclub/icon_tv.gif"/>'; }
           thumb+='<p class="btnProfile"><a href="javascript:void(0);" onClick="openPreview(\''+fc_recommend[i].user_name+'\')"><img width="75" height="23" src="/img/fanclub/btn_goProfile_10.gif"/></a></p>';
           thumb+='<br style="clear: left;"/>';
           thumb+='<table class="pfComment" cellspacing="0" cellpadding="0" border="0"><tr><td>';
           thumb+='<img src="/img/fanclub/bg_pfComment_top.jpg"/></td></tr><tr><td>';
           thumb+='<p>'+message+'</p>';
           thumb+='</td></tr><tr><td><img src="/img/fanclub/bg_pfComment_bottom.jpg"/></td></tr></table>'
           thumb+='<div class="btnJoinFC"><a href="/fanclub/join/'+fc_recommend[i].user_name+'" target="_blank">このファンクラブに入会する</a></div>';
           thumb+='</div>';
           ++num;
        }
        if (thumb!='') { $('#'+divID).empty();$('#'+divID).append(thumb); }
        else { $("#"+divID).hide(); }
       } else {
         showOsusume('recommendFC_wrapper');
       }
    });
  });   
}

