<?php
/**
 * Created by Sublime Text.
 * User: Gael Wamba Musikingala
 * Date: 2019-05-23
 * Time: 11:24 AM
 */
ini_set('display_errors', '1');
//error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING);
error_reporting(E_ALL);

require (CONFIG.'dbconnect.php');
require (PAGE_CONTENT.$PageContent);

//20190617 - Change Sell KR and Buy KR pages to use new table web_retail_pricing. -Gael
//$pdo = $SA->query("SELECT GoldPriceZARPerOz FROM web_gold_pricing ORDER BY ID DESC LIMIT 1");
$pdo = $SA->query("SELECT GoldPriceZARPerOz, SellToUsSpread FROM web_retail_pricing ORDER BY ID DESC LIMIT 1");
$pdo->execute();
$results = $pdo->fetch();
$KrugerRandTotalPriceZAR = number_format((float)$results['GoldPriceZARPerOz'] + ((float)$results['GoldPriceZARPerOz'] * ((float)$results['SellToUsSpread']/100)) , 2);
//var_dump($KrugerRandTotalPriceZAR);
$sellPrice = str_replace(",", "", $KrugerRandTotalPriceZAR);

$oneOunce = number_format($sellPrice, 2, ".", ",");
$oneHalfOunce = number_format(($sellPrice/2), 2, ".", ",");
$oneQuarterOunce = number_format(($sellPrice/4), 2, ".", ",");
$oneTenthOunce = number_format(($sellPrice/10), 2, ".", ",");

$strOneOunce = "R ".$oneOunce." one oz";
$strOneHalfOunce = "R ".$oneHalfOunce."  one half oz";
$strOneQuarterOunce = "R ".$oneQuarterOunce."  one quarter oz";
$strOneTenthOunce = "R ".$oneTenthOunce."  one tenth oz";

//print_r($KrugerRandTotalPriceZAR);

