Subversion Repositories SmartDukaan

Rev

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