/**
 * Header Logo
 *
 * @package Total WordPress Theme
 * @subpackage Partials
 * @version 3.0.0
 */
// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
// Define variables
$logo_url = wpex_header_logo_url();
$logo_img = wpex_global_obj('header_logo');
$overlay_logo = wpex_header_overlay_logo();
$logo_icon = wpex_header_logo_icon();
$logo_title = wpex_header_logo_title();
?>

<div id="site-logo" class="<?php 
echo wpex_header_logo_classes();
?>
">

	<div id="site-logo-inner" class="clr">

		<?php 
if ($logo_img || $overlay_logo) {
    ?>
/**
 * Adds js for the retina logo
 *
 * @since 1.1.0
 */
function wpex_retina_logo()
{
    // Get theme options
    $logo_url = wpex_get_mod('retina_logo');
    $logo_height = wpex_get_mod('retina_logo_height');
    // Translate theme mods
    $logo_url = wpex_translate_theme_mod('retina_logo', $logo_url);
    $logo_height = wpex_translate_theme_mod('retina_logo_height', $logo_height);
    // Header overlay Retina logo
    if (wpex_header_overlay_logo() && wpex_global_obj('has_overlay_header')) {
        $post_id = wpex_global_obj('post_id');
        $overlay_retina_logo = get_post_meta($post_id, 'wpex_overlay_header_logo_retina', true);
        $overlay_retina_logo_height = get_post_meta($post_id, 'wpex_overlay_header_logo_retina_height', true);
        if ($overlay_retina_logo && $overlay_retina_logo_height) {
            if (is_numeric($overlay_retina_logo)) {
                $overlay_retina_logo = wp_get_attachment_image_src($overlay_retina_logo, 'full');
                $overlay_retina_logo = $overlay_retina_logo[0];
            } else {
                $overlay_retina_logo = esc_url($overlay_retina_logo);
            }
            if ($overlay_retina_logo) {
                $logo_url = $overlay_retina_logo;
                $logo_height = $overlay_retina_logo_height;
            }
        }
    }
    // Apply filters
    $logo_url = apply_filters('wpex_retina_logo_url', $logo_url);
    $logo_height = apply_filters('wpex_retina_logo_height', $logo_height);
    // Output JS for retina logo
    if ($logo_url && $logo_height) {
        $output = '<!-- Retina Logo -->
					<script type="text/javascript">
						var $wpexRetinaLogo = "' . $logo_url . '",
							$wpexRetinaLogoHeight = "' . intval($logo_height) . '";
						jQuery(function($){
							if ( window.devicePixelRatio >= 2 ) {
								$("#site-logo img").attr("src", "' . $logo_url . '");
								$("#site-logo img").css("max-height", "' . intval($logo_height) . 'px");
							}
						});
					</script>';
        echo $output;
    }
}