<?php

function pageHeader ( $navInfo, $type = 'CARREF' ) {

    $pageHeader = '';
    if ($type == 'CARNEW') {

        $pageHeader = '';

    }
    else {

      //  $homeLink = mkcurl('/','LINKTEXT','<img src="/images/rg-logo2007.gif" alt="Vehicle Refinance" class="headerLogo">');
        $pageHeader = '';

    }

    return $pageHeader;
}

function getGitTag() {

    $prefix = 'HOME=' . getcwd() . ' ';
    $lines = array();
    // get tag
    return exec($prefix . 'git tag', $lines);

}


function utilityNav ( $navInfo ) {

    switch($navInfo['pageClass']) {
        default:
            $homePageVar = "GVAR_homePage_{$navInfo['mainPerm']}";
            //$homePage = ifNull(globalVar($homePageVar),'/Index.php');
            $homePage = '/Index.php';
            // Set the login text based on login status and inheritance status
            if ( $navInfo['userName'] ) {
                if ( $navInfo['inheritID'] ) {
                    $logText = "Logged in as <b>{$navInfo['userName']}</b>";
                    $logLink = mkcurl('/Login/IdentityDrop.php','LINKTEXT','drop identity','SECURE');
                } else {
                    $logText = "Welcome {$navInfo['userName']}";
                    $logLink = mkcurl('/Login/Logout.php','LINKTEXT','logout','SECURE');
                }
                $contactLink = mkcurl('/Content/ContactUs.php','LINKTEXT','contact us','SECURE');
                $helpLink = mkcurl('/Content/HelpIndex.php','LINKTEXT','help','SECURE');
            } else {
                $logText = 'home';
                $logLink = mkcurl('/Login/Login.php','LINKTEXT','login','SECURE','LINKEXTRAS', 'rel="nofollow"');
                $contactLink = mkcurl('/Content/ContactUs.php','LINKTEXT','contact us');
                $helpLink = mkcurl('/Content/HelpIndex.php','LINKTEXT','help');
            }

            if(!in_array($homePage, array("/","")))
                $homeLink = mkcurl("/Admin/TaskList.php",'LINKTEXT',$logText,'SECURE');
            else
                $homeLink = mkcurl($homePage,'LINKTEXT',$logText,'UNSECURE');


            break;
    }

    $utilityNav = <<<EONAV

	<div id="header-top" class="row">
		<div class="twelve columns">
			<ul class="nav-bar">
				<li class="first"> {$homeLink} </li>
				<li> {$contactLink} </li>
				<li> {$helpLink}  </li>
				<li class="last"> {$logLink} </li>
			</ul>
		</div>
	</div>

EONAV;

    return $utilityNav;
}

function topNav ( $navInfo, $type = 'CARREF' ) {

    switch($navInfo['pageClass']) {
        case 'InsHome':
            $topNavFile = LIBRARY_PATH."navigation/topNav_INSURANCE.inc";
            include($topNavFile);

            break;
        case 'HolidayHome':

            break;
        default:
            $pageClass = $navInfo['pageClass'];
//            $homePageVar = "GVAR_homePage_{$navInfo['mainPerm']}";
//            $homePage = globalVar($homePageVar);

            // Get the topnav library file to load
            switch ( $navInfo['mainPerm'] ) {
                case 'BOARD':
                case 'EXTERNAL':
                case 'LENDER':
                case 'CUST':
                    // These all load a topnav of the same name as the perm
                    $topNavLib = $navInfo['mainPerm'];
                    break;

                case 'ADMIN':
                case 'AGENT':
                    $topNavLib = 'INTERNAL';
                    break;

                default:
                    // These use the visitor nav bar
                    $topNavLib = 'VISITOR';
                    break;
            }
            // Include the topnav library. Each one will set a variable named topNav, which we return
            $topNavFile = LIBRARY_PATH."navigation/topNav_{$topNavLib}.inc";
            if($pageClass != 'HolidayHome') include($topNavFile);
            break;
    }
    return $topNav;
}


