Subversion Repositories SmartDukaan

Rev

Rev 14839 | Rev 15788 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11289 lgm 1
var pheight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
2
if(document.getElementsByClassName('mobile-recharge')[0] != undefined){
3
    document.getElementsByClassName('mobile-recharge')[0].style.minHeight = pheight - 195 +'px';  
4
}
5
if(document.getElementsByClassName('dth-recharge')[0] != undefined){
6
    document.getElementsByClassName('dth-recharge')[0].style.minHeight = pheight - 195 +'px';  
7
}
8
if(document.getElementsByClassName('conf-cont')[0] != undefined){
9
    document.getElementsByClassName('conf-cont')[0].style.minHeight = pheight - 170 +'px';  
10
}
10582 lgm 11
var operatorId;
12
var circleCode;
11715 lgm 13
var isOperaMini = (navigator.userAgent.indexOf('Opera Mini') > -1);
14
if(isOperaMini){
15
  document.getElementById('operator-list').style.display = "block";
16
}
10582 lgm 17
function operator(){
18
	var number = document.getElementById('mobile-number').value;
11721 lgm 19
	number = number.trim();
20
	if(!/^\d+$/.test(number)){
21
		document.getElementById('error').style.display = "block";
22
		document.getElementById('error').innerHTML ='Please Use numbers only for Mobile Number!';
23
		window.scrollTo(0,0); return false;
24
	}
10582 lgm 25
	if(number.length == 10)
26
	{
11325 lgm 27
 
10582 lgm 28
		var url = base_url+'recharge/operator/'+number;
29
	    //window.location.href = a;
30
	    microAjax(url, function (res) {
11325 lgm 31
 
10582 lgm 32
	    	if(res != ''){
11325 lgm 33
 
10582 lgm 34
	    		var data = JSON.parse(res);
35
	    		var planId;
36
	    		operatorId = data.operatorId;
37
	    		circleCode = data.circleCode;
38
	    		var dropdownlistbox = document.getElementById("mobile-operator");
39
				for(var x=0;x < dropdownlistbox.length -1 ; x++)
40
				{
41
				   if(data.operatorName == dropdownlistbox.options[x].text)
42
				   {
43
				       dropdownlistbox.selectedIndex = x;
11546 lgm 44
				       document.getElementById("mobile-operator").disabled = false;
10582 lgm 45
				       var opids ='';
46
				        for(var i=0;i<plan.length;i++){
47
							if(plan[i].operatorId == operatorId){
48
								var planId = plan[i].operatorId;
49
								opids += '<option value='+plan[i].Name+'>'+plan[i].displayName+'</option>';
50
							}
51
						}
52
						if(planId == operatorId){
53
							document.getElementById('plans').style.display = 'block';
54
						}else{
55
							document.getElementById('plans').style.display = 'none';
56
						}
13006 anikendra 57
						document.getElementById('operator-palns').innerHTML = opids;
10582 lgm 58
						if(special.indexOf(operatorId) != -1){
59
							document.getElementById('operatorName').innerHTML = data.operatorName;
60
							document.getElementById('special').style.display = 'block';
61
						}
62
						else{
63
							document.getElementById('special').style.display = 'none';
64
						}	      
65
				   	   	break;
66
					}
67
				}
68
			}
69
 
70
	    });
11546 lgm 71
	}else if(number.length < 10){
72
		if(document.getElementById("mobile-operator").disabled != true){
73
			document.getElementById("mobile-operator").disabled = true;
74
		}
11722 lgm 75
		var isOperaMini = (navigator.userAgent.indexOf('Opera Mini') > -1);
11715 lgm 76
		if(isOperaMini){
77
			if(number ==''){    
78
				document.getElementById('error').style.display = "block";
79
				document.getElementById('error').innerHTML ='Please fill Your Mobile Number!';
80
				window.scrollTo(0,0); return false;
81
			}
82
		    if(!/^\d+$/.test(number)){
83
		        document.getElementById('error').style.display = "block";
84
				document.getElementById('error').innerHTML ='Please Use numbers only for Mobile Number!';
85
				window.scrollTo(0,0); return false;
86
			}
87
			if(number.length != 10){    
88
				document.getElementById('error').style.display = "block";
89
				document.getElementById('error').innerHTML ='Mobile Number should be of 10 digits';
90
				window.scrollTo(0,0); return false;
91
			}
92
		}
10582 lgm 93
	}
94
}
95
 
