<?php
/**
 * @version    $Id$
 * @package    IT_Theme_Framework
 * @author     InnoThemes Team <support@innothemes.com>
 * @copyright  Copyright (C) 2012 InnoThemes.com. All Rights Reserved.
 * @license    GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
 *
 * Websites: http://www.innothemes.com
 */

// Do some initialization before rendering
IT_Init_Theme::prepare();

// Get theme options
global $it_options;

// Turn off all error reporting
error_reporting( 0 );

// Generate custom style
$custom_style = array();

// Begin Custom Style For General Section
if ( 'boxed' == $it_options['page_layout'] ) :
	$custom_style[] = '
	#it-wrapper {
		width: 100%;
		max-width: 960px;
	}
	#it-container {';

switch ( $it_options['page_background_type'] ) :

case 'solid_color':
	$custom_style[] = '
		background-color: ' . $it_options['page_background_solid_color'] . ';';
break;

case 'gradient_color':
	$custom_style[] = "\n\t\t" . $it_options['page_background_gradient_color']['css'];
break;

case 'pattern':
	$custom_style[] = '
		background-image: url(' . $it_options['page_background_pattern'] . ');
		background-repeat: ' . $it_options['page_background_pattern_repeat'] . ';';
break;

case 'image':
	$page_position = str_replace( '_', ' ', $it_options['page_background_image_position'] );

	$custom_style[] = '
		background-image: url(' . $it_options['page_background_image'] . ');
		background-position: ' . $page_position . ';';

	if ( 'full' == $it_options['page_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: 100% 100%;';
	}
	elseif ( 'cover' == $it_options['page_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: cover;';
	}
	elseif ( 'contain' == $it_options['page_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: contain;';
	}
	if ( $it_options['page_background_image_scroll'] ) {
		$custom_style[] = '
		background-attachment: fixed;';
	}
break;

endswitch;

$custom_style[] = '
	}';

elseif ( 'full_width' == $it_options['page_layout'] ) :

$custom_style[] = '
	#it-wrapper {
		border: 0;
		-webkit-box-shadow: none;
		-moz-box-shadow:    none;
		box-shadow: 		none;
	}';

endif;

if ( 'standard' == $it_options['heading_font_face']['font-type'] ) {
	$custom_style[] = '
		#it-container h1,
		#it-container h2,
		#it-container h3,
		#it-container h4,
		#it-container h5,
		#it-container h6,
		#it-main-menu > li {
			font-family: ' . $it_options['heading_font_face']['font-family'] . ';
		}';
	}
elseif ( 'google' == $it_options['heading_font_face']['font-type'] ) {
	// Load google font
	IT_Init_Assets::load(
		'google-font-heading-css',
		'https://fonts.googleapis.com/css?family=' . str_replace( ' ', '+', $it_options['heading_font_face']['font-google'] )
	);
	$custom_style[] = '
		#it-container h1,
		#it-container h2,
		#it-container h3,
		#it-container h4,
		#it-container h5,
		#it-container h6,
		#it-main-menu > li {
			font-family: ' . $it_options['heading_font_face']['font-google'] . ';
		}';
	}

if ( 'standard' == $it_options['body_font_face']['font-type'] ) {
	$custom_style[] = '
		#it-container {
			font-family: ' . $it_options['body_font_face']['font-family'] . ';
		}';
	}
elseif ( 'google' == $it_options['body_font_face']['font-type'] ) {
	// Load google font
	IT_Init_Assets::load(
		'google-font-body-css',
		'https://fonts.googleapis.com/css?family=' . str_replace( ' ', '+', $it_options['body_font_face']['font-google'] )
	);
	$custom_style[] = '
		#it-container {
			font-family: ' . $it_options['body_font_face']['font-google'] . ';
		}';
	}
// End General Section

// Begin Custom Style For Header Section
$custom_style[] = '
	#it-header {
		font-size: ' .$it_options['header_base_font_attributes']['font-size'].$it_options['header_base_font_attributes']['font-unit']. ';
		font-weight: ' .$it_options['header_base_font_attributes']['font-display']. ';
		color: ' . $it_options['header_base_font_attributes']['text-color'] . ';';

switch ( $it_options['header_background_type'] ) :

case 'solid_color':
	$custom_style[] = '
		background-color: ' . $it_options['header_background_solid_color'] . ';';
break;

case 'gradient_color':
	$custom_style[] = "\n\t\t" . $it_options['header_background_gradient_color']['css'];
break;

case 'pattern':
	$custom_style[] = '
		background-image: url(' . $it_options['header_background_pattern'] . ');
		background-repeat: ' . $it_options['header_background_pattern_repeat'] . ';';
break;