function bottomNav ( $navInfo ) {
    $thisyear = date(Y);

    $logLink = mkcurl('/Login/Login.php','LINKTEXT','Login to check status','SECURE','LINKEXTRAS', 'rel="nofollow"');
    $affiliateLink =  '<li><a href="/Content/AffiliateProgram.php">Affiliate Program</a></li>';
    //Get Git Version to Show at bottom of footer using $navInfo to make sure user is logged in
    if (!is_null($navInfo['userName']) && $navInfo['userName'] != "")
    {
        $gitVersion = 'Version '.getGitTag();
    }
    else
    {
        $gitVersion = "";
    }

    $timestamp = time();

    $footer = <<<EOFTR
<div class="container" id="footer">
	<!-- footer one -->
	<div class="row">
   			<div class="two columns offset-by-one">
				<ul>
					<li><a1 href="/Content/TermsOfUse.php">Terms of Use</a></li>
					<li><a1 href="/Content/PrivacyPolicy.php">Privacy Policy</a></li>
					<li><a1 href="/Content/SecurityStatement.php">Security</a></li>
					<li><a1 href="/Content/Disclosures.php">Licensing</a></li>
					<li><a1 href="/Content/ElectronicDocumentPolicy.php">Electronic Document Policy</a></li>
					<li><a1 href="/Content/Patriot.php">Patriot Act</a></li>
				</ul>
			</div>
			<div class="two columns">
				<ul>
                    {$affiliateLink}
					<li><a1 href="/Content/AboutCompany.php">About AAXY</a></li>
					<li><a1 href="/Content/ContactUs.php">Contact Us</a></li>
				</ul>
			</div>
			<div class="two columns">
				<ul>
					$logLink
					<li><a1 href="/Content/HelpIndex.php">AAXY Help</a></li>
					<li><a1 href="/Content/SiteMap.php">Site Map</a></li>
				</ul>
			</div>
			<div class="two columns">
				<ul class="keepintouch">
					<li class="facebook"><a1 href="http://www.facebook.com/pages/RateGenius/90418874683">Find us on Facebook</a></li>
					<li class="twitter"><a1 href="http://www.twitter.com/rategenius">Follow us on Twitter</a></li>
					<li>
					<div style="margin: 7px 0px 7px 0px;">
					<g:plusone></g:plusone>
                    <script type="text/javascript">
                    (function() {
                    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
                    po.src = 'https://apis.google.com/js/plusone.js';
                    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
                    })();
                    </script>
                    </div>
				</li>
					<li class="rss"><a href="http://blog.rategenius.com">Read our Blog</a></li>
				</ul>
			</div>
			<div class="two columns">
				<ul>
					<li><a1 href="http://www.bbb.org/central-texas/business-reviews/consumer-finance-and-loan-companies/rategenius-in-austin-tx-48392/"><img height="51" width="135" alt="Better Business Bureau" src="../images/bbbsealh1US.GIF"></a></li>
					<li><img src="../images/basicsqgreen.gif"></li>
				</ul>
			</div>
    </div>
	<!-- footer two -->
	<div class="row legal">
    	<div class="ten columns offset-by-one">
    		<p>&copy; 2002-{$thisyear} xxxxxx, Inc. All Rights Reserved. All other trademarks and copyrights are the property of their respective holders. </p>
    		<p style = 'width: 100%; text-align: center;'>{$gitVersion}</p>
    	</div>
    </div>
    


EOFTR;

    return $footer;
}

