Subversion Repositories SmartDukaan

Rev

Rev 17738 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10629 lgm 1
function shippingform(){
11325 lgm 2
 
18109 amit.gupta 3
  var fname = document.getElementById("name").value.trim();
10629 lgm 4
  var street1 = document.getElementById("line1").value;
5
  var street2 = document.getElementById("line2").value;
6
  var city = document.getElementById("city").value;
10657 lgm 7
  var state = document.getElementById("state");
8
  state = state.options[state.selectedIndex].text;
10629 lgm 9
  var zipcode = document.getElementById("pin").value; 
10
  var phone = document.getElementById("phone").value;
11
  if(fname =='')
12
      {   
13
        document.getElementById('error').style.display = "block";
14
        document.getElementById('error').innerHTML ='Please fill name field!';
15
        window.scrollTo(0,0); return false;}
10675 lgm 16
  if(!removeScript(fname))
17
      {   
18
        document.getElementById('error').style.display = "block";
19
        document.getElementById('error').innerHTML ='Please remove script tags!';
20
        window.scrollTo(0,0); return false;}  
10629 lgm 21
  if(fname.length> 50)
22
      {   
23
        document.getElementById('error').style.display = "block";
24
        document.getElementById('error').innerHTML ='Please Enter Less Than 50 Characters in name field!';
25
        window.scrollTo(0,0); return false;}
18109 amit.gupta 26
  /*if(fname !== fname.trim())
10741 lgm 27
      {   
28
        document.getElementById('error').style.display = "block";
29
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from name field!';
18109 amit.gupta 30
        window.scrollTo(0,0); return false;}*/
10741 lgm 31
  if(fname !== fname.replace(/\s+/g, ' '))
32
      {   
33
        document.getElementById('error').style.display = "block";
34
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from name field!';
35
        window.scrollTo(0,0); return false;}
10629 lgm 36
  if(street1 =='')
37
      {   
38
        document.getElementById('error').style.display = "block";
39
        document.getElementById('error').innerHTML ='Please fill address field!';
40
        window.scrollTo(0,0); return false;}
10741 lgm 41
  if(street1 != street1.trim())
42
      {   
43
        document.getElementById('error').style.display = "block";
44
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
45
        window.scrollTo(0,0); return false;}
46
  if(street1 != street1.replace(/\s+/g, ' '))
47
      {   
48
        document.getElementById('error').style.display = "block";
49
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
50
        window.scrollTo(0,0); return false;}
10740 lgm 51
  if(!removeScript(street1))
10675 lgm 52
      {   
53
        document.getElementById('error').style.display = "block";
10740 lgm 54
        document.getElementById('error').innerHTML ='Please remove script tags!';
10675 lgm 55
        window.scrollTo(0,0); return false;}
10741 lgm 56
  if(street2 != street2.trim())
57
      {   
58
        document.getElementById('error').style.display = "block";
59
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
60
        window.scrollTo(0,0); return false;}
61
  if(street2 != street2.replace(/\s+/g, ' '))
62
      {   
63
        document.getElementById('error').style.display = "block";
64
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
65
        window.scrollTo(0,0); return false;}
10740 lgm 66
  if(!removeScript(street2))
10675 lgm 67
      {   
68
        document.getElementById('error').style.display = "block";
69
        document.getElementById('error').innerHTML ='Please remove script tags!';
70
        window.scrollTo(0,0); return false;}
10741 lgm 71
  if(state =='Select State' || state == ' ')
72
      {   
73
        document.getElementById('error').style.display = "block";
74
        document.getElementById('error').innerHTML ='Please fill state field!';
75
        window.scrollTo(0,0); return false;}
76
  if(!removeScript(state))
77
      {   
78
        document.getElementById('error').style.display = "block";
79
        document.getElementById('error').innerHTML ='Please remove script tags!';
80
        window.scrollTo(0,0); return false;}
10629 lgm 81
  if(city =='')
82
      {   
83
        document.getElementById('error').style.display = "block";
84
        document.getElementById('error').innerHTML ='Please fill City field!';
85
        window.scrollTo(0,0); return false;}
10675 lgm 86
  if(!removeScript(city))
87
      {   
88
        document.getElementById('error').style.display = "block";
89
        document.getElementById('error').innerHTML ='Please remove script tags!';
90
        window.scrollTo(0,0); return false;}
10741 lgm 91
  if(city != city.trim())
10657 lgm 92
      {   
93
        document.getElementById('error').style.display = "block";
10741 lgm 94
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from city!';
10657 lgm 95
        window.scrollTo(0,0); return false;}
10741 lgm 96
  if(city != city.replace(/\s+/g, ' '))
10675 lgm 97
      {   
98
        document.getElementById('error').style.display = "block";
10741 lgm 99
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from city!';
10675 lgm 100
        window.scrollTo(0,0); return false;}
10629 lgm 101
  if(zipcode =='')
102
      {   
103
        document.getElementById('error').style.display = "block";
104
        document.getElementById('error').innerHTML ='Please fill pincode field!';
105
        window.scrollTo(0,0); return false;}
106
  if(zipcode.length !=6)
107
      {   
108
        document.getElementById('error').style.display = "block";
109
        document.getElementById('error').innerHTML ='Pincode should be 6 digits long';
110
        window.scrollTo(0,0); return false;}
10744 lgm 111
  if(!/^\d+$/.test(zipcode))
10629 lgm 112
      {   
113
        document.getElementById('error').style.display = "block";
114
        document.getElementById('error').innerHTML ='Please Use numbers only for pincode!';
115
        window.scrollTo(0,0); return false;}
10741 lgm 116
  if(zipcode != zipcode.trim())
117
      {   
118
        document.getElementById('error').style.display = "block";
119
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from pincode!';
120
        window.scrollTo(0,0); return false;}
121
  if(zipcode != zipcode.replace(/\s+/g, ' '))
122
      {   
123
        document.getElementById('error').style.display = "block";
124
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from pincode!';
125
        window.scrollTo(0,0); return false;}
10629 lgm 126
  if(phone =='')
127
      {   
128
        document.getElementById('error').style.display = "block";
129
        document.getElementById('error').innerHTML ='Please fill phone number field!';
130
        window.scrollTo(0,0); return false;}
10744 lgm 131
  if(!/^\d+$/.test(phone))
10629 lgm 132
        {    document.getElementById('error').style.display = "block";
133
          document.getElementById('error').innerHTML ='Please Use numbers only for Mobile Number!';
134
          window.scrollTo(0,0); return false;}
135
  if(phone.length != 10)
136
        {    document.getElementById('error').style.display = "block";
137
          document.getElementById('error').innerHTML ='Mobile number should be of 10 digits!';
138
          window.scrollTo(0,0); return false;}
10741 lgm 139
  if(phone != phone.trim())
140
      {   
141
        document.getElementById('error').style.display = "block";
142
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from phone number!';
143
        window.scrollTo(0,0); return false;}
144
  if(phone != phone.replace(/\s+/g, ' '))
145
      {   
146
        document.getElementById('error').style.display = "block";
147
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from phone number!';
148
        window.scrollTo(0,0); return false;}
10629 lgm 149
 
150
}
151
function showForm(){
152
  document.getElementsByClassName("address-form")[0].style.display = 'block';
153
  document.getElementsByClassName("delivery-cont")[0].style.display = 'none';
154
}
155
 