case 'image':
	$header_position = str_replace( '_', ' ', $it_options['header_background_image_position'] );

	$custom_style[] = '
		background-image: url(' . $it_options['header_background_image'] . ');
		background-position: ' . $header_position . ';';

	if ( 'full' == $it_options['header_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: 100% 100%;';
	}
	elseif ( 'cover' == $it_options['header_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: cover;';
	}
	elseif ( 'contain' == $it_options['header_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: contain;';
	}
	if ( $it_options['header_background_image_scroll'] ) {
		$custom_style[] = '
		background-attachment: fixed;';
	}
break;

endswitch;

$custom_style[] = '
	}';

if ( $it_options['logo_image_retina'] ) {
	$custom_style[] = '
	@media only screen and (-webkit-min-device-pixel-ratio: 2),
	only screen and (-ms-min-device-pixel-ratio: 2),
	only screen and (-o-min-device-pixel-ratio: 2/1),
	only screen and (min--moz-device-pixel-ratio: 2),
	only screen and (min-device-pixel-ratio: 2),
	only screen and (min-resolution: 192dpi),
	only screen and (min-resolution: 2dppx) {
		a.desktop-logo,
		a.responsive-logo {
			display: none !important;
		}
		a.retina-logo {
			display: block !important;
		}
	}';
}

if ( $it_options['top_menu_font_attributes'] ) {
	$custom_style[] = '
	#it-top-menu > li > a {
		color: ' . $it_options['top_menu_font_attributes']['text-color'] . ';
		font-size: ' . $it_options['top_menu_font_attributes']['font-size'].$it_options['top_menu_font_attributes']['font-unit'] . ';
		font-weight: ' . $it_options['top_menu_font_attributes']['font-display'] . ';
	}';
	if ( 'italic' == $it_options['top_menu_font_attributes']['font-display'] ) {
		$custom_style[] = '
		#it-top-menu > li > a {
			font-style: italic;
		}';
	}
}

if ( $it_options['main_menu_font_attributes'] ) {
	$custom_style[] = '
	#it-main-menu > li {
		font-size: ' . $it_options['main_menu_font_attributes']['font-size'].$it_options['main_menu_font_attributes']['font-unit'] . ';
		font-weight: ' . $it_options['main_menu_font_attributes']['font-display'] . ';
	}
	#it-main-menu > li > a {
		color: ' . $it_options['main_menu_font_attributes']['text-color'] . ';
	}';
	if ( 'italic' == $it_options['main_menu_font_attributes']['font-display'] ) {
		$custom_style[] = '
		#it-main-menu > li > a {
			font-style: italic;
		}';
	}
}

if ( $it_options['sub_menu_font_attributes'] ) {
	$custom_style[] = '
	.sub-menu li a {
		font-size: ' . $it_options['sub_menu_font_attributes']['font-size'].$it_options['sub_menu_font_attributes']['font-unit'] . ';
		font-weight: ' . $it_options['sub_menu_font_attributes']['font-display'] . ';
	}
	#it-main-menu ul li a {
		color: ' . $it_options['sub_menu_font_attributes']['text-color'] . ';
	}';
	if ( 'italic' == $it_options['sub_menu_font_attributes']['font-display'] ) {
		$custom_style[] = '
		.sub-menu li a {
			font-style: italic;
		}';
	}
}
// End Header Section

// Begin Custom Style For Promo Section
$custom_style[] = '
	#it-promo h1,
	#it-promo h2,
	#it-promo h3,
	#it-promo h4,
	#it-promo h5,
	#it-promo h6 {
		font-size: ' .$it_options['promo_heading_font_attributes']['font-size'].$it_options['promo_heading_font_attributes']['font-unit']. ';
		font-weight: ' .$it_options['promo_heading_font_attributes']['font-display']. ';
		color: ' . $it_options['promo_heading_font_attributes']['text-color'] . ';
	}
	#it-promo {
		font-size: ' .$it_options['promo_body_font_attributes']['font-size'].$it_options['promo_body_font_attributes']['font-unit']. ';
		font-weight: ' .$it_options['promo_body_font_attributes']['font-display']. ';
		color: ' . $it_options['promo_body_font_attributes']['text-color'] . ';';

switch ( $it_options['promo_background_type'] ) :

case 'solid_color':
	$custom_style[] = '
		background-color: ' . $it_options['promo_background_solid_color'] . ';';
break;

case 'gradient_color':
	$custom_style[] = "\n\t\t" . $it_options['promo_background_gradient_color']['css'];
break;

case 'pattern':
	$custom_style[] = '
		background-image: url(' . $it_options['promo_background_pattern'] . ');
		background-repeat: ' . $it_options['promo_background_pattern_repeat'] . ';';
break;