96
function changeOperator(e){
11325 lgm 97
 
10582 lgm 98
	var Id = e.currentTarget.value;
99
    var opids ='';
100
    for(var i=0;i<plan.length;i++){
101
		if(plan[i].operatorId == Id){
102
			var planId = plan[i].operatorId;
103
			opids += '<option value='+plan[i].Name+'>'+plan[i].displayName+'</option>';
104
		}
105
	}
106
	if(planId == Id){
107
		document.getElementById('plans').style.display = 'block';
108
	}else{
109
		document.getElementById('plans').style.display = 'none';
110
	}
111
	document.getElementById('operator-palns').innerHTML = opids;
112
	if(special.indexOf(parseInt(Id)) != -1){
113
		var dropdownlistbox = document.getElementById("mobile-operator");
114
		var index = e.currentTarget.selectedIndex;
115
		document.getElementById('operatorName').innerHTML = dropdownlistbox.options[index].text;;
116
		document.getElementById('special').style.display = 'block';
117
	}
118
	else{
119
	document.getElementById('special').style.display = 'none';
120
	}	    
121
}
122
 
123
function topup(e){
11325 lgm 124
 
10582 lgm 125
	var Id = e.currentTarget.id;
126
	var url = base_url+'recharge/topupSpecial/'+Id+'/'+operatorId+'/'+circleCode;
127
	microAjax(url, function (res) {
11325 lgm 128
 
10582 lgm 129
	    	if(res != '')
130
	    	{
131
	    		document.getElementsByClassName('rech-cont')[0].style.display = 'none';
132
	    		document.getElementsByClassName('topup-cont')[0].style.display = 'block';
133
	    		var appenddata = document.getElementById('appendlist');
11574 lgm 134
	    		//appenddata.innerHTML= appenddata.innerHTML +  res;
135
	    		appenddata.innerHTML =  res;
10582 lgm 136
	    	}
137
		});
138
}
139
 
