<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/** @var $this Mage_Adminhtml_Block_Page_Header */
?>
<div class="header-top">
    <a href="<?php echo $this->getHomeLink() ?>"><img src="<?php echo $this->getSkinUrl('images/logo.gif') ?>" alt="<?php echo $this->__('Magento Logo') ?>" class="logo"/></a>
    <div class="header-right">
        <p class="super">
            <?php echo $this->__("Logged in as %s", $this->escapeHtml($this->getUser()->getUsername())) ?><span class="separator">|</span><?php echo $this->formatDate(null, 'full') ?><span class="separator">|</span><a href="http://golinks.magento.com/CE15" onclick="this.target='_blank'" class="go-try"><?php echo $this->__('Try Magento Go for Free') ?></a><span class="separator">|</span><a href="<?php echo $this->getLogoutLink() ?>" class="link-logout"><?php echo $this->__('Log Out') ?></a>
        </p>
        <?php if ( Mage::getSingleton('admin/session')->isAllowed('admin/global_search') ): ?>
        <fieldset>
            <legend>Search</legend>
            <span id="global_search_indicator" class="autocomplete-indicator" style="display: none">
                <img src="<?php echo $this->getSkinUrl('images/ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading...') ?>" class="v-middle"/>
            </span>
            <?php $defSearch = $this->__('Global Record Search') ?>
            <input id="global_search" name="query" type="text" class="input-text" value="<?php if(!empty($query)): ?><?php echo $query ?><?php else: ?><?php echo $defSearch ?><?php endif ?>" onfocus="if(this.value=='<?php echo $defSearch ?>')this.value=''; " onblur="if(this.value=='')this.value='<?php echo $defSearch ?>';" />
            <div id="global_search_autocomplete" class="autocomplete"></div>
            <script type="text/javascript">
                new Ajax.Autocompleter(
                    'global_search',
                    'global_search_autocomplete',
                    '<?php echo $this->getUrl('adminhtml/index/globalSearch') ?>',
                    {
                        paramName:"query",
                        minChars:2,
                        indicator:"global_search_indicator",
                        updateElement:getSelectionId,
                        evalJSON:'force'
                    }
                );
                function getSelectionId(li) {
                    location.href = li.getAttribute('url');
                }
            </script>
        </fieldset>
        <?php endif; ?>
    </div>
</div>
