<?php
/*
Template Name: Custom Template
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' - '; } ?><?php bloginfo('name'); ?></title>
<link href="<?php bloginfo('template_directory'); ?>/ctstyles.php" rel="stylesheet" type="text/css" />
<?php if (get_post_meta($post->ID, 'pagestyle', true)) { $sp = get_post_meta($post->ID, 'pagestyle', true); ?>
<style type="text/css">
#bg { 
background: url(<?php echo bloginfo('template_url'); ?>/images/page-elements/sales-<?php echo $sp; ?>-bg.png) repeat-x top center;
<?php if($sp == '1') { ?> background-color:#444;
<?php } else if ($sp == '2') { ?> background-color:#000;
<?php } else if ($sp == '3') { ?> background-color:#d4d4d4;
<?php } else if ($sp == '4') { ?> background-color:#f2f2f2;
<?php } else if ($sp == '5') { ?> background-color:#DDD;
<?php } else if ($sp == '6') { ?> background-color:#6C788C;
<?php } else if ($sp == '7') { ?> background-color:#40525B;
<?php } else if ($sp == '8') { ?> background-color:#35464F;
<?php } else if ($sp == '9' || $sp == '10') { ?> background-color:#333;
<?php } ?>}
#header { 
background: url(<?php echo bloginfo('template_url'); ?>/images/page-elements/sales-<?php echo $sp; ?>-top.png) no-repeat top center;
<?php if($sp == '1') { ?> height: 43px;
<?php } else if ($sp == '2' || $sp == '3') { ?> height: 58px;
<?php } else if($sp == '4' || $sp == '5') { ?> height: 36px;
<?php } else if($sp == '6' || $sp == '7') { ?> height: 135px;
<?php } else if($sp == '8') { ?> height: 152px;
<?php } else if($sp == '9') { ?> height: 122px;
<?php } else if($sp == '10') { ?> height: 90px;
<?php } ?>
}
#content { background: url(<?php echo bloginfo('template_url'); ?>/images/page-elements/sales-<?php echo $sp; ?>-fill.png) repeat-y top center;}
#footer { background: url(<?php echo bloginfo('template_url'); ?>/images/page-elements/sales-<?php echo $sp; ?>-footer.png) no-repeat top center;
padding-top:40px;
height: 100px;
}
#footer, #footer a {
<?php if($sp == '1' || $sp == '3' || $sp == '6' || $sp == '7' || $sp == '8' || $sp == '9' || $sp == '10') { ?> color: #fff;
<?php } else if ($sp == '2') { ?> color: #ff9900;
<?php } else if($sp == '4') { ?> color: #999;
<?php } ?>
}
</style>
<?php } ?>
<?php if (get_post_meta($post->ID, 'header', true)) { ?>
<style type="text/css">
#bg { 
<?php if (get_post_meta($post->ID, 'background', true)) { ?>
background: url(<?php echo get_post_meta($post->ID, 'background', true);?>) repeat-x top center;
<?php } ?>
<?php if (get_post_meta($post->ID, 'backgroundcolor', true)) { ?>
background-color: #<?php echo get_post_meta($post->ID, 'backgroundcolor', true);?>;
<?php } ?>
}
#content { background: url(<?php echo get_post_meta($post->ID, 'fill', true);?>) repeat-y top center;}
#header { 
background: url(<?php echo get_post_meta($post->ID, 'header', true);?>) no-repeat top center;
height: <?php echo get_post_meta($post->ID, 'headerheight', true); ?>px;
}
#footer { 
background: url(<?php echo get_post_meta($post->ID, 'footer', true);?>) no-repeat top center;
height: <?php echo get_post_meta($post->ID, 'footerheight', true); ?>px;
padding-top:40px;
}
</style>
<?php } ?>
<?php wp_head(); ?>
<link rel="shortcut icon" href="<?php if (get_option('flex_favicon')) { echo get_option('flex_favicon'); } else { echo bloginfo('template_url') . '/favicon.ico'; } ?>" type="image/x-icon" />
<script type='text/javascript' src='<?php echo bloginfo('template_url'); ?>/js/jquery-ui-1.8/js/jquery-ui-1.8.min.js'></script>

<!--[if lte IE 6]>
  <script>
  DD_belatedPNG.fix('div');
</script>
  <![endif]-->
</head>
<body>
<div id="wrapper">

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content();?>
<?php endwhile;?>
<?php endif; ?>
<?php wp_footer(); ?>
</div>
<?php if (get_option('flex_analytics_id')) { ?>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("<?php echo get_option('flex_analytics_id'); ?>");
pageTracker._trackPageview();
} catch(err) {}
</script>

<?php } ?>
<script type="text/javascript">
// stop = false;
// function tidy() {
// if(jQuery(document).height() > jQuery('#bg').height() && stop == false) {
// jQuery('#bg').height( jQuery(document).height() );
// }
// stop = true;
// setTimeout('stop = false', 100);
// }
// tidy();
// jQuery(window).resize( tidy );
</script>

</body>
</html>