<!-- Community responsive dynamic menus starting here-->
<?php 
	//$community=$loggedInUser->present()->getNewViewsCommunity();	
	$community=$loggedInUser->present()->getVisitingCommunity();	
	$isCmUrl=\Request::segment(1);	
?>

@if($community)
	<?php 
        $marketplaceTitle=$community->present()->marketplaceTitle();
		$canViewCommunity=$community->present()->canView();
		$websiteFullUrl=$community->present()->getCommunityDomainUrl();
		
		$webUrlName=explode("://",$websiteFullUrl);
		
		if(isset($webUrlName[1])){
			$iswww=explode("www.",$webUrlName[1]);
			if(isset($iswww[1])){
				$websiteFullUrl=$webUrlName[1];
			}else{	
				$websiteFullUrl="www.".$webUrlName[1];
			}	
		}	
		//echo "website full url =".$websiteFullUrl;		
    ?>
	
    
    <style type="text/css">               
        .mm-menu{
            background:#d4d2cd;
        }
		
		.explore-community-events-link, .explore-community-crowdfunds-link{
			display:none;
		}			
    </style>
    
    @if($canViewCommunity && $isCmUrl=='c')
    	  <style type="text/css">
			.community-outside-menu{
				display:none !important;	
			}	
			
			.hide-on-community-pages{
				display:none !important;	
			}
			
			.explore-community-events-link, .explore-community-crowdfunds-link{
				 display:inline-block !important;	
			}
			
			/*.menubar-profile-settings-link{
				display:block !important;	
			}*/
			
			.menubar-privacy-settings-link{
				display:block !important;	
			}			
		  </style>
    @endif      
    
    <script language="javascript">
		@if($canViewCommunity && $isCmUrl=='c')
			document.getElementsByClassName("explore-community-events-link")[0].innerHTML = '<a href="{{$community->present()->url("allpostevents")}}"><i class="fa fa-calendar" aria-hidden="true"></i><span>{{trans("community.community-events")}}</span></a>';
			document.getElementsByClassName("explore-community-crowdfunds-link")[0].innerHTML = '<a href="{{$community->present()->url("allcrowdfunding")}}"><i class="fa fa fa-gift" aria-hidden="true"></i> <span>{{trans("community.community-crowdfunds")}}</span></a>';
			document.getElementsByClassName("explore-community-survey-link")[0].innerHTML = '<a href="{{$community->present()->url("surveys")}}"><i class="fa fa-pie-chart" aria-hidden="true"></i> <span>{{trans("community.my-polls")}}</span></a>';
			/*document.getElementById("explore-community-marketplace-menu").classList.add("redirectToCommunityMarketplace");*/
        @endif
		
		@if($isCmUrl=='c')
			document.getElementsByClassName("networking-link-home")[0].classList.add("redirectToCommunitySocial");
			document.getElementById("explore-community-social-link").classList.add("redirectToCommunitySocial");
			document.getElementById("explore-community-social-link-responsive").classList.add("redirectToCommunitySocial");
						
			/*document.getElementsByClassName("community-header-logo")[0].src ="{{$community->present()->getLogo()}}";
			
			document.querySelectorAll(".navbar-brand.hideonpostpage").forEach(function(menuLink) {
				menuLink.href="{{$community->present()->url()}}";
			});	*/
		@endif
		
		<?php /*?>document.getElementsByClassName("explore-community-business-link")[0].innerHTML = '<a href="{{$community->present()->url("businesses")}}"><i class="fa fa-briefcase" aria-hidden="true"></i> <span>{{$marketplaceTitle}}</span></a>';<?php */?>

        
		@if($canViewCommunity)			
			document.querySelectorAll(".personal-notes-link").forEach(function(menuLink) {
				menuLink.href="{{$community->present()->url('personalnotes')}}";
			});
			
			document.querySelectorAll(".my-polls-link").forEach(function(menuLink) {
				menuLink.href="{{$community->present()->url('mypolls')}}";
			});	
			
			document.querySelectorAll(".org-menubar-profile-settings-link a").forEach(function(menuLink) {
				menuLink.href="{{$community->present()->url('memberprofilesettings')}}";				
			});
			
			document.querySelectorAll(".menubar-privacy-settings-link a").forEach(function(menuLink) {
				menuLink.href="{{$community->present()->url('memberprofilesettings')}}";
			});
        @endif
		
		//document.getElementsByClassName("polls-creating-url")[0].href="{{URL::route('community-home',['slug'=>$community->id])}}?pstact=poll";
		
        document.querySelectorAll(".networking-link-home").forEach(function(menuLink) {
            menuLink.href="{{URL::route('community-home',['slug'=>$community->id])}}";
            
        });
		
		document.querySelectorAll(".mobile-home-menu").forEach(function(menuLink) {
            menuLink.href="{{$community->present()->url()}}";
            
        });
        
        document.querySelectorAll(".my-friends-network-connection").forEach(function(menuLink) {
            menuLink.href="{{URL::route('community-friends-network',['slug'=>$community->id])}}";
            
        });	
        
		document.getElementById("explore-community-social-link").href="{{URL::route('community-home',['slug'=>$community->id])}}";
		document.getElementById("explore-community-social-link-responsive").href="{{URL::route('community-home',['slug'=>$community->id])}}";
        
		document.getElementsByClassName("networking-link-home-logo")[0].src ="{{$community->present()->getLogoAvatar()}}";
    	document.getElementsByClassName("networking-link-home")[0].title = "{{$community->title}} Community Network";
		document.getElementById("explore-community-social-link").title = "{{$community->title}} Community Network";
   		document.getElementById("explore-community-social-link-name").innerHTML ="{{$community->title}} Community Network";
		
		document.getElementById("explore-community-social-link-responsive").title = "{{$community->title}} Community Network";
		
   		document.getElementById("networking-link-home-logo-responsive").src ="{{$community->present()->getLogoAvatar()}}";
		
		/*document.getElementById("browse-website-menu-link").href="{{URL::route('community-website-home',['slug'=>$community->id])}}"; 

		document.getElementById("browse-website-menu-link-name").innerHTML ="Open - {{$websiteFullUrl}}";	*/		
        
    </script>
	
	@if(\Session::has('appLogin') and \Session::get('appLogin')=='appLogin')

	@else
		 <script language="javascript">
			document.getElementById("browse-website-menu-link-side").href="{{URL::route('community-website-home',['slug'=>$community->id])}}"; 
			
			document.getElementById("browse-website-menu-link-name-side").innerHTML ="Open - {{$websiteFullUrl}}";
		 </script>		
	@endif
    
    @if($community->community_access!=1 || $community->owner_community_access!=1)
        <script language="javascript">		
            document.querySelectorAll(".user-ip-link").forEach(function(menuLink) {
                var existingUrl=menuLink.href.replace('/manage','');
                
                var newUrl=existingUrl.replace('/ip','/c/{{$community->id}}/ip');
                
                menuLink.href=newUrl;
            });
        </script>
        
        <style type="text/css">
			.top-header-cart-count{
				display:none !important
			}
		</style>        
    @endif
    
    <!-- Community responsive dynamic menus ends here-->
	
	{!! Theme::section('community.page.dynamic-menu-settings',['community'=>$community]) !!}	
