Subversion Repositories SmartDukaan

Rev

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