<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php include_once("_globalViewers.php") ?>
<?php
  
// submit form
if (@$_REQUEST['submit']) {

  // error checking
  $alertsAndErrors = "";
  if (!@$_REQUEST['a'])    { $alertsAndErrors .= "Please specify Question - NB Need to set mandatory fields!<br/>\n"; }

  // turn off strict mysql error checking for: STRICT_ALL_TABLES
  $mysqlVersion = preg_replace("/[^0-9\.]/", "", mysql_get_server_info());
  $isMySql5     = version_compare($mysqlVersion, '5.0.0', '>=');
  if ($isMySql5) {
    mysql_query("SET SESSION sql_mode = 'NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER'") or die("MySQL Error: " .mysql_error(). "\n");
  }

  // add record
  if (!@$alertsAndErrors) {
    mysql_query("INSERT INTO `{$TABLE_PREFIX}tell_a_friend` SET
		a                      = '".mysql_real_escape_string( $_REQUEST['a'] )."',
		b                      = '".mysql_real_escape_string( $_REQUEST['b'] )."',
		c                      = '".mysql_real_escape_string( $_REQUEST['c'] )."',
		d                      = '".mysql_real_escape_string( $_REQUEST['d'] )."',

                      createdDate      = NOW(),
                      updatedDate      = NOW(),
                      createdByUserNum = '0',
                      updatedByUserNum = '0'")
    or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
    $recordNum = mysql_insert_id();

    // display thanks message and clear form
    $alertsAndErrors = "We've sent you brochure!";

  // PDF VIA EMAIL
 $url = "http://blakemachinery.com.au/2012/brochureEmail.php?num=".mysql_escape(@$_REQUEST['id'])."";
 $data = createPDF_fromUrl($url);
   
sendMessage(array(   
    'from'    => @$_REQUEST['a'],   
    'to'      => @$_REQUEST['b'],   
    'subject' => @$_REQUEST['c'],   
    'text'    => @$_REQUEST['d'],   
    'attachments' => array( 
      'BMG.pdf'  => $data 
    )   
  ));

  }
}
?>
<!DOCTYPE html>
<html>
<head>	
	<title><?php echo htmlencode($snippetsRecord['title']) ?></title>

<?php include_once("_top.php") ?>
<?php include_once("_categories.php") ?>

<section class="pageContent shadow">
	<div id="main" class="row">
		<div class="third ">
			<h2 class="sectionTitle"><?php echo $detailRecord['type:label'] ?></h2>
	        <!-- Normal Menu -->
			<ul id="sideNav">
		    <?php foreach ($productsRecords as $listRecord): ?>
		      <?php $isSelected = ($listRecord['num'] == $detailRecord['num']); ?>
		      <li<?php if ($isSelected) { print " class='active'"; } ?>><a href="<?php echo htmlencode($listRecord['_link']) ?>">
		      <div class="thumb">
			      <img src="<?php foreach ($listRecord['images'] as $index => $upload): ?><?php echo $upload['thumbUrlPath2'] ?><?php break ?><?php endforeach ?>">
		      </div>
		      <div>
		      <span style="font-weight:600;"><?php echo htmlencode($listRecord['make']) ?> <?php echo htmlencode($listRecord['model']) ?></span><br />
		      Year: <?php echo htmlencode($listRecord['year']) ?><br />
		      Hours: <?php echo htmlencode($listRecord['hours']) ?><br />
		      <span class="priceSm"><?php echo htmlencode($listRecord['total_price_ex_gst']) ?></span> + GST
		      </div>
		      </a></li>
		    <?php endforeach ?>
			<?php if (!$productsRecords): ?>
				<li>No records were found!</li>
			<?php endif ?>
			</ul>
	        <!-- Mobile Menu -->
	        
	        <form id="responsive-menu" action="#" method="post">
	          <select>
	            <option value="">Select item</option>
			    <?php foreach ($productsRecords as $listRecord): ?>
		            <option value="#"><?php echo htmlencode($listRecord['make']) ?> | <?php echo htmlencode($listRecord['model']) ?> | <?php echo htmlencode($listRecord['year']) ?></option>
			    <?php endforeach ?>
	          </select>
	        </form>
		</div>
		<div class="twothird">
		<?php if ($productsRecords): ?>
			<div class="row">

				<div id="rg-gallery" class="rg-gallery">
					<div class="rg-thumbs">
						<!-- Elastislide Carousel Thumbnail Viewer -->
						<div class="es-carousel-wrapper">
							<div class="es-nav">
								<span class="es-nav-prev">Previous</span>
								<span class="es-nav-next">Next</span>
							</div>
							<div class="es-carousel">
								<ul>
									<?php foreach ($detailRecord['images'] as $index => $upload): ?>
									<li><a href="#"><img src="<?php echo $upload['thumbUrlPath2'] ?>" data-large="<?php echo $upload['urlPath'] ?>" alt="<?php echo htmlencode($detailRecord['make']) ?> <?php echo htmlencode($detailRecord['model']) ?>" data-description="caption" /></a></li>
									<?php endforeach ?>
								</ul>
							</div>
						</div>
						<!-- End Elastislide Carousel Thumbnail Viewer -->
					</div><!-- rg-thumbs -->
				</div><!-- rg-gallery -->

		<script type="text/javascript" src="ResponsiveImageGallery/js/jquery.tmpl.min.js"></script>
		<script type="text/javascript" src="ResponsiveImageGallery/js/jquery.easing.1.3.js"></script>
		<script type="text/javascript" src="ResponsiveImageGallery/js/jquery.elastislide.js"></script>
		<script type="text/javascript" src="ResponsiveImageGallery/js/gallery.js"></script>

			</div>
			<div class="row">
				<div class="third leftPad">
					<h1><?php echo $detailRecord['make'] ?> | <?php echo htmlencode($detailRecord['model']) ?></h1>
					<p><span class="price"><?php echo $detailRecord['total_price_ex_gst'] ?></span><span> + GST</span></p>

					<?php foreach ($contact_personRecord['photo'] as $index => $upload): ?>
					<img src="<?php echo $upload['urlPath'] ?>" alt="<?php echo ($contact_personRecord['title']) ?> <?php echo ($contact_personRecord['surname']) ?>" class="headShot">
					<?php endforeach ?>
					
					<p class="leadIn">For inquiries contact:</p>
					<h4><?php echo ($contact_personRecord['title']) ?> <?php echo ($contact_personRecord['surname']) ?></h4>
					<p><?php echo ($contact_personRecord['position']) ?><br />
					m <?php echo ($contact_personRecord['mobile']) ?><br />
					Email <a href="mailto:<?php echo ($contact_personRecord['email']) ?>"><?php echo ($contact_personRecord['title']) ?></a></p>

					<p><a href="/productBrochure.php?num=<?php echo $productsRecord['num'] ?>" class="button embossed-link fullWidth">PRINT BROCHURE</a></p>

                         <div id="tellfriend" class="blackBack">
                            <form id='tellafriend_form' method="post" action="">
                            <input type="hidden" name="submit" value="1" />
                            <input type="hidden" name="id" value="<?php echo $detailRecord['num'] ?>" />
								<?php if (@$alertsAndErrors): ?>
									<div style="color: red; font-weight: bold; font-size: 16px; font-family: arial;"><br/>
									<?php echo $alertsAndErrors; ?><br/><br/>
									</div>
                                <?php endif ?>
                            <p>
                            <input type="text" name="a" id="a" value="<?php echo htmlspecialchars(@$_REQUEST['a']) ?>" placeholder="Your email..."/>
                            </p>
                        
                            <p>
                            <input type="text" name="b" id="b" value="<?php echo htmlspecialchars(@$_REQUEST['b']) ?>" placeholder="Recipient email..."/>
                            </p>
                        
                            <p>
                            <input type="text" name="c" id="c" value="<?php echo htmlspecialchars(@$_REQUEST['c']) ?>" placeholder="Email subject..."/>
                            </p>
                        
                            <p>
                            <input type="text" name="d" id="d" value="<?php echo htmlspecialchars(@$_REQUEST['d']) ?>" placeholder="Your message..."/>
                            </p>
                        
                             <input type="submit" name="add" value="EMAIL BROCHURE" class="button embossed-link"/>
                           </form> 
                         </div>

					
					
				</div>
				<div class="detail">
					<table class="width-100 hovered">
						<tbody>
							<tr><td>Stock Number:</td><td><?php echo htmlencode($detailRecord['stock_number']) ?></td><td>
							<tr><td>Year:</td><td><?php echo htmlencode($detailRecord['year']) ?></td><td>
							<tr><td>Serial No.:</td><td><?php echo htmlencode($detailRecord['serial_no']) ?></td><td>
							<tr><td>Engine No.:</td><td><?php echo htmlencode($detailRecord['engine_no']) ?></td><td>
							<tr><td>Hours:</td><td><?php echo htmlencode($detailRecord['hours']) ?></td><td>
							<tr><td>Engine Type:</td><td><?php echo htmlencode($detailRecord['engine']) ?></td><td>
							<tr><td>Transmission Type:</td><td><?php echo htmlencode($detailRecord['transmission']) ?></td><td>
							<tr><td>Steer Tyre Condition:</td><td><?php echo htmlencode($detailRecord['steer_tyre_condition']) ?></td><td>
							<tr><td>First Drive Tyre Condition:</td><td><?php echo htmlencode($detailRecord['first_drive_tyre_condition']) ?></td><td>
							<tr><td>Second Drive Tyre Condition:</td><td><?php echo htmlencode($detailRecord['second_drive_tyre_condition']) ?></td><td>
							<tr><td>Tyre Size:</td><td><?php echo htmlencode($detailRecord['tyre_size']) ?></td><td>
							<tr><td>Undercarriage Condition:</td><td><?php echo htmlencode($detailRecord['undercarriage']) ?></td><td>
							<tr><td>Cabin:</td><td><?php echo htmlencode($detailRecord['cabin']) ?></td><td>
							<tr><td>Paint:</td><td><?php echo htmlencode($detailRecord['paint']) ?></td><td>
							<tr><td>Machine Features:</td><td><?php echo $detailRecord['machine_features']; ?></td><td>
							<tr><td>Comments:</td><td><?php echo htmlencode($detailRecord['comments']) ?></td><td>
      						</tbody>	
					</table>
				</div>
			</div>
		<?php endif ?>
    	</div>
	</div>
</section>

<?php include_once("_bottom.php") ?>