@endif  


@if(($community and $community->eventmeeting==1) || ($isidmeetcommunity))
	<style type="text/css">
		ul.website-main-menu-list li{
			display:none !important;
		}
		
		ul.website-main-menu-list li.eventcommunityshowmenu{
			display:block !important;
		}
		
		.eventcommunityhidemenu{
			display:none !important;	
		}
		
		.navbar-nav.search-box-container{
			display:none !important;	
		}
    </style>
@endif  

<?php
	$visitingCommunity=getVisitingCommunityId();
	//$communityUrl=URL::to('/');
	$communityUrl=URL::route('user-home');
	$communityLogo =Theme::asset()->img('theme/images/logo.png');	

	$themeColorCode="#fffefe";
	
	$canShowCmLogo="yes";
	$websiteCommunityTextLogo="";
	if($visitingCommunity>0){
		$visitingCm=$loggedInUser->present()->getCommunityById($visitingCommunity);
		
		if($visitingCm){
			if($visitingCm->use_own_theme_color==1){
						$themeColorCode =$visitingCm->own_theme_color;					
			}elseif($visitingCm->theme_color!=""){
				$themeColorCode =$visitingCm->theme_color;
			}	
			//$communityUrl=$visitingCm->present()->url();
			
			$userSettings = app('App\\Repositories\\UserCommunitySettingsRepository')->getByUserId($visitingCm->id);
			if ($userSettings and $userSettings->community_view == 0) {
				 $communityUrl = $visitingCm->present()->url();
			}else{
				$communityUrl = $visitingCm->present()->url('cbdashboard');
			}  
			
			
			$communityLogo =$visitingCm->present()->getLogo();
			if(!$visitingCm->logo){
				$canShowCmLogo="no";
			}
			$websiteCommunityTextLogo=$visitingCm->title;
		}
	}
?>

<script language="javascript">
	document.getElementsByClassName("website-own-logo")[0].src ="{{$communityLogo}}";
			
	document.querySelectorAll(".navbar-brand.hideonpostpage").forEach(function(menuLink) {
		menuLink.href="{{$communityUrl}}";
	});	
</script>

@if($themeColorCode)
	<style type="text/css">
		.website-fixed-top-header{
			background-color:<?php echo $themeColorCode;?> !important;
		}
	</style>	
@endif