140
function closePlan(){
11325 lgm 141
	//
10582 lgm 142
	document.getElementsByClassName('rech-cont')[0].style.display = 'block';
143
	document.getElementsByClassName('topup-cont')[0].style.display = 'none';
144
}
145
function fillAmount(e){
11325 lgm 146
	//
10582 lgm 147
	var amount = e.currentTarget.innerHTML;
148
	document.getElementById('mobile-amount').value = amount;
149
	document.getElementsByClassName('rech-cont')[0].style.display = 'block';
150
	document.getElementsByClassName('topup-cont')[0].style.display = 'none';
151
}
152
function changeName(e){
11325 lgm 153
 
10582 lgm 154
	var id = e.currentTarget.value;
10806 lgm 155
	if(id != -1){
156
		var name = dthIdMap[id];
157
		document.getElementById('accountName').innerHTML = name;
158
	}else if(id == -1){
159
		document.getElementById('accountName').innerHTML = 'Account Number :';
160
	}
10582 lgm 161
}
162
function mobileValidation(){
11325 lgm 163
 
10582 lgm 164
	var operator = document.getElementById('mobile-operator');
165
	var number = document.getElementById('mobile-number').value;
166
	var amount = document.getElementById('mobile-amount').value;
167
	var email = document.getElementById("emailId").value;
168
	document.getElementById('operator_hidden').value = operator[operator.selectedIndex].text;
169
	email = email.trim();
170
    var atpos = email.indexOf("@");
171
    var dotpos = email.lastIndexOf(".");
11721 lgm 172
    number = number.trim();
10582 lgm 173
	if(number ==''){    
174
		document.getElementById('error').style.display = "block";
175
		document.getElementById('error').innerHTML ='Please fill Your Mobile Number!';
176
		window.scrollTo(0,0); return false;
177
	}
10778 lgm 178
    if(!/^\d+$/.test(number)){
10582 lgm 179
        document.getElementById('error').style.display = "block";
180
		document.getElementById('error').innerHTML ='Please Use numbers only for Mobile Number!';
181
		window.scrollTo(0,0); return false;
182
	}
183
	if(number.length != 10){    
184
		document.getElementById('error').style.display = "block";
185
		document.getElementById('error').innerHTML ='Mobile Number should be of 10 digits';
186
		window.scrollTo(0,0); return false;
187
	}
188
	if(operator.selectedIndex == 0){
189
		document.getElementById('error').style.display = "block";
190
        document.getElementById('error').innerHTML ='Please select your operator!';
191
        window.scrollTo(0,0); return false;
192
	}
193
	if(amount ==''){    
194
		document.getElementById('error').style.display = "block";
195
		document.getElementById('error').innerHTML ='Please fill recharge amount!';
196
		window.scrollTo(0,0); return false;
197
	}
10748 lgm 198
    if(!/^\d+$/.test(amount)){
10582 lgm 199
        document.getElementById('error').style.display = "block";
200
		document.getElementById('error').innerHTML ='Please Use numbers only!';
201
		window.scrollTo(0,0); return false;
202
	}
203
	if((parseInt(amount) < 10) || (parseInt(amount) > 1000)){
204
        document.getElementById('error').style.display = "block";
205
		document.getElementById('error').innerHTML ='Recharge amount should be between Rs. 10-1000';
206
		window.scrollTo(0,0); return false;
207
	}
208
 
209
  	if(email ==''){     
210
        document.getElementById('error').style.display = "block";
211
        document.getElementById('error').innerHTML ='Please fill email field!';
212
        window.scrollTo(0,0); return false;}
213
  	if((atpos<1) || (dotpos < atpos+2) || (dotpos+2 >= email.length)){
214
        document.getElementById('error').style.display = "block";
215
        document.getElementById('error').innerHTML ='Please fill email in correct format!';
216
        window.scrollTo(0,0); return false;
217
    }    
218
  	if(email.length> 50){  
219
        document.getElementById('error').style.display = "block";
220
        document.getElementById('error').innerHTML ='Please enter less than 50 characters in email field!';
221
        window.scrollTo(0,0); return false;
222
    }
223
    if(email.indexOf(' ') != -1){  
224
        document.getElementById('error').style.display = "block";
225
        document.getElementById('error').innerHTML ='Please remove space from email field!';
226
        window.scrollTo(0,0); return false;
227
    }
10748 lgm 228
    if(email != email.trim()){  
229
        document.getElementById('error').style.display = "block";
230
        document.getElementById('error').innerHTML ='Please remove space from email field!';
231
        window.scrollTo(0,0); return false;
232
    }
10582 lgm 233
 
234
}
235
function dthValidation(){
11325 lgm 236
 
10582 lgm 237
	var operator = document.getElementById('dth-operator');
238
	var number = document.getElementById('dth-number').value;
239
	var amount = document.getElementById('dth-amount').value;
240
	var email = document.getElementById("dth-email").value;
10806 lgm 241
	var value = document.getElementById('accountName').innerHTML;
242
	value = value.split(':')[0];
10582 lgm 243
	document.getElementById('dth_hidden').value = operator[operator.selectedIndex].text;
244
	email = email.trim();
245
    var atpos = email.indexOf("@");
246
    var dotpos = email.lastIndexOf(".");
11721 lgm 247
    number = number.trim();
10582 lgm 248
	if(operator.selectedIndex == 0){
249
		document.getElementById('error').style.display = "block";
250
        document.getElementById('error').innerHTML ='Please select your operator!';
251
        window.scrollTo(0,0); return false;
252
	}
253
	if(number ==''){    
254
		document.getElementById('error').style.display = "block";
10948 lgm 255
		document.getElementById('error').innerHTML ='Please enter the '+value+'!';
10582 lgm 256
		window.scrollTo(0,0); return false;
257
	}
10748 lgm 258
    if(!/^\d+$/.test(number)){
259
        document.getElementById('error').style.display = "block";
10806 lgm 260
		document.getElementById('error').innerHTML ='Please Use numbers only for '+value+' field!';
10748 lgm 261
		window.scrollTo(0,0); return false;
262
	}
10582 lgm 263
	if(amount ==''){    
264
		document.getElementById('error').style.display = "block";
265
		document.getElementById('error').innerHTML ='Please fill recharge amount!';
266
		window.scrollTo(0,0); return false;
267
	}
10748 lgm 268
    if(!/^\d+$/.test(amount)){
10582 lgm 269
        document.getElementById('error').style.display = "block";
270
		document.getElementById('error').innerHTML ='Please Use numbers only!';
271
		window.scrollTo(0,0); return false;
272
	}
273
	if((parseInt(amount) < 200) || (parseInt(amount) > 2000)){
274
        document.getElementById('error').style.display = "block";
275
		document.getElementById('error').innerHTML ='Recharge amount should be between Rs. 200-2000';
276
		window.scrollTo(0,0); return false;
277
	}
278
 
279
  	if(email ==''){     
280
        document.getElementById('error').style.display = "block";
281
        document.getElementById('error').innerHTML ='Please fill email field!';
282
        window.scrollTo(0,0); return false;}
283
  	if((atpos<1) || (dotpos < atpos+2) || (dotpos+2 >= email.length)){
284
        document.getElementById('error').style.display = "block";
285
        document.getElementById('error').innerHTML ='Please fill email in correct format!';
286
        window.scrollTo(0,0); return false;
287
    }    
288
  	if(email.length> 50){  
289
        document.getElementById('error').style.display = "block";
290
        document.getElementById('error').innerHTML ='Please enter less than 50 characters in email field!';
291
        window.scrollTo(0,0); return false;
292
    }
293
    if(email.indexOf(' ') != -1){  
294
        document.getElementById('error').style.display = "block";
295
        document.getElementById('error').innerHTML ='Please remove space from email field!';
296
        window.scrollTo(0,0); return false;
297
    }
298
 
299
}
300
 
