<?php /* Smarty version Smarty-3.1.8, created on 2020-12-10 18:50:53
         compiled from "/home/agmc/beta/application/core/views/frontend/mini/FinanceCalculator.tpl" */ ?>
<?php /*%%SmartyHeaderCode:7907527455e44cc5a196f40-95530040%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '1040c75ac05b0ce668a24afe8b0caafd7c8e6892' => 
    array (
      0 => '/home/agmc/beta/application/core/views/frontend/mini/FinanceCalculator.tpl',
      1 => 1605520856,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '7907527455e44cc5a196f40-95530040',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.8',
  'unifunc' => 'content_5e44cc5a1fc973_16526066',
  'variables' => 
  array (
    'SelCurrLanguage' => 0,
    'languageDirection' => 0,
    'commonMetaTitle' => 0,
    'language' => 0,
    'commonMetaDescription' => 0,
    'resBrandCategories' => 0,
    'downPaymentPercentage' => 0,
    'currencySymbol' => 0,
    'finance_term' => 0,
    'processingFeesPercentage' => 0,
    'view_public_path' => 0,
  ),
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_5e44cc5a1fc973_16526066')) {function content_5e44cc5a1fc973_16526066($_smarty_tpl) {?><!DOCTYPE html>
<html lang="<?php echo $_smarty_tpl->tpl_vars['SelCurrLanguage']->value;?>
" dir="<?php echo $_smarty_tpl->tpl_vars['languageDirection']->value;?>
">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title><?php if ($_smarty_tpl->tpl_vars['commonMetaTitle']->value){?><?php echo $_smarty_tpl->tpl_vars['commonMetaTitle']->value;?>
<?php }else{ ?><?php echo $_smarty_tpl->tpl_vars['language']->value['lblFinanceCalculator'];?>
<?php }?></title>
<meta name="Description" content="<?php echo $_smarty_tpl->tpl_vars['commonMetaDescription']->value;?>
" />
<meta name="viewport" content="width=device-width">
<?php echo $_smarty_tpl->getSubTemplate ('CommonJavaScript.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0); ?>

<?php echo $_smarty_tpl->getSubTemplate ('CommonStyles.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0); ?>


<?php echo $_smarty_tpl->smarty->registered_objects['form'][0]->rootpath_script(array(),$_smarty_tpl);?>

<?php echo $_smarty_tpl->smarty->registered_objects['form'][0]->basepath_script(array(),$_smarty_tpl);?>


</head>
<body ng-controller="SearchCtrl" class="<?php echo $_smarty_tpl->tpl_vars['languageDirection']->value;?>
">
<!-- Begin : Outer Pane -->
<div id="main"> 
  <!-- Begin : Header Pane--> 
  <?php echo $_smarty_tpl->getSubTemplate ('CommonTop.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0); ?>
 
  <!-- End : Header -->
  <div id="content-wrapper" ng-show="!query" >
    <div class="wrapper clearfix">
      <div id="common_message"></div>
      <div id="common_message_forgot" ></div>
      <div id="invalid_email"></div>
      <div class="full-width-div clearfix">
       <!--  <h2><?php echo $_smarty_tpl->tpl_vars['language']->value['lblFinanceCalculator'];?>
</h2> -->

        </div>
      </div>


    <div id="finance-calculator-blk">
      <div class="container pt-4 pb-5">
        <div class="row mt-3">
          <div class="col-lg-12 col-md-12 col-sm-12">
            <h1 class="h4 font-weight-bold"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblFinanceCalculator'];?>
</h1>
            <p class="font-family-primary mb-lg-5 mb-4"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblFinanceInTwoStepsMini'];?>
</p>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-12">
            <div class="finance-calculator-box form-blk col-md-7 col-12 p-0">
              <h6 class="font-weight-bold f15 mb-4"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblStepOneSelectMini'];?>
</h6>
              <div class="col-12 p-0 mb-4">
                <label class="font-normal text-secondary mb-1 font-weight-bold"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblModel'];?>
</label>
				<?php echo $_smarty_tpl->smarty->registered_objects['form'][0]->select(array('name'=>"series",'caption'=>"->".($_smarty_tpl->tpl_vars['language']->value['lblSelect']),'class'=>"form-control",'options'=>$_smarty_tpl->tpl_vars['resBrandCategories']->value),$_smarty_tpl);?>
 
              </div>
              <div class="col-12 p-0 mb-4">
                <label class="font-normal text-secondary mb-1 font-weight-bold"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblShortDescription'];?>
</label>
				<?php echo $_smarty_tpl->smarty->registered_objects['form'][0]->select(array('name'=>"shortDesc",'caption'=>"->".($_smarty_tpl->tpl_vars['language']->value['lblSelect']),'class'=>"form-control"),$_smarty_tpl);?>
 
              </div>
              <div class="col-12 p-0 mb-4">
                <label class="font-normal text-secondary mb-1 font-weight-bold"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblVariant'];?>
</label>
				<?php echo $_smarty_tpl->smarty->registered_objects['form'][0]->select(array('name'=>"variant",'caption'=>"->".($_smarty_tpl->tpl_vars['language']->value['lblSelect']),'class'=>"form-control"),$_smarty_tpl);?>
 
              </div>
              <div class="col-12 p-0 mb-4">
                <img id="vehicleImage" src="" class="img-fluid"/>
                <h6 id="productTitle" class="text-secondary font-weight-bold mt-0 mb-3"></h6>
                <div id="regularPriceText" class="text-secondary font-weight-bold mt-0"></div>
                <div id="regularPrice" class="text-secondary font-weight-bold mt-0 mb-3 h4"></div>
               
              </div>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-12">
          <h6 class="font-weight-bold f15 mb-4"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblStepTwoSelectDownpayAndTerm'];?>
</h6>
          <div class="finance-calculator-box form-blk col-md-9 col-12 p-0">
              <div class="col-12 p-0 mb-4">
                <label class="font-normal text-secondary mb-0 font-weight-bold"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblDownpayment'];?>
 (<span id="downpaymentval"><?php echo $_smarty_tpl->tpl_vars['downPaymentPercentage']->value;?>
</span>%) </label>
                <div class="row align-items-center">
                  <div class="col-sm-8 col-12" dir="ltr">
                    <div id="donwpaymentrangeslider" class="mb-3 mt-4"></div>
                    <div class="d-flex justify-content-between font-xsmall text-muted">
                      <span><?php echo $_smarty_tpl->tpl_vars['downPaymentPercentage']->value;?>
%</span>
                      <span>80%</span>
                    </div>
					
                  </div>
                  <div class="col-sm-4 col-12" dir="ltr">
                    <div id="donwpaymentamount" class="h6 font-weight-bold m-0">0</div>
                    <span class="font-xsmall text-muted"> <?php echo $_smarty_tpl->tpl_vars['currencySymbol']->value;?>
</span>
                  </div>
                </div>
              </div>
              <div class="col-12 p-0 mb-4" >
                <label class="font-normal text-secondary mb-0 font-weight-bold"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblTerm'];?>
</label>
                <div class="row align-items-center">
                  <div class="col-sm-8 col-12" dir="ltr">
                    <div id="termrangeslider" class="mb-3 mt-4"></div>
                    <div class="d-flex justify-content-between font-xsmall text-muted">
                      <span>12</span>
                      <span><?php echo $_smarty_tpl->tpl_vars['finance_term']->value;?>
</span>
                    </div>
                  </div>
                  <div class="col-sm-4 col-12">
                    <div id="termlength" class="h6 font-weight-bold m-0"></div>
                    <span class="font-xsmall text-muted"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblMonths'];?>
</span>
                  </div>
                </div>
              </div>
              <div class="col-sm-8 col-12 p-0 mb-4">
                <label class="font-normal text-secondary mb-1 font-weight-bold"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblFinanceRate'];?>
 <span class="font-normal font-weight-normal">*</span></label>
                <input type="text" class="form-control"  id="finRate"  readonly="readonly"/>
              </div>
              <div class="col-12 p-3 mb-lg-5 mb-4 bg-light">
                <p class="font-family-primary text-secondary mb-0"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblMonthlyPayment'];?>
</p>
                <h5 class="text-secondary font-weight-bold mb-4" id="monthlyPayment"></h5>
                <p class="font-family-primary font-base text-secondary font-weight-bold mt-2 mb-3"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblSpecialOffer'];?>
</p>
				<p id="detailedDesc"></p>
                <p class="font-family-primary text-secondary"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblSpecialOfferText'];?>
 <?php echo $_smarty_tpl->smarty->registered_objects['html'][0]->anchor(array('href'=>"/contact.html",'class'=>"text-primary",'caption'=>($_smarty_tpl->tpl_vars['language']->value['lblLiveChatAgentNow'])),$_smarty_tpl);?>
</p>
              </div>
              <div class="col-12 p-0 mb-5">
                <p class="font-family-primary text-secondary"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblFinanceDisclaim'];?>
</p>
				<h6 class="font-normal text-secondary font-weight-bold"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblDisclaimer'];?>
</h6>
                <p class="font-family-primary"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblDisclaimerText'];?>
</p>
              </div>
              <div class="col-12 p-0 mb-4">
                <button class="btn-primary continue-btn cursor-pointer py-3 px-5 border-0 font-small font-weight-bold"><?php echo $_smarty_tpl->tpl_vars['language']->value['lblContinue'];?>
</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- End : Content Pane --> 
  </div>
  <!-- Begin : Footer	Pane --> 
  <?php echo $_smarty_tpl->getSubTemplate ('CommonBottom.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0); ?>
 
  <!-- End : Footer Pane --> 
</div>
<!-- End : Outer Pane --> 
<?php echo $_smarty_tpl->getSubTemplate ('CommonJavaScriptBottom.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0); ?>
 

<?php echo $_smarty_tpl->smarty->registered_objects['html'][0]->messages_script(array('id'=>"common_message"),$_smarty_tpl);?>
 
<script type="text/javascript">
 var processingFeesPercentage 		= '<?php echo $_smarty_tpl->tpl_vars['processingFeesPercentage']->value;?>
';
 var downPaymentPercentage 		= '<?php echo $_smarty_tpl->tpl_vars['downPaymentPercentage']->value;?>
';
 var view_public_path 		= '<?php echo $_smarty_tpl->tpl_vars['view_public_path']->value;?>
';
 var redirectPath			= '';
 var finance_term               =   '<?php echo $_smarty_tpl->tpl_vars['finance_term']->value;?>
';
 var lblFinanceEMI              =   '<?php echo $_smarty_tpl->tpl_vars['language']->value['lblFinanceEMI'];?>
';
 var lblFinanceEMIinfo              =   '<?php echo $_smarty_tpl->tpl_vars['language']->value['lblFinanceEMIinfo'];?>
';
$( function() {
			$( "#monthlyPayment" ).html($.getFormattedCurrency(0));
                        
          $( "#donwpaymentrangeslider" ).slider({
              range: 'min',
              min: parseInt(downPaymentPercentage),
              max: 80,
              step: 1,
              
              slide: function(event, ui) {
				$( "#downpaymentval" ).html(ui.value);//$( "#donwpaymentrangeslider" ).slider( "values", 1 )
				financeRateCalculator();
              }
          });
		 
          $( "#termrangeslider" ).slider({
              range: 'min',
              min: 12,
              max: finance_term,
              step: 6,
              value: finance_term,
              slide: function(event, ui) {
				$( "#termlength" ).html(ui.value);
				financeRateCalculator();
              }
          });
          $( "#termlength" ).html($( "#termrangeslider" ).slider( "values", 1 ));
		  
		 $('#series').change(function(){ 
			if($(this).val() != ''){
				$.ajax({
					type: "POST",
					url: GLOBAL_BASE_PATH + "/financecalculator/ajaxGetShortDesc/",
					data: 'category='+$(this).val(),
					success: function (data) 
					{          		
						  $( "#shortDesc" ).html(data);
					}
				});
			}
		});
		$('#shortDesc').change(function(){ 
			if($(this).val() != ''){
				$.ajax({
					type: "POST",
					url: GLOBAL_BASE_PATH + "/financecalculator/ajaxGetProducts/",
					data: 'shortDesc='+$(this).val(),
					success: function (data) 
					{          		
						  $( "#variant" ).html(data);
					}
				});
			}
		});
		$('#variant').change(function(){ 
			var product_id 	= $('#variant option:selected').attr("product_id"); 
			$.ajax({
			type: "POST",
			url: GLOBAL_BASE_PATH + "/financecalculator/ajaxGetFinanceRate/",
			data: 'variantCode='+$(this).val()+'&product_id='+product_id,
			success: function (data) 
			{          		
				
				var obj = JSON.parse(data);
				$( "#productTitle" ).html(obj.productTitle);
				$( "#regularPriceText" ).html('<i class="icon-info" data-toggle="tooltip" data-placement="top" title="'+lblFinanceEMIinfo+'"></i> '+lblFinanceEMI);
                                $( "#regularPrice" ).html($.getFormattedCurrency(obj.monthlyInstallment));
				$( "#vehicleImage" ).attr('src',view_public_path+'/uploads/catalog/vehicles/thumb/'+obj.vehicleImage);
				redirectPath = obj.requestPath;
				$( "#detailedDesc" ).html(obj.detailedDescription);
				if(obj.financeRate!='')
				$( "#finRate" ).val(obj.financeRate+'%');
				financeRateCalculator();
			}
		});
			
		});
		$('.continue-btn').click(function(){
			var link = siteUrl;
			link = link.replace(/\/$/, "")
			if(redirectPath!='')
				link += '/'+redirectPath;
			window.location =   link;
		});
  });
function financeRateCalculator() {
	var mainPrice 				= $('#variant option:selected').attr("price"); 
	if($('#variant').val()!= '' && mainPrice>0) {
	var downpaymentvalslider	= $( "#downpaymentval" ).text();
	var downPayment				= (mainPrice *  downpaymentvalslider)/100;
	var financeAmount			=  mainPrice - downPayment;
	<!-- if(financeAmount <  50000) { -->
		  <!-- var differenceValue 	= 50000 - financeAmount; -->
		  <!-- downPayment			= downPayment - differenceValue; -->
		  <!-- financeAmount			= financeAmount + differenceValue; -->
	<!--  } -->
	var processingFees			= (financeAmount *  processingFeesPercentage)/100;
	if(processingFees >= 2500) {
		processingFees			= 2500 * 1.05; 
	} else if(processingFees <= 500) {
		processingFees			= 500 * 1.05; 
	}
	var totalFinanceAmount		= financeAmount + processingFees;
	var financeTerm				= $( "#termlength" ).text();
	var financeRate				= $( "#finRate" ).val();
	if(financeRate.indexOf("%")>= 0) {
		var array = financeRate.split('%');
		financeRate = array[0];
	}
	if(financeRate!='') 	{		
			financeRate		= financeRate/100;
		installment			= ((totalFinanceAmount*financeRate*financeTerm/12)+totalFinanceAmount+200)/financeTerm;
	} else
		installment 			= 0;
	installment			= Math.round(installment);
	downPayment			= Math.round(downPayment);
	$( "#monthlyPayment" ).html($.getFormattedCurrency(installment));
	$( "#donwpaymentamount" ).html(downPayment);
	}
}
$(document).ready(function(){
 //while coming back to this page on browser back button press, the dropdowns populated
		 if($('#series').val()>0) {
			$('#series').trigger("change");
			
		 }	
});
</script>
</body>
</html>
<?php }} ?>