<?php 

require(ghostpool_inc . 'options.php');
global $gp_settings;
	
// Detect Browsers
$gp_settings['MSIE'] = (stripos($_SERVER['HTTP_USER_AGENT'],'MSIE') !== false);
$gp_settings['iPhone'] = (stripos($_SERVER['HTTP_USER_AGENT'],"iPhone") !== false);
$gp_settings['iPad'] = (stripos($_SERVER['HTTP_USER_AGENT'],"iPad") !== false);

// Browser Class
if($gp_settings['iPhone'] OR $gp_settings['iPad']) {
	$gp_settings['browser'] = "ios-class";
} else {
	$gp_settings['browser'] = "";
}

// Skins
if(isset($_GET['skin']) && $_GET['skin'] != "default") {
	$gp_settings['skin'] = "skin-".$_GET['skin'];
} elseif(isset($_COOKIE['SkinCookie']) && $_COOKIE['SkinCookie'] != "default") {
	$gp_settings['skin'] = "skin-".$_COOKIE['SkinCookie']; 
} elseif(get_post_meta($post->ID, 'ghostpool_skin', true) && get_post_meta($post->ID, 'ghostpool_skin', true) != "Default") {
	$gp_settings['skin'] = "skin-".get_post_meta($post->ID, 'ghostpool_skin', true);
} else {
	$gp_settings['skin'] = "skin-".$theme_skin;
}	

// Post Type
$gp_settings['post_type'] = get_post_meta($post->ID, 'ghostpool_post_type', true);	


/*************************** Homepage ***************************/

