<?php
/**
 * @package 	WordPress
 * @subpackage 	Welfare
 * @version 	1.1.2
 * 
 * Website Header Template
 * Created by CMSMasters
 * 
 */


$cmsms_option = cmsms_get_global_options();


?><!DOCTYPE html>
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 8)]><!-->
<html <?php language_attributes(); ?> class="cmsms_html">
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo('charset'); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<?php if (version_compare(get_bloginfo('version'), '4.1', '<')) : ?>
<title><?php wp_title(); ?></title>
<?php endif; ?>
<?php cmsms_favicon(); ?>

<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />

<?php 
$ua = $_SERVER['HTTP_USER_AGENT'];

$checker = array( 
	'ios' => 			preg_match('/iPhone|iPod|iPad/', $ua), 
	'blackberry' => 	preg_match('/BlackBerry/', $ua), 
	'android' => 		preg_match('/Android/', $ua), 
	'mac' => 			preg_match('/Macintosh/', $ua), 
	'chrome' => 		preg_match('/Chrome/', $ua), 
	'safari' => 		preg_match('/Safari/', $ua), 
	'ie' => 			preg_match('/MSIE/', $ua), 
	'ie11' => 			preg_match('/Trident/', $ua) 
);


if (is_singular() && get_option('thread_comments')) {
	wp_enqueue_script('comment-reply');
}


$nav_args = array( 
	'theme_location' => 	'primary', 
	'menu_id' => 			'navigation', 
	'menu_class' => 		'navigation', 
	'link_before' => 		'<span>', 
	'link_after' => 		'</span>', 
	'fallback_cb' => 		'cmsms_fallback_menu' 
);


if (class_exists('Walker_Cmsms_Nav_Mega_Menu')) {
	$nav_args['link_before'] = '';
	$nav_args['link_after'] = '';
	$nav_args['walker'] = new Walker_Cmsms_Nav_Mega_Menu();
}


wp_head();

?>
</head>
<body <?php body_class(); ?>>
	
<!-- _________________________ Start Page _________________________ -->
<section id="page" class="<?php cmsms_get_page_classes($cmsms_option); ?>hfeed site">

<?php 
if (CMSMS_WOOCOMMERCE) {
	cmsms_woocommerce_cart_dropdown(); 
}
?>

<!-- _________________________ Start Main _________________________ -->
<div id="main">
	
