/****************************************
 ** FOR TOP ARTICLE MENU -- ICON --
 ***************************************/

function getDataService2(go, action, id, id2, b) 
{
   processLoading(id);
   
   try
   {
      http.open('post', go);
      http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      http.send(action);

      http.onreadystatechange = function () {
         if(http.readyState == 4) 
         {
            var response = http.responseText;

            if (http.status == 200) 
            {
               var sp = response.split('||');
           
               document.getElementById(id).innerHTML = sp[1];
               if (sp[0] == 'OK')
               {
                  clearForm(id2);
                  b.disabled = true;
               }
            }
            else 
            {
               alert("ERROR:" + http.status + " Ada masalah pada pengiriman data!");
            }
         }
      }
   }
   catch (e){}
   finally {}
}

function clearForm(tab) {
   var d = document.getElementById(tab);
   if (d)
   {
      for (i = 0; i < d.length; i++)
      {
         if ((d[i].type == "text") || d[i].type == "textarea")
         {
             d[i].value = '';
         }
         
         if (d[i].type == "checkbox")
         {
             d[i].checked = false;
         }
      }
   }
}

/*
   show message with red color
*/
function boxError(id, msg) {
   document.getElementById(id).innerHTML = '<div style="background:#FF0000; color: #FFFFFF; padding:2px;">'+ msg +'</div>';
}

/*
   Show process info
*/
function processLoading(id) {
   boxError(id, 'Sedang Proses...');
}
 
 /*
    Clear all message status
 */
function clearAllMessage() {
   var stf = document.getElementById('sendToFriend');
   if (stf) stf.innerHTML = '';
   
   var stft = document.getElementById('sendToFriendTop');
   if (stft) stft.innerHTML = '';
}
 
function switchNewsTabTop(active) {
    
   var eleActive = document.getElementById(active);
   var valNow = eleActive.style.display;

   var f1 = document.getElementById('newsTopInfoEmail');
   
   if (f1) f1.style.display = "none";
   
   clearAllMessage();
   
   if (valNow == "inline")
   {
      eleActive.style.display = "none";
   }
   else
   {
      eleActive.style.display = "inline";
   }
   
   setEmailSender('cSenderTmp', 'cEmailTmp', 'nameFriendTop', 'emailFriendTop');
   for (var i = 1; i <= 5; i++) setEmailSender('cDestNameTmp'+ i, 'cDestEmailTmp'+ i, 'recipientTop'+ i, 'remTop'+ i);
   
   setEmailSender('cSenderTmp', 'cEmailTmp', 'nameNewsletterTop', 'emailNewsletterTop');
   setEmailSender('cSenderTmp', 'cEmailTmp', 'commentNamaTop', 'commentEmailTop');
   setEmailSender('cSenderTmp', 'cEmailTmp', 'namaFansTop', 'emailFansTop');
}

function checkMemberLoginTop() {
    
    var member_email = readCookie("klb_email");
    var member_name = '';
 
    if (member_email != null)
    {
          member_email = decodeURIComponent(readCookie("klb_email"));
 
          if (readCookie('c_member_album') != null)
          {
                member_name = readCookie("c_member_album");					
          }
          else 
          {
                if (readCookie('member_album') != null)
                {
                      member_name = readCookie("member_album");
                }
          }
 
          if (member_name == "" || member_name == null) 
          {
                member_name = member_email;
          }
 

          if (document.getElementById("lineNameTop"))
          {
             document.getElementById("namaFansTop").value = member_name;
             document.getElementById("emailFansTop").value = member_email;
             document.getElementById("lineNameTop").style.display = "none";
             document.getElementById("line2Top").innerHTML = ": "+ member_name;
             document.getElementById("lineEmailTop").style.display = "none";
             document.getElementById("line1Top").innerHTML = ": "+ member_email;
          }
          
          if (document.getElementById("commentLineNameTop"))
          {
             document.getElementById("commentNamaTop").value = member_name;
             document.getElementById("commentEmailTop").value = member_email;
             document.getElementById("commentLineNameTop").style.display = "none";
             document.getElementById("commentLine2Top").innerHTML = ": "+ member_name;
             document.getElementById("commentLineEmailTop").style.display = "none";
             document.getElementById("commentLine1Top").innerHTML = ": "+ member_email;
          }
    }
}
 