@if($canShowCmLogo=='no')
	<style type="text/css">
		.website-own-logo{
			display:none !important;
		}
		
		#website-internal-logo-text{
			display:block;
		}
	</style>
    
    <?php
		$logo_link_edit="";	
	?>
    
    @if($community->isOwner())
    	<?php
			$logo_link=$community->present()->url('pannelsetting');	
			$logo_link_edit="<a href='".$logo_link."' class='cm_logo_link_edit' title='Click to change logo'><i class='fa fa-exclamation-circle' aria-hidden='true'></i></a>";
		?>	 
    @endif
    
	<script language="javascript">
		document.getElementById("website-internal-logo-text").innerHTML="{!!$websiteCommunityTextLogo!!}{!!$logo_link_edit!!}";
	</script>	
@endif

@if($community and $community->gift_app_community==1 || $selected_pricing_plan_type=='giftapp')
	<style type="text/css">
    	.giftcommunityhidemenu{
			 display:none !important;	
		}	
		
		.giftcommunityshowmenu{
			display:block !important;
		}
    </style>	
@endif

<style type="text/css">
	.menubar-my-stores-link-specific{
		display:none !important;
	}
	
	.top-main-menu-icon-store{
		display:none !important;
	}
	
	.top-main-menu-icon-notes{
		display:none;
	}
	
	.menubar-my-website-link-specific{
		display:none;
	}
</style>

@if($community)

    <?php
		$socialMenuSettings = app('App\\Repositories\\CommunitySocialMenuSettingsRepository')->getByCommunityId($community->id);
	?>
    
    @if($socialMenuSettings)
    	@if($socialMenuSettings->connected_organization == 0)
        	<style type="text/css">      
				 .menubar-ecosystem-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->my_website == 0)
        	<style type="text/css">      
				 .menubar-my-website-link{
					display:none !important;
				 }
				 
				 .menubar-my-stores-link-parent .mn-dvdr{
				 	display:none;
				 }
				 
				 .menubar-my-stores-link-parent .ext-menu-ln{
				 	margin-left:0px !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->my_website == 0 and $socialMenuSettings->stores == 1)
         	<style type="text/css">
				.top-main-menu-icon-store{
					display:inline-block !important;
					margin-left: 18px;
				}
			</style>
        @endif
        
        @if($socialMenuSettings->stores == 0)
        	<style type="text/css">      
				 .menubar-my-stores-link,.menubar-my-stores-link-parent{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->my_website == 0 && $socialMenuSettings->stores == 0)
        	<style type="text/css">      
				 .menubar-my-website-store-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->my_social_profile == 0)
        	<style type="text/css">      
				 .menubar-social-profile-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->my_calendar == 0)
        	<style type="text/css">      
				 .menubar-my-calendar-link{
					display:none !important;
				 }
				 
				  
				 .menubar-personal-notes-link .mn-dvdr{
				 	display:none;
				 }
				 
				 .menubar-personal-notes-link .ext-menu-ln{
				 	margin-left:0px !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->my_calendar == 0 && $socialMenuSettings->notes == 0)
         	<style type="text/css">      
				 .menubar-personal-calendar-notes-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->my_calendar == 0 and $socialMenuSettings->notes == 1)
         	<style type="text/css">
				.top-main-menu-icon-notes{
					display:inline-block !important;
					margin-left: 18px;
				}
			</style>
        @endif
        
        @if($socialMenuSettings->notes == 0)
        	<style type="text/css">      
				 .menubar-personal-notes-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->invite_a_friend == 0)
        	<style type="text/css">      
				 .menubar-invite-a-friend-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->job_dashboard == 0)
        	<style type="text/css">      
				 .menubar-jobs-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->marketplace == 0)
        	<style type="text/css">      
				 .menubar-eMarketplace-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->trends_mention == 0)
        	<style type="text/css">      
				 .menubar-trends-mention-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->group_sync == 0)
        	<style type="text/css">      
				 .social-app-marketplace-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->agreements == 0)
        	<style type="text/css">      
				 .menubar-agreements-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->transactions == 0)
        	<style type="text/css">      
				 .menubar-transactions-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->account_settings == 0)
        	<style type="text/css">      
				 .menubar-account-settings-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->my_identity == 0)
        	<style type="text/css">      
				 .menubar-my-identity-link{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->website_logo == 0)
        	<style type="text/css">      
				 .website-menubar-logo{
					display:none !important;
				 }
			</style>
        @endif
        
        @if($socialMenuSettings->logout == 0)
        	<style type="text/css">      
				 .menubar-logout-link{
					display:none !important;
				 }
			</style>
        @endif
    @endif
    
    @if($community->id==299 and ($socialMenuSettings and $socialMenuSettings->stores == 0))
        @if(\Auth::user()->id==28293 || \Auth::user()->id==31702)
            <style type="text/css">
                .menubar-my-stores-link-specific{
                    display:block !important;
                }
            </style>
        @endif
   @endif     
@endif