    <?php if ($D->is_my_page) {?>
    
    <div id="areabfriend">
    	<div id="bteditprofile" class="bfriendly hand"><?php echo $this->lang('profile_page_editprofile'); ?></div>
    </div>

    <script>
        $('#bteditprofile').click(function(){
            location.href = siteurl + "dashboard/pages/edit/p:<?php echo $D->page->code?>";
        });
    </script>            
    
    <?php } else { ?>
    
    <div id="areabfriend">
        <div id="bactionlike" class="blike" 
        style=" <?php if ($D->ilikeme==0) { ?> background-image:url(<?php echo $C->SITE_URL.'themes/'.$C->THEME.'/imgs/ico-like-page.png'?>); background-repeat:no-repeat; background-position:10px 4px; <?php } else { ?> background-image:url(<?php echo $C->SITE_URL.'themes/'.$C->THEME.'/imgs/ico-like-page-true.png'?>); background-repeat:no-repeat; background-position:10px 4px; <?php } ?> ">
        <?php
        if ($D->ilikeme==1) echo('&nbsp;&nbsp;&nbsp;&nbsp;'.$this->lang('profile_page_txt_liked'));
        if ($D->ilikeme==0) { echo('&nbsp;&nbsp;&nbsp;&nbsp;'.$this->lang('profile_page_txt_like')); }
        ?>
        </div>
        <div id="preload-like" class="hide"><img src="<?php echo $C->SITE_URL?>themes/<?php echo $C->THEME?>/imgs/loading.gif"></div>
        <input name="ilikeme" type="hidden" id="ilikeme" value="<?php echo $D->ilikeme?>">
        <div id="smn1" class="boxsubmenu hide">
            <div id="opc-unlike" class="opcsm"><?php echo $this->lang('profile_page_txt_unlike');?></div>
        </div>    
	</div>

   	<?php if ($D->is_logged) { ?>
    <script>
	var dsm1, dsm2;
	var msg_norequest = '<?php echo $this->lang('dashboard_no_request')?>';
	var idpage = <?php echo $D->page->idpage; ?>;
	
	$('#bactionlike').mouseover(function() {
		if ($('#ilikeme').val() != 0) {
			$('#bactionlike').css('cursor','default');
		} else {
			$('#bactionlike').css('cursor','pointer');
		}
		
		if ($('#ilikeme').val() != 0) {
			showSmn('#smn' + $('#ilikeme').val());
		}
	});
	
	$('#bactionlike').mouseleave(function() {
		if ($('#ilikeme').val() != 0) {
			hideSmn('#smn' + $('#ilikeme').val());
		}
	});
	
	function keepSmnVisible() {
		clearInterval(dsm2);
	}
	
	function hideSmn(submenu) {
		clearInterval(dsm1);
		dsm2 = setInterval(function() {
			$(submenu).hide();
			clearInterval(dsm2);	
		},200);
	}
	
	function hideSmnFast(submenu, value) {
		clearInterval(dsm1);
		clearInterval(dsm2);
		$(submenu).hide();
		$('#ilikeme').val(value);
	}
	
	function showSmn(submenu) {
		clearInterval(dsm2);
		dsm1 = setInterval(function() {
			$(submenu).show();
		},50);
	}
	
	$('#smn1').mouseover(function() {
		keepSmnVisible();
	});

	$('#smn1').mouseleave(function() {
		hideSmn('#smn1');
	});

	//////////////////////////////	
	//action UNLIKE
	$('#opc-unlike').click(function(){
		
		$('#bactionlike').hide();
		$('#preload-like').show();
		
		$.ajax({
			type: 'POST',
			url: siteurl + "ajax/likes-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':
						$('#spaceFollow').hide();
						hideSmnFast('#smn1',0);
						$('#ilikeme').val(0);
						$('#bactionlike').css('background-image','url(<?php echo $C->SITE_URL.'themes/'.$C->THEME.'/imgs/ico-like-page.png'?>)');
						$('#bactionlike').html('&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $this->lang('profile_page_txt_like')?>');
						$('#numlikes').html(parseInt($('#numlikes').html()) - 1);
						break;
					}
			},
			error: function(){
				alert(msg_norequest);
			} //end error
		}); // end ajax	
		
		$('#bactionlike').show();
		$('#preload-like').hide();			

		return false;
	});
	
	
	//////////////////////////////
	// action CLICK LIKE
	$('#bactionlike').click(function(){

		if ($('#ilikeme').val() == 0) {
			
			$('#bactionlike').hide();
			$('#preload-like').show();
			
			$.ajax({
				type: 'POST',
				url: siteurl + "ajax/likes-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':
							$('#bactionlike').css('background-image','url(<?php echo $C->SITE_URL.'themes/'.$C->THEME.'/imgs/ico-like-page-true.png'?>)');
							$('#bactionlike').html('&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $this->lang('profile_page_txt_liked')?>');
							$('#ilikeme').val(1);
							$('#numlikes').html(parseInt($('#numlikes').html()) + 1);
							break;
						}
				},
				error: function(){
					alert(msg_norequest);

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

	<?php } else { ?>

    <div id="msgnotloggedin" class="hide">
		<div class="only-redbox"><?php echo $this->lang('profile_areafollow_youmustbe');?> <span class="linkblue"><a href="<?php echo $C->SITE_URL?>"><?php echo $this->lang('profile_areafollow_signed');?></a></span>.</div>
    </div>

	<script> 
	
	$('#bactionlike').mouseover(function(){
		if ($('#ilikeme').val() == 0) {
			$('#bactionlike').css('cursor','pointer');
		}
	});
	
	$('#bactionlike').one('click',function(){
	
		$("#areabfriend").fadeOut("slow",function(){
			$("#areabfriend").hide(function(){
				$("#msgnotloggedin").fadeIn('slow');
			});
		});			
	
	});  
	</script>
	
	<?php } //end isloged ?>
    

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