
    <?php if (!$D->is_my_page) {?>

    <div id="areabfollow">
    
        <div id="bactionfollow" class="bfriendly2 hand">
        <?php
        if ($D->i_follow_him==0) echo('<img src="'.$C->SITE_URL.'themes/'.$C->THEME.'/imgs/ico-bfollow.png"> '.$this->lang('profile_areafollow_follow'));
        else echo('<img src="'.$C->SITE_URL.'themes/'.$C->THEME.'/imgs/ico-check-black.png"> '.$this->lang('profile_areafollow_following'));
        ?>
        </div>
        <input name="followship" type="hidden" id="followship" value="<?php echo $D->i_follow_him?>">
		<div id="preload-follow" class="hide"><img src="<?php echo $C->SITE_URL?>themes/<?php echo $C->THEME?>/imgs/loading.gif"></div>
                   
    </div>

	<script>

	$('#bactionfollow').click(function(){
		$('#bactionfollow').hide();
		$('#preload-follow').show();
		if ($('#followship').val() == 0) {

			$.ajax({
				type: 'POST',
				url: siteurl + "ajax/relationspage-actions/r:" + Math.round(Math.random()*1000),
				data: 'todo=1&idp=' + idpage,
				success: function(resp){
					switch(resp.charAt(0)){
						case '0':
							alert(resp.substring(3));
							break;
						case '1':							
							$('#bactionfollow').html('<?php echo('<img src="'.$C->SITE_URL.'themes/'.$C->THEME.'/imgs/ico-check-black.png"> '.$this->lang('profile_areafollow_following'))?>');
							$('#followship').val(1);
							break;
						}
				},
				error: function(){
					alert(msg_norequest);
				} //end error
			}); // end ajax	
			
			
		} else {
	
			$.ajax({
				type: 'POST',
				url: siteurl + "ajax/relationspage-actions/r:" + Math.round(Math.random()*1000),
				data: 'todo=2&idp=' + idpage,
				success: function(resp){
					switch(resp.charAt(0)){
						case '0':
							alert(resp.substring(3));
							break;
						case '1':
							$('#bactionfollow').html('<?php echo('<img src="'.$C->SITE_URL.'themes/'.$C->THEME.'/imgs/ico-bfollow.png"> '.$this->lang('profile_areafollow_follow'))?>');
							$('#followship').val(0);
							break;
						}
				},
				error: function(){
					alert(msg_norequest);

				} //end error
			}); // end ajax			
		}
		$('#bactionfollow').show();
		$('#preload-follow').hide();
		return false;
	});    
    </script>

	<?php } // end not is my page ?>