10716 lgm 156
function deleteAddress(e){
11325 lgm 157
 
10716 lgm 158
var addressId = e.currentTarget.id;
10629 lgm 159
var url = base_url+'checkout/delete/'+addressId;
160
  microAjax(url, function (res) {
11325 lgm 161
 
10629 lgm 162
        if(res != ''){
163
          document.getElementById(addressId).style.display = 'none';
164
        }
165
  });
10716 lgm 166
  e.stopPropagation();
10629 lgm 167
}
168
function changeAddress(addressId,type){
11325 lgm 169
 
10629 lgm 170
  if(defaultAddress != addressId){
171
    var url = base_url+'checkout/changeAddress/'+addressId+'/'+type;
172
    microAjax(url, function (res) {
11325 lgm 173
 
10786 lgm 174
        if(res != ''){
175
          var data = JSON.parse(res);
176
          if(data.locationServiceable == false){
177
            document.getElementById('error').style.display = "block";
178
            document.getElementById('error').innerHTML = data.locationServiceableMessage;
179
            locationServiceable = data.locationServiceable;
180
            document.getElementById(defaultAddress).className = 'deliver-address';
181
            document.getElementById(addressId).className += ' selected-add';
182
            defaultAddress = addressId;
183
          }else{
184
            if(document.getElementById('error').style.display == "block"){
185
              document.getElementById('error').style.display = "none";
186
            }
187
            document.getElementById(defaultAddress).className = 'deliver-address';
188
            document.getElementById(addressId).className += ' selected-add';
189
            defaultAddress = addressId;
190
            locationServiceable = true;
191
          }
10629 lgm 192
        }
193
        else{
194
          return false;
195
        }
196
    });
197
  }
198
}
199
 