function sendToFriendDataTop(button) {
  
      var name    = document.getElementById('nameFriendTop').value;
      var email   = document.getElementById('emailFriendTop').value
      var type    = document.getElementById('typeTop').value;
      var url     = document.getElementById('urlTop').value;
      var flag    = document.getElementById('flagTop').value;
      var allow   = false;
      var allow2  = false;
      var copy    = 0;
      if (document.getElementById('idcopyTop').checked)
      {
            copy = 1;
      }
      
      if (name == '')
      {
          boxError('sendToFriendTop', 'Nama tidak boleh kosong.');
          return false;
      }
      /* set name sender to cookie, set it to 30 minutes*/
      createCookie2('cSenderTmp', name, 30);
        
      
      if (email == '')
      {
          boxError('sendToFriendTop', 'Email tidak boleh kosong.');
          return false;
      }
      
      /* set email to cookie, set it to 30 minutes*/
      createCookie2('cEmailTmp', email, 30);
      
      var variable = 'action=send_to_friend&name='+ name +'&email='+ email +'&type='+ type +'&url='+ url +'&flag='+ flag +'&copy='+ copy;
      for (i = 1; i <= 5; i++)
      {
          var x = document.getElementById('recipientTop'+ i).value;
          variable += '&recipient'+ i +'='+ x;
          
          if (x != '')
          {
              createCookie2('cDestNameTmp'+ i, x, 30);
              allow = true;
          }
      }
      for (i = 1; i <= 5; i++)
      {
          var y = document.getElementById('remTop'+ i).value;
          variable += '&rem'+ i +'='+ y;

          if (y != '')
          {
              createCookie2('cDestEmailTmp'+ i, y, 30);
              allow2 = true;
          }
      }
      
      if ((! allow) || (! allow2))
      {
          boxError('sendToFriendTop', 'Nama dan Email tujuan tidak boleh kosong.');
          return false;
      }
    
    getDataService2('/u/news_service.php', variable, 'sendToFriendTop', 'newsTopInfoEmailForm', button);
    
    return true;
}


   var TopMenu = '<div style="clear: both; padding: 1px 3px 10px 5px; text-align: left;">';
   TopMenu += '    <div style="padding: 3px; float: left;">';
   TopMenu += '        <a alt="Kirim Email ke Teman" title="Kirim Email ke Teman" href="javascript: void(0);" onclick="javascript: switchNewsTabTop(\'newsTopInfoEmail\');"><img src="http://www.kapanlagi.com/i/v3/email2pren.png" /></a>';
   TopMenu += '    </div>';
   
   if(have_print){
      TopMenu += '    <div style="padding: 3px; float: left;">';
      TopMenu += '        <a href="'+ print_url +'" target="_BLANK"><img src="http://www.kapanlagi.com/i/v3/cetak_berita.png" alt="Cetak Berita" title="Cetak Berita" /></a>';
      TopMenu += '    </div>';
   }

if (have_artist)
{
   TopMenu += '   <div style="padding: 3px; float: left;">';
   TopMenu += '      <a  alt="Kirim Komentar Ke Fans" title="Kirim Komentar Ke '+ artist_name +'" href="javascript: void(0);" onclick="javascript: switchNewsTabTop(\'newsTopInfoFans\');"><img src="http://www.kapanlagi.com/i/v3/fans.png" /></a>';
   TopMenu += '   </div>';
}