301
function recahrgeAmount(){
11325 lgm 302
 
10582 lgm 303
	var couponCode = document.getElementById('couponCode').value;
304
	var recharge_Amount = document.getElementById('recharge_Amount').innerHTML;
305
	var rechargeOperator = document.getElementById('rechargeOperator').innerHTML;
306
	if(couponCode.length !=0){
307
		var url = base_url+'recharge/rechargeAmount/'+recharge_Amount+'/'+couponCode;
308
		microAjax(url, function (res) {
11325 lgm 309
 
10582 lgm 310
		    	if(res != '')
311
		    	{
312
		    		var data = JSON.parse(res);
313
		    		if(parseInt(data.couponAmount) == 0){
314
		    			document.getElementById('error').style.display = "block";
315
	        			document.getElementById('error').innerHTML ='Invalid Coupon Code!';
316
		    		}
317
		    		else{
318
		    			if(data.payAmount == 0){
319
		    				if(document.getElementById('captcha').style.display == 'none'){
320
		    					changeCaptcha();
321
		    				}
322
		    				//document.getElementById('amount').value = parseInt(data.payAmount);
11330 lgm 323
			    			//document.getElementById('recharge_Amount').innerHTML = parseInt(data.payAmount);
11289 lgm 324
			    			document.getElementById('payAmount').innerHTML = parseInt(data.payAmount);
10582 lgm 325
			    			if(document.getElementById('walletAmount')){
11330 lgm 326
			    				if(parseInt(data.walletAmount) == 0){
327
			    					document.getElementById('walletAmount').style.display = 'none';
328
			    					document.getElementById('waText').style.display = 'none';
329
			    				}else{
330
			    					document.getElementById('walletAmount').innerHTML = parseInt(data.walletAmount);
331
			    				}
10582 lgm 332
			    			}
333
			    			if(document.getElementById('walletAmountLeft')){
11330 lgm 334
			    				if(parseInt(data.walletAmountLeft) == 0 || data.walletAmountLeft == undefined){
335
			    					document.getElementById('walletAmountLeft').style.display = 'none';
336
			    					document.getElementById('walText').style.display = 'none';
337
			    				}else{
338
			    					document.getElementById('walletAmountLeft').innerHTML = parseInt(data.walletAmountLeft);
339
			    				}
340
			    			}
10582 lgm 341
			    			document.getElementById('coupon_code').value = document.getElementById('couponCode').value;
11289 lgm 342
			    			document.getElementById('payAmount').value = parseInt(data.payAmount);
10582 lgm 343
			    			document.getElementById('coupon').style.display = "none";
344
		        			document.getElementById('coupon_msg').innerHTML ='Coupon Code applied!';
345
		        			document.getElementById('submit').value ='Recharge Now';
346
		    			}else{
347
		    				//document.getElementById('amount').value = parseInt(data.payAmount);
11330 lgm 348
			    			//document.getElementById('recharge_Amount').innerHTML = parseInt(data.payAmount);
10582 lgm 349
			    			document.getElementById('payAmount').innerHTML = parseInt(data.payAmount);
350
			    			document.getElementById('coupon_code').value = document.getElementById('couponCode').value;
351
			    			document.getElementById('payAmount').value = parseInt(data.payAmount);
352
			    			document.getElementById('coupon').style.display = "none";
353
		        			document.getElementById('coupon_msg').innerHTML ='Coupon Code applied!';
354
		    			}
355
		    		}
356
		    	}
357
			});
358
	}
359
	else{
360
		document.getElementById('error').style.display = "block";
361
	    document.getElementById('error').innerHTML ='Please enter a Coupon Code!';
362
	}
363
}
364
 