200
function changePayment(e){
11325 lgm 201
 
10629 lgm 202
  var Id = e.currentTarget.id;
203
  var defaultId = defaultPayment.id;
204
  if(defaultId != Id){
205
    var title = e.currentTarget.textContent.split('+')[0];
206
    document.getElementById(defaultId).className = 'card';
207
    defaultPayment.nextElementSibling.style.display = 'none';
208
    defaultPayment.children[0].innerHTML = '+';
209
    document.getElementById(Id).className += ' selected';
210
    document.getElementById(Id).children[0].innerHTML = '-';
211
    e.currentTarget.nextElementSibling.style.display = 'block';
212
    //document.getElementById(Id).style.display = 'block';
213
    defaultPayment = e.currentTarget;
12524 anikendra 214
    /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 215
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab clicked',title]);
12524 anikendra 216
    }*/
217
	ga('send', 'event', 'Payment Option', 'Payment option tab clicked', title);
10629 lgm 218
  }
219
}
220
if(typeof bankInfo != 'undefined'){
221
var defaultBank = bankInfo.Id;
222
}
223
function changeBank(e){
11325 lgm 224
 
10629 lgm 225
  var Id = e.currentTarget.value;
226
  var payOption = document.getElementById(Id).children[0].id;
227
  document.getElementById(defaultBank).style.display = 'none';
228
  document.getElementById(Id).style.display = 'block';
229
  document.getElementById('pay-emi').value = payOption;
230
  defaultBank = Id;
231
  var id = e.currentTarget.id;
232
  var a = document.getElementById(id);
233
  var bankName = a.options[a.selectedIndex].text;
12524 anikendra 234
  /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 235
      _gaq.push(['_trackEvent', 'EMI', 'Bank Selection',bankName]);
12524 anikendra 236
    }*/
237
	ga('send', 'event', 'EMI', 'Bank Selection', bankName);
10629 lgm 238
}
239
function changePay(e){
11325 lgm 240
 
10629 lgm 241
  var Id = e.currentTarget.id;
242
  var payOption = document.getElementById('pay-emi').value;
243
  document.getElementById(payOption).className = 'emi-body clearfix';
244
  document.getElementById(Id).className += ' selected';
245
  document.getElementById('pay-emi').value = Id;
246
  var bankName = e.currentTarget.getAttribute('data-bank');
247
  var tenure = e.currentTarget.getAttribute('data-tenure');
248
  bankName = bankName+'-'+tenure;
12524 anikendra 249
  /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 250
      _gaq.push(['_trackEvent', 'EMI', 'Plan Selection',bankName]);
12524 anikendra 251
    }*/
252
	ga('send', 'event', 'EMI', 'Plan Selection', bankName);
10629 lgm 253
}
11091 lgm 254
var netBankingInfo;
11137 lgm 255
var prevClass;
10629 lgm 256
function changeNetBanking(e){
11325 lgm 257
 
10657 lgm 258
  var Id;
11131 lgm 259
  var selected;
11137 lgm 260
  var hasClass;
10657 lgm 261
  Id = e.currentTarget.value;
262
  if(Id == undefined){
11131 lgm 263
    selected = 1;
10657 lgm 264
    Id = e.currentTarget.id;
11137 lgm 265
    var dropDown = document.getElementById('net');
266
    if(dropDown.selectedIndex != 0){
267
      dropDown.selectedIndex = 0;
268
    }
10657 lgm 269
  }
11091 lgm 270
  if(netBankingInfo == undefined){
11137 lgm 271
    if((selected == 1))
11119 lgm 272
    document.getElementById(Id).className = 'selected';
10657 lgm 273
  }
11091 lgm 274
  else if(netBankingInfo != undefined){
11137 lgm 275
    if((selected == 1)) {
11131 lgm 276
      document.getElementById(Id).className = 'selected';
11137 lgm 277
      if(prevClass == 'selected'){
278
        document.getElementById(netBankingInfo).className = '';   
279
      }   
280
    }else{
281
      if(prevClass == 'selected'){
282
          document.getElementById(netBankingInfo).className = '';
283
      }  
11131 lgm 284
    }
10657 lgm 285
  }
10629 lgm 286
  document.getElementById('pay-net').value = Id;
11091 lgm 287
  netBankingInfo = Id;
11137 lgm 288
  prevClass = e.currentTarget.className;
10629 lgm 289
  var title = e.currentTarget.getAttribute('data-parent');
290
  title = title+'-'+Id;
12524 anikendra 291
  /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 292
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
12524 anikendra 293
    }*/