TopMenu += '<div style="clear: both;"></div>';
TopMenu += '	<div style="float: left; display: none; border: 1px solid #666666;" id="newsTopInfoEmail">';
TopMenu += '	  <div style="padding: 0px; width: 330px;">';
TopMenu += '	    <div style="padding: 10px; font-weight:bold;text-align:center; background-color: #ededed;">KIRIM EMAIL KE TEMAN</div>';
TopMenu += '	    <div style="padding: 10px;">Informasikan ke teman-teman Anda mengenai '+ type_prog_uc +' dibawah melalui email.</div>';
TopMenu += '	    <div style="padding: 8px;">';
TopMenu += '	      <form action="/u/sendtofriend.php" method="post" target="subscribe" onSubmit="return false;" id="newsTopmInfoEmailForm">';
TopMenu += '	        <div style="float:left; margin:2px">Nama Anda</div>';
TopMenu += '	        <div style="float:right;text-align:right; margin:2px;"><input style="width:150px" type="text" name="name" id="nameFriendTop" value=""></div>';
TopMenu += '	        <div style="clear: both; width: 120px; float:left; margin:2px">Alamat Email Anda</div>';
TopMenu += '	        <div style="float:right;text-align:right; margin:2px;"><input style="width:150px" type="text" name="email" id="emailFriendTop" value=""></div>';
TopMenu += '	        <div style="clear: both;"></div>';
TopMenu += '	        <br />';
TopMenu += '	        <div style="clear: both; text-align:center; margin: 3px;font-weight:bold;">Kirim Ke</div>';
TopMenu += '	        <div style="float:left; padding-left: 10px;">Nama</div>';
TopMenu += '	        <div style="float:right;text-align:right; padding-right: 10px;">Email</div>';
TopMenu += '	        <br style="clear: both;" />';
TopMenu += '                <div style="float:left;margin:1px;"><input style="width:135px" type="text" name="recipientTop1" id="recipientTop1" value=""></div><div style="float:right;margin:1px;text-align:right;"><input style="width:140px" type="text" name="remTop1" id="remTop1" value=""></div><div style="float:left;margin:1px;"><input style="width:135px" type="text" name="recipientTop2" id="recipientTop2" value=""></div><div style="float:right;margin:1px;text-align:right;"><input style="width:140px" type="text" name="remTop2" id="remTop2" value=""></div><div style="float:left;margin:1px;"><input style="width:135px" type="text" name="recipientTop3" id="recipientTop3" value=""></div><div style="float:right;margin:1px;text-align:right;"><input style="width:140px" type="text" name="remTop3" id="remTop3" value=""></div><div style="float:left;margin:1px;"><input style="width:135px" type="text" name="recipientTop4" id="recipientTop4" value=""></div><div style="float:right;margin:1px;text-align:right;"><input style="width:140px" type="text" name="remTop4" id="remTop4" value=""></div><div style="float:left;margin:1px;"><input style="width:135px" type="text" name="recipientTop5" id="recipientTop5" value=""></div><div style="float:right;margin:1px;text-align:right;"><input style="width:140px" type="text" name="remTop5" id="remTop5" value=""></div>';
TopMenu += '	        <br style="clear:both;" />';
TopMenu += '	        <br />';
TopMenu += '                <div id="sendToFriendTop"></div>';
TopMenu += '	        <div style="float:left; padding-top: 5px;">';
TopMenu += '	          <div style="float:left;text-align:left; width:260px;">';
TopMenu += '                        <input type="checkbox" name="copyTop" id="idcopyTop" value=1 checked /> kirim copy ke email saya';
TopMenu += '                  </div>';
TopMenu += '                  <br style="clear: both;" />';
TopMenu += '	        </div>';
TopMenu += '                <div style="clear: both;"></div>';
TopMenu += '                <div style="width: 100%; padding-top: 10px; text-align: right;">';
TopMenu += '                             <input type=hidden name="typeTop" id="typeTop" value="'+ type_prog +'">';
TopMenu += '                             <input type=hidden name="urlTop" id="urlTop" value="'+ lirik_url +'">';
TopMenu += '                             <input type=hidden name="flagTop" id="flagTop" value="true">';
TopMenu += '                             <input type="button" value="Tutup form ini" onclick="javascript: document.getElementById(\'newsTopInfoEmail\').style.display = \'none\';" />';
TopMenu += '                             <input value="Kirim" class=button onclick="javascript: sendToFriendDataTop(this);" type="submit" />';
TopMenu += '                </div>';
TopMenu += '	        <br style="clear:both;" />';
TopMenu += '	      </form>';
TopMenu += '	    </div>';
TopMenu += '	  </div>';
TopMenu += '	</div>';