echo "
   <style>
      .SellPrice p {
         padding:0; 
         margin:0;
         font-size: 16px;
         color:#B09068;
      }

      #tblDenomination td {
         padding:0; 
         margin:0;
      }

      .table-no-padding td {
         padding:0; 
         margin:0;
      }

      .div-circle{
         position: relative;
         width: 230px;
         height: 230px;
         border-radius: 150px;
         text-align: center;
         line-height: 25px;
         border: double 8px #ffffff;
         color: #ffffff;
         background-color: #B09068;
         display: block;
         margin: auto;
      }

      .list-ul li:before {
        content: '-';
        display: block;
        float: left;
        padding-right: 20px;
      }

      div.container4 {
         height: 10em;
         position: relative }
      div.container4 p {
         margin: 0;
         background: yellow;
         position: absolute;
         top: 50%;
         left: 50%;
         margin-right: -50%;
         transform: translate(-50%, -50%) 
      }

      ul.stepper.horizontal .step.active .step-title::before, ul.stepper.horizontal .step.done .step-title::before
      {
         background-color:#3b1c5f;
      }

      .img-center{
         display: block; 
         margin: 0 auto;
      }

      .box{
         border: 2px solid red;
      }
   </style>
   <div class='container-fluid'>
      <div class='panel'>
      <form id='frmKruggerSell' class='container' action='$SiteUrl/krugerrand/sell/index.php' method='post'>
         <ul class='stepper horizontal' style='height: 850px;width: 100%;'>
            <li class='step' style='padding: 0;'>
               <div class='step-title waves-effect'>Sell To Us</div>
               <div class='step-content' style='height: 550px;width: 100%;overflow: hidden;'>
                  <div class='row' style='color:#3b1c5f;'>
                     <div class='col s12 m12 row'>
                        <div style='display:inline-block;vertical-align:top;' class='col s12 m1 l1'>
                           ".file_get_contents(TEMPLATES_ASSETS.'/svgs/sab_home_tick.svg')." 
                        </div>
                        <div style='display:inline-block;' class='col s12 m11 l11'>
                             <p>$bao_txtOffering1</p>
                        </div>
                     </div>
                     <div class='col s12 m12 row'>
                        <div style='display:inline-block;vertical-align:top;' class='col s12 m1 l1'>
                           ".file_get_contents(TEMPLATES_ASSETS.'/svgs/sab_home_tick.svg')." 
                        </div>
                        <div style='display:inline-block;' class='col s12 m11 l11'>
                             <p>$bao_txtOffering2</p>
                        </div>
                     </div>
                     <div class='col s12 m12 row'>
                        <div style='display:inline-block;vertical-align:top;' class='col s12 m1 l1'>
                           ".file_get_contents(TEMPLATES_ASSETS.'/svgs/sab_home_tick.svg')." 
                        </div>
                        <div style='display:inline-block;' class='col s12 m11 l11'>
                             <p>$bao_txtOffering3</p>
                        </div>
                     </div>

                     <div class='col m6 s12 row'>
                        <div class='col l1 m1 s1' style=''>
                           <img id='back_krugerrand' style='visibility: hidden; width:20px; padding-top:120px;' src='https://sabullion.co.za/Krugerrand Coin/back.png' class='img-center'>
                        </div>
                        <div class='col l10 m10 s10' style='margin: 0 auto; display: block;'>
                           <img id='main_image' style='width:300px;' src='https://sabullion.co.za/Krugerrand Coin/Kruger_back.png' class='responsive-img img-center' >
                        </div>
                        <div class='col l1 m1 s1' style=''>
                           <img id='next_krugerrand' src='https://sabullion.co.za/Krugerrand Coin/next.png' style='width:20px; padding-top:120px;' class='img-center'>
                        </div>
                     </div>
                     <div class='col m6 s12 row'>
                        <div class='img-center'>
                           <div class='col m3 SellPrice'>
                              <p>Sell price</p>
                           </div>
                           <div class='col m6 SellPrice'>
                              <p id='strOneOunce'>$strOneOunce</p>
                              <p id='strOneHalfOunce'>$strOneHalfOunce</p>
                              <p id='strOneQuarterOunce'>$strOneQuarterOunce</p>
                              <p id='strOneTenthOunce'>$strOneTenthOunce</p>
                           </div>
                           <div class='col m12'>
                              <p style='font-weight:bold; color:#3b1c5f; '>Prices may move up or down subject to changes in the gold price.</p>
                           </div>
                        </div>
                     </div>
                  </div>
                  <div class='step-actions'>
                     <!-- Here goes your actions buttons -->
                     <button class='waves-effect btn next-step' style='background-color:#3b1c5f;'>NEXT</button>
                  </div>
               </div>
            </li>
            <li class='step'>
               <div class='step-title waves-effect'>Seller's Details</div>
               <div class='step-content'>
                  <div id='investment-calculator' class='row'>
                     <div class='row'>
                        <div class='col s12 m6'>

                           <div class='input-field col s12'>
                              <input id='sell_krugerrand_first_name' type='text'>
                              <label for='sell_krugerrand_first_name'>My name is 
                                 <span class='required' aria-required='true' style='color:red'>*</span>
                              </label>
                           </div>

                           <div class='input-field col s12'>
                              <input id='sell_krugerrand_last_name' type='text'>
                              <label for='sell_krugerrand_last_name'>My last name is 
                                 <span class='required' aria-required='true' style='color:red'>*</span>
                              </label>
                           </div>

                           <div class='input-field col s12'>
                              <input id='sell_krugerrand_email' type='email'>
                              <label for='sell_krugerrand_email'>My email is
                                 <span class='required' aria-required='true' style='color:red'>*</span>
                              </label>
                           </div>

                           <div class='input-field col s12'>
                              <input class='sell_krugerrand_telephone'  id='sell_krugerrand_telephone' type='text' >
                              <label for='sell_krugerrand_telephone'>Telephone number is
                                 <span class='required' aria-required='true' style='color:red'>*</span>
                              </label>
                           </div>
                        </div>
                        <div class='col s12 m6'>

                           <div class='alrightsansmedium' id='collectLocation'>
                              <div class='col s12 m12'>
                                 <label for='location' style='color:#3b1c5f;'>Drop Off Location</label>
                              </div>
                              <br>
                              <div class='col s12 m6'>
                                 <p style='color:#3b1c5f;' style='padding-bottom: 15px;'>
                                    <label for='BBed'>
                                       <input id='BBed' class='with-gap' name='location' type='radio' value='BRINKS Bedfordview'  style='position:relative; left:0; visibility:visible;' checked />
                                       <span style='color:#3b1c5f;'>BRINKS Bedfordview</span>
                                    </label>
                                 </p>
                              </div>
                              <div class='col s12 m6' style='padding-bottom: 15px;'>
                                 <p style='color:#3b1c5f;'>
                                    <label for='BCap'>
                                       <input id='BCap' class='with-gap' name='location' type='radio' value='BRINKS Cape Town' 
                                       style='position:relative; left:0; visibility:visible;'/>
                                       <span style='color:#3b1c5f;'>BRINKS Cape Town</span>
                                    </label>
                                 </p>
                              </div>
                           </div>

                           <div class='input-field col s12'>
                              <input class='sell_krugerrand_notes' id='sell_krugerrand_notes' type='text' >
                              <label for='sell_krugerrand_notes'>Additional notes</label>
                           </div>

                           <div class='input-field col s12' id='courierLocation' style='display:none;'>
                              <input class='sell_krugerrand_address' id='sell_krugerrand_address' type='text' >
                              <label for='sell_krugerrand_address'>Delivery Address</label>
                           </div>

                           <div class='input-field col s12'>
                              <input class='sell_krugerrand_mobile'  id='sell_krugerrand_mobile' type='text' >
                              <label for='sell_krugerrand_mobile'>Mobile number</label>
                           </div>
                        </div>
                        <div class='col s12 m12'>
                           <input id='dblTotalCoinWeight' type='hidden'>
                           <input id='dblCurrentSellPrice' type='hidden'>
                           <input id='dblTotalSellPrice' type='hidden'>
                           <table id='tblDenomination' class='highlight condense responsive-table' style='font-family: Alright Sans;color:#3b1c5f;' width='100%'>
                              <thead>
                                 <tr>
                                    <th>Denomination</th>
                                    <th>Quantity</th>
                                    <th style='text-align: right;'>Sell Price per Denomination</th>
                                 </tr>
                              </thead>
                              <tbody>
                                 <tr>
                                    <td>One ounce Bullion Krugerrand</td>
                                    <td width='12%'><input id='sell_krugerrand_quantity' type='number' min='0' value='0' placeholder='Enter Sell Krugerrand Quantity for One Once' onchange='calculateCoinWeight();' style='height:30px;'>
                                    </td>
                                    <td id='lblOneOnce' width='30%'style='text-align: right;'>R1000</td>
                                 </tr>
                                 <tr>
                                    <td>One half ounce Bullion Krugerrand</td>
                                    <td width='12%'><input id='sell_krugerrand_quantity_2' type='number' min='0' value='0' placeholder='Enter Sell Krugerrand Quantity for One half Once' onchange='calculateCoinWeight();' style='height:30px;'>
                                    </td>
                                    <td id='lblOneHalfOnce' style='text-align: right;'>R1000</td>
                                 </tr>
                                 <tr>
                                    <td>One quarter ounce Bullion Krugerrand</td>
                                    <td width='12%'><input id='sell_krugerrand_quantity_3' type='number' min='0' value='0' placeholder='Enter Sell Krugerrand Quantity for One quater Once' onchange='calculateCoinWeight();' style='height:30px;'>
                                    </td>
                                    <td id='lblOneQuaterOnce' style='text-align: right;'>R1000</td>
                                 </tr>
                                 <tr>
                                    <td>One tenth ounce Bullion Krugerrand</td>
                                    <td width='12%'><input id='sell_krugerrand_quantity_4' type='number' min='0' value='0' placeholder='Enter Sell Krugerrand Quantity for One tenth Once' onchange='calculateCoinWeight();' style='height:30px;'>
                                    </td>
                                    <td id='lblOneTenthOnce' style='text-align: right;'>R1000</td>
                                 </tr>
                              </tbody>
                              <tfoot>
                                 <tr>
                                    <th style='font-size:12px; padding:5px;'></th>
                                    <th style='font-size:12px; padding:5px; text-align:left;'>Total Coins</th>
                                    <th style='font-size:12px; padding:5px; text-align:right;'>Total Sell Price</th>
                                 </tr>
                                 <tr>
                                    <td>
                                       <span style='float:left;font-size: 18px;color:#B09068;'>Sell Price: <span id='currentSellPrice'>R 18 000</span>
                                       </span>
                                    </td>
                                    <td>
                                       <span style='font-weight: bold;'>
                                          <span id='spanTotalCoinWeight'>0 Ounces</span>
                                       </span>
                                    </td>
                                    <td style='text-align: right;'>
                                       <span style='float:left;font-size: 18px;color:#B09068; float:right;'>
                                          <span id='spanTotalSellPrice'>0</span>
                                       </span>
                                    </td>
                                 </tr>
                              </tfoot>
                           </table>
                        </div>
                     </div>
                  </div>
                  <div class='step-actions'>
                     <!-- Here goes your actions buttons -->
                     <button class='waves-effect waves-dark btn next-step' style='background-color:#3b1c5f;'>NEXT</button>
                     <button class='waves-effect waves-dark btn-flat previous-step'>BACK</button>
                  </div>
               </div>
            </li>
             <li class='step'>
               <div class='step-title waves-effect'>Review & Submit</div>
               <div class='step-content investment-calculator-illustration'>
                  <h2 class='center-align alrightsansmedium intro-head-type'>$resultsHeading</h2>
                  <p class=''>$resultsSubHeading</p>
                  <div class='row'>
                     <div class='col m6 s12'>
                        <div class='div-circle' style=''>
                           <p id='pTotalSellPrice' class='intro-head-type' style='text-align: center; 
                           vertical-align: middle; line-height: 150px; font-size: 30px;'>R 18000</p>
                        </div>
                     </div>
                     <div class='col m6 s12'>
                        <table class='table-no-padding bordered ' border='1'>
                           <thead>
                              <tr>
                                 <th>No. Coins</th>
                                 <th width='10%'></th>
                                 <th>Denomination</th>
                                 <th style='text-align:right'>Total</th>
                              </tr>
                           </thead>
                           <tbody>
                           <tr>
                              <td style='text-align:left' id='intOneOunce'>1</td>
                              <td style='text-align:left'>x</td>
                              <td style='text-align:left'>Full Ounce</td>
                              <td style='text-align:right' id='dblOneOunce'>R 1000</td>
                           </tr>
                           <tr>
                              <td style='text-align:left' id='intHalfOunce'>2</td>
                              <td style='text-align:left'>x</td>
                              <td style='text-align:left'>Half Ounce</td>
                              <td style='text-align:right' id='dblHalfOunce'>R 1000</td>
                           </tr>
                           <tr>
                              <td style='text-align:left' id='intQuarterOunce' >2</td>
                              <td style='text-align:left'>x</td>
                              <td style='text-align:left'>Quarter Ounce</td>
                              <td style='text-align:right' id='dblQuarterOunce'>R 1000</td>
                           </tr>
                           <tr>
                              <td style='text-align:left' id='intTenthOunce'>2</td>
                              <td style='text-align:left'>x</td>
                              <td style='text-align:left'>Tenth Ounce</td>
                              <td style='text-align:right' id='dblTenthOunce'>R 1000</td>
                           </tr>
                           </tbody>
                           <tfoot>
                              <tr>
                                 <th style='font-size:12px; padding:5px;'>Total Coins</th>
                                 <th style='font-size:12px; padding:5px; text-align:left; width:10%'></th>
                                 <th style='font-size:12px; padding:5px; text-align:left;'>Current Sell Price</th>
                                 <th style='font-size:12px; padding:5px; text-align:right;'>Total Sell Price</th>
                              </tr>
                              <tr>
                                 <td id='intCoinTotalReview'>2</td>
                                 <td>x</td>
                                 <td id='dblCurrentSellPriceReview'></td>
                                 <td style='text-align:right; font-size: 16px;color:#B09068;' id='dblTotalReview'>R 2000</td>
                              </tr>
                           <tfoot>
                        </table>
                        <br>
                     </div>
                     <div class='col m12 s12 container'>
                        <br>
                        <p>$resultsSubHeading2</p>
                        <p>$resultsSubHeading3</p>
                     </div>
                  </div>
                  <div class='step-actions'>
                     <!-- Here goes your actions buttons -->
                     <button class='waves-effect waves-dark btn' style='background-color:#3b1c5f;' id='XkrugerrandSellCalcOver' type='submit'>SUBMIT</button>
                     <button class='waves-effect waves-dark btn-flat previous-step'>BACK</button>
                  </div>
               </div>
            </li>
         </ul>
      </form>
      </div>
   </div>

   <script>
      $(document).ready(function(){
         var stepper = document.querySelector('.stepper');
         var stepperInstace = new MStepper(stepper, {
            // options
            firstActive: 0, // this is the default
            showFeedbackPreloader: true,
            stepTitleNavigation: false,
            validationFunction: jsValidateSelleForm,
            feedbackPreloader: '<div class=\"spinner-layer spinner-blue-only\">...</div>'
         });

         calculateCoinWeight();
      });

      function calculateCoinWeight()
      {
         var quantityOne = parseInt(document.getElementById('sell_krugerrand_quantity').value);
         var quantityTwo = parseInt(document.getElementById('sell_krugerrand_quantity_2').value);
         var quantityThree = parseInt(document.getElementById('sell_krugerrand_quantity_3').value);
         var quantityFour = parseInt(document.getElementById('sell_krugerrand_quantity_4').value);
         

         quantityOne = isNaN(quantityOne) ? 0 : quantityOne;
         quantityTwo = isNaN(quantityTwo) ? 0 : quantityTwo;
         quantityThree = isNaN(quantityThree) ? 0 : quantityThree;
         quantityFour = isNaN(quantityFour) ? 0 : quantityFour;

         var dblTotalCoinWeight = quantityOne + (quantityTwo/2) + (quantityThree/4) + (quantityFour/10);

         var span = document.getElementById('spanTotalCoinWeight');
         span.textContent = dblTotalCoinWeight+' Ounces';


         $.get(SiteUrl+'/dashboard/api/calc/index.php?krugerrandAmount='+dblTotalCoinWeight+'&krugerrandCalc=true'+'&sellKrugerrand=true')
            .done(function (data) {
             var Myresponse = JSON.parse(data);
            //alert(Myresponse.KrugerRandPriceZAR);
            if (Myresponse.success == true) {
               var strCurrentSellPrice = 'R ' + Myresponse.KrugerRandPriceZAR;
               var dblCurrentSellPrice = Myresponse.KrugerRandPriceZAR;
               var dblTotalSellPrice = Myresponse.KrugerRandTotalPriceZAR;

               //alert(dblTotalSellPrice);

               var sellPrice = Myresponse.KrugerRandPriceZAR.replace(',', '');

               var oneOunce = (sellPrice * quantityOne).toFixed(2);
               var oneHalfOunce   = ( (sellPrice) * (quantityTwo/2)   ).toFixed(2);
               var oneQuaterOunce = ( (sellPrice) * (quantityThree/4) ).toFixed(2);
               var oneTenthOunce  = ( (sellPrice) * (quantityFour/10) ).toFixed(2);

               var strOneOunce = 'R ' + addCommas(oneOunce);
               var strOneHalfOunce = 'R ' + addCommas(oneHalfOunce);
               var strOneQuaterOunce = 'R ' + addCommas(oneQuaterOunce);
               var strOneTenthOunce = 'R ' + addCommas(oneTenthOunce);

               

               $('#lblOneOnce').html(strOneOunce);
               $('#lblOneHalfOnce').html(strOneHalfOunce);
               $('#lblOneQuaterOnce').html(strOneQuaterOunce);
               $('#lblOneTenthOnce').html(strOneTenthOunce);

               //ADD REVIEW Denominations
               $('#intOneOunce').html(quantityOne);
               $('#intHalfOunce').html(quantityTwo);
               $('#intQuarterOunce').html(quantityThree);
               $('#intTenthOunce').html(quantityFour);
               $('#intCoinTotalReview').html(dblTotalCoinWeight);

               $('#dblOneOunce').html(strOneOunce);
               $('#dblHalfOunce').html(strOneHalfOunce);
               $('#dblQuarterOunce').html(strOneQuaterOunce);
               $('#dblTenthOunce').html(strOneTenthOunce);
               $('#dblTotalReview').html('R '+dblTotalSellPrice);
                $('#dblCurrentSellPriceReview').html('R '+dblCurrentSellPrice);
               // --- END --- ADD REVIEW Denominations


               $('#currentSellPrice').html(strCurrentSellPrice);
               $('#spanTotalSellPrice').html('R '+dblTotalSellPrice);
               $('#pTotalSellPrice').html('R '+dblTotalSellPrice);



               dblCurrentSellPrice = parseFloat(dblCurrentSellPrice.replace(',',''));
               dblTotalSellPrice = parseFloat(dblTotalSellPrice.replace(',',''));

               $('#dblTotalCoinWeight').val(dblTotalCoinWeight);
               $('#dblCurrentSellPrice').val(dblCurrentSellPrice);
               $('#dblTotalSellPrice').val(dblTotalSellPrice);
            }
         });
      }

      function jsValidateSelleForm(stepperForm, activeStepContent)
      {
         var inputs = activeStepContent.querySelectorAll('input, textarea, select');
         var state = false;
         for (let i = 0; i < inputs.length; i++)
         {
            var input = inputs[i];
            console.log(input.id);
            if(input.id == 'sell_krugerrand_first_name')
            {
               if(input.value == '')
               {
                  $('#'+input.id).css({'border-bottom': '1px solid #F44336', '-webkit-box-shadow': '0 1px 0 0 #F44336', 'box-shadow': '0 1px 0 0 #F44336' });
                  swal('Please fill out your First Name', '', 'warning');
                  return false;
               }else{
                  $('#'+input.id).css({'border-bottom': '', '-webkit-box-shadow': '', 'box-shadow': '' });
               }
            }

            if(input.id == 'sell_krugerrand_last_name')
            {
               if(input.value == '')
               {
                  $('#'+input.id).css({'border-bottom': '1px solid #F44336', '-webkit-box-shadow': '0 1px 0 0 #F44336', 'box-shadow': '0 1px 0 0 #F44336' });
                  swal('Please fill out your Last Name', '', 'warning');
                  return false;
               }else{
                  $('#'+input.id).css({'border-bottom': '', '-webkit-box-shadow': '', 'box-shadow': '' });
               }
            }

            if(input.id == 'sell_krugerrand_email')
            {
               if(input.value == '')
               {
                  $('#'+input.id).css({'border-bottom': '1px solid #F44336', '-webkit-box-shadow': '0 1px 0 0 #F44336', 'box-shadow': '0 1px 0 0 #F44336' });
                  swal('Please fill out your Email Address', '', 'warning');
                  return false;
               }else{
                  $('#'+input.id).css({'border-bottom': '', '-webkit-box-shadow': '', 'box-shadow': '' });
               }

               if(validateEmail(input.value) == false)
               {
                  $('#'+input.id).css({'border-bottom': '1px solid #F44336', '-webkit-box-shadow': '0 1px 0 0 #F44336', 'box-shadow': '0 1px 0 0 #F44336' });
                  swal('Your email address is not correctly formatted', '', 'warning');
                  return false;
               }else{
                  $('#'+input.id).css({'border-bottom': '', '-webkit-box-shadow': '', 'box-shadow': '' });
               }
            }

            if(input.id == 'sell_krugerrand_telephone')
            {
               if(input.value == '')
               {
                  $('#'+input.id).css({'border-bottom': '1px solid #F44336', '-webkit-box-shadow': '0 1px 0 0 #F44336', 'box-shadow': '0 1px 0 0 #F44336' });
                  swal('Please fill out your Telephone Number', '', 'warning');
                  return false;
               }else{
                  $('#'+input.id).css({'border-bottom': '', '-webkit-box-shadow': '', 'box-shadow': '' });
               }
            }

            if(input.id == 'selectedLocation')
            {
               if(input.value == '')
               {
                  $('#'+input.id).css({'border-bottom': '1px solid #F44336', '-webkit-box-shadow': '0 1px 0 0 #F44336', 'box-shadow': '0 1px 0 0 #F44336' });
                  swal('Please select your Drop Off Location', '', 'warning');
                  return false;
               }else{
                  $('#'+input.id).css({'border-bottom': '', '-webkit-box-shadow': '', 'box-shadow': '' });
               }
            }

            if(input.id == 'dblTotalCoinWeight')
            {
               //alert(input.value);
               if(input.value == 0)
               {
                  // $('#'+input.id).css({'border-bottom': '1px solid #F44336', '-webkit-box-shadow': '0 1px 0 0 #F44336', 'box-shadow': '0 1px 0 0 #F44336' });
                  swal('Please enter at least one of the Krugerrand quantity fields', '', 'warning');
                  return false;
               }else{
                  $('#'+input.id).css({'border-bottom': '', '-webkit-box-shadow': '', 'box-shadow': '' });
               }
            }
         } 
         return true;
      }

      function validateEmail(email) 
      {
         if(/(.+)@(.+){2,}\.(.+){2,}/.test(String(email).toLowerCase())){
            return true;
         } else {
           return false;
         }
      }

      function addCommas(nStr) {
         nStr += '';
         var x = nStr.split('.');
         var x1 = x[0];
         var x2 = x.length > 1 ? '.' + x[1] : '';
         var rgx = /(\d+)(\d{3})/;
         while (rgx.test(x1)) {
            x1 = x1.replace(rgx, '$1' + ',' + '$2');
         }
         return x1 + x2;
      }
   </script>
";
?>