294
	ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
10629 lgm 295
}
11066 lgm 296
var countryId;
10629 lgm 297
function changeCountry(e){
11325 lgm 298
 
10629 lgm 299
  var Id = e.currentTarget.id;
11066 lgm 300
  countryId = Id;
10629 lgm 301
  if(Id == 'india'){
302
    document.getElementById('india').className = 'selected';
303
    document.getElementById('outside').className = '';
304
    document.getElementsByClassName('in-india')[0].style.display = 'block';
305
    document.getElementsByClassName('out-india')[0].style.display = 'none';
306
  }
307
  if(Id == 'outside'){
308
    document.getElementById('outside').className = 'selected';
309
    document.getElementById('india').className = '';
310
    document.getElementsByClassName('out-india')[0].style.display = 'block';
311
    document.getElementsByClassName('in-india')[0].style.display = 'none';
312
  }
313
}
314
var previousCard;
315
function selectCard(e){
11325 lgm 316
 
10629 lgm 317
  var Id = e.currentTarget.id;
318
  if(previousCard == undefined){
11066 lgm 319
    e.currentTarget.className = 'selected';
10629 lgm 320
  }
321
  else if(previousCard != undefined){
11066 lgm 322
    previousCard.className = '';
323
    e.currentTarget.className = 'selected'; 
10629 lgm 324
  }
325
  document.getElementById('pay-credit').value = Id;
11066 lgm 326
  previousCard = e.currentTarget;
10629 lgm 327
  var title = e.currentTarget.getAttribute('data-parent');
328
  title = title+'-'+Id;
12524 anikendra 329
  /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 330
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
12524 anikendra 331
    }*/
332
	ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
10629 lgm 333
}
334
var previousDebit;
335
function selectDebitCard(e){
11325 lgm 336
 
10629 lgm 337
  var Id = e.currentTarget.id;
338
  if(previousDebit == undefined){
11066 lgm 339
    e.currentTarget.className = 'selected';
10629 lgm 340
  }
341
  else if(previousDebit != undefined){
11066 lgm 342
    previousDebit.className = '';
343
    e.currentTarget.className = 'selected'; 
10629 lgm 344
  }
345
  document.getElementById('pay-debit').value = Id;
11066 lgm 346
  previousDebit = e.currentTarget;
10629 lgm 347
  var title = e.currentTarget.getAttribute('data-parent');
348
  title = title+'-'+Id;
12524 anikendra 349
  /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 350
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
12524 anikendra 351
    }*/
352
	ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
10629 lgm 353
}
354
var previousCC;
355
function selectCashCard(e){
11325 lgm 356
 
10629 lgm 357
  var Id = e.currentTarget.id;
358
  if(previousCC == undefined){
11066 lgm 359
    e.currentTarget.className = 'selected';
10629 lgm 360
  }
361
  else if(previousCC != undefined){
11066 lgm 362
    previousCC.className = '';
363
    e.currentTarget.className = 'selected'; 
10629 lgm 364
  }
365
  document.getElementById('pay-cc').value = Id;
11066 lgm 366
  previousCC = e.currentTarget;
10629 lgm 367
  var title = e.currentTarget.getAttribute('data-parent');
368
  title = title+'-'+Id;
12524 anikendra 369
  /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 370
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
12524 anikendra 371
    }*/
372
	ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
10629 lgm 373
}
374
// function changeCaptcha(){
375
//   var url = base_url+'checkout/changeCaptcha';
376
//     microAjax(url, function (res) {
11325 lgm 377
//         
10629 lgm 378
//         if(res != ''){
11325 lgm 379
//           
10629 lgm 380
//           data = JSON.parse(res);
381
//           document.getElementById('captcha').innerHTML = data.image;
382
//         }
383
//         else{
384
//           return false;
385
//         }
386
//     });
387
// }
388
function infoPage(){
389
        document.getElementsByClassName("address-form")[0].style.display = 'none';
390
        document.getElementsByClassName("delivery-cont")[0].style.display = 'block';
391
      }