if(is_home() OR is_front_page()) {

	$gp_settings['page_var'] = 'homepage';
	$gp_settings['cats'] = $theme_homepage_cats;
	$gp_settings['thumbnail_width'] = $theme_homepage_thumbnail_width;
	$gp_settings['thumbnail_height'] = $theme_homepage_thumbnail_height;
	$gp_settings['image_wrap'] = $theme_homepage_image_wrap;
	$gp_settings['layout'] = $theme_homepage_layout;
	$gp_settings['title'] = $theme_homepage_title;
	$gp_settings['posts_per_page'] = $theme_homepage_posts_per_page;
	$gp_settings['content_display'] = $theme_homepage_content_display;	
	$gp_settings['excerpt_length'] = $theme_homepage_excerpt_length; 
	$gp_settings['read_more'] = $theme_homepage_read_more;
	//$gp_settings['score_type'] = $theme_homepage_score_type;
	$gp_settings['review_date_column'] = $theme_homepage_review_date_column;	
	$gp_settings['dropdown_filter'] = $theme_homepage_dropdown_filter;
        $gp_settings['pagination'] = $theme_homepage_pagination;
	$gp_settings['meta_date'] = $theme_homepage_date;
	$gp_settings['meta_author'] = $theme_homepage_author;
	$gp_settings['meta_cats'] = $theme_homepage_cats_;
	$gp_settings['meta_tags'] = $theme_homepage_tags;
	$gp_settings['meta_comments'] = $theme_homepage_comments;
	$gp_settings['meta_share_link'] = "1";
	$gp_settings['meta_tags'] = $theme_homepage_tags;
			
	// Column Width
	if($gp_settings['layout'] == "fullwidth") {
		$gp_settings['content_width'] = "920";
	} else {
		$gp_settings['content_width'] = "590";
	}
	
	
/*************************** BuddyPress ***************************/
	
} elseif((function_exists('bp_is_active') && !bp_is_blog_page()) OR (function_exists('is_bbpress') && is_bbpress())) {

	$gp_settings['layout'] = "sb-right";
	$gp_settings['title'] = "Show";
	$gp_settings['meta_date'] = "1";
	$gp_settings['meta_author'] = "1";
	$gp_settings['meta_cats'] = "1";
	$gp_settings['meta_tags'] = "1";
	$gp_settings['meta_comments'] = "1";
	$gp_settings['meta_share_link'] = "1";
	

/*************************** Categories, Archives etc. ***************************/

} elseif(is_archive() OR is_search()) {

	$gp_settings['thumbnail_width'] = $theme_cat_thumbnail_width;
	$gp_settings['thumbnail_height'] = $theme_cat_thumbnail_height;
	$gp_settings['image_wrap'] = $theme_cat_image_wrap;
	$gp_settings['layout'] = $theme_cat_layout;	
	$gp_settings['title'] = $theme_cat_title;
	$gp_settings['posts_per_page'] = $theme_cat_posts_per_page;
	$gp_settings['content_display'] = $theme_cat_content_display;
	$gp_settings['excerpt_length'] = $theme_cat_excerpt_length;
	$gp_settings['read_more'] = $theme_cat_read_more;
	$gp_settings['score_type'] = $theme_cat_score_type;
	$gp_settings['review_date_column'] = $theme_cat_review_date_column;	
	$gp_settings['dropdown_filter'] = $theme_cat_dropdown_filter;					
	$gp_settings['meta_date'] = $theme_cat_date;
	$gp_settings['meta_author'] = $theme_cat_author;
	$gp_settings['meta_cats'] = $theme_cat_cats;
	$gp_settings['meta_tags'] = $theme_cat_tags;
	$gp_settings['meta_comments'] = $theme_cat_comments;
	$gp_settings['meta_share_link'] = "1";
	$gp_settings['meta_tags'] = $theme_cat_tags;
		
	// Column Width
	if($gp_settings['layout'] == "fullwidth") {
		$gp_settings['content_width'] = "920";
	} else {
		$gp_settings['content_width'] = "590";
	}
			

/*************************** Blog Page Template ***************************/

} elseif(is_page_template('blog.php')) {

	$gp_settings['cats'] = $theme_blog_cats;
	$gp_settings['thumbnail_width'] = $theme_blog_thumbnail_width;
	$gp_settings['thumbnail_height'] = $theme_blog_thumbnail_height;
	$gp_settings['image_wrap'] = $theme_blog_image_wrap;
	$gp_settings['layout'] = $theme_blog_layout;	
	$gp_settings['title'] = $theme_blog_title;
	$gp_settings['posts_per_page'] = $theme_blog_posts_per_page;
	$gp_settings['content_display'] = $theme_blog_content_display;
	$gp_settings['excerpt_length'] = $theme_blog_excerpt_length;
	$gp_settings['read_more'] = $theme_blog_read_more;
	$gp_settings['score_type'] = $theme_blog_score_type;
	$gp_settings['review_date_column'] = $theme_blog_review_date_column;	
	$gp_settings['dropdown_filter'] = $theme_blog_dropdown_filter;
	$gp_settings['meta_date'] = $theme_blog_date;
	$gp_settings['meta_author'] = $theme_blog_author;
	$gp_settings['meta_cats'] = $theme_blog_cats_;
	$gp_settings['meta_tags'] = $theme_blog_tags;
	$gp_settings['meta_comments'] = $theme_blog_comments;
	$gp_settings['meta_share_link'] = "1";
	$gp_settings['meta_tags'] = $theme_blog_tags;
		
	// Column Width
	if($gp_settings['layout'] == "fullwidth") {
		$gp_settings['content_width'] = "920";
	} else {
		$gp_settings['content_width'] = "590";
	}
		

/*************************** Posts ***************************/

} elseif(is_single() && $gp_settings['post_type'] != "Review") {

	// Show Image
	if(get_post_meta($post->ID, 'ghostpool_show_image', true) && get_post_meta($post->ID, 'ghostpool_show_image', true) != "Default") {
		$gp_settings['show_image'] = get_post_meta($post->ID, 'ghostpool_show_image', true);
	} else {
		$gp_settings['show_image'] = $theme_show_post_image;
	}
	
	// Image Dimensions
	if(get_post_meta($post->ID, 'ghostpool_image_width', true) && get_post_meta($post->ID, 'ghostpool_image_width', true)) {
		$gp_settings['image_width'] = get_post_meta($post->ID, 'ghostpool_image_width', true);
	} else {
		$gp_settings['image_width'] = $theme_post_image_width;
	}
	if(get_post_meta($post->ID, 'ghostpool_image_height', true) && get_post_meta($post->ID, 'ghostpool_image_height', true)) {
		$gp_settings['image_height'] = get_post_meta($post->ID, 'ghostpool_image_height', true);
	} else {
		$gp_settings['image_height'] = $theme_post_image_height;
	}
	
	// Image Wrap
	if(get_post_meta($post->ID, 'ghostpool_image_wrap', true) && get_post_meta($post->ID, 'ghostpool_image_wrap', true) != "Default") {
		$gp_settings['image_wrap'] = get_post_meta($post->ID, 'ghostpool_image_wrap', true);
	} else {
		$gp_settings['image_wrap'] = $theme_post_image_wrap;
	}
	
	// Layout
	if(is_attachment()) {
		$gp_settings['layout'] = "fullwidth";
	} else {
		if(get_post_meta($post->ID, 'ghostpool_layout', true) && get_post_meta($post->ID, 'ghostpool_layout', true) != "Default") {
			$gp_settings['layout'] = get_post_meta($post->ID, 'ghostpool_layout', true);
		} else {
			$gp_settings['layout'] = $theme_post_layout;
		}
	}

	// Title
	if(get_post_meta($post->ID, 'ghostpool_title', true) && get_post_meta($post->ID, 'ghostpool_title', true) != "Default") {
		$gp_settings['title'] = get_post_meta($post->ID, 'ghostpool_title', true);
	} else {
		$gp_settings['title'] = $theme_post_title;
	}

	// Post Meta						
	$gp_settings['meta_date'] = $theme_post_date;
	$gp_settings['meta_author'] = $theme_post_author;
	$gp_settings['meta_cats'] = $theme_post_cats;
	$gp_settings['meta_tags'] = $theme_post_tags;
	$gp_settings['meta_comments'] = $theme_post_comments;
	$gp_settings['meta_share_link'] = $theme_post_share_link;
		
	// Author Info Panel
	$gp_settings['author_info'] = $theme_post_author_info;
						
	// Related Items
	$gp_settings['related_items'] = $theme_post_related_items;


/*************************** Review Posts ***************************/

} elseif(is_single() && $gp_settings['post_type'] == "Review") {

	// Show Image
	if(get_post_meta($post->ID, 'ghostpool_show_image', true) && get_post_meta($post->ID, 'ghostpool_show_image', true) != "Default") {
		$gp_settings['show_image'] = get_post_meta($post->ID, 'ghostpool_show_image', true);
	} else {
		$gp_settings['show_image'] = $theme_show_review_image;
	}
	
	// Image Dimensions
	if(get_post_meta($post->ID, 'ghostpool_image_width', true) && get_post_meta($post->ID, 'ghostpool_image_width', true)) {
		$gp_settings['image_width'] = get_post_meta($post->ID, 'ghostpool_image_width', true);
	} else {
		$gp_settings['image_width'] = $theme_review_image_width;
	}
	if(get_post_meta($post->ID, 'ghostpool_image_height', true) && get_post_meta($post->ID, 'ghostpool_image_height', true)) {
		$gp_settings['image_height'] = get_post_meta($post->ID, 'ghostpool_image_height', true);
	} else {
		$gp_settings['image_height'] = $theme_review_image_height;
	}
	
	// Image Wrap
	if(get_post_meta($post->ID, 'ghostpool_image_wrap', true) && get_post_meta($post->ID, 'ghostpool_image_wrap', true) != "Default") {
		$gp_settings['image_wrap'] = get_post_meta($post->ID, 'ghostpool_image_wrap', true);
	} else {
		$gp_settings['image_wrap'] = $theme_review_image_wrap;
	}
	
	// Layout
	if(get_post_meta($post->ID, 'ghostpool_layout', true) && get_post_meta($post->ID, 'ghostpool_layout', true) != "Default") {
		$gp_settings['layout'] = get_post_meta($post->ID, 'ghostpool_layout', true);
	} else {
		$gp_settings['layout'] = $theme_review_layout;
	}

	// Title
	if(get_post_meta($post->ID, 'ghostpool_title', true) && get_post_meta($post->ID, 'ghostpool_title', true) != "Default") {
		$gp_settings['title'] = get_post_meta($post->ID, 'ghostpool_title', true);
	} else {
		$gp_settings['title'] = $theme_review_title;
	} 	

	// User Voting
	if(get_post_meta($post->ID, 'ghostpool_user_voting', true) && get_post_meta($post->ID, 'ghostpool_user_voting', true) != "Default") {
		$gp_settings['user_voting'] = get_post_meta($post->ID, 'ghostpool_user_voting', true);
	} else {
		$gp_settings['user_voting'] = $theme_user_voting;
	}

	// User Comments
	if(get_post_meta($post->ID, 'ghostpool_user_comments', true) && get_post_meta($post->ID, 'ghostpool_user_comments', true) != "Default") {
		$gp_settings['user_comments'] = get_post_meta($post->ID, 'ghostpool_user_comments', true);
	} else {
		$gp_settings['user_comments'] = $theme_user_comments;
	}

	// Comment Thumbs
	if(get_post_meta($post->ID, 'ghostpool_comment_thumbs', true) && get_post_meta($post->ID, 'ghostpool_comment_thumbs', true) != "Default") {
		$gp_settings['comment_thumbs'] = get_post_meta($post->ID, 'ghostpool_comment_thumbs', true);
	} else {
		$gp_settings['comment_thumbs'] = $theme_comment_thumbs;
	}
	
	// Column Width
	if($gp_settings['layout'] == "fullwidth") {
		$gp_settings['content_width'] = "920";
	} else {
		$gp_settings['content_width'] = "590";
	}

	// Score Colors
	if(defined('STARRATING_INSTALLED')) { 
			
		$gp_settings['gp_gdsr'] = wp_gdsr_rating_article();
				
		// Site Score Colors		
		if($gp_settings['gp_gdsr']->review <= $theme_score_range_2) {		
			$site_score_color = ' style="background: '.$theme_site_score_color_1.';"';
		} elseif($gp_settings['gp_gdsr']->review >= $theme_score_range_3 && $gp_settings['gp_gdsr']->review <= $theme_score_range_4) {
			$site_score_color = ' style="background: '.$theme_site_score_color_2.';"';		
		} elseif($gp_settings['gp_gdsr']->review >= $theme_score_range_5 && $gp_settings['gp_gdsr']->review <= $theme_score_range_6) {
			$site_score_color = ' style="background: '.$theme_site_score_color_3.';"';		
		} elseif($gp_settings['gp_gdsr']->review >= $theme_score_range_7) {
			$site_score_color = ' style="background: '.$theme_site_score_color_4.';"';
		}
	
		// User Score Colors
		if($gp_settings['gp_gdsr']->rating <= $theme_score_range_2) {		
			$user_score_color = ' style="background: '.$theme_user_score_color_1.';"';
		} elseif($gp_settings['gp_gdsr']->rating >= $theme_score_range_3 && $gp_settings['gp_gdsr']->rating <= $theme_score_range_4) {
			$user_score_color = ' style="background: '.$theme_user_score_color_2.';"';		
		} elseif($gp_settings['gp_gdsr']->rating >= $theme_score_range_5 && $gp_settings['gp_gdsr']->rating <= $theme_score_range_6) {
			$user_score_color = ' style="background: '.$theme_user_score_color_3.';"';		
		} elseif($gp_settings['gp_gdsr']->rating >= $theme_score_range_7) {
			$user_score_color = ' style="background: '.$theme_user_score_color_4.';"';
		}
		
	}
			
	// Review Post Options
	$gp_settings['review_image_link'] = get_post_meta($post->ID, 'ghostpool_review_image_link', true);
	$gp_settings['review_image_links_to'] = get_post_meta($post->ID, 'ghostpool_review_image_links_to', true);
	
	// Review Container Widths
	$gp_settings['review_left_width'] = $gp_settings['image_width'] + 2;
	$gp_settings['review_right_width'] = $gp_settings['content_width'] - $gp_settings['image_width'] - 32;
	
	// Good/Bad Width
	if($gp_settings['gp_gdsr']->review > 0) {
		$gp_settings['good_bad_width'] = $gp_settings['content_width'] - $gp_settings['image_width'] - 182;
	} else {
		$gp_settings['good_bad_width'] = $gp_settings['content_width'] - $gp_settings['image_width'] - 62;
	}
	
	// Review Tab
	if(get_post_meta($post->ID, 'ghostpool_link_title_0', true)) {
		$gp_settings['review_tab'] = get_post_meta($post->ID, 'ghostpool_link_title_0', true);
	} else {
		$gp_settings['review_tab'] = __('Review', 'gp_lang');
	}
		
	// Review Meta						
	$gp_settings['meta_date'] = $theme_review_date;
	$gp_settings['meta_author'] = $theme_review_author;
	$gp_settings['meta_cats'] = $theme_review_cats;
	$gp_settings['meta_tags'] = $theme_review_tags;
	$gp_settings['meta_comments'] = $theme_review_comments;
	$gp_settings['meta_share_link'] = $theme_review_share_link;
	$gp_settings['meta_tags'] = $theme_review_tags;
		
	// Author Info Panel
	$gp_settings['author_info'] = $theme_review_author_info;
						
	// Related Items
	$gp_settings['related_items'] = $theme_review_related_items;
	
	
/*************************** Pages, Attachments, 404 etc. ***************************/

} else {

	// Show Image
	if(get_post_meta($post->ID, 'ghostpool_show_image', true) && get_post_meta($post->ID, 'ghostpool_show_image', true) != "Default") {
		$gp_settings['show_image'] = get_post_meta($post->ID, 'ghostpool_show_image', true);
	} else {
		$gp_settings['show_image'] = $theme_show_page_image;
	}
	
	// Image Dimensions
	if(get_post_meta($post->ID, 'ghostpool_image_width', true) && get_post_meta($post->ID, 'ghostpool_image_width', true)) {
		$gp_settings['image_width'] = get_post_meta($post->ID, 'ghostpool_image_width', true);
	} else {
		$gp_settings['image_width'] = $theme_page_image_width;
	}
	if(get_post_meta($post->ID, 'ghostpool_image_height', true) && get_post_meta($post->ID, 'ghostpool_image_height', true)) {
		$gp_settings['image_height'] = get_post_meta($post->ID, 'ghostpool_image_height', true);
	} else {
		$gp_settings['image_height'] = $theme_page_image_height;
	}
	
	// Image Wrap
	if(get_post_meta($post->ID, 'ghostpool_image_wrap', true) && get_post_meta($post->ID, 'ghostpool_image_wrap', true) != "Default") {
		$gp_settings['image_wrap'] = get_post_meta($post->ID, 'ghostpool_image_wrap', true);
	} else {
		$gp_settings['image_wrap'] = $theme_page_image_wrap;
	}
	
	// Layout
	if(get_post_meta($post->ID, 'ghostpool_layout', true) && get_post_meta($post->ID, 'ghostpool_layout', true) != "Default") {
		$gp_settings['layout'] = get_post_meta($post->ID, 'ghostpool_layout', true);
	} else {
		$gp_settings['layout'] = $theme_page_layout;
	}

	// Title
	if(get_post_meta($post->ID, 'ghostpool_title', true) && get_post_meta($post->ID, 'ghostpool_title', true) != "Default") {
		$gp_settings['title'] = get_post_meta($post->ID, 'ghostpool_title', true);
	} else {
		$gp_settings['title'] = $theme_page_title;
	} 
	
	// Page Meta						
	$gp_settings['meta_date'] = $theme_page_date;
	$gp_settings['meta_author'] = $theme_page_author;
	$gp_settings['meta_comments'] = $theme_page_comments;
	$gp_settings['meta_share_link'] = $theme_page_share_link;
			
	// Author Info Panel
	$gp_settings['author_info'] = $theme_page_author_info;
	
}

?>