diff --git a/plugins/unl_theme/views/default/page_elements/header.php b/plugins/unl_theme/views/default/page_elements/header.php
index deccad6fa80e0230e4f8febcf83cca4fff4530f1..0a99a3a8a58d7d485f885ac5c0d2c381b12a1c9d 100644
--- a/plugins/unl_theme/views/default/page_elements/header.php
+++ b/plugins/unl_theme/views/default/page_elements/header.php
@@ -46,6 +46,7 @@ $release = get_version(true);
 <script type="text/javascript" src="<?php echo $vars['url']; ?>vendors/jquery/jquery-ui-1.7.2.custom.min.js"></script>
 <script type="text/javascript" src="<?php echo $vars['url']; ?>vendors/jquery/jquery.form.js"></script>
 <script type="text/javascript" src="<?php echo $vars['url']; ?>_css/js.php?lastcache=<?php echo $vars['config']->lastcache; ?>&amp;js=initialise_elgg&amp;viewtype=<?php echo $vars['view']; ?>"></script>
+
 <?php
     global $pickerinuse;
     if (isset($pickerinuse) && $pickerinuse == true) { 
@@ -75,11 +76,14 @@ $release = get_version(true);
 
 <?php if (!isloggedin()) { //The styles for the information box to be displayed if a non-authenticated user has arrived. ?>
 	<script type="text/javascript" src="<?php echo $vars['url'] .'mod/unl_theme/scripts/JS/actionNotice.js'?>"></script>
-<?php } ?>
-
-
+<?php } else {?>
+<script type"text/javascript">
+//Use the correct logout URL for IDM
+WDN.idm.setLogoutURL('<?php echo $vars['url']; ?>action/logout');
+</script>
 
-<?php if ($vars['title'] == "Edit profile") { //CSS and JS for only the profile edit form page.	    
+<?php }
+	if ($vars['title'] == "Edit profile") { //CSS and JS for only the profile edit form page.	    
         require_once(dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/unl_theme/scripts/JS/enhanceProfileForm.php');
 ?>
     	<style type="text/css">