10773 lgm 392
var prevDiv;
393
var pickupStore;
10629 lgm 394
function togglepicup(e){
11325 lgm 395
 
10773 lgm 396
    if(document.getElementById('error').style.display == 'block'){
397
      document.getElementById('error').style.display = 'none';
398
    }
399
    prevDiv = e.currentTarget.className;
10629 lgm 400
    if(e.currentTarget.className == 'pick-up'){
10773 lgm 401
      pickupStore = true;
402
      inStoreDelivery = false;
10629 lgm 403
      e.currentTarget.className += ' selected';
404
      document.getElementsByClassName("deliverhere")[0].setAttribute('class','deliverhere');
405
      document.getElementsByClassName("pickup")[0].style.display = 'block';
406
      document.getElementsByClassName("deliver-here")[0].style.display = 'none';
10773 lgm 407
    }else if(prevDiv.indexOf('pick-up') == -1){
10629 lgm 408
       e.currentTarget.className += ' selected';
10773 lgm 409
       pickupStore = false;
10629 lgm 410
       document.getElementsByClassName("pick-up")[0].setAttribute('class','pick-up');
411
       document.getElementsByClassName("deliver-here")[0].style.display = 'block'; 
412
       document.getElementsByClassName("pickup")[0].style.display = 'none';
10582 lgm 413
 
10629 lgm 414
    }
415
}
416
var prevZone;
417
function changeZone(e){
11325 lgm 418
 
10629 lgm 419
 var value = e.currentTarget.value;
420
 var currentStore = storeInfo[value];
421
 var storeAddress = '';
422
 if(prevZone == undefined || prevZone != value){
423
  for(i=0;i<currentStore.length;i++){
424
    storeAddress +='<div class="pickup-spot" id="'+currentStore[i].id+'" data-key="'+currentStore[i].hotspotId+'" onclick=selectStore(event)><div>'+currentStore[i].name+'</div><div>'+currentStore[i].line1+'</div><div>'+currentStore[i].line2+'</div><div>'+currentStore[i].city+'</div><div>'+currentStore[i].state+'</div><div>Pin: '+currentStore[i].pin+'</div><div>Phone: '+currentStore[i].phone+'</div></div>'; 
425
  }
426
 document.getElementById('appendData').innerHTML = storeAddress;
427
 prevZone = value;
12524 anikendra 428
/* if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 429
      _gaq.push(['_trackEvent', 'InStore Pickup Region', 'Store Zone',value]);
12524 anikendra 430
    }*/
431
	ga('send', 'event', 'InStore Pickup Region', 'Store Zone', value);
10629 lgm 432
 }
433
}
434
var shopId;
435
var inStoreDelivery;
436
function selectStore(e){
11325 lgm 437
 
10629 lgm 438
 var id = e.currentTarget.id;
439
 var hotspotId = e.currentTarget; 
440
 if(shopId == undefined){
441
  document.getElementById(id).className += ' selected-add'; 
442
  shopId = id;
10773 lgm 443
  inStoreDelivery = true;
10629 lgm 444
 }else if(shopId != id){
11186 lgm 445
  if(document.getElementById(shopId)){
446
    document.getElementById(shopId).className += 'pickup-spot';
447
  }
10629 lgm 448
  document.getElementById(id).className += ' selected-add';
449
  shopId = id;
450
  inStoreDelivery = true;
451
 }
452
 var url = base_url+'checkout/pickupSpot/'+id;
453
   microAjax(url,function(res){
11325 lgm 454
 
10629 lgm 455
    if(res != ''){
456
    }else{
457
      window.location.href = document.URL;
458
    }
459
  });
460
 document.getElementById('hotSpot').value = id;
461
}
462
if(insuranceInfo != undefined){
463
  var insuranceInfo = insuranceInfo;
464
}
465
function validateInsurance(type){
11325 lgm 466
 
10629 lgm 467
var type = type;
468
if(document.getElementById('ccAddress') && insuranceInfo == 1){
469
  var bday = document.getElementById('bday').value;
470
  var gname = document.getElementById('gName').value;
471
  if(gname == '')
472
    {   
473
      document.getElementById('error1').style.display = "block";
474
      document.getElementById('error1').innerHTML ='Please fill name field!';
475
      return false;}
476
  if(gname.length> 50)
477
    {   
478
      document.getElementById('error1').style.display = "block";
479
      document.getElementById('error1').innerHTML ='Please Enter Less Than 50 Characters in name field!';
480
      return false;}
10741 lgm 481
  if(gname != gname.trim())
482
    {   
483
      document.getElementById('error1').style.display = "block";
484
      document.getElementById('error1').innerHTML ='Please remove excess whitespace from name field!';
485
      return false;}
486
  if(gname != gname.replace(/\s+/g,' '))
487
    {   
488
      document.getElementById('error1').style.display = "block";
489
      document.getElementById('error1').innerHTML ='Please remove excess whitespace from name field!';
490
      return false;}
10629 lgm 491
  var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
492
  var returnval=false
493
  if (!validformat.test(bday)){
494
    document.getElementById('error1').style.display = "block";
495
    document.getElementById('error1').innerHTML ='Please Enter valid date';
496
    return false;
497
  }else if(validformat.test(bday)){ //Detailed check for valid date ranges
498
        var monthfield=bday.split("/")[0]
499
        var dayfield=bday.split("/")[1]
500
        var yearfield=bday.split("/")[2]
10741 lgm 501
        var dayobj = new Date(yearfield, monthfield-1, dayfield);
502
        var today = new Date();
10837 lgm 503
        var limit = new Date('1900/01/01');
10629 lgm 504
        if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)){
505
          document.getElementById('error1').style.display = "block";
506
          document.getElementById('error1').innerHTML ='Invalid Day, Month, or Year range detected. Please correct and submit again.';
507
          return false;
508
        }
10741 lgm 509
        if (dayobj > today){
510
          document.getElementById('error1').style.display = "block";
511
          document.getElementById('error1').innerHTML ="Date should be less than today's date" ;
512
          return false;
513
        }
514
        if (dayobj < limit){
515
          document.getElementById('error1').style.display = "block";
516
          document.getElementById('error1').innerHTML ="Date should be greater than 1st jan 1940" ;
517
          return false;
518
        }
10629 lgm 519
    }
