<?php include_once('includes.php'); ?>
<?php
$bbLink = 'http://xml.canadianblackbook.com/XMLWebServices/service?&account=absolute_xml&key=Dgje48Sw39&schemaVersion=3.0&';
$lists = array('years','makes','models','trims','styles');
if(isset($_GET['getList']))
{
$curKey = array_search($_GET['getList'],$lists);
if($_GET['getList'] == 'years')
{
$xml = simplexml_load_file($bbLink . 'command=' . $_GET['getList']);
$list = $xml->response->years->year;
if($list == '') exit;
}
else if($_GET['getList'] == 'makes')
{
$xml = simplexml_load_file($bbLink . 'year=' . $_GET['year'] . '&command=' . $_GET['getList']);
$list = $xml->response->makes->make;
if($list == '') exit;
}
else if($_GET['getList'] == 'models')
{
$xml = simplexml_load_file($bbLink . 'year=' . $_GET['year'] . '&make=' . urlencode($_GET['make']) . '&command=' . $_GET['getList']);
$list = $xml->response->models->model;
if($list == '') exit;
}
else if($_GET['getList'] == 'trims')
{
$xml = simplexml_load_file($bbLink . 'year=' . $_GET['year'] . '&make=' . urlencode($_GET['make']) . '&model=' . urlencode($_GET['model']) . '&command=' . $_GET['getList']);
$list = $xml->response->trims->trim;
}
else if($_GET['getList'] == 'styles')
{
$xml = simplexml_load_file($bbLink . 'year=' . $_GET['year'] . '&make=' . urlencode($_GET['make']) . '&model=' . urlencode($_GET['model']) . '&trim=' . urlencode($_GET['trim']) . '&command=' . $_GET['getList']);
$list = $xml->response->styles->style;
}
$html = '<select id="' . $_GET['getList'] . '" name="' . $_GET['getList'] . '"' . ($curKey < (count($lists)-1) ? ' onChange="getList(\'' . $lists[$curKey+1] . '\')"' : '') . '>';
if(count($list) > 1) $html .= '<option value=""></option>';
if($list == '') $html .= '<option value="">None</option>';
foreach($list as $item)
{
$html .= '<option value="' . $item . '">' . $item . '</option>';
}
$html .= '</select>';
?>
document.getElementById('<?= $_GET['getList'] ?>Div').innerHTML = '<?= ajaxHTML($html) ?>';
<?php
for($i = ($curKey+1); $i < count($lists); $i++)
{
?>
document.getElementById('<?= $lists[$i] ?>Div').innerHTML = '';
<?php
}
if(($curKey < (count($lists)-1)) && count($list) == 1)
{
?>
getList('<?= $lists[$curKey+1]?>');
<?php
}
exit;
}
if(isset($_GET['submitList']))
{
//unset($_SESSION['registration']['customer']);
foreach($_GET as $key => $val)
{
if(in_array($key,array('fullname','email','mobilePhone','postalCode'))) $_SESSION['registration']['customer'][$key] = $val;
else $_SESSION['registration']['tradeIn'][$key] = $val;
}
$xml = simplexml_load_file($bbLink . 'kilometers=' . ereg_replace("[^0-9]", "", $_SESSION['registration']['tradeIn']['kilometers']) . '&year=' . $_SESSION['registration']['tradeIn']['years'] . '&make=' . urlencode($_SESSION['registration']['tradeIn']['makes']) . '&model=' . urlencode($_SESSION['registration']['tradeIn']['models']) . '&trim=' . urlencode($_SESSION['registration']['tradeIn']['trims']) . '&style=' . urlencode($_SESSION['registration']['tradeIn']['styles']) . '&command=priceVehicle');
$list = $xml->response->vehicles->vehicle->values;
$_SESSION['registration']['tradeIn']['values'] = get_object_vars ($list);
?>
document.getElementById('emailFrame').src = 'http://ar.absoluteresults.com/digital2013/appraisalEmail.php?regID=<?= urlencode(serialize($_SESSION['registration'])) ?>';
<?php
exit;
}
if(isset($_GET['complete'])) $_SESSION['offers'][$currentPage]['complete'] = true;
?>
<?php include_once('header.php'); ?>
<script src="scripts/ajax.js" language="javascript"></script>
<script>
function getList(val)
{
htmlStr = 'appraisal.php?getList=' + val;
var arr = new Array('years','makes','models','trims','styles');
var arr2 = new Array('year','make','model','trim','style');
for (var i = 0; i < arr.length; i++)
{
var temp = '';
if(document.getElementById(arr[i]) != undefined) temp=encodeURIComponent(document.getElementById(arr[i]).value);
htmlStr = htmlStr + '&' + arr2[i] + '=' + temp;
}
ajax_do(htmlStr);
}
function submitList()
{
htmlStr = 'appraisal.php?submitList=';
var arrRequired = new Array('fullname','email','postalCode','mobilePhone','years','makes','models','styles','kilometers');
var arr = new Array('fullname','email','postalCode','mobilePhone','years','makes','models','trims','styles','kilometers');
for (var i = 0; i < arrRequired.length; i++)
{
if(document.getElementById(arrRequired[i]).value == "")
{
alert('Please complete all the required fields to see your offer.\nThank you.');
return false;
}
}
for (var i = 0; i < arr.length; i++)
{
var temp = '';
if(document.getElementById(arr[i]) != undefined) temp=encodeURIComponent(document.getElementById(arr[i]).value);
htmlStr = htmlStr + '&' + arr[i] + '=' + temp;
}
document.getElementById('submitButton').value = 'Please wait...';
document.getElementById('submitButton').disabled = true;
ajax_do(htmlStr);
}
function emailSent()
{
if(document.getElementById('emailFrame').src != "")
{
alert('Thank you for your submission.\nPlease check your email for details.');
location.href = 'appraisal.php?complete';
//document.getElementById('submitButton').disabled = false;
//document.getElementById('submitButton').value = 'See Offer';
}
}
</script>
<style>
.formTbl th,.formTbl td {text-align:left;padding-right:10px}
</style>
<table cellspacing="0" cellpadding="0" style="width:100%">
<tr>
<td style="width:530px;padding:20px 0px 0px 40px;font-size:15pt;text-align:left;vertical-align:top">
<?php if(!isset($_GET['complete'])) { ?>
<font style="font-weight:bold;font-size:18pt">Fill out the information below<br>to receive your free Trade-In Appraisal</font>
<br><br>
<form method="POST">
<table cellspacing="0" cellpadding="0" style="width:90%">
<tr>
<td colspan="2">
<table cellspacing="0" cellpadding="0" class="formTbl">
<tr>
<th>First & Last Name</th>
<td><input type="text" style="width:200px" id="fullname" name="fullname" value="<?= $_SESSION['registration']['customer']['fullname'] ?>"></td>
</tr>
<tr>
<th>Email</th>
<td><input type="text" style="width:200px" id="email" name="email" value="<?= $_SESSION['registration']['customer']['email'] ?>"></td>
</tr>
<tr>
<th>Mobile Phone</th>
<td><input type="text" style="width:200px" id="mobilePhone" name="mobilePhone" value="<?= $_SESSION['registration']['customer']['mobilePhone'] ?>"></td>
</tr>
<tr>
<th>Postal Code</th>
<td><input type="text" style="width:200px" id="postalCode" name="postalCode" value="<?= $_SESSION['registration']['customer']['postalCode'] ?>"></td>
</tr>
<tr><td colspan="2" style="height:20px"></td></tr>
</table>
</td>
</tr>
<tr>
<td style="width:250px">
<table cellspacing="0" cellpadding="0" class="formTbl">
<tr>
<th>Year</th>
<td style=""><div id="yearsDiv" style="display:inline"></div></td>
</tr>
<tr>
<th>Make</th>
<td><div id="makesDiv" style="display:inline"></div></td>
</tr>
<tr>
<th>Model</th>
<td><div id="modelsDiv" style="display:inline"></div></td>
</tr>
</table>
</td>
<td>
<table cellspacing="0" cellpadding="0" class="formTbl">
<tr>
<th>Trim</th>
<td><div id="trimsDiv" style="display:inline"></div></td>
</tr>
<tr>
<th>Style</th>
<td><div id="stylesDiv" style="display:inline"></div></td>
</tr>
<tr>
<th>KM</th>
<td><input type="text" style="width:100px" id="kilometers" name="kilometers" value="<?= $_SESSION['registration']['tradeIn']['kilometers'] ?>"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" style="padding-top:10px">
<input type="button" id="submitButton" value="Email my Trade-in Value" onClick="submitList()" style="font-weight:bold;font-size:16pt;background-color:#efd23b;width:330px">
</td>
</tr>
</table>
<br>
</form>
<script>
getList('years');
</script>
<?php } else { ?>
<font style="font-weight:bold;font-size:25pt">
Thank You.
</font>
<br>
<br>
<font style="font-weight:bold;font-size:18pt">
The trade-In value of your vehicle has been emailed to you.
</font>
<br><br>
<?php if($nextOffer != "") { ?>
<div style="font-size:12pt"><i>Want another offer?</i></div>
<a href="<?= $nextOffer ?>.php"><img src="images/<?= $nextOffer ?>Button.png" border="0"></a>
<?php } ?>
<?php } ?>
</td>
<td style="color:white;padding-top:50px;text-align:left;font-size:15pt;vertical-align:top">
Right now we are offering top-dollar for all
trade-in vehicles. Your current car, truck or
SUV might be worth thousands more than
you think! Fill out the form on the left to
get the Canadian Black Book value on your
trade-in!
<br><br>
<div style="width:400px;text-align:right;font-size:9pt">* Subject to physical inspection</div>
<img src="images/<?= $currentPage ?>Image.png">
</td>
</tr>
</table>
<iframe id="emailFrame" height="0" width="0" frameborder="0" onload="emailSent()"></iframe>
<?php include_once('footer.php'); ?>