365
function clearError(){
366
	if(document.getElementById('error').style.display == "block"){
367
		document.getElementById('error').style.display = "none";
368
	}
369
}
370
window.onload=function(){
371
	var value = localStorage.getItem('rechargeValue');
372
	if(parseInt(value) == 2){
373
		if(document.getElementsByClassName('mobile-recharge')[0]){
374
			document.getElementsByClassName('mobile-recharge')[0].style.display = 'none';
375
	    	document.getElementsByClassName('dth-recharge')[0].style.display = 'block';
376
	    	document.getElementsByClassName('mobile-re')[0].className = 'mobile-re';
377
	    	document.getElementsByClassName('dth-re')[0].className += ' selected';
378
		}
379
	}
380
};
381
function changePayment(e){
11325 lgm 382
 
10582 lgm 383
  var Id = e.currentTarget.id;
384
  var defaultId = defaultPayment.id;
385
  if(defaultId != Id){
11027 lgm 386
  	var title = e.currentTarget.textContent.split('+')[0];
10582 lgm 387
    document.getElementById(defaultId).className = 'card';
388
    defaultPayment.nextElementSibling.style.display = 'none';
389
    defaultPayment.children[0].innerHTML = '+';
390
    document.getElementById(Id).className += ' selected';
391
    document.getElementById(Id).children[0].innerHTML = '-';
392
    e.currentTarget.nextElementSibling.style.display = 'block';
393
    //document.getElementById(Id).style.display = 'block';
394
    defaultPayment = e.currentTarget;
12524 anikendra 395
    /*if(typeof _gaq != "undefined" && _gaq != null)  {
11027 lgm 396
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab clicked',title]);
12524 anikendra 397
    }*/
398
	ga('send', 'event', 'Payment Option', 'Payment option tab clicked', title);
10582 lgm 399
  }
400
}
401
var previousDebit;
402
function selectDebitCard(e){
11325 lgm 403
 
10582 lgm 404
  var Id = e.currentTarget.id;
405
  if(previousDebit == undefined){
406
    document.getElementById(Id).className = 'selected';
407
  }
408
  else if(previousDebit != undefined){
409
    document.getElementById(previousDebit).className = '';
410
    document.getElementById(Id).className = 'selected'; 
411
  }
412
  document.getElementById('pay-debit').value = Id;
413
  previousDebit = Id;
11027 lgm 414
  var title = e.currentTarget.getAttribute('data-parent');
415
  title = title+'-'+Id;
12524 anikendra 416
/*
11027 lgm 417
  if(typeof _gaq != "undefined" && _gaq != null)  {
418
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
419
    }
12524 anikendra 420
*/
421
	ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
10582 lgm 422
}
13350 anikendra 423
function selectPayu(e){
424
 
425
  var Id = e.currentTarget.id;
426
  console.log(Id);
427
  document.getElementById('pay-payu').value = Id;
428
  var title = e.currentTarget.getAttribute('data-parent');
429
  title = title+'-'+Id;
430
  ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
431
}
10582 lgm 432
var previousCard;
433
function selectCard(e){
11325 lgm 434
 
10582 lgm 435
  var Id = e.currentTarget.id;
436
  if(previousCard == undefined){
437
    document.getElementById(Id).className = 'selected';
438
  }
439
  else if(previousCard != undefined){
440
    document.getElementById(previousCard).className = '';
441
    document.getElementById(Id).className = 'selected'; 
442
  }
443
  document.getElementById('pay-credit').value = Id;
444
  previousCard = Id;
11027 lgm 445
  var title = e.currentTarget.getAttribute('data-parent');
446
  title = title+'-'+Id;
12524 anikendra 447
/*
11027 lgm 448
  if(typeof _gaq != "undefined" && _gaq != null)  {
449
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
450
    }
12524 anikendra 451
*/
452
	ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
10582 lgm 453
}
11092 lgm 454
var netBankingInfo;
11137 lgm 455
var prevClass;
10582 lgm 456
function changeNetBanking(e){
11325 lgm 457
 
10678 lgm 458
  var Id;
11131 lgm 459
  var selected;
11137 lgm 460
  var hasClass;
10678 lgm 461
  Id = e.currentTarget.value;
462
  if(Id == undefined){
11131 lgm 463
    selected = 1;
10678 lgm 464
    Id = e.currentTarget.id;
11137 lgm 465
    var dropDown = document.getElementById('net');
466
    if(dropDown.selectedIndex != 0){
467
      dropDown.selectedIndex = 0;
468
    }
10678 lgm 469
  }
11092 lgm 470
  if(netBankingInfo == undefined){
11137 lgm 471
    if((selected == 1))
11131 lgm 472
    document.getElementById(Id).className = 'selected';
10678 lgm 473
  }
11092 lgm 474
  else if(netBankingInfo != undefined){
11137 lgm 475
    if((selected == 1)) {
11131 lgm 476
      document.getElementById(Id).className = 'selected';
11137 lgm 477
      if(prevClass == 'selected'){
478
        document.getElementById(netBankingInfo).className = '';   
479
      }   
480
    }else{
481
      if(prevClass == 'selected'){
482
          document.getElementById(netBankingInfo).className = '';
483
      }  
11131 lgm 484
    }
10678 lgm 485
  }
10582 lgm 486
  document.getElementById('pay-net').value = Id;
11092 lgm 487
  netBankingInfo = Id;
11137 lgm 488
  prevClass = e.currentTarget.className;
10678 lgm 489
  var title = e.currentTarget.getAttribute('data-parent');
490
  title = title+'-'+Id;
12524 anikendra 491
/*
11027 lgm 492
  if(typeof _gaq != "undefined" && _gaq != null)  {
493
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
494
    }
12524 anikendra 495
*/
496
	ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
10582 lgm 497
}
498
function submitform(){
11319 lgm 499
    if(parseInt(document.getElementById('amountPayable').value) == 0 ){
10582 lgm 500
      if(document.getElementById('captcha_response_box').value == ''){
501
        // document.forms['recharge-confirm'].submit();
502
      // }else{
503
        var bRed = document.getElementById('captcha_response_box');
504
        bRed.style.border = 'red solid 1px';
505
        bRed.style.color = 'red';
506
        bRed.value = 'Please enter the captcha' 
507
        setTimeout(function(){
508
          bRed.style.border = '';
509
          bRed.style.color = '';
510
          bRed.value = '';
511
        },3000);
512
        return false;
513
      }
514
    }
515
    var value = localStorage.getItem('rechargeValue');
516
    if(parseInt(value) == 1){
12524 anikendra 517
    	/*if(typeof _gaq != "undefined" && _gaq != null)	{
10953 lgm 518
			_gaq.push(['_trackEvent', 'Recharge', 'Confirm','Mobile']);
12524 anikendra 519
	  }*/	
520
	ga('send', 'event', 'Recharge', 'Confirm', 'Mobile');
10582 lgm 521
    }else if(parseInt(value) == 2){
12524 anikendra 522
    	/*if(typeof _gaq != "undefined" && _gaq != null)	{
523
		_gaq.push(['_trackEvent', 'Recharge', 'Confirm','DTH']);
524
	}*/
525
	ga('send', 'event', 'Recharge', 'Confirm', 'DTH');
10582 lgm 526
    }
14841 anikendra 527
 	var obj = document.getElementById('submit');
528
    obj.style.display = 'none'
529
    var textnode = document.createTextNode("Submitting");
530
    var errordiv = document.getElementById('error1');
531
    errordiv.appendChild(textnode);
532
    errordiv.style.display = 'block';
10582 lgm 533
  }