10838 lgm 520
  var alreadySubmitted;
10835 lgm 521
  if((type == 1 || type == 2) && alreadySubmitted != true){
522
    alreadySubmitted = true;
10629 lgm 523
    var bday = bday.replace(/\//g, '-');
524
    gname = gname.replace(/\ /g,'-');
525
    var url = base_url+'checkout/insuranceInfo/'+bday+'/'+gname+'/'+insuranceAddressId;
526
    microAjax(url,function(res){
11325 lgm 527
 
10629 lgm 528
    if(res != ''){
11325 lgm 529
 
10629 lgm 530
      var data = JSON.parse(res);
531
      if(data['response'].status == 'SUCCESS'){
532
        if(document.getElementById('ccAddress').style.display == ''){
533
          document.getElementById('ccAddress').style.display = 'none';
534
        }    
535
      }
536
      else{
10835 lgm 537
        alreadySubmitted = false;
10629 lgm 538
        document.getElementById('error1').style.display = "block";
539
        document.getElementById('error1').innerHTML ='Request could not be completed.Please try again!';
10835 lgm 540
        return false;
10629 lgm 541
      }
542
    }
543
  });
544
  }
545
  if(type == 2){
10773 lgm 546
    if(pickupStore == true){
10629 lgm 547
    if(inStoreDelivery == true){
12524 anikendra 548
      /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 549
      _gaq.push(['_trackEvent', 'Delivery Type','In-Store Pickup']);
12524 anikendra 550
    }*/
551
	ga('send', 'event', 'Delivery Type', 'In-Store Pickup');
10773 lgm 552
    }else if(inStoreDelivery == false){
553
      document.getElementById('error').style.display = "block";
554
      document.getElementById('error').innerHTML ="Please select a delivery store!" ;
555
      return false;
556
    }
557
  }else{
12524 anikendra 558
      /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 559
      _gaq.push(['_trackEvent', 'Delivery Type','Deliver to address']);
12524 anikendra 560
    }*/
561
	ga('send', 'event', 'Delivery Type', 'Deliver to address');
10629 lgm 562
    }
12524 anikendra 563
    /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 564
      _gaq.push(['_trackEvent', 'Order','Proceed To Pay']);
12524 anikendra 565
    }*/
566
	ga('send', 'event', 'Order', 'Proceed To Pay');
10786 lgm 567
    if(locationServiceable == false){
568
      document.getElementById('error').style.display = "block";
569
      document.getElementById('error').innerHTML ='Location not serviceable. Please specify a different address';
570
      return false;
571
    }
10629 lgm 572
    window.location.href = base_url+'payment';
573
  }
