<?php
include_once('includes.php');
include_once('displayUtils.php');
/*
if(!isset($dealerInfo[$_SESSION['tradeup']['selectedDealer']]))
{
$_SESSION['tradeup']['selectedDealer'] = 'abc';
$_SESSION['selectedDealer'] = 'abc';
header("location: index.php");
exit;
}
*/
$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($_POST['years']))
{
//unset($_SESSION['tradeup']);
foreach($_POST as $key => $val) $_SESSION['tradeup'][$key] = $val;
//$_SESSION['tradeup']['selectedDealer'] = $_SESSION['selectedDealer'];
$xml = simplexml_load_file($bbLink . 'kilometers=' . ereg_replace("[^0-9]", "", $_SESSION['tradeup']['kilometers']) . '&year=' . $_SESSION['tradeup']['years'] . '&make=' . urlencode($_SESSION['tradeup']['makes']) . '&model=' . urlencode($_SESSION['tradeup']['models']) . '&trim=' . urlencode($_SESSION['tradeup']['trims']) . '&style=' . urlencode($_SESSION['tradeup']['styles']) . '&command=priceVehicle');
$list = $xml->response->vehicles->vehicle->values;
$_SESSION['tradeup']['values'] = get_object_vars ($list);
header("location: info.php");
exit;
}
if(isset($_POST['date']) || isset($_POST['isEmail']) || isset($_POST['isSMS']))
{
//unset($_SESSION['tradeup']);
foreach($_POST as $key => $val) $_SESSION['tradeup'][$key] = $val;
header("location: info.php");
exit;
}
?>
<?php include_once('header.php'); ?>
<script src="scripts/ajax.js" language="javascript"></script>
<script>
function getList(val)
{
year = '';
make = '';
model = '';
trim = '';
styleVal = '';
if(document.getElementById('years') != undefined) year=document.getElementById('years').value;
if(document.getElementById('makes') != undefined) make=document.getElementById('makes').value;
if(document.getElementById('models') != undefined) model=document.getElementById('models').value;
if(document.getElementById('trims') != undefined) trim=document.getElementById('trims').value;
if(document.getElementById('styles') != undefined) styleVal=document.getElementById('styles').value;
htmlStr = 'index.php?getList=' + val + '&year=' + year.replace(/&/,"%26") + '&make=' + make.replace(/&/,"%26") + '&model=' + model.replace(/&/,"%26") + '&trim=' + trim.replace(/&/,"%26") + '&style=' + styleVal.replace(/&/,"%26");
//htmlStr = 'index.php?getList=' + val + '&year=' + year + '&make=' + make + '&model=' + model + '&trim=' + trim + '&style=' + styleVal;
//alert(htmlStr);
ajax_do(htmlStr);
}
function checkForm()
{
if(document.getElementById('kilometers').value == "")
{
alert('Please tell us the kilometers of your trade in.');
return false;
}
else if((document.getElementById('styles') == undefined || document.getElementById('styles').value == ""))
{
alert('Please tell us information about your current vehicle.');
return false;
}
else
{
return true;
}
}
</script>
<style>
.formTbl td {padding-bottom:2px;height:20px}
.formTbl td input {width:160px}
</style>
<table cellspacing="0" cellpadding="0" style="width:100%">
<tr>
<td style="background-color:white;border:1px solid #707070">
<table cellspacing="0" cellpadding="0" style="width:100%;padding:10px;padding-left:0px;text-align:left;">
<tr>
<td></td>
<td style="height:80px;vertical-align:middle">
<font style="font-size:22pt;font-weight:bold;color:#636363;">Find your next vehicle now...</font>
</td>
</tr>
<tr>
<td style="height:50px;vertical-align:middle;padding-right:15px"><img src="images/pointer.jpg"></td>
<td>
<form method="POST" onSubmit="return checkForm()">
<table cellspacing="0" cellpadding="0" style="width:100%">
<tr>
<td>
<font style="color:#777">Find out what <b>Canadian Black Book</b> says your trade is worth.</font>
<br>
<div style="background-color:#efefef;padding:15px;padding-bottom:0px;border:1px solid #ccc;width:540px">
<table cellspacing="0" cellpadding="0" class="formTbl" style="width:100%">
<tr>
<td style="width:50%">
<table cellspacing="0" cellpadding="0" class="formTbl" style="width:100%">
<tr>
<td style="width:60px;font-weight:bold;color:#465681;">Year</td>
<td style=""><div id="yearsDiv" style="display:inline"></div></td>
</tr>
<tr>
<td style="font-weight:bold;color:#465681;">Make</td>
<td><div id="makesDiv" style="display:inline"></div></td>
</tr>
<tr>
<td style="font-weight:bold;color:#465681;">Model</td>
<td><div id="modelsDiv" style="display:inline"></div></td>
</tr>
</table>
</td>
<td>
<table cellspacing="0" cellpadding="0" class="formTbl" style="width:100%">
<tr>
<td style="font-weight:bold;color:#465681;">Trim</td>
<td><div id="trimsDiv" style="display:inline"></div></td>
</tr>
<tr>
<td style="font-weight:bold;color:#465681;">Style</td>
<td><div id="stylesDiv" style="display:inline"></div></td>
</tr>
<tr>
<td style="font-weight:bold;color:#465681;">KM</td>
<td><input type="text" style="width:100px" id="kilometers" name="kilometers" value="<?= $_SESSION['tradeup']['kilometers'] ?>" onkeypress="return onlyNumbers(event);"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" style="padding-top:10px"><img src="images/blackbooklogo.jpg"></td>
</tr>
</table>
</div>
</td>
<td style="vertical-align:middle">
<center>
<input type="image" src="images/submit.png">
</center>
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2" style="padding:20px 40px">
<div style="border-bottom:1px solid #aaa;height:1px"></div>
</td>
</tr>
<tr>
<td style="height:50px;vertical-align:middle;padding-right:15px"><img src="images/pointer.jpg"></td>
<td>
<form method="POST">
<table cellspacing="0" cellpadding="0" style="width:100%">
<tr>
<td>
<font style="color:#777">Take a no obligation test drive to find the vehicle and model you like best.</font>
<br>
<div style="background-color:#efefef;padding:15px;border:1px solid #ccc;width:540px">
<table cellspacing="0" cellpadding="0" class="formTbl" style="width:100%">
<tr>
<td>
<table cellspacing="0" cellpadding="0" class="formTbl">
<tr>
<td style="padding-right:10px;vertical-align:middle">
<font style="font-size:16pt;color:#e31636;font-weight:bold">VIEW OVER 300 NEW & USED VEHICLES!</font>
<br><br>
<table cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" style="font-size:9pt">
<b><i>Which day is most convenient for you?</b></i>
</td>
<td style="padding-left:30px;padding-right:10px;vertical-align:middle;font-size:18pt;color:#465681;font-weight:bold">JAN</td>
<td style=";vertical-align:middle">
<select name="date" style="font-size:15pt">
<option></option>
<?php for($i = 25;$i<= 31;$i++) { ?>
<option value="<?= $i ?>" <?= ($_SESSION['tradeup']['date'] == $i ? 'SELECTED' : '') ?>><?= $i ?></option>
<?php } ?>
</select>
</td>
<td style="padding-left:10px;font-size:18pt;color:#465681;font-weight:bold;vertical-align:middle">2013</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
<td style="vertical-align:middle">
<center>
<input type="image" src="images/submit.png">
</center>
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2" style="padding:20px 40px">
<div style="border-bottom:1px solid #aaa;height:1px"></div>
</td>
</tr>
<tr>
<td style="height:50px;vertical-align:middle;padding-right:15px"><img src="images/pointer.jpg"></td>
<td>
<form method="POST">
<input type="hidden" name="isEmail" value="on">
<table cellspacing="0" cellpadding="0" style="width:100%">
<tr>
<td>
<font style="color:#777">Discover ALL available Rebates and Dealer Discounts to get a fair price.</font>
<br>
<div style="background-color:#efefef;padding:15px;border:1px solid #ccc;width:540px">
<!--
<table cellspacing="0" cellpadding="0" class="formTbl">
<tr>
<td style="padding-right:20px">How do you like to receive your discounts?</td>
<td style="padding-right:10px;font-size:18pt;color:#465681;font-weight:bold">EMAIL</td>
<td style="vertical-align:middle"><input type="checkbox" name="isEmail" style="width:20px" <?= ($_SESSION['tradeup']['isEmail'] == 'on' ? 'CHECKED' : '') ?>></td>
</tr>
<tr>
<td></td>
<td style="padding-right:10px;font-size:18pt;color:#465681;font-weight:bold">SMS</td>
<td style="vertical-align:middle"><input type="checkbox" name="isSMS" style="width:20px" <?= ($_SESSION['tradeup']['isEmail'] == 'on' ? 'CHECKED' : '') ?>></td>
</tr>
</table>
-->
<table cellspacing="0" cellpadding="0" class="formTbl">
<tr>
<td><img src="images/senators.png"></td>
<td style="padding-left:10px;padding-right:50px;vertical-align:middle" nowrap>
<font style="font-size:20pt"><b>ENTER TO WIN</b></font>
<br><font style="font-size:16pt;color:#e31636;font-weight:bold">SENATOR TICKETS</font>
<br><font style="font-size:12pt">with every vehicle purchase!</font>
</td>
<td style="padding-right:20px"><b>Receive <?= $dealerInfo[$_SESSION['tradeup']['selectedDealer']]['name'] ?>'s latest offers and discounts in your inbox!</b></td>
</tr>
</table>
</div>
</td>
<td style="vertical-align:middle">
<center>
<input type="image" src="images/submit.png">
</center>
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td colspan="2" style="height:30px">
</td>
</tr>
<tr>
<td colspan="2" style="padding:5px 40px">
<div style="border-bottom:1px solid #aaa;height:1px"></div>
</td>
</tr>
<tr>
<td colspan="2" style="height:30px">
<center>
<style>
.mediaTbl {}
.mediaTbl td {padding:5px;color:#555;font-size:9pt;}
.mediaTbl td a {color:#555;font-size:9pt;}
</style>
<table cellspacing="0" cellpadding="0" class="mediaTbl">
<tr>
<td><a href="https://twitter.com/CapitalDodge" target="_blank">follow on Twitter</a></td>
<td>|</td>
<td><a href="http://www.facebook.com/CapitalDodgeChryslerJeepFiat" target="_blank">friend on Facebook</a></td>
<td>|</td>
<td><a href="share.php">forward to a Friend</a></td>
</tr>
</table>
</center>
</td>
</tr>
<tr>
<td colspan="2" style="padding:5px 40px">
<div style="border-bottom:1px solid #aaa;height:1px"></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
if(!isset($_SESSION['webhit']))
{
$_SESSION['webhit'] = true;
?>
<iframe height="0" width="0" src="http://ar.absoluteresults.com/misc/webHits.php?url=<?= str_replace(array('www.'),'',$_SERVER['HTTP_HOST']); ?>&dealer=<?= $_SESSION['tradeup']['selectedDealer'] ?>&eventID=<?= $dealerInfo[$_SESSION['tradeup']['selectedDealer']]['eventID'] ?>" frameborder="0"></iframe>
<?php
}
?>
<script>
getList('years');
</script>
<?php include_once('footer.php'); ?>