<!-- _________________________ Start Header _________________________ -->
<header id="header">
	<?php if ($cmsms_option[CMSMS_SHORTNAME . '_header_top_line']) { ?>
		<div class="header_top" data-height="<?php echo $cmsms_option[CMSMS_SHORTNAME . '_header_top_height']; ?>">
			<div class="header_top_outer">
				<div class="header_top_inner">
				<?php 
					if (
						$cmsms_option[CMSMS_SHORTNAME . '_header_top_line_add_cont'] !== 'none' || 
						(
							CMSMS_DONATIONS && 
							isset($cmsms_option[CMSMS_SHORTNAME . '_header_top_line_donations_but']) && 
							$cmsms_option[CMSMS_SHORTNAME . '_header_top_line_donations_but'] &&
							isset($cmsms_option[CMSMS_SHORTNAME . '_header_top_line_donations_but_text']) && 
							$cmsms_option[CMSMS_SHORTNAME . '_header_top_line_donations_but_text'] != '' 
						)
					) {
						echo '<div class="header_top_right">' . 
							'<div class="header_top_aligner"></div>';
						
						
						if (
							$cmsms_option[CMSMS_SHORTNAME . '_header_top_line_add_cont'] == 'social' && 
							isset($cmsms_option[CMSMS_SHORTNAME . '_social_icons'])
						) {
							cmsms_social_icons();
						} elseif (
							$cmsms_option[CMSMS_SHORTNAME . '_header_top_line_add_cont'] == 'nav' && 
							has_nav_menu('top_line')
						) {
							echo '<div class="nav_wrap">' . 
								'<a class="responsive_top_nav cmsms_theme_icon_resp_nav" href="javascript:void(0);"></a>' . 
								'<nav>';
							
							
							wp_nav_menu(array( 
								'theme_location' => 	'top_line', 
								'menu_id' => 			'top_line_nav', 
								'menu_class' => 		'top_line_nav' 
							));
							
							
							echo '</nav>' . 
							'</div>';
						}
						
						
						if (
							CMSMS_DONATIONS && 
							isset($cmsms_option[CMSMS_SHORTNAME . '_header_top_line_donations_but']) && 
							$cmsms_option[CMSMS_SHORTNAME . '_header_top_line_donations_but'] &&
							isset($cmsms_option[CMSMS_SHORTNAME . '_header_top_line_donations_but_text']) && 
							$cmsms_option[CMSMS_SHORTNAME . '_header_top_line_donations_but_text'] != '' 
						) {
							$cmsms_donations_form_page = get_option('cmsms_donations_form_page');
							
							
							if (function_exists('icl_object_id')) {
								$donations_page_id = icl_object_id($cmsms_donations_form_page, 'page', false);
							} else {
								$donations_page_id = $cmsms_donations_form_page;
							}
							
							
							echo '<a href="' . get_permalink($donations_page_id) . '" class="header_top_donation_but"><span>' . $cmsms_option[CMSMS_SHORTNAME . '_header_top_line_donations_but_text'] . '</span></a>';
						}
						
						
						echo '</div>';
					}
					
					
					if ($cmsms_option[CMSMS_SHORTNAME . '_header_top_line_short_info'] !== '') {
						echo '<div class="header_top_left">' . 
							'<div class="header_top_aligner"></div>' . 
							'<div class="meta_wrap">' . 
								stripslashes($cmsms_option[CMSMS_SHORTNAME . '_header_top_line_short_info']) . 
							'</div>' . 
						'</div>';
					} 
				?>
					<div class="cl"></div>
				</div>
			</div>
			<div class="header_top_but closed">
				<span class="cmsms_bot_arrow_pixel">
					<span></span>
				</span>
			</div>
		</div>
	<?php } ?>
	<div class="header_mid" data-height="<?php echo $cmsms_option[CMSMS_SHORTNAME . '_header_mid_height']; ?>">
		<div class="header_mid_outer">
			<div class="header_mid_inner">
			<?php 
			if (
				CMSMS_DONATIONS && 
				isset($cmsms_option[CMSMS_SHORTNAME . '_header_donations_but']) && 
				$cmsms_option[CMSMS_SHORTNAME . '_header_donations_but'] && 
				isset($cmsms_option[CMSMS_SHORTNAME . '_header_donations_but_text']) && 
				$cmsms_option[CMSMS_SHORTNAME . '_header_donations_but_text'] != '' && 
				$cmsms_option[CMSMS_SHORTNAME . '_header_styles'] != 'default' && 
				$cmsms_option[CMSMS_SHORTNAME . '_header_styles'] != 'c_nav'
			) {
				$cmsms_donations_form_page = get_option('cmsms_donations_form_page');
				
				
				if (function_exists('icl_object_id')) {
					$donations_page_id = icl_object_id($cmsms_donations_form_page, 'page', false);
				} else {
					$donations_page_id = $cmsms_donations_form_page;
				}
				
				
				echo '<div class="header_donation_but_wrap">' . 
					'<div class="header_donation_but_wrap_inner">' . 
						'<div class="header_donation_but">' . 
							'<a href="' . get_permalink($donations_page_id) . '" class="cmsms_button">' . 
								'<span>' . $cmsms_option[CMSMS_SHORTNAME . '_header_donations_but_text'] . '</span>' . 
							'</a>' . 
						'</div>' . 
					'</div>' . 
				'</div>';
			}
			
			
			if (
				$cmsms_option[CMSMS_SHORTNAME . '_header_search'] && 
				$cmsms_option[CMSMS_SHORTNAME . '_header_styles'] != 'c_nav'
			) {
			?>
				<div class="search_wrap">
					<div class="search_wrap_inner">
						<div class="search_wrap_inner_left">
							<?php get_search_form(); ?>
						</div>
					</div>
				</div>
			<?php 
			}
			
			
			if (
				$cmsms_option[CMSMS_SHORTNAME . '_header_styles'] != 'default' && 
				$cmsms_option[CMSMS_SHORTNAME . '_header_styles'] != 'c_nav'
			) { 
				if (
					$cmsms_option[CMSMS_SHORTNAME . '_header_add_cont'] == 'cust_html' && 
					$cmsms_option[CMSMS_SHORTNAME . '_header_add_cont_cust_html'] !== ''
				) {
			?>
				<div class="slogan_wrap">
					<div class="slogan_wrap_inner">
						<div class="slogan_wrap_text">
							<?php echo stripslashes($cmsms_option[CMSMS_SHORTNAME . '_header_add_cont_cust_html']) ?>
						</div>
					</div>
				</div>
			<?php 
				} elseif (
					$cmsms_option[CMSMS_SHORTNAME . '_header_add_cont'] == 'social' && 
					isset($cmsms_option[CMSMS_SHORTNAME . '_social_icons'])
				) {
					cmsms_social_icons();
				}
			}
			?>
			
			<div class="logo_wrap"><?php cmsms_logo(); ?></div>
			
			<?php if ($cmsms_option[CMSMS_SHORTNAME . '_header_styles'] == 'default') { ?>
				<div class="resp_nav_wrap">
					<div class="resp_nav_wrap_inner">
						<div class="resp_nav_content">
							<a class="responsive_nav cmsms_theme_icon_resp_nav" href="javascript:void(0);"></a>
							<?php 
							if (class_exists('woocommerce')) {
								cmsms_woocommerce_header_cart_link();
							}
							?>
						</div>
					</div>
				</div>
				
				<!-- _________________________ Start Navigation _________________________ -->
				<nav role="navigation">
				<?php
					echo "\t";
					
					
					wp_nav_menu($nav_args);
					
					
					echo "\r";
				?>
					<div class="cl"></div>
				</nav>
				<!-- _________________________ Finish Navigation _________________________ -->
			<?php } ?>
			</div>
		</div>
	</div>
