<?php
use Orchard\Service\SegmentAnalyticsTracking;
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
$this->browserType = (stristr($_SERVER['HTTP_USER_AGENT'], 'msie') ? 'IE' : '');
?>
<?=$this->headMeta()?>

<?php
$this->loadcss();
?>

<?=$this->headTitle("OrchAdmin")?>

<?=$this->headLink()?>

<?=$this->headStyle()?>
<?php echo $this->partial('partials/site-analytics.phtml', array(
    "configs" => array(
        'consumerKey' => \Service_GoogleAnalyticsTracking::getTrackingCode(APPLICATION_ENV, 'oa'),
        'userId' => $_SESSION['S_USERID']
    )
));

echo $this->partial('partials/segment-analytics.phtml', array(
    'configs' => array(
        'key' => SegmentAnalyticsTracking::getKey('oa'),
        'userId' => $_SESSION['S_USERID']
    )
));

?>
</head>
<!-- end head -->
<body>
<?php
$this->oa_acl = new Web_Acl_OaAcl();
?>
<?=$this->render('_header.phtml')?>
<?=$this->render('_topnav.phtml')?>

<div id="contentWrapper">
	<p class="breadcrumb"><?=$this->placeholder('breadcrumb');?></p>
	<?=$this->render('msgPanel.phtml')?>

	<!--End Header Wrap -->
	<div id="contentArea">
		<div id="rightPane">
			<?=$this->render('quickSearch.phtml')?>
		</div>

		<div id="leftPane">
			<?=$this->layout()->content?>
		</div>
	</div>
</div>
<?=$this->bottomScripts();?>

<script type="text/javascript">
    (function() {
        document.getelementbyid("quickSearchForm").submit(function(){

            var searchStr = document.getelementbyid("smartSearch").value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');

            if(isNaN(searchStr) && searchStr.length <=2){
                alert('Please make your search longer than 2 characters');
                return false;
            };

            if(searchStr = ''){
                alert('Please enter a value to search for');
                return false;
            };

            // Send releases quicksearch to the new CloudSearch quicksearch form
            if ($("div#quickSearch input#release").is(':checked')) {
                $("div#quickSearch form").attr('action', '/quicksearch/release/');
            }

            // Send label quicksearch to the new CloudSearch quicksearch form
            if ($("div#quickSearch input#label").is(':checked')) {
                $("div#quickSearch form").attr('action', '/quicksearch/label/');
            }
            // end new quicksearch redirection
        })
    });
</script>

</body>
</html>
