<?php 
/**
 * 	Template Name: Model Page Template
 *	@description: this file handles the request to template services
 *
 */
get_header(); // including the page header ?>
<?php //get_sidebar("left"); ?>
<div id="main" role="main">
<?php 
		/* Gets the content of the page */
		if ( have_posts() ) : while ( have_posts() ) : the_post(); 
			global $post,$wpdb,$prefix;
			//if (has_post_thumbnail( $post->ID ) ): // check if thumbnail exists
			//	$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
          	//	echo $image[0];
          	//endif; ?>
         <?php 
		 
		 $postMetaFields = get_post_custom($post->ID);
			// $meta = get_post_meta( get_the_ID() );
		 ?>	
	<div id="banner">
		<h1><?php echo $postMetaFields["{$prefix}model_title"][0]; ?></h1>
  	</div>
  <div class="partOverview">
  	<div class="partImgBig float_left">
	<img src="<?php 
				$modelImage = wp_get_attachment_image_src($postMetaFields["{$prefix}model_image"][0],"medium");
				echo $modelImage[0]; 
	?>" alt="<?php the_title();?>"/></div>
  	<div class="partInfor float_left">
		<table cellspacing="0" cellpadding="0">
		  <tr>
			<td class="align-right"><strong>Car Make :</strong></td>
			<td><?php echo $postMetaFields["{$prefix}car_make"][0]; ?></td>
		  </tr>
		  <tr>
			<td class="align-right"><strong>Car Model :</strong></td>
			<td><?php echo $postMetaFields["{$prefix}car_model"][0]; ?></td>
		  </tr>
		  <?php if(!empty($postMetaFields["{$prefix}car_series"][0])):?>
		  <tr>
			<td class="align-right"><strong>Series :</strong></td>
			<td><?php echo $postMetaFields["{$prefix}car_series"][0]; ?></td>
		  </tr>
		  <?php endif;?>
		  <tr>
			<td class="align-right"><strong>Car Year :</strong></td>
			<td><?php echo $postMetaFields["{$prefix}car_year"][0]; ?></td>
		  </tr>
		  <tr>
			<td class="align-right"><strong>Engine Size / Code :</strong></td>
			<td><?php echo $postMetaFields["{$prefix}car_engine"][0]; ?></td>
		  </tr>
		</table>
  </div>
  <div class="clear"></div>
 </div>
 <?php
 		if($postMetaFields["{$prefix}show_request_form"][0]){
			if(function_exists("nmw_requestpartform")){
				echo nmw_requestpartform();
				?>
				<script>
				jQuery(document).ready(function(){
					jQuery("#drpMake").val("<?php echo strtoupper($postMetaFields["{$prefix}car_make"][0]); ?>");
					jQuery("#drpMake").trigger("change");
					jQuery("#drpModel").val("<?php echo ($postMetaFields["{$prefix}car_model"][0]); ?>");
				});
				</script>
				<?php
			}
		}
 ?>
 <div class="partDetail">
	<div class="partHeader">Overview</div>
	<div class="partDetailInfo">
		<?php the_content(); ?>
	</div>
  </div>
  	<?php echo $postMetaFields["{$prefix}model_overview"][0]; ?>
	<br class="clear"/>
	<?php get_template_part( 'footer', 'links' ); ?>
<?php endwhile; endif; ?>		
</div>
<?php get_footer();
// including the footer