534
 function addressValidation(e){
11325 lgm 535
 
10582 lgm 536
 	var Id = e.currentTarget.id;
537
 	if(Id == 'creditcard'){
538
 		if(previousCard == undefined){
539
 			document.getElementById('error').style.display = "block";
540
	        document.getElementById('error').innerHTML ='Please select payment method!';
541
	        window.scrollTo(0,0); return false;
542
 		}
543
 	}else if(Id == 'debitcard'){
544
 		if(previousDebit == undefined){
545
 			document.getElementById('error').style.display = "block";
546
	        document.getElementById('error').innerHTML ='Please select payment method!';
547
	        window.scrollTo(0,0); return false;
548
 		}
549
 	}else if(Id == 'netbanking'){
550
 		var payOption = document.getElementById('pay-net').value;
551
 		if(payOption == undefined || payOption ==""){
552
 			document.getElementById('error').style.display = "block";
553
	        document.getElementById('error').innerHTML ='Please select payment method!';
554
	        window.scrollTo(0,0); return false;
555
 		}
556
 	}
557
 	if(document.getElementById('ccAddress')){
558
 	  var error = Id+'error';
559
 	  var fname = document.getElementById(Id).name.value;
560
	  var street1 = document.getElementById(Id).line1.value;
561
	  var street2 = document.getElementById(Id).line2.value;
562
	  var city = document.getElementById(Id).city.value;
563
	  var state = document.getElementById(Id).state.value;
564
	  var zipcode = document.getElementById(Id).pincode.value; 
565
	  var phone = document.getElementById(Id).phone.value;
10742 lgm 566
  if(fname =='')
10678 lgm 567
      {   
568
        document.getElementById('error').style.display = "block";
569
        document.getElementById('error').innerHTML ='Please fill name field!';
570
        window.scrollTo(0,0); return false;}
10742 lgm 571
  if(!removeScript(fname))
572
      {   
573
        document.getElementById('error').style.display = "block";
574
        document.getElementById('error').innerHTML ='Please remove script tags!';
575
        window.scrollTo(0,0); return false;}  
576
  if(fname.length> 50)
577
      {   
578
        document.getElementById('error').style.display = "block";
579
        document.getElementById('error').innerHTML ='Please Enter Less Than 50 Characters in name field!';
580
        window.scrollTo(0,0); return false;}
581
  if(fname !== fname.trim())
582
      {   
583
        document.getElementById('error').style.display = "block";
584
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from name field!';
585
        window.scrollTo(0,0); return false;}
586
  if(fname !== fname.replace(/\s+/g, ' '))
587
      {   
588
        document.getElementById('error').style.display = "block";
589
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from name field!';
590
        window.scrollTo(0,0); return false;}
591
  if(street1 =='')
592
      {   
593
        document.getElementById('error').style.display = "block";
594
        document.getElementById('error').innerHTML ='Please fill address field!';
595
        window.scrollTo(0,0); return false;}
596
  if(street1 != street1.trim())
597
      {   
598
        document.getElementById('error').style.display = "block";
599
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
600
        window.scrollTo(0,0); return false;}
601
  if(street1 != street1.replace(/\s+/g, ' '))
602
      {   
603
        document.getElementById('error').style.display = "block";
604
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
605
        window.scrollTo(0,0); return false;}
606
  if(!removeScript(street1))
607
      {   
608
        document.getElementById('error').style.display = "block";
609
        document.getElementById('error').innerHTML ='Please remove script tags!';
610
        window.scrollTo(0,0); return false;}
611
  if(street2 != street2.trim())
612
      {   
613
        document.getElementById('error').style.display = "block";
614
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
615
        window.scrollTo(0,0); return false;}
616
  if(street2 != street2.replace(/\s+/g, ' '))
617
      {   
618
        document.getElementById('error').style.display = "block";
619
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
620
        window.scrollTo(0,0); return false;}
621
  if(!removeScript(street2))
622
      {   
623
        document.getElementById('error').style.display = "block";
624
        document.getElementById('error').innerHTML ='Please remove script tags!';
625
        window.scrollTo(0,0); return false;}
626
  if(state == -1)
627
      {   
628
        document.getElementById('error').style.display = "block";
629
        document.getElementById('error').innerHTML ='Please fill state field!';
630
        window.scrollTo(0,0); return false;}
631
  if(!removeScript(state))
632
      {   
633
        document.getElementById('error').style.display = "block";
634
        document.getElementById('error').innerHTML ='Please remove script tags!';
635
        window.scrollTo(0,0); return false;}
636
  if(city =='')
637
      {   
638
        document.getElementById('error').style.display = "block";
639
        document.getElementById('error').innerHTML ='Please fill City field!';
640
        window.scrollTo(0,0); return false;}
641
  if(!removeScript(city))
642
      {   
643
        document.getElementById('error').style.display = "block";
644
        document.getElementById('error').innerHTML ='Please remove script tags!';
645
        window.scrollTo(0,0); return false;}
646
  if(city != city.trim())
647
      {   
648
        document.getElementById('error').style.display = "block";
649
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from city!';
650
        window.scrollTo(0,0); return false;}
651
  if(city != city.replace(/\s+/g, ' '))
652
      {   
653
        document.getElementById('error').style.display = "block";
654
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from city!';
655
        window.scrollTo(0,0); return false;}
656
  if(zipcode =='')
657
      {   
658
        document.getElementById('error').style.display = "block";
659
        document.getElementById('error').innerHTML ='Please fill pincode field!';
660
        window.scrollTo(0,0); return false;}
661
  if(zipcode.length !=6)
662
      {   
663
        document.getElementById('error').style.display = "block";
664
        document.getElementById('error').innerHTML ='Pincode should be 6 digits long';
665
        window.scrollTo(0,0); return false;}
10779 lgm 666
  if(!/^\d+$/.test(zipcode))
10742 lgm 667
      {   
668
        document.getElementById('error').style.display = "block";
669
        document.getElementById('error').innerHTML ='Please Use numbers only for pincode!';
670
        window.scrollTo(0,0); return false;}
671
  if(zipcode != zipcode.trim())
672
      {   
673
        document.getElementById('error').style.display = "block";
674
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from pincode!';
675
        window.scrollTo(0,0); return false;}
676
  if(zipcode != zipcode.replace(/\s+/g, ' '))
677
      {   
678
        document.getElementById('error').style.display = "block";
679
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from pincode!';
680
        window.scrollTo(0,0); return false;}
681
  if(phone =='')
682
      {   
683
        document.getElementById('error').style.display = "block";
684
        document.getElementById('error').innerHTML ='Please fill phone number field!';
685
        window.scrollTo(0,0); return false;}
10778 lgm 686
  if(!/^\d+$/.test(phone)){
10779 lgm 687
  		  document.getElementById('error').style.display = "block";
10742 lgm 688
          document.getElementById('error').innerHTML ='Please Use numbers only for Mobile Number!';
689
          window.scrollTo(0,0); return false;}
690
  if(phone.length != 10)
691
        {    document.getElementById('error').style.display = "block";
692
          document.getElementById('error').innerHTML ='Mobile number should be of 10 digits!';
693
          window.scrollTo(0,0); return false;}
694
  if(phone != phone.trim())
695
      {   
696
        document.getElementById('error').style.display = "block";
697
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from phone number!';
698
        window.scrollTo(0,0); return false;}
699
  if(phone != phone.replace(/\s+/g, ' '))
700
      {   
701
        document.getElementById('error').style.display = "block";
702
        document.getElementById('error').innerHTML ='Please remove excess whitespaces from phone number!';
703
        window.scrollTo(0,0); return false;}	 
10678 lgm 704
	}
11725 lgm 705
	if(document.getElementById('ccPhone')){
706
		var phone = document.getElementById(Id).phone.value;
707
		phone = phone.trim();
708
		if(phone =='')
709
      	{   
710
	        document.getElementById('error').style.display = "block";
711
	        document.getElementById('error').innerHTML ='Please fill phone number field!';
712
	        window.scrollTo(0,0); return false;
713
    	}
714
  		if(!/^\d+$/.test(phone)){
715
  			document.getElementById('error').style.display = "block";
716
        	document.getElementById('error').innerHTML ='Please Use numbers only for Mobile Number!';
717
        	window.scrollTo(0,0); return false;
718
      	}
719
	    if(phone.length != 10){    
720
	    	document.getElementById('error').style.display = "block";
721
	        document.getElementById('error').innerHTML ='Mobile number should be of 10 digits!';
722
	        window.scrollTo(0,0); return false;
723
	    }
724
  		if(phone != phone.replace(/\s+/g, ' '))
725
      	{   
726
        	document.getElementById('error').style.display = "block";
727
        	document.getElementById('error').innerHTML ='Please remove excess whitespaces from phone number!';
728
        	window.scrollTo(0,0); return false;
729
        }	 
730
	}
10582 lgm 731
	var value = localStorage.getItem('rechargeValue');
732
    if(parseInt(value) == 1){
12524 anikendra 733
    	/*if(typeof _gaq != "undefined" && _gaq != null)	{
734
		_gaq.push(['_trackEvent', 'Recharge', 'Pay Now','Mobile']);
735
	}*/
736
	ga('send', 'event', 'Recharge', 'Pay Now', 'Mobile');
10582 lgm 737
    }else if(parseInt(value) == 2){
12524 anikendra 738
    	/*if(typeof _gaq != "undefined" && _gaq != null)	{
739
		_gaq.push(['_trackEvent', 'Recharge', 'Pay Now','DTH']);
740
	}*/
741
	ga('send', 'event', 'Recharge', 'Pay Now', 'DTH');
10582 lgm 742
    }
743
 }