574
}else{
10773 lgm 575
  if(pickupStore == true){
576
    if(inStoreDelivery == true){
12524 anikendra 577
      /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 578
      _gaq.push(['_trackEvent', 'Delivery Type','In-Store Pickup']);
12524 anikendra 579
    }*/
580
	ga('send', 'event', 'Delivery Type', 'In-Store Pickup');
10773 lgm 581
    }else if(inStoreDelivery == false){
582
      document.getElementById('error').style.display = "block";
583
      document.getElementById('error').innerHTML ="Please select a delivery store!" ;
584
      return false;
585
    }
586
  }else{
12524 anikendra 587
      /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 588
      _gaq.push(['_trackEvent', 'Delivery Type','Deliver to address']);
12524 anikendra 589
    }*/
590
	ga('send', 'event', 'Delivery Type', 'Deliver to address');
10629 lgm 591
    }
12524 anikendra 592
    /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 593
      _gaq.push(['_trackEvent', 'Order','Proceed To Pay']);
12524 anikendra 594
    }*/
595
	ga('send', 'event', 'Order', 'Proceed To Pay');
10786 lgm 596
    if(locationServiceable == false){
597
      document.getElementById('error').style.display = "block";
598
      document.getElementById('error').innerHTML ='Location not serviceable. Please specify a different address';
599
      return false;
600
    }
10773 lgm 601
    window.location.href = base_url+'payment';
10629 lgm 602
}
603
}
604
function paymentValidation(e){
15740 amit.gupta 605
  	if(typeof clickedFlag != "undefined" && clickedFlag){
606
		return false;
607
	}
608
  clickedFlag=true;
609
  var Id = e.currentTarget.id;
11325 lgm 610
 
10629 lgm 611
  var Id = e.currentTarget.id;
612
  if(Id == 'creditcard'){
613
    if(previousCard == undefined){
614
      document.getElementById('error').style.display = "block";
615
          document.getElementById('error').innerHTML ='Please select payment method!';
15740 amit.gupta 616
          window.scrollTo(0,0);clickedFlag=false; return false;
10629 lgm 617
    }
618
    var paymentTitle = e.currentTarget.getAttribute('data-key');
12524 anikendra 619
    /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 620
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
12524 anikendra 621
    }*/
622
	ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
10629 lgm 623
 
624
  }else if(Id == 'debitcard'){
625
    if(previousDebit == undefined){
626
      document.getElementById('error').style.display = "block";
627
          document.getElementById('error').innerHTML ='Please select payment method!';
15740 amit.gupta 628
          window.scrollTo(0,0);clickedFlag=false; return false;
10629 lgm 629
    }
630
    var paymentTitle = e.currentTarget.getAttribute('data-key');
12524 anikendra 631
    /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 632
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
12524 anikendra 633
    }*/
634
	ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
10629 lgm 635
  }else if(Id == 'netbanking'){
636
    var payOption = document.getElementById('pay-net').value;
637
    if(payOption == undefined || payOption ==""){
638
      document.getElementById('error').style.display = "block";
639
          document.getElementById('error').innerHTML ='Please select payment method!';
15740 amit.gupta 640
          window.scrollTo(0,0);clickedFlag=false; return false;
10629 lgm 641
    }
642
    var paymentTitle = e.currentTarget.getAttribute('data-key');
12524 anikendra 643
    /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 644
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
12524 anikendra 645
    }*/
646
	ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
10629 lgm 647
  }else if(Id == 'cashcards'){
648
    if(previousCC == undefined){
649
      document.getElementById('error').style.display = "block";
650
          document.getElementById('error').innerHTML ='Please select payment method!';
15740 amit.gupta 651
          window.scrollTo(0,0);clickedFlag=false; return false;
10629 lgm 652
    }
653
    var paymentTitle = e.currentTarget.getAttribute('data-key');
12524 anikendra 654
    /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 655
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
12524 anikendra 656
    }*/
657
	ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
10629 lgm 658
  }else if(Id == 'emiform'){
659
    var payOption = document.getElementById('pay-emi').value;
660
    if(payOption == undefined || payOption ==""){
661
      document.getElementById('error').style.display = "block";
662
          document.getElementById('error').innerHTML ='Please select payment method!';
15740 amit.gupta 663
          window.scrollTo(0,0);clickedFlag=false; return false;
10629 lgm 664
    }
665
    var paymentTitle = e.currentTarget.getAttribute('data-key');
12524 anikendra 666
    /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 667
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
12524 anikendra 668
    }*/
669
	ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