if (have_artist)
{
    TopMenu += '<div style="float: left; display: none; border: 1px solid #666666;" id="newsTopInfoFans">';
    TopMenu += '    <form id="newsTopInfoFansForm">';
    TopMenu += '	  <div style="padding: 0px; width: 330px;" id="mainCommentTop">';
    TopMenu += '	    <div style="font-weight:bold; padding: 10px; text-align:center; background-color: #ededed;">KOMENTAR FANS '+ artist_name +'</div>';
    TopMenu += '	      <div style="padding: 10px;">';
    TopMenu += '	      Anda fans <a href="http://selebriti.kapanlagi.com/'+ artist_url +'"><b>'+ artist_name +'</b></a>? Berikan komentar Anda.<br />';
    TopMenu += '	      Komentar akan ditampilkan di halaman biografi <a href="http://selebriti.kapanlagi.com/'+ artist_url +'"><b>'+ artist_name +'</b></a>, diharapkan sopan dan bertanggung jawab.';
    TopMenu += '	      </div>';
    TopMenu += '        <div style="padding: 8px;">';
    TopMenu += '                   <div style="clear: both; text-align: left; padding-top: 8px;">';
    TopMenu += '                    <div style="float:left; width:75px;">Nama Anda</div>';
    TopMenu += '                    <div style="float:left;" id="line2">:&nbsp;</div>';
    TopMenu += '                    <div style="float:left;" id="lineName"><input style="width:210px !important; width:200px;" type="text" name="namaTop" id="namaFansTop" /></div>';
    TopMenu += '	      </div>';
    TopMenu += '	      <div style="clear: both; text-align: left; padding-top: 1px;">';
    TopMenu += '                    <div style="float:left; width:75px;">Email Anda</div>';
    TopMenu += '                    <div style="float:left;" id="line1">:&nbsp;</div>';
    TopMenu += '                    <div style="float:left;" id="lineEmail"><input style="width:210px !important; width:200px;" type="text" name="emailTop" id="emailFansTop" /></div>';
    TopMenu += '	      </div>';
    TopMenu += '	      <div style="clear: both; padding-top: 1px;" id="lineMessage">';
    TopMenu += '	    	<div style="float: left; width: 75px;">Pesan</div>';
    TopMenu += '	    	<div style="float: left;">:&nbsp;</div>';
    TopMenu += '	    	<div style="float: left;"><textarea style="width:210px;" rows="5" name="pesanTop" id="pesanTop"></textarea></div>';
    TopMenu += '	      </div>';
    TopMenu += '	      <div style="clear: both;"></div>';
    TopMenu += '	      <div style="padding: 5px 0px 0px 90px; clear: both;">';
    TopMenu += '	    	<span style="font-size: 11px;">KapanLagi.com berhak menghapus komentar yang tidak layak ditampilkan</span><br /><br />';
    TopMenu += '	      </div>';
    TopMenu += '        <div id="commentTop"></div>';
    TopMenu += '        <div style="padding-top: 5px; text-align: right;">';
    TopMenu += '                       <input type="hidden" name="newsArtist" id="newsArtistTop" value="'+ artist_name +'" />';
    TopMenu += '                       <input type="button" value="Tutup form ini" onclick="javascript: document.getElementById(\'newsTopInfoFans\').style.display = \'none\';" />';
    TopMenu += '                       <input name="submitNewsCommentTop" value="   Kirim   " onclick="javascript: newsFansCommentTop(this);" type="button" />';
    TopMenu += '        </div>';
    TopMenu += '      </div>';
    TopMenu += '	  </div>';
    TopMenu += '    </form>';
    TopMenu += '	</div>';
}

TopMenu += '       <div style="clear: both;"></div>';
TopMenu += '      </div>';


document.write(TopMenu);