case 'image':
	$promo_position = str_replace( '_', ' ', $it_options['promo_background_image_position'] );

	$custom_style[] = '
		background-image: url(' . $it_options['promo_background_image'] . ');
		background-position: ' . $promo_position . ';';

	if ( 'full' == $it_options['promo_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: 100% 100%;';
	}
	elseif ( 'cover' == $it_options['promo_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: cover;';
	}
	elseif ( 'contain' == $it_options['promo_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: contain;';
	}
	if ( $it_options['promo_background_image_scroll'] ) {
		$custom_style[] = '
		background-attachment: fixed;';
	}
break;

endswitch;

$custom_style[] = '
	}';
// End Promo Section

// Begin Custom Style For Main Content
if ( $it_options['heading_font_attributes'] ) {
	$custom_style[] = '
	#it-content h1,
	#it-content h2,
	#it-content h3,
	#it-content h4,
	#it-content h5,
	#it-content h6 {
		font-size: ' . $it_options['heading_font_attributes']['font-size'].$it_options['heading_font_attributes']['font-unit'] . ';
		font-weight: ' . $it_options['heading_font_attributes']['font-display'] . ';
		color: ' . $it_options['heading_font_attributes']['text-color'] . ';
	}';
	if ( 'italic' == $it_options['heading_font_attributes']['font-display'] ) {
		$custom_style[] = '
		#it-content h1,
		#it-content h2,
		#it-content h3,
		#it-content h4,
		#it-content h5,
		#it-content h6 {
			font-style: italic;
		}';
	}
}

if ( $it_options['body_font_attributes'] ) {
	$custom_style[] = '
	#it-content {
		font-size: ' . $it_options['body_font_attributes']['font-size'].$it_options['body_font_attributes']['font-unit'] . ';
		font-weight: ' . $it_options['body_font_attributes']['font-display'] . ';
		color: ' . $it_options['body_font_attributes']['text-color'] . ';
	}';
	if ( 'italic' == $it_options['body_font_attributes']['font-display'] ) {
		$custom_style[] = '
		#it-content {
			font-style: italic;
		}';
	}
}
// End Main Content Section

// Begin Custom Style For Content Bottom
$custom_style[] = '
	#it-content-bottom { ';

switch ( $it_options['bottom_background_type'] ) :

case 'solid_color':
	$custom_style[] = '
		background-color: ' . $it_options['bottom_background_solid_color'] . ';';
break;

case 'gradient_color':
	$custom_style[] = "\n\t\t" . $it_options['bottom_background_gradient_color']['css'];
break;

case 'pattern':
	$custom_style[] = '
		background-image: url(' . $it_options['bottom_background_pattern'] . ');
		background-repeat: ' . $it_options['bottom_background_pattern_repeat'] . ';';
break;

case 'image':
	$bottom_position = str_replace( '_', ' ', $it_options['bottom_background_image_position'] );

	$custom_style[] = '
		background-image: url(' . $it_options['bottom_background_image'] . ');
		background-position: ' . $bottom_position . ';';

	if ( 'full' == $it_options['bottom_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: 100% 100%;';
	}
	elseif ( 'cover' == $it_options['bottom_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: cover;';
	}
	elseif ( 'contain' == $it_options['bottom_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: contain;';
	}
	if ( $it_options['bottom_background_image_scroll'] ) {
		$custom_style[] = '
		background-attachment: fixed;';
	}
break;

endswitch;

if ( $it_options['bottom_body_font_attributes'] ) {
	$custom_style[] = '
		font-size: ' . $it_options['bottom_body_font_attributes']['font-size'].$it_options['bottom_body_font_attributes']['font-unit'] . ';
		font-weight: ' . $it_options['bottom_body_font_attributes']['font-display'] . ';
		color: ' . $it_options['bottom_body_font_attributes']['text-color'] . ';
	';
	if ( 'italic' == $it_options['bottom_body_font_attributes']['font-display'] ) {
		$custom_style[] = '
			font-style: italic;
		';
	}
}

$custom_style[] = '
	}';

if ( $it_options['bottom_heading_font_attributes'] ) {
	$custom_style[] = '
	#it-content-bottom h1,
	#it-content-bottom h2,
	#it-content-bottom h3,
	#it-content-bottom h4,
	#it-content-bottom h5,
	#it-content-bottom h6 {
		font-size: ' . $it_options['bottom_heading_font_attributes']['font-size'].$it_options['bottom_heading_font_attributes']['font-unit'] . ';
		font-weight: ' . $it_options['bottom_heading_font_attributes']['font-display'] . ';
		color: ' . $it_options['bottom_heading_font_attributes']['text-color'] . ';
	}';
	if ( 'italic' == $it_options['bottom_heading_font_attributes']['font-display'] ) {
		$custom_style[] = '
		#it-content-bottom h1,
		#it-content-bottom h2,
		#it-content-bottom h3,
		#it-content-bottom h4,
		#it-content-bottom h5,
		#it-content-bottom h6 {
			font-style: italic;
		}';
	}
}
// End Bottom Section