11063 lgm 670
  }else if(Id == 'cashod'){
14939 anikendra 671
        if(document.getElementById('captcha_response_box').value == '' && !document.getElementById('captcha_response_box').disabled){
10629 lgm 672
        // document.forms['recharge-confirm'].submit();
673
      // }else{
674
        var bRed = document.getElementById('captcha_response_box');
675
        bRed.style.border = 'red solid 1px';
676
        bRed.style.color = 'red';
677
        bRed.value = 'Please enter the captcha' 
678
        setTimeout(function(){
679
          bRed.style.border = '';
680
          bRed.style.color = '';
681
          bRed.value = '';
682
        },3000);
15740 amit.gupta 683
        clickedFlag=false;return false;
10629 lgm 684
      }
685
    var paymentTitle = e.currentTarget.getAttribute('data-key');
12524 anikendra 686
    /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 687
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
12524 anikendra 688
    }*/
689
	ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
10629 lgm 690
  }else if(Id == 'zod'){
691
        if(document.getElementById('captcha_response_box').value == ''){
692
        // document.forms['recharge-confirm'].submit();
693
      // }else{
694
        var bRed = document.getElementById('captcha_response_box');
695
        bRed.style.border = 'red solid 1px';
696
        bRed.style.color = 'red';
697
        bRed.value = 'Please enter the captcha' 
698
        setTimeout(function(){
699
          bRed.style.border = '';
700
          bRed.style.color = '';
701
          bRed.value = '';
702
        },3000);
15740 amit.gupta 703
        clickedFlag=false;return false;
10629 lgm 704
      }
705
    var paymentTitle = e.currentTarget.getAttribute('data-key');
12524 anikendra 706
    /*if(typeof _gaq != "undefined" && _gaq != null)  {
10953 lgm 707
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
12524 anikendra 708
    }*/
709
	ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
10629 lgm 710
  }
10675 lgm 711
}
10696 lgm 712
var url;
713
 url = document.URL;
714
 if(url.indexOf('pay-success') != -1){
715
  if(orderConfirmation != undefined){
11913 anikendra 716
    if(!storeName){
717
	storeName = 'Saholic';
718
    }
10696 lgm 719
    var orders = orderConfirmation['result']['orders'];
720
    for(i=0;i<orders.length;i++){
721
      var amount = orders[i].totalAmount.replace(',','');
17738 manish.sha 722
      var unitPrice = orders[i].unitPrice;
10696 lgm 723
      amount = parseFloat(amount).toFixed(2);
17738 manish.sha 724
      unitPrice = parseFloat(unitPrice).toFixed(2);
10696 lgm 725
      var orderId = orders[i].orderId;
12524 anikendra 726
/*
10953 lgm 727
      _gaq.push(['_addTrans',
728
          orderId,                     // Transaction ID. Required.
11913 anikendra 729
          storeName,   // Affiliation or store name.
10953 lgm 730
          amount,               // Grand Total.
731
          '0',                  // Shipping.
732
          '0',                     // Tax.
733
          "",
734
          "",
735
          "India"
736
      ]);
737
      _gaq.push(['_addItem',
738
          orderId,                     // Transaction ID. Required.
739
          orders[i].itemName,    // Product name. Required.
740
          orders[i].itemName,                 // SKU/code.
741
          'Physical',         // Category or variation.
742
          amount,                 // Unit price.
743
          orders[i].quantity                   // Quantity.
744
      ]);
12524 anikendra 745
*/
746
	ga('ecommerce:addTransaction', {
747
	  'id': orderId,                     // Transaction ID. Required
748
	  'affiliation': storeName,   // Affiliation or store name
749
	  'revenue': amount,               // Grand Total
750
	  'shipping': '0',                  // Shipping
751
	  'tax': '0'                     // Tax
752
	});
753
	// addItem should be called for every item in the shopping cart.
754
	ga('ecommerce:addItem', {
755
	  'id': orderId,                     // Transaction ID. Required
756
	  'name': orders[i].itemName,                // Product name. Required
757
	  'sku': orders[i].itemName,                    // SKU/code
758
	  'category': 'Physical',       // Category or variation
17738 manish.sha 759
	  'price': unitPrice,                 // Unit price
12524 anikendra 760
	  'quantity': orders[i].quantity                   // Quantity
761
	});
10696 lgm 762
    }
12524 anikendra 763
//    _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
764
	ga('ecommerce:send');      // Send transaction and item data to Google Analytics.
10696 lgm 765
  }
766
 }