<?php if ($cmsms_option[CMSMS_SHORTNAME . '_header_styles'] != 'default') { ?>
	<div class="header_bot" data-height="<?php echo $cmsms_option[CMSMS_SHORTNAME . '_header_bot_height']; ?>">
		<div class="header_bot_outer">
			<div class="header_bot_inner">
				<div class="resp_nav_wrap">
					<div class="resp_nav_wrap_inner">
						<div class="resp_nav_content">
							<a class="responsive_nav cmsms_theme_icon_resp_nav" href="javascript:void(0);"></a>
							<?php 
							if (class_exists('woocommerce')) {
								cmsms_woocommerce_header_cart_link();
							}
							?>
						</div>
					</div>
				</div>
				
				<!-- _________________________ Start Navigation _________________________ -->
				<nav role="navigation">
				<?php
					echo "\t";
					
					
					wp_nav_menu($nav_args);
					
					
					echo "\r";
				?>
					<div class="cl"></div>
				</nav>
				<!-- _________________________ Finish Navigation _________________________ -->
				
			</div>
		</div>
	</div>
<?php } ?>
</header>
<!-- _________________________ Finish Header _________________________ -->

	
<!-- _________________________ Start Middle _________________________ -->
<section id="middle"<?php echo (is_404()) ? ' class="error_page"' : ''; ?>>
<?php 
if (!is_404() && !is_home()) {
	cmsms_page_heading();
} else {
	echo "<div class=\"headline\">
		<div class=\"headline_outer cmsms_headline_disabled\"></div>
	</div>";
}


list($cmsms_layout, $cmsms_page_scheme) = cmsms_theme_page_layout_scheme();


echo '<div class="middle_inner' . (($cmsms_page_scheme != 'default') ? ' cmsms_color_scheme_' . $cmsms_page_scheme : '') . '">' . "\n" . 
	'<section class="content_wrap ' . $cmsms_layout . 
	((is_singular('project')) ? ' project_page' : '') . 
	((is_singular('profile')) ? ' profile_page' : '') . 
	((CMSMS_WOOCOMMERCE && (
		is_woocommerce() || 
		is_cart() || 
		is_checkout() || 
		is_checkout_pay_page() || 
		is_account_page() || 
		is_order_received_page() || 
		is_add_payment_method_page()
	)) ? ' cmsms_woo' : '') . 
	'">' . "\n\n";