function frameNav($navInfo)
{
    $thisyear = Date(Y);
    $poweredByLogo = '<img src="/images/PoweredBy_RGLPS.gif" border="0">';
    $copyrightStatement = globalVar('GVAR_copyrightStatement');

    $footer = <<<EOFTR
<div id="footer" class="container">
	<!-- footer one -->

	<div class="row">
		<div class="two columns">
			<ul>
				<li><a href="#">Terms of Use</a></li>
				<li><a href="#">Privacy Policy</a></li>
				<li><a href="#">Security</a></li>
				<li><a href="#">Licensing</a></li>
				<li><a href="#">Electronic Document Policy</a></li>
				<li><a href="#">Patriot Act</a></li>
			</ul>
		</div>
		<div class="two columns">
			<ul>
				<li><a href="#">Affiliate Program</a></li>
				<li><a href="#">About RateGenius</a></li>
				<li><a href="#">Contact Us</a></li>

			</ul>
		</div>
		<div class="three columns">
			<ul>
				<li><a href="#">Login to check status</a></li>
				<li><a href="#">RateGenius Help</a></li>
				<li><a href="#">Site Map</a></li>

			</ul>
		</div>
		<div class="three columns">
			<ul class="keepintouch">
				<li class="facebook"><a href="http://www.facebook.com/pages/RateGenius/90418874683">Find us on Facebook</a></li>
				<li class="twitter"><a href="http://www.twitter.com/rategenius">Follow us on Twitter</a></li>
				<li>
			    <g:plusone></g:plusone>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
				</li>
				<li class="rss"><a href="#">Read our Blog</a></li>
			</ul>
		</div>
		<div class="two columns">
			<ul>
				<li><a href="http://www.bbb.org/central-texas/business-reviews/consumer-finance-and-loan-companies/rategenius-in-austin-tx-48392/"><img height="51" width="135" alt="Better Business Bureau" src="../images/bbbsealh1US.GIF"></li>
				<li><img src="../images/basicsqgreen.gif"></li>
			</ul>
		</div>

	</div>
	<!-- footer two -->
	<div class="row legal">
		<div class="ten columns offset-by-one">
			<p>*APR=Annual   Percentage Rate. APR is determined at the time of your application,   based on creditworthiness and the loan to value of the vehicle. Rate   quoted is the lowest rate for qualified applicants.</p>
			<p>© 2002-{$thisyear} rateGenius, Inc. All Rights Reserved. All other trademarks and copyrights are the property of their respective holders. </p>
			<p>{$gitVersion}</p>
		</div>
	</div>
</div>

EOFTR;

    return $footer;
}

function leftNav ( $navInfo ) {


    $homePageVar = "GVAR_homePage_{$navInfo['mainPerm']}";
    $homePage = globalVar($homePageVar);


    // Create an empty left nav
    $leftNav = '<div class="three columns sidebar">';


    /* LOGGED OUT FEATURE LIBRARY */

    // Only do this is we're not suppressing left navs
    if ( !$navInfo['suppressNavs'] and !$navInfo['mainPerm'] ) {

        // Include the feature library, if it exists. Each one will append to the $leftNav variable
        $featureFile = LIBRARY_PATH."navigation/leftNav_feature_VISITOR.inc";
        if ( file_exists($featureFile) ) { include($featureFile); }

    }

    /* PAGE CLASS LIBRARY */

    // Check to see if their is a pageClass library for this pageClass
    // Note: this gets done whether we're suppressing navs or not
    if ( $navInfo['pageClass'] ) {

        // Uppercase the page class
        $pageClass = strtoupper($navInfo['pageClass']);
        // Include the leftnav library, if it exists. Each one will append to the $leftNav variable
        $pageClassFile = LIBRARY_PATH."navigation/leftNav_class_{$pageClass}.inc";
        if ( file_exists($pageClassFile) ) { include($pageClassFile); }
    }


    /* PERMISSION LIBRARIES */


    // Only do this is we're not suppressing left navs
    if ( !$navInfo['suppressNavs'] ) {

        // Create an array from the user's permissions and add the root perms to that array
        $userPerms = preg_split('/ /', $navInfo['fullPerm']);
        $userPerms[] = $navInfo['mainPerm'];


        // Create one array for the sections, and one array for the links. These will be filled
        // by the various nav libs loaded
        $navSections = array();
        $navLinks = array();


        // Now, loop through all the user perms. If that perm has a library load it.
        foreach ( $userPerms as $thisPerm ) {

            // If this perm is in our array, include the perm library, if it exists. Each one will append to the $leftNav variable
            if ( in_array($thisPerm, $userPerms) ) {
                $permFile = LIBRARY_PATH."navigation/leftNav_perm_{$thisPerm}.inc";
                if ( file_exists($permFile) ) { include($permFile); }
            }
        }


        // Now include the final perm library that will translate the navSections and navLinks into html
        $permFile = LIBRARY_PATH."navigation/leftNav_perm_SHOWALL.inc";
        include($permFile);
    }


    /* LOGGED IN FEATURE LIBRARY */

    // Only do this is we're not suppressing left navs
    if ( !$navInfo['suppressNavs'] and $navInfo['mainPerm'] ) {

        // Include the feature library, if it exists. Each one will append to the $leftNav variable
        $featureFile = LIBRARY_PATH."navigation/leftNav_feature_LOGIN.inc";
        if ( file_exists($featureFile) ) { include($featureFile); }

    }

    $leftNav .= '</div>';

    return $leftNav;
}

?>
