<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><?php echo $this->account; ?> - <?php echo $this->translate('Webmail') ?></title>
	
	<!--[if IE]>
		<link rel="stylesheet" href="<?php echo $this->siteBaseUrl; ?>css/ie.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen" />
	<![endif]-->

	<!--[if lte IE 7]>
		<link rel="stylesheet" href="<?php echo $this->siteBaseUrl; ?>css/ie7.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen" />
	<![endif]-->

	<!--[if lte IE 6]>
		<link rel="stylesheet" href="<?php echo $this->siteBaseUrl; ?>css/ie6.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen" />
		<script type="text/javascript" src="<?php echo $this->siteBaseUrl; ?>js/dd_png.js"></script>
		<script type="text/javascript" src="<?php echo $this->siteBaseUrl; ?>js/pngfix_selectors.js"></script>
	<![endif]-->
	
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl; ?>css/common.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen, print" />
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/reset.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen, projection, print"/>
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl; ?>css/calendar.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen, print" />
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/contacts.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen, print" />
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/mail.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen, print" />
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/settings.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen" />
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/TextboxList.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen" />
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/TextboxList.Autocomplete.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen" />

	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl; ?>css/flashmessage.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen" />
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/tabs.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen, projection"/>
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/flora.datepickertweaked.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen, projection"/>
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/menu.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen, projection"/>
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/printMessage.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="print"/>
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/checkboxes.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen"/>
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/lang.css?<?php echo Zend_registry::get('config')->global['version'] ?>" type="text/css" media="screen"/>

	
	<!-- jQuery -->
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/jquery-1.3.2.min.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/ui/jquery-ui-1.7.2.custom.min.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.json-1.3.min.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.jcacher-1.0.0.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.php.pack.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.flash.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.corners.min.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.ajaxupload.3.9.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.disable.text.select.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.highlight-3.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.single-ddm.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/GrowingInput.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/TextboxList.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/TextboxList.Autocomplete.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/TextboxList.Autocomplete.Binary.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.spellchecker.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.rte.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.blockUI.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.bgiframe.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.dimensions.pack.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.scrollTo-min.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/iphone-style-checkboxes.js"></script>
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.simpletreeview.js"></script>
	<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/jquery.bt.css" type="text/css" media="screen" />

	<!-- 
	TODO: Implement keyboard shortcuts
	<script type="text/javascript" src="<?php echo $this->siteBaseUrl ?>js/jQuery/plugins/jquery.hotkeys-0.7.8-packed.js"></script>
	-->

	<!-- Atmail specific files -->
	<script type="text/javascript" language="JavaScript" src="<?php echo $this->siteBaseUrl ?>js/atmail/mail/mail.js?<?php echo Zend_registry::get('config')->global['version'] ?>"></script>
	<script type="text/javascript" language="JavaScript" src="<?php echo $this->siteBaseUrl ?>js/atmail/mail/viewmessage.js?<?php echo Zend_registry::get('config')->global['version'] ?>"></script>
	<script type="text/javascript" language="JavaScript" src="<?php echo $this->siteBaseUrl ?>js/atmail/abook/abook.js?<?php echo Zend_registry::get('config')->global['version'] ?>"></script>
	<script type="text/javascript" language="JavaScript" src="<?php echo $this->siteBaseUrl ?>js/atmail/calendar/calendar.js?<?php echo Zend_registry::get('config')->global['version'] ?>"></script>

	<!-- php compatible js functions (htmlentities etc) -->
	<script type="text/javascript" language="JavaScript" src="<?php echo $this->siteBaseUrl ?>js/php.js"></script>
	<script type="text/javascript" language="JavaScript" src="<?php echo $this->siteBaseUrl ?>js/rounded_corners.inc.js"></script>

	<!-- Fav icon -->
	<link rel="shortcut icon" href="<?php echo $this->siteBaseUrl ?>images/favicon.ico?<?php echo Zend_registry::get('config')->global['version'] ?>" type="image/x-icon" />

	<!-- Safari -->
	<script type="text/javascript">
	ua = navigator.userAgent.toLowerCase();
	if ( ua && ua.indexOf("safari") != -1 ) {
		document.write('<link rel="stylesheet" href="<?php echo $this->siteBaseUrl ?>css/safari.css" type="text/css">')
	}
	</script>
	
	<script type="text/javascript">	
		
	// Global JS name for script access
	var siteBaseUrl 	= "<?php echo $this->siteBaseUrl ?>";
	var moduleBaseUrl	= "<?php echo $this->moduleBaseUrl ?>";

	// Tab control
	var lastTabNumber = 0;
	
	var WEBMAIL_TAB_ID 	= 0;
	var ABOOK_TAB_ID 	= 1;
	var CALENDAR_TAB_ID 	= 2;
	var SETTINGS_TAB_ID 	= 3;

	// IS GD ENABLED
	<?php 
	if(!function_exists("gd_info")) {
		echo "var gd_enabled = 0;";
	}
	else {
		echo "var gd_enabled = 1;";
	}
	?>
	
	// drop down menu		
	var timeout = 500;
	var closetimer = 0;
	var ddmenuitem = 0;
	var firstclick = 0;
	
	// error flash
	var flashTimeout 	= null;
	

	// Drop down menu functions
	function jsddm_open()
	{
        
		ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
		var left = Math.round($(this).offset().left - 8) + 'px';
		// Must manually set !important, to get the more button to display on the right position for different UI languages
		ddmenuitem.css("cssText", "visibility:visible; position: absolute; left: " + left + " !important;");
		
		firstclick = 1;
	
	}
	
	function jsddm_close()
	{
	
		if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
	
	}
	
	function jsddm_timer()
	{
		
		//closetimer = window.setTimeout(jsddm_close, timeout);
		
	}   
	
	function jsddm_canceltimer()
	{
		
		if ( closetimer )
		{
		
			window.clearTimeout(closetimer);
			closetimer = null;
		
		}
		
	}
	document.onclick = function () 
	{ 
		
		if( firstclick != 1 ) 
		{ 
			
			jsddm_close(); 
			
		} 
		firstclick = 0;
		
	};

	function displaySessionTimeout()
	{
		window.location.replace("<?php echo $this->siteBaseUrl ?>index.php/default/index/sessiontimeout");
	}

	$( function() {

		// check if browser is IE6 
		if ($.browser.msie && $.browser.version < 7) 
		{
			window.location.replace("<?php echo $this->siteBaseUrl ?>index.php/default/index/ie6");
		}
	
		// default help bind
		$("#help").bind('click', function() 
		{
			openHelp('help');
		});

	 	function unbind_search()
		{
			$('#searchQuery').unbind('keyup');
			$('#searchForm').unbind('submit');
		}			
			
		$("#dialog").dialog(
		{
			autoOpen: false, 
			height: 250,
			minHeight: 250,
			minWidth: 350,
			modal: true,
			overlay: 
			{
				opacity: 0.5,
				background: "white"
			},
			width: 350
		});
			
		$('#exclamation').hide();
	
		function messageBubble(type, message) {
			switch (type)
			{
				case 'Error': 
					var noticeIcon = '<img src="<?php echo $this->siteBaseUrl ?>images/rte-light/link.png" />'
				break;
				default:
					var noticeIcon = '<img src="<?php echo $this->siteBaseUrl ?>images/rte-light/link.png" />'
			}
			$('#exclamation').show();
			$('#exclamation').bt(noticeIcon + '<span>' + type + '</span><br /><small>' + message + '</small>', 
			{
				width: 200,
				fill: 'white',
				cornerRadius: 20,
				padding: 20,
				strokeWidth: 1,
				trigger: ['none']
			});
			
			$('#exclamation').btOn();
			setTimeout( "$('#exclamation').btOff()" , 10000);
			$('#exclamation').bind('click', function() 
			{
				$('#exclamation').btOn();
				setTimeout( "$('#exclamation').btOff()" , 10000);
			});
		}
	
		// Add the loading div
		function showLoadingIconInVisibleContext()
		{
			visiblePanelContext = $('.ui-tabs-selected a', 'div#nav').attr('href');
			$('#primary_header', visiblePanelContext).addClass('loading')
			$('#back_button').each( function() { $(this).fadeTo(100, 0.5) } );
		}   

		function hideAllLoadingIcons() {

			//CONSIDER: revising to allow selectively removing loading icons, i.e. when multiple segments are loading we dont want to remove all loading icons when first completes		    
			$('.loading').each( function() { $(this).removeClass('loading') } );
            $('#back_button').each( function() { $(this).fadeTo(100, 1) } );

		}

		php.beforeSend = function () { 

			showLoadingIconInVisibleContext()		
		}

		php.complete = function () { 

			hideAllLoadingIcons()

		}  

		$("body").bind("ajaxSend", function(){

			showLoadingIconInVisibleContext()

		}).bind("ajaxComplete", function(){

			hideAllLoadingIcons()

		});

		php.errors.defaultCallBack = function (msg, params) 
		{
			$.simpleFlash(msg, 'error');
		}

		php.messages.defaultCallBack = function (msg, params) 
		{
			$.simpleFlash(msg, 'notice');
		}

		//add a custom error handler to suppress aborted requests or empty responses
		//keep existing error handler to be called if other
		php.debugError = php.error;
		php.error = function (xmlEr, typeEr, except) 
		{
			
			if( xmlEr.readyState == 4 && xmlEr.status == '200' && xmlEr.statusText == 'OK' && (xmlEr.responseText == undefined || xmlEr.responseText.length == 0)  )
			{
				
				if( xmlEr.responseText == undefined || xmlEr.responseText.length == 0 )
				{

					//$.simpleFlash('Empty response from server.', 'error');
					return;
				}
				else
				{
					
					//$.simpleFlash('Corrupted response from server.', 'error');
					//return;
					
				}
				
			}
			
			if( xmlEr.readyState == 4 && xmlEr.status == '0' && (xmlEr.responseText == undefined || xmlEr.responseText.length == 0) )
			{
				
				//$.simpleFlash('Previous request aborted.', 'error');
				return;
				
			}
			php.debugError(xmlEr, typeEr, except);
			
		}

		// lets add a custom error handler
		// but save current one
		previous_php_error_handler = php.error;
		php.error = function(XMLHttpRequest, textStatus, errorThrown) 
		{
			// check for session timeout
			if( XMLHttpRequest.responseText.indexOf("__ATMAIL_SESSION_TIMEOUT") != -1 )
			{
				displaySessionTimeout();
				return;
			}
			
			// use the default handler
			previous_php_error_handler(XMLHttpRequest, textStatus, errorThrown);
		}
		
		$.simpleFlash = function(message, type) {
			if( type == undefined )
				type = 'notice';
				
			if( $('.ui-tabs-selected a', 'div#nav').attr('href') == '#Email' ||  $('.ui-tabs-selected', 'div#nav').length == 0 )
				visiblePanelContext = $('.ui-tabs-selected', 'div#navMessages').attr('name');
			else
				visiblePanelContext = $('.ui-tabs-selected a', 'div#nav').attr('href');
				
			if( $('#Flash', visiblePanelContext).length == 0 )
			{
				//no #Flash exists so append one
				if( $('#primary_content_inner', visiblePanelContext).length == 0 )
				{
					alert(message);
				} 
				else if ( $('#mail_info', visiblePanelContext).length != 0 ) 
				{
					//we are inside 3pane to append to mail_info
					$('#mail_info', visiblePanelContext).prepend('<div id="Flash" aria-live="polite"></div>');
				} 
				else
				{
					$('#primary_content_inner', visiblePanelContext).prepend('<div id="Flash" aria-live="polite"></div>');
				}
			}
				
			if( type.toLowerCase() == 'notice' ) 
			{
				$('#Flash', visiblePanelContext).removeClass('flash_notice_error');
				$('#Flash', visiblePanelContext).addClass('flash_notice');
			}
			else
			{
				$('#Flash', visiblePanelContext).removeClass('flash_notice');
				$('#Flash', visiblePanelContext).addClass('flash_notice_error');
			}
				
			$('#mail_info').scrollTo(0);
			$('#primary_content', visiblePanelContext).scrollTo(0);
			$('#Flash', visiblePanelContext).html(message);
			$('#Flash', visiblePanelContext).show();
			
			if(flashTimeout)
				clearTimeout(flashTimeout);
					
			flashTimeout = setTimeout(function() { $('#Flash', visiblePanelContext).fadeOut() },5000);
			$('#Flash', visiblePanelContext).unbind('click');
			$('#Flash', visiblePanelContext).bind('click', function() { $(this).fadeOut(); clearTimeout(flashTimeout) });
		}
	});

	</script>
	<style>
	    #primary_header 
		{ 
			left: 0px !important; 
			top: 36px !important; 
		}
		#primary_content 
		{
			left: 0px !important;
			top: 76px !important;
		}
	</style>
</head>

<body class="caloff">
<?php $this->pluginCall("startBodyTag") ?>
	<div id="header">
		<div id="EmailSignature" class='Signature' style="display:none;">
		<?php echo $this->UserSettings['Signature']; ?>
		</div>
		<h3 class='branding'><a href="<?php echo $this->siteBaseUrl ?>" target="_blank"><?php echo $this->global['brandname'] ?></a></h3>
		
		<div id="help">
			<a href="#">&nbsp;</a>
		</div>
		
		<div id="sign_out">
			<a href="<?php echo $this->moduleBaseUrl ?>/auth/logout"><span><?php print $this->translate('Sign Out')?></span></a>
		</div>
	</div>

