<div class="sites_autocomplete">
    <label>{'General_Website'|translate}</label>
    <div id="sitesSelectionSearch" class="custom_select">
    
        <a href="index.php?module=CoreHome&amp;action=index&amp;idSite={$idSite}&amp;period={$period}&amp;date={$rawDate}" onclick="return false" class="custom_select_main_link">{$siteName}</a>
        
        <div class="custom_select_block">
            <div id="custom_select_container">
            <ul class="custom_select_ul_list" >
                {foreach from=$sites item=info}
                    <li {if $idSite==$info.idsite} style="display: none"{/if}><a href="index.php?module=CoreHome&amp;action=index&amp;idSite={$info.idsite}&amp;period={$period}&amp;date={$rawDate}" siteid="{$info.idsite}" onclick="switchSite({$info.idsite}, $(this).text());">{$info.name}</a></li>
				{/foreach}
            </ul>
            </div>
            <div class="custom_select_all" style="clear: both">
				<br />
				<a href="index.php?module=MultiSites&amp;action=index&amp;period={$period}&amp;date={$rawDate}&amp;idSite={$idSite}">{'General_MultiSitesSummary'|translate}</a>
			</div>
            
            <div class="custom_select_search">
                <input type="text" length="15" id="websiteSearch" class="inp">
                <input type="hidden" class="max_sitename_width" id="max_sitename_width" value="130" />
                <input type="submit" value="Search" class="but">
				<img title="Clear" id="reset" style="position: relative; top: 4px; left: -44px; cursor: pointer; display: none;" src="plugins/CoreHome/templates/images/reset_search.png"/>
            </div>
        </div>
	</div>
    
	<script type="text/javascript">
    {if !$show_autocompleter}{literal}
    $('.custom_select_search').hide();
    {/literal}{/if}
	{literal}
    if($('.custom_select_ul_list li').length > 1) {
        $("#sitesSelectionSearch .custom_select_main_link").click(function(){
    		$("#sitesSelectionSearch .custom_select_block").toggleClass("custom_select_block_show");
    		$('#websiteSearch').focus();
    		return false;
    	});
        $('#sitesSelectionSearch .custom_select_block').on('mouseenter', function(){
            $('.custom_select_ul_list li a').each(function(){
                var hash = broadcast.getHashFromUrl();
                $(this).attr('href', piwikHelper.getCurrentQueryStringWithParametersModified('idSite='+$(this).attr('siteid')) + 
                						(hash 
                						? hash.replace(/idSite=[0-9]+/, 'idSite='+$(this).attr('siteid')) 
                						: "")
                );
            });
        });
        var inlinePaddingWidth=22;
        var staticPaddingWidth=34;
        if($(".custom_select_block ul")[0]){
            var widthSitesSelection = Math.max($(".custom_select_block ul").width()+inlinePaddingWidth, $(".custom_select_main_link").width()+staticPaddingWidth);
            $(".custom_select_block").css('width', widthSitesSelection);
        }
    } else {
        $('.custom_select_main_link').addClass('noselect');
    }
    {/literal}
    </script>
</div>