744
 var url;
745
 url = document.URL;
746
 if(url.indexOf('recharge-result') != -1){
12085 lgm 747
 	// if(orderConfirmation != undefined){
748
 	// 	var amount = parseFloat(orderConfirmation['response'].totalAmount).toFixed(2);
749
 	// 	var orderId = orderConfirmation['response'].rechargeDisplayId;
750
 	// 	var deviceNumber = orderConfirmation['response'].rechargeDeviceNumber;
751
 	// 	_gaq.push(['_addTrans',
752
		// 	orderId,                     // Transaction ID. Required.
753
		// 	'Saholic',   // Affiliation or store name.
754
		// 	amount,               // Grand Total.
755
		// 	'0',                  // Shipping.
756
		// 	'0',                     // Tax.
757
		// 	"",
758
		// 	"",
759
		// 	"India"
760
		// ]);
761
		// _gaq.push(['_addItem',
762
		// 	orderId,                     // Transaction ID. Required.			
763
		// 	deviceNumber,                 // SKU/code.
764
		// 	orderConfirmation['response'].rechargeProvider,    // Product name. Required.
765
		// 	'Digital',         // Category or variation.
766
		// 	amount,                 // Unit price.
767
		// 	'1'                   // Quantity.
768
		// ]);
769
		//  _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
770
 	// }
11885 anikendra 771
 }