// Begin Custom Style For Footer Section
$custom_style[] = '
	#it-footer { ';

switch ( $it_options['footer_background_type'] ) :

case 'solid_color':
	$custom_style[] = '
		background-color: ' . $it_options['footer_background_solid_color'] . ';';
break;

case 'gradient_color':
	$custom_style[] = "\n\t\t" . $it_options['footer_background_gradient_color']['css'];
break;

case 'pattern':
	$custom_style[] = '
		background-image: url(' . $it_options['footer_background_pattern'] . ');
		background-repeat: ' . $it_options['footer_background_pattern_repeat'] . ';';
break;

case 'image':
	$footer_position = str_replace( '_', ' ', $it_options['footer_background_image_position'] );

	$custom_style[] = '
		background-image: url(' . $it_options['footer_background_image'] . ');
		background-position: ' . $footer_position . ';';

	if ( 'full' == $it_options['footer_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: 100% 100%;';
	}
	elseif ( 'cover' == $it_options['footer_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: cover;';
	}
	elseif ( 'contain' == $it_options['footer_background_image_stretch'] ) {
		$custom_style[] = '
		background-size: contain;';
	}
	if ( $it_options['footer_background_image_scroll'] ) {
		$custom_style[] = '
		background-attachment: fixed;';
	}
break;

endswitch;

if ( $it_options['footer_body_font_attributes'] ) {
	$custom_style[] = '
		font-size: ' . $it_options['footer_body_font_attributes']['font-size'].$it_options['footer_body_font_attributes']['font-unit'] . ';
		font-weight: ' . $it_options['footer_body_font_attributes']['font-display'] . ';
		color: ' . $it_options['footer_body_font_attributes']['text-color'] . ';
	';
	if ( 'italic' == $it_options['footer_body_font_attributes']['font-display'] ) {
		$custom_style[] = '
			font-style: italic;
		';
	}
}

$custom_style[] = '
	}';

if ( $it_options['footer_heading_font_attributes'] ) {
	$custom_style[] = '
	#it-footer h1,
	#it-footer h2,
	#it-footer h3,
	#it-footer h4,
	#it-footer h5,
	#it-footer h6 {
		font-size: ' . $it_options['footer_heading_font_attributes']['font-size'].$it_options['footer_heading_font_attributes']['font-unit'] . ';
		font-weight: ' . $it_options['footer_heading_font_attributes']['font-display'] . ';
		color: ' . $it_options['footer_heading_font_attributes']['text-color'] . ';
	}';
	if ( 'italic' == $it_options['footer_heading_font_attributes']['font-display'] ) {
		$custom_style[] = '
		#it-footer h1,
		#it-footer h2,
		#it-footer h3,
		#it-footer h4,
		#it-footer h5,
		#it-footer h6 {
			font-style: italic;
		}';
	}
}
// End Footer Section

// Begin Custom Style For Extra Section
$custom_style[] = '
	#it-corner-pagepeel {';

switch ( $it_options['corner_pagepeel_position'] ) :

case 'top_left':
	$custom_style[] = '
		top: 0;
		left: 0;';
break;

case 'top_right':
	$custom_style[] = '
		top: 0;
		right: 0;';
break;

case 'bottom_left':
	$custom_style[] = '
		bottom: 0;
		left: 0;';
	break;

case 'bottom_right':
	$custom_style[] = '
		bottom: 0;
		right: 0;';
break;

endswitch;

$custom_style[] = '
	}';

if ( $it_options['side_tabs_text'] ) {
	$custom_style[] = '
	#it-sidetabs {
		background: ' .$it_options['side_tabs_background_color']. ';
		color: ' .$it_options['side_tabs_text_color']. ';';

	if ( ( 'top' == $it_options['side_tabs_position'] ) || ( 'bottom' == $it_options['side_tabs_position'] ) ) {
		$custom_style[] = '
		' .$it_options['side_tabs_position']. ': 0;
		left: 50%;';
	} elseif ( ( 'right' == $it_options['side_tabs_position'] ) || ( 'left' == $it_options['side_tabs_position'] ) ) {
		$custom_style[] = '
		' .$it_options['side_tabs_position']. ': 0;
		top: 50%;';
	}

	$custom_style[] = '
	}';
}
// End Extra Section


// Register inline styles
if ( count( $custom_style ) ) {
	IT_Init_Assets::inline( 'css', implode( $custom_style ) );
}
