PageSourceSearch

https://www.ifaxapp.com/wp-content/themes/jumpstart-child/assets/js/controllers.js?v=7.30.5

js ifaxapp.com collected 2026-09-24 09:38:19 UTC 171,444 bytes, 4,686 lines download raw bytes

1var vurl = location.href;
2var baseURL = vurl.substring(0, vurl.indexOf('/', 14));
3var ifaxapp = angular.module('iFax',['ngSanitize'])
4    .config(function ($interpolateProvider) {
5        $interpolateProvider.startSymbol('[[');
6        $interpolateProvider.endSymbol(']]');
7    })
8    .constant('config', {
9        BASE_URL: baseURL + '/'
10    });
11ifaxapp.directive('onlyDigits', function () {
12
13    return {
14        restrict: 'A',
15        require: '?ngModel',
16        link: function (scope, element, attrs, modelCtrl) {
17            modelCtrl.$parsers.push(function (inputValue) {
18                if (inputValue == undefined) return '';
19                var transformedInput = inputValue.replace(/[^0-9]/g, '');
20                if (transformedInput !== inputValue) {
21                    modelCtrl.$setViewValue(transformedInput);
22                    modelCtrl.$render();
23                }
24                return transformedInput;
25            });
26        }
27    };
28});
29ifaxapp.directive('customRange', function ($timeout) {
30  return {
31    restrict: 'A',
32    scope: {
33      min: '@?',
34      max: '@?',
35      value: '=ngModel'
36    },
37    link: function (scope, element) {
38      var prefs = ['webkit-slider-runnable-track', 'moz-range-track', 'ms-track'];
39
40      function getTrackStyle(val, min, max) {
41        var steps = max - min;
42        var percent = ((val - min) / steps) * 100;
43
44        var style = '';
45        prefs.forEach(function (p) {
46          style += '.range input::-' + p + ' {' +
47            'background: linear-gradient(to right, #A0EAFF 0%, #5C9DFF ' + percent + '%, #9292922B ' + percent + '%, #9292922B 100%);' +
48            '}';
49        });
50        return style;
51      }
52
53      // Add dynamic <style> tag
54      var sheet = document.createElement('style');
55      document.head.appendChild(sheet);
56
57      function update() {
58        var curVal = parseInt(scope.value || scope.min || 1, 10);
59        var min = parseInt(scope.min || 1, 10);
60        var max = parseInt(scope.max || 8, 10);
61
62        // Update style
63        sheet.textContent = getTrackStyle(curVal, min, max);
64      }
65
66      // Watch for value change
67      scope.$watch('value', function () {
68        update();
69      });
70
71      // Initialize
72      $timeout(update);
73    }
74  };
75});
76ifaxapp.directive('bootstrapTooltip', function ($timeout) {
77    return {
78        restrict: 'A',
79        link: function (scope, element, attrs) {
80            scope.$watch(attrs.tooltipTitle, function (newVal) {
81                $timeout(function () {
82                    element.attr('title', newVal).tooltip('dispose').tooltip();
83                });
84            });
85        }
86    };
87});
88ifaxapp.directive('onlyString', function () {
89
90    return {
91        restrict: 'A',
92        require: '?ngModel',
93        link: function (scope, element, attrs, modelCtrl) {
94            modelCtrl.$parsers.push(function (inputValue) {
95                if (inputValue == undefined) return '';
96                var transformedInput = inputValue.replace(/[^A-Za-z ]/g, '');
97                if (transformedInput !== inputValue) {
98                    modelCtrl.$setViewValue(transformedInput);
99                    modelCtrl.$render();
100                }
101                return transformedInput;
102            });
103        }
104    };
105});
106var compareTo = function () {
107    return {
108        require: "ngModel",
109        scope: {
110            otherModelValue: "=compareTo"
111        },
112        link: function (scope, element, attributes, ngModel) {
113
114            ngModel.$validators.compareTo = function (modelValue) {
115                if(!modelValue){
116                	return true;
117                }
118                return modelValue == scope.otherModelValue;
119            };
120
121            scope.$watch("otherModelValue", function () {
122                ngModel.$validate();
123            });
124        }
125    };
126};
127
128ifaxapp.directive("compareTo", compareTo);
129
130ifaxapp.controller('controllers', function($scope, $http,config,$timeout,$location,$window,$compile) { 
131	// alert('hiii')
132	
133	$scope.getCookie = function(cname) {
134	  let name = cname + "=";
135	  let decodedCookie = decodeURIComponent(document.cookie);
136	  let ca = decodedCookie.split(';');
137	  for(let i = 0; i <ca.length; i++) {
138	    let c = ca[i];
139	    while (c.charAt(0) == ' ') {
140	      c = c.substring(1);
141	    }
142	    if (c.indexOf(name) == 0) {
143	      return c.substring(name.length, c.length);
144	    }
145	  }
146	  return "";
147	}
148	$scope.setCookie = function(cname, cvalue, exdays = 365){
149	  const d = new Date();
150	  d.setTime(d.getTime() + (exdays*24*60*60*1000));
151	  let expires = "expires="+ d.toUTCString();
152	  document.cookie = cname + "=" + cvalue + ";" + expires + ";domain=.ifaxapp.com;path=/";
153	  if(cname == "g_state"){
154	  	document.cookie = cname + "=" + cvalue + ";" + expires + ";domain=www.ifaxapp.com;path=/";
155	  }
156	}
157
158	if (window.location.href.includes('contact-sales') || window.location.href.includes('fax-api-draft-new') || window.location.href.includes('/lp/fax-api')) {
159
160	    hbspt.forms.create({
161	      portalId: "6530257",
162	      formId: "5648823f-6546-41a7-b012-1c19f59e997e",
163	      target: "body .hubspot_iframe",
164	      onFormReady: ($form) => {
165	        $form.find('#phone_ext-5648823f-6546-41a7-b012-1c19f59e997e').css('cssText', 'width: 120px !important');
166	        $form.find('#phone_ext-5648823f-6546-41a7-b012-1c19f59e997e').css({ 'min-width': '120px' });
167
168	        $form.find('#phone-5648823f-6546-41a7-b012-1c19f59e997e').css({ 'min-width': 'calc(100% - 127px)', 'max-width': 'calc(100% - 127px)', 'padding': '5px' });
169
170			if(window.location.href.includes('fax-api-draft-new')){
171				$form.find('.hs_company').css({ 'width': '100%' });
172				$form.find('#email-5648823f-6546-41a7-b012-1c19f59e997e').css({ 'width': '100%' });
173				$form.find('#company-5648823f-6546-41a7-b012-1c19f59e997e').css({ 'width': '100%' });
174				
175				$form.find('.hs_phone').css({ 'width': '100%' });
176				$form.find('.hs_email').css({ 'width': '100%' });
177				$form.find('.hs_monthly_page_ranges').css({ 'width': '100%' });
178				$form.find('.hs_preferred_channel_partners_tsd_msp').css({ 'display': 'none' });
179
180				$form.find('.hs-button.primary.large').css({ 'width': '100%' });
181				
182			}
183
184	        $form.find('div.input').css({ 'margin-right': '0px'});
185
186	        $form.find('select[name="monthly_page_ranges"]').change(function(){
187	        	let value = this.value;
188	        	let finalValue = 0;
189				  if (value.includes("Less than")) {
190				    const number = value.replace(/\D/g, '');
191				    finalValue = number;
192				    // console.log("Max Value:", parseInt(number) - 1);
193				  }
194				  else if (value.includes("+")) {
195				    const number = value.replace(/\D/g, '');
196				    finalValue = number;
197				    // console.log("Max Value:", parseInt(number));
198				  }
199				  else {
200				    const parts = value.split("-");
201				    const max = parts[1].replace(/\D/g, '');
202				    finalValue = max;
203				    // console.log("Max Value:", parseInt(max));
204				  }
205
206	        	$form.find('input[name="pages_received_mo"]').val(finalValue);
207	        });
208	        
209
210	        var ss = $scope.getCookie('trackFeature');
211	        if (ss != '') {
212	          $form.find('input[name="product_category"]').val(ss).change();
213	        } else {
214	          $form.find('input[name="product_category"]').val('App').change();
215	        }
216
217	        var ss = $scope.getCookie('pagesFromPricingPage');
218	        if(ss != ''){
219	        	$form.find('select[name="monthly_page_ranges"]').val(ss).change();
220	        }
221
222
223	        // console.log("full width", window.innerWidth);
224	        if (window.innerWidth < 481) {
225	          // console.log("mobile", )
226	          $form.find('.actions').css({ 'margin-top': '30px'});
227	        } else {
228	          $form.find('.actions').css({ 'margin-top': '0px', 'padding-top': '10px'});
229	        }
230	        
231
232	      },
233	      onFormSubmit: ($form) => {
234	        let email = $form.find('input[name="email"]').val();
235	        let firstname = $form.find('input[name="firstname"]').val();
236	        let lastname = $form.find('input[name="lastname"]').val();
237	        let mobile = $form.find('input[name="phone"]').val();
238	        let company = $form.find('input[name="company"]').val();
239	        let pages = $form.find('select[name="monthly_page_ranges"]').val();
240	        
241
242	        // window.hj('identify', null, {
243	        //   'Hubspot Email': email,
244	        // });
245
246	        $scope.setCookie('_hubspot_email', email);
247	        $scope.setCookie('_hubspot_firstname', firstname);
248	        $scope.setCookie('_hubspot_lastname', lastname);
249	        $scope.setCookie('_hubspot_mobile', mobile);
250	        $scope.setCookie('_hubspot_company', company);
251	        $scope.setCookie('_hubspot_pages', pages);
252	        // window.goal_set_track('/get-quote-website');
253	      },
254	      onFormSubmitted: ($form) => {
255
256			
257	        let dataInstanceId = $form.attr('data-instance-id');
258			window.dataLayer = window.dataLayer || [];
259			window.dataLayer.push({
260			'event': 'hubspot-form-success',
261			'form_id': '5648823f-6546-41a7-b012-1c19f59e997e',
262			'form_name': 'contact-sales'
263			});
264	        // console.log('_hubspot_pages', $scope.getCookie('_hubspot_pages'));
265	        if ($scope.getCookie('_hubspot_pages') == 'Less than 1,000') {
266	          window.location.href = "https://web.ifaxapp.com/message-sales";
267	        } else {
268	          window.location.href = "https://web.ifaxapp.com/schedule-meeting?submissionGuid=" + dataInstanceId;
269	        }
270
271	      },
272	    });
273
274	}
275
276
277	if (window.location.href.includes('/partners/contact') || window.location.href.includes('/complete-page')) {
278		
279	    hbspt.forms.create({
280	      portalId: "6530257",
281	      formId: "33c7983d-d52c-4366-99de-fa3f131015c6",
282	      target: "body .hubspot_iframe",
283	      onFormReady: ($form) => {
284
285	        $form.find('#phone_ext-33c7983d-d52c-4366-99de-fa3f131015c6').css('cssText', 'width: 120px !important');
286	        $form.find('#phone_ext-33c7983d-d52c-4366-99de-fa3f131015c6').css({ 'min-width': '120px' });
287
288	        $form.find('#phone-33c7983d-d52c-4366-99de-fa3f131015c6').css({ 'min-width': 'calc(100% - 127px)', 'max-width': 'calc(100% - 127px)', 'padding': '5px' });
289	        $form.find('#notes-text').css({ 'position': 'absolute', 'bottom': '10px' });
290	        // if (this._guestservice.getCookie('_fprom_code') != undefined && this._guestservice.getCookie('_fprom_code')) {
291	        //   let name = this._guestservice.getCookie('_fprom_code').split('_r_');
292	        //   this._api.firstpromoter(name[1]).subscribe((res) => {
293
294	        //     $form.find('input[name="promoter"]').val(res.email).change();
295	        //   })
296	        // }
297	      },
298	      onFormSubmitted: ($form) => {
299	        let email = $form.find('input[name="email"]').val();
300	        let firstname = $form.find('input[name="firstname"]').val();
301	        let lastname = $form.find('input[name="lastname"]').val();
302	        let mobile = $form.find('input[name="phone"]').val();
303	        let company = $form.find('input[name="company"]').val();
304			$scope.setCookie('trackFeature','Reseller');
305	        $scope.setCookie('_hubspot_email', email);
306	        $scope.setCookie('_hubspot_firstname', firstname);
307	        $scope.setCookie('_hubspot_lastname', lastname);
308	        $scope.setCookie('_hubspot_mobile', mobile);
309	        $scope.setCookie('_hubspot_company', company);
310
311	      },
312	    });
313
314	}
315
316	if (window.location.href.includes('ifax-enterprise')) {
317
318	    hbspt.forms.create({
319	      portalId: "6530257",
320	      formId: "5648823f-6546-41a7-b012-1c19f59e997e",
321	      target: "body .hubspot_iframe",
322	      translations: {
323	        en: {
324	          submitText: "REQUEST A QUOTE",
325	        }
326	      },
327	      onFormReady: ($form) => {
328	        $form.find('#phone_ext-5648823f-6546-41a7-b012-1c19f59e997e').css('cssText', 'width:120px!important');
329	        $form.find('#phone_ext-5648823f-6546-41a7-b012-1c19f59e997e').css({ 'min-width': '120px', 'border': '0 none', 'border-radius': '0px', 'padding': '0 10px', 'height': '28px' });
330
331	        $form.find('#phone-5648823f-6546-41a7-b012-1c19f59e997e').css({ 'min-width': 'calc(100% - 130px)', 'max-width': 'calc(100% - 130px)', 'padding': '0 5px', 'border': '0 none', 'border-radius': '0px', 'padding-left': '15px', 'margin-left': '10px', 'height': '28px', 'border-left': '2px solid #cbd6e2' });
332	        $form.find('.hs_phone.hs-phone.hs-fieldtype-phonenumber.field.hs-form-field').css({ 'width': '100%' });
333
334	        $form.find('.form-columns-2 .hs-form-field').css({ 'width': '100%' });
335
336	        $form.find('input.hs-input').css({ 'width': '100%' });
337
338	        $form.find('.actions').css({ 'margin-top': '0px', 'margin-bottom': '0px', 'padding-top': '10px' });
339	        $form.find('.hs-button').css({ 'width': '100%' });
340
341	        $form.find('div.input').css({ 'margin-right': '0px' });
342	        $form.find('#phone_ext-5648823f-6546-41a7-b012-1c19f59e997e').parent('.hs-input').parent('.input').css({ 'background-color': '#f5f8fa', 'border': '1px solid #cbd6e2', 'border-radius': '3px', 'padding': '5px 0' });
343
344	        var ss = $scope.getCookie('trackFeature');
345	        if (ss != '') {
346	          $form.find('input[name="product_category"]').val(ss).change();
347	        } else {
348	          $form.find('input[name="product_category"]').val('App').change();
349	        }
350	        // console.log(window.innerWidth);
351	        if (window.innerWidth < 768) {
352	          $form.find('.form-columns-2 .hs_firstname.hs-form-field').css({ 'width': '100%', 'padding-right': '0px' });
353	          $form.find('.form-columns-2 .hs_lastname.hs-form-field').css({ 'width': '100%', 'padding-left': '0px' });
354	        } else {
355	          $form.find('.form-columns-2 .hs_firstname.hs-form-field').css({ 'width': '50%', 'padding-right': '7px' });
356	          $form.find('.form-columns-2 .hs_lastname.hs-form-field').css({ 'width': '50%', 'padding-left': '7px' });
357	        }
358	      },
359	      onFormSubmit: ($form) => {
360	        let email = $form.find('input[name="email"]').val();
361	        let firstname = $form.find('input[name="firstname"]').val();
362	        let lastname = $form.find('input[name="lastname"]').val();
363	        let mobile = $form.find('input[name="phone"]').val();
364	        let company = $form.find('input[name="company"]').val();
365	        let pages = $form.find('select[name="monthly_page_ranges"]').val();
366	        // window.hj('identify', null, {
367	        //   'Hubspot Email': email,
368	        // });
369
370	        $scope.setCookie('_hubspot_email', email);
371	        $scope.setCookie('_hubspot_firstname', firstname);
372	        $scope.setCookie('_hubspot_lastname', lastname);
373	        $scope.setCookie('_hubspot_mobile', mobile);
374	        $scope.setCookie('_hubspot_company', company);
375	        $scope.setCookie('_hubspot_pages', pages);
376	        // window.goal_set_track('/get-quote-website');
377	      },
378	      onFormSubmitted: ($form) => {
379	        let dataInstanceId = $form.attr('data-instance-id');
380	        // console.log('_hubspot_pages', $scope.getCookie('_hubspot_pages'));
381	        if ($scope.getCookie('_hubspot_pages') == 'Less than 1,000') {
382	          window.location.href = "https://web.ifaxapp.com/message-sales";
383	        } else {
384	          window.location.href = "https://web.ifaxapp.com/schedule-meeting?submissionGuid=" + dataInstanceId;
385	        }
386
387	      },
388	    });
389
390	}
391	$scope.closeBanner = function() {
392		$scope.setCookie('amplify_banner_closed', 'true');
393		jQuery('.amplify-top-banner').remove();
394	}	
395	if (window.location.href.includes('faxing-api')) {
396
397	    hbspt.forms.create({
398	      portalId: "6530257",
399	      formId: "5648823f-6546-41a7-b012-1c19f59e997e",
400	      target: "body .hubspot_iframe",
401	      translations: {
402	        en: {
403	          submitText: "REQUEST A QUOTE",
404	        }
405	      },
406	      onFormReady: ($form) => {
407	        $form.find('#phone_ext-5648823f-6546-41a7-b012-1c19f59e997e').css('cssText', 'width:120px!important');
408	        $form.find('#phone_ext-5648823f-6546-41a7-b012-1c19f59e997e').css({ 'min-width': '120px', 'border': '0 none', 'border-radius': '0px', 'padding': '0 10px', 'height': '28px' });
409
410	        $form.find('#phone-5648823f-6546-41a7-b012-1c19f59e997e').css({ 'min-width': 'calc(100% - 130px)', 'max-width': 'calc(100% - 130px)', 'padding': '0 5px', 'border': '0 none', 'border-radius': '0px', 'padding-left': '15px', 'margin-left': '10px', 'height': '28px', 'border-left': '2px solid #cbd6e2' });
411	        $form.find('.hs_phone.hs-phone.hs-fieldtype-phonenumber.field.hs-form-field').css({ 'width': '100%' });
412
413	        $form.find('.form-columns-2 .hs-form-field').css({ 'width': '100%' });
414
415	        $form.find('input.hs-input').css({ 'width': '100%' });
416
417	        $form.find('.actions').css({ 'margin-top': '0px', 'margin-bottom': '0px', 'padding-top': '10px' });
418	        $form.find('.hs-button').css({ 'width': '100%' });
419
420	        $form.find('div.input').css({ 'margin-right': '0px' });
421	        $form.find('#phone_ext-5648823f-6546-41a7-b012-1c19f59e997e').parent('.hs-input').parent('.input').css({ 'background-color': '#f5f8fa', 'border': '1px solid #cbd6e2', 'border-radius': '3px', 'padding': '5px 0' });
422
423	        var ss = $scope.getCookie('trackFeature');
424	        if (ss != '') {
425	          $form.find('input[name="product_category"]').val(ss).change();
426	        } else {
427	          $form.find('input[name="product_category"]').val('App').change();
428	        }
429	        // console.log(window.innerWidth);
430	        if (window.innerWidth < 768) {
431	          $form.find('.form-columns-2 .hs_firstname.hs-form-field').css({ 'width': '100%', 'padding-right': '0px' });
432	          $form.find('.form-columns-2 .hs_lastname.hs-form-field').css({ 'width': '100%', 'padding-left': '0px' });
433	        } else {
434	          $form.find('.form-columns-2 .hs_firstname.hs-form-field').css({ 'width': '50%', 'padding-right': '7px' });
435	          $form.find('.form-columns-2 .hs_lastname.hs-form-field').css({ 'width': '50%', 'padding-left': '7px' });
436	        }
437	      },
438	      onFormSubmit: ($form) => {
439	        let email = $form.find('input[name="email"]').val();
440	        let firstname = $form.find('input[name="firstname"]').val();
441	        let lastname = $form.find('input[name="lastname"]').val();
442	        let mobile = $form.find('input[name="phone"]').val();
443	        let company = $form.find('input[name="company"]').val();
444	        let pages = $form.find('select[name="monthly_page_ranges"]').val();
445	        // window.hj('identify', null, {
446	        //   'Hubspot Email': email,
447	        // });
448
449	        $scope.setCookie('_hubspot_email', email);
450	        $scope.setCookie('_hubspot_firstname', firstname);
451	        $scope.setCookie('_hubspot_lastname', lastname);
452	        $scope.setCookie('_hubspot_mobile', mobile);
453	        $scope.setCookie('_hubspot_company', company);
454	        $scope.setCookie('_hubspot_pages', pages);
455	        // window.goal_set_track('/get-quote-website');
456	      },
457	      onFormSubmitted: ($form) => {
458	        let dataInstanceId = $form.attr('data-instance-id');
459	        // console.log('_hubspot_pages', $scope.getCookie('_hubspot_pages'));
460	        if ($scope.getCookie('_hubspot_pages') == 'Less than 1,000') {
461	          window.location.href = "https://web.ifaxapp.com/message-sales";
462	        } else {
463	          window.location.href = "https://web.ifaxapp.com/schedule-meeting?submissionGuid=" + dataInstanceId;
464	        }
465
466	      },
467	    });
468
469	}
470	$scope.showNow = 0;
471	$scope.defaultGoogle = false;
472	$scope.weburl = window.weburl;
473	$scope.webappurl = window.webappurl;
474	$scope.apiurl = window.apiurl;
475	$scope.my_userID = $scope.getCookie('_userID');
476	$scope.my_email = $scope.getCookie('_email');
477	$scope.my_login_type = $scope.getCookie('_social_login');
478	$scope.uuid = $scope.getCookie('uuid');
479	var ngurl = window.location.href;
480	
481    var ngparts = ngurl.split("/");
482    var nglast_part = ngparts[ngparts.length - 1];
483    if(nglast_part == ''){
484      nglast_part = ngparts[ngparts.length - 2];
485    }
486    $scope.cancel_msg = "";
487	$scope.pagename = nglast_part;
488	$scope.showLoginButton = 0;
489	$scope.showFlag = true;
490	$scope.cjevent = window.cjevent;
491	$scope.noofuser = 1;
492	$scope.globalDuration = 12;
493	$scope.selectedNumbers = 1;
494	$scope.arrCountry = [];
495	$scope.alert = {
496
497	}
498    $scope.selectedPages = 1000;
499    $scope.variantID = 3;
500    // show popup for techshoup company user only
501    const ref = new Proxy(new URLSearchParams(window.location.search), {
502	  get: (searchParams, prop) => searchParams.get(prop),
503	});
504
505    $scope.capitalize = function(string) {
506	  return string.charAt(0).toUpperCase() + string.slice(1);
507	}
508
509	if(ref.referral && ref.referral != ''){
510		if(!$scope.getCookie('techsoup_cookie')){
511			setTimeout(function(){
512				$scope.techsoupTitle = "Hello "+$scope.capitalize(ref.referral)+" User";
513				$scope.setCookie('techsoup_cookie',ref.referral);
514				jQuery('#techsoupModal').modal();	
515			},500)
516			
517		}
518		
519	}
520
521
522	$scope.sliderOptions = [
523	    { id: 1, label: "200" },
524	    { id: 2, label: "500" },
525	    { id: 3, label: "1K" },
526	    { id: 4, label: "5K" },
527	    { id: 5, label: "10K" },
528	    { id: 6, label: "50K" },
529	    { id: 7, label: "100K" },
530	    { id: 8, label: "500K" },
531	    { id: 9, label: "1M+" }
532	  ];
533	$scope.confirmation = function(type,buttonNumber,data = ''){
534		// console.log(data);
535		// $scope.alert = {
536		// 	closeIcon:false,
537		// 	title:'Oops!',
538		// 	desc:'Please enter your work email',
539		// 	buttonText:'OKAY',
540		// 	buttonText2:'CLOSE',
541		// 	type:'error'		
542		// }
543		// jQuery('#alert-dialog').modal({backdrop: 'static', keyboard: false});
544		if(type == "error"){
545			if(buttonNumber == '1'){
546				jQuery('#alert-dialog').modal('hide');			
547			}
548		}else if(type=="redirect"){
549			if(buttonNumber == '1'){
550				window.location.href="https://"+data.defaultDomain;
551			}
552		}
553	}
554
555	$scope.showErrorPopup = function(closeIcon,title,desc,type,buttonText = false,buttonText2 = false,data = ''){
556		// console.log(data)
557		$scope.alert = {
558			closeIcon:closeIcon,
559			title:title,
560			desc:desc,
561			buttonText: buttonText ? buttonText : false,
562			buttonText2: buttonText2 ? buttonText2 : false,
563			type:type,
564			data: data		
565		}
566		jQuery('#alert-dialog').modal({backdrop: 'static', keyboard: false});
567	}
568
569	
570	
571	
572	if(window.location.href.indexOf("utm_medium=affiliates") >= 0){
573		$scope.setCookie('utm_medium',"affiliates");
574	}
575	
576    $scope.handleGgOneTap = function(resp) {
577	    // console.log('handleGgOneTap ', resp);
578	    resp = $scope.parseJwt(resp.credential);
579	    var obj = {
580		    app : 'angular',
581		    app_name : 'ifax',
582		    login_by : 'Google',
583		    f_name : resp.given_name,
584		    l_name : resp.family_name,
585		    user_type : 'guest',
586		    avatar : resp.picture,
587		    fax_id : '',
588		    uuid : $scope.uuid,
589		    email : resp.email,
590		    social_id : $scope.encryptRequest(resp.email) + CryptoJS.SHA256(resp.email),
591		    ipaddress : $scope.getCookie('ipaddress'),
592		    timezone : $scope.getCookie('_client_timezone'),
593		    referralUnique : $scope.getCookie('ifax_referral'),
594    		emailUnique : $scope.getCookie('ifax_referral_token')
595		  }
596		$scope.social_signin(obj);
597	  }
598
599	$scope.parseJwt = function(token) {
600	    var base64Url = token.split('.')[1];
601	    var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
602	    var jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
603	      return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
604	    }).join(''));
605
606	    return JSON.parse(jsonPayload);
607	  };
608
609	  
610	// if(window.google){
611	// 	if(window.google.accounts){
612	// 		$scope.setCookie('g_state','');
613	// 		window.google.accounts.id.initialize({
614	// 	      client_id: '924789033676-cm7ts09sujq300n5d2md93tsgvcndlvq.apps.googleusercontent.com',
615	// 	      callback: $scope.handleGgOneTap.bind(this),
616	// 	      cancel_on_tap_outside: false,
617	// 	      prompt_parent_id: 'g_id_onload',
618	// 	      // allowed_parent_origin: "https://www.ifaxapp.com"
619	// 	    });
620
621	// 	    window.google.accounts.id.prompt();   
622
623	// 	}
624	// }  
625	  
626
627	$scope.verifySAML = function(saml,state){
628		// var obj = {
629  //   		saml : saml,
630  //   		state: state
631  //   	}
632    	// obj = $scope.encryptRequest(obj);
633    	$scope.showLoader();
634    	$http({
635			method : 'POST',	
636			url : $scope.apiurl+"ajax/verifySAML",	
637			data : jQuery.param({
638				saml: saml,
639				state : state
640			}),
641	        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
642	    }).then(function(response) {
643	    	$scope.hideLoader();
644
645	    	// console.log('SAML api response',response.data)
646	    	if(response.data.code == 1){
647	    		 var obj = {
648				    app : 'angular',
649				    app_name : 'ifax',
650				    login_by : 'Google',
651				    user_type : 'guest',
652				    fax_id : '',
653				    uuid : $scope.uuid,
654				    email : response.data.result.samlNameId,
655				    social_id : $scope.encryptRequest(response.data.result.samlNameId) + CryptoJS.SHA256(response.data.result.samlNameId),
656				    ipaddress : $scope.getCookie('ipaddress'),
657				    timezone : $scope.getCookie('_client_timezone'),
658				    bySSO : 1,
659				    referralUnique : $scope.getCookie('ifax_referral'),
660    				emailUnique : $scope.getCookie('ifax_referral_token')
661				  }
662				$scope.social_signin(obj);
663	    	}else{
664	    		jQuery('#loader').hide();
665	    		toastr.error(response.data.message);
666	    	}
667	    	
668        })
669    }
670    
671    
672
673	$scope.changeUserNo = function(flag){
674		if(flag == '+'){
675			$scope.noofuser++;
676
677			if($scope.noofuser > 1){
678				jQuery('.custom-quote-btn').attr('href',$scope.weburl+'custom-quote?user='+$scope.noofuser);
679				if (jQuery(window).width() < 1366 && (window.location.href.includes('pricing') || window.location.href.includes('plans'))) {
680					$scope.carousel.trigger('to.owl.carousel', [3, 500]);
681				}
682				$scope.selectedUsers = $scope.noofuser;
683				$scope.erp.teamsubaccount = $scope.noofuser - 1;
684				$scope.erp.fax_numbers = parseInt($scope.selectedNumbers);
685		    	if($scope.selectedNumbers){
686		    		$scope.erp.send_pages = parseInt($scope.selectedPages);
687		    		$scope.erp.receive_pages = 0;
688		    	}else{
689		    		$scope.erp.send_pages = parseInt($scope.selectedPages);
690		    		$scope.erp.receive_pages = 0;
691		    	}
692				$scope.changeDuration();
693			}
694		}else{
695			if($scope.noofuser == 1){
696				return false;
697			}
698			$scope.noofuser--;
699			if($scope.noofuser == 1){
700				jQuery('.custom-quote-btn').attr('href',$scope.weburl+'custom-quote');							
701			}
702			$scope.selectedUsers = $scope.noofuser;
703			$scope.erp.teamsubaccount = $scope.noofuser - 1;
704			$scope.erp.fax_numbers = parseInt($scope.selectedNumbers);
705	    	if($scope.selectedNumbers > 0){
706	    		$scope.erp.send_pages = parseInt($scope.selectedPages);
707	    		$scope.erp.receive_pages = 0;
708	    	}else{
709	    		$scope.erp.send_pages = parseInt($scope.selectedPages);
710	    		$scope.erp.receive_pages = 0;
711	    	}
712			$scope.changeDuration();
713		}
714
715
716	}
717	
718	if (!!$scope.getCookie('cookie_policy')) {
719        // have cookie
720        jQuery(".cookie_txt_main").hide();
721    } else {
722        // no cookie
723        var cook = '<div class="cookie_accept_div">';
724        cook += '<span class="cookie_txt">
724By using this website you agree to our</span>';
725        cook += '<a target="_blank" href="https://web.ifaxapp.com/policy_pdf/iFax_Privacy_Policy.pdf" class="cookie_link">cookie policy.</a>';
726        cook += '<a href="javascript:void(0)" class="close_cookie_div" onclick="read_policy()">';
727        cook += '<i class="fa fa-close" aria-hidden="true"></i></a>';
728        cook += '</div>';
729        jQuery('.cookie_txt_main').html(cook);
730
731    }
732
733	$scope.getUserType = function(){
734		return $scope.my_userID != '' ? 'user' : 'guest';
735	}
736
737	$scope.getUserID = function(){
738		return $scope.my_userID !='' ? $scope.my_userID : $scope.uuid;
739	}
740	$scope.getSubUserID = function(){
741		return $scope.getCookie('_subUserID') ? $scope.getCookie('_subUserID') : '';
742	}
743
744	$scope.roundValue = function(price){
745		var s = price.toString().split(".");
746		if(s[1]){
747			var a =price.toString().substring(0, price.toString().indexOf(".") + 3);
748			return a;	
749		}else{
750			return price;
751		}
752		
753	}
754
755	if (ngurl.indexOf('/login') > -1)
756	{
757	  if($scope.getUserType() == 'user'){
758    		const params = new Proxy(new URLSearchParams(window.location.search), {
759			  get: (searchParams, prop) => searchParams.get(prop),
760			});
761			if(params.redirect){
762				window.location.href = params.redirect;
763			}else{
764				window.location.href = webappurl;	
765			}
766    	}
767	}
768
769	$scope.showLoader = function(){
770		jQuery(".progress").show();		
771	}
772	$scope.hideLoader = function(){
773		jQuery(".progress").hide();		
774	}
775
776	$scope.ifax_fn_open_modal = function(ids){
777		var arr = ["how-to-receive-email-faxes","pricing","business","support","how-ifax-works","beforeyougo","how-to-send-a-fax-online"];
778		// if(arr.indexOf($scope.pagename) >= 0){
779			// jQuery('.modal').modal({
780			//     dismissible: true
781			// });
782			// jQuery(ids).modal('open');
783		// 	jQuery(ids).addClass('in');
784		// 	jQuery(ids).modal('show');
785			
786		// }else{
787
788			jQuery(ids).modal();
789
790		// }
791		
792	}
793	$scope.ifax_fn_close_modal = function(ids){
794		// jQuery('.modal').modal({
795  //           dismissible: true
796  //       });
797  		var arr = ["how-to-receive-email-faxes","pricing","business","support","how-ifax-works","beforeyougo","how-to-send-a-fax-online"];
798		if(arr.indexOf($scope.pagename) >= 0){
799  			jQuery(ids).removeClass('in');
800  			if(ids){
801				if(jQuery(ids).hasClass('show')) jQuery(ids).modal('hide');
802			}else{
803				jQuery('.modal').modal('hide');
804			}
805  		}else{
806  			if(ids){
807  				if(jQuery(ids).hasClass('show')) jQuery(ids).modal('hide');
808			}else{
809				jQuery('.modal').modal('hide');
810			}	
811  		}
812
813		
814	}
815
816
817	$scope.encryptRequest = function(data){
818		var CryptoJSAesJson = {
819	      stringify: (cipherParams) => {
820	        var j  = { ct: cipherParams.ciphertext.toString(CryptoJS.enc.Base64) };
821	        if (cipherParams.iv) j.iv = cipherParams.iv.toString();
822	        if (cipherParams.salt) j.s = cipherParams.salt.toString();
823	        return JSON.stringify(j);
824	      },
825	      parse: (jsonStr) => {
826	        var j = JSON.parse(jsonStr);
827	        var cipherParams = CryptoJS.lib.CipherParams.create({ ciphertext: CryptoJS.enc.Base64.parse(j.ct) });
828	        if (j.iv) cipherParams.iv = CryptoJS.enc.Hex.parse(j.iv)
829	        if (j.s) cipherParams.salt = CryptoJS.enc.Hex.parse(j.s)
830	        return cipherParams;
831	      }
832	    }
833		// Encrypt
834		var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), '$#s$5f$%3y%^6&^%%f9#@$&^*',{ format: CryptoJSAesJson }).toString();
835		return btoa(ciphertext);
836	}
837	$scope.setCookie('currency_code', "USD");
838	$scope.setCookie('currency_symbol', "$");
839	$scope.ipaddress = function(){
840		$http({
841		method : 'GET',	
842		url : "https://api.ipify.org/?format=json",	
843		}).then(function(response) {
844        	if(response.data.ip){
845        		 $scope.setCookie('ipaddress', response.data.ip);
846        	}
847
848        	$http({
849				method : 'GET',	
850				url : "https://api.ipstack.com/"+ response.data.ip + "?access_key=e5855c10bd073505d83178d2057add88",	
851				data :{},
852		        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
853		        }).then(function(response) {
854		        	if(response.data){
855		        		$scope.setCookie('_client_timezone', response.data.time_zone.id);
856			            $scope.setCookie('location', response.data.time_zone.id);
857			            $scope.setCookie('country_prefix', response.data.location.calling_code);
858			            $scope.setCookie('country_name', response.data.continent_name);
859			            $scope.setCookie('country_code', response.data.country_code);
860			            $scope.setCookie('state_name', response.data.region_name);
861			            // $scope.setCookie('currency_code', "GBP");
862			            // $scope.setCookie('currency_symbol', "£");
863			            if(response.data.currency.code == "GBP"){
864			            	$scope.setCookie('currency_code', "GBP");
865			            	$scope.setCookie('currency_symbol', "£");	
866			            }else{
867			            	$scope.setCookie('currency_code', "USD");
868			            	$scope.setCookie('currency_symbol', "$");
869			            }
870			            
871		        	}
872		        })
873
874
875
876        })
877	}
878
879	if(!$scope.getCookie('ipaddress')){
880		$scope.ipaddress();
881	}
882	
883	$scope.getVWOCookie = function(campaignID) {
884        var name = "_vis_opt_exp_" + campaignID + "_combi=";
885        var decodedCookie = decodeURIComponent(document.cookie);
886        var cookies = decodedCookie.split(';');
887        for (var i = 0; i < cookies.length; i++) {
888            var cookie = cookies[i].trim();
889            if (cookie.indexOf(name) == 0) {
890                return cookie.substring(name.length, cookie.length);
891            }
892        }
893        return 1;
894    }
895
896    $scope.currentPlan = "";
897	$scope.allowTrialNew = "";
898	$scope.buttonTextNew = "START NOW";
899	$scope.currentPlanBasic = "";
900	$scope.allowTrialNewBasic = 0;
901	$scope.buttonTextNewBasic = "START NOW";
902	$scope.currentPlanPlus = "";
903	$scope.allowTrialNewPlus = 0;
904	$scope.buttonTextNewPlus = "START NOW";
905
906	$scope.getSettings = function(){
907		$http({
908		method : 'POST',	
909		url : $scope.apiurl+"ajax/getSettingsAngular",	
910		data : jQuery.param({
911			userID: $scope.getUserID(),
912			usertype: $scope.getUserType(),
913			app: 'angular',
914			push_token: undefined,
915			userAgent: 'Chrome',
916			subUserID : $scope.getSubUserID()
917		}),
918        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
919        }).then(function(response) {
920        	if(response.data.code == 0){
921        		$scope.showLoginButton = 1;
922        		return false;
923        	}
924        	
925        	$scope.settings = response.data.data[0];
926        	$scope.settings.email_verified = $scope.settings.emailVerified;
927
928        	// if($scope.settings.email_verified == '0' && $scope.login_by != '' && $.cookie('showEmailVeifiedPop') == 1){
929        	// 	if($scope.pagename == 'beforeyougo'){
930         //            $scope.showWarningErrorPopup("To cancel your iFax subscription, verify you are the account holder. We've sent you an email to validate your email address "+$scope.global_email+".",'Verify Email Address','RESEND','1','resend');
931         //        }else{
932         //            // $scope.showWarningErrorPopup('To receive real-time notifications about the faxes you send, go to your inbox and verify your email address '+$scope.global_email+".",'Verify Email Address','RESEND','1','resend');
933         //        }
934                
935        	// 	// $.cookie('showEmailVeifiedPop',0);
936        	// }
937        	if($scope.settings.active_plan.code){
938        		
939        		$scope.settings.active_plan.code = $scope.settings.active_plan.code.toUpperCase();
940
941        		if($scope.settings.active_plan.code.includes("PLUS") || $scope.settings.active_plan.name == "PLUS"){
942        			$scope.leftbar = {
943        				plan : 'PLUS',
944	        			planname : 'My Plan: iFax Plus',
945	        			title : 'iFax Plus',
946						btn : ($scope.settings.active_plan.status == "ACTIVE" ? 'UPGRADE' : $scope.settings.active_plan.status),
947						status : $scope.settings.active_plan.status,
948						ob_txt : ($scope.settings.active_plan.status == "EXPIRING" && $scope.settings.active_plan.remaining_days < 8 ? 'EXPIRES IN '+$scope.settings.active_plan.remaining_days+' DAYS' : ($scope.settings.active_plan.status == "ACTIVE" ? 'UPGRADE' : $scope.settings.active_plan.status) ),
949						subscr_id : $scope.settings.active_plan.subscr_id,
950						payment_by : $scope.settings.active_plan.payment_by.toLowerCase(),
951						ob_id : $scope.settings.active_plan.ob_id,
952						platform : $scope.settings.active_plan.platform,
953						monthly_price : "$"+($scope.settings.active_plan.duration == 1 ? $scope.roundValue($scope.settings.active_plan.price) : $scope.roundValue($scope.settings.active_plan.price/12) )+"/mo" ,
954						renew_time : ($scope.settings.active_plan.duration == 1 ? 'Monthly' : 'Yearly'),
955						pages : Math.floor($scope.settings.remain_credits),
956						text : (!$scope.settings.active_plan && Math.floor($scope.settings.remain_credits) == 0 ? 'Select a plan or get a quote' : Math.floor($scope.settings.remain_credits) + ' credits'),
957						remain_fax : $scope.settings.active_plan.remain_fax_numbers,
958						ib_pages : $scope.settings.active_plan.ib_pages,
959						duration : $scope.settings.active_plan.duration,
960						isPrimary : $scope.settings.isPrimary
961
962	        		}        					
963        		}else if($scope.settings.active_plan.code.includes("PRO") || $scope.settings.active_plan.name == "PRO"){
964        			$scope.leftbar = {
965        				plan : 'PRO',
966	        			planname : 'My Plan: iFax Pro',
967	        			title : 'iFax Pro',
968						btn : ($scope.settings.active_plan.status == "ACTIVE" ? 'UPGRADE' : $scope.settings.active_plan.status),
969						status : $scope.settings.active_plan.status,
970						ob_txt : ($scope.settings.active_plan.status == "EXPIRING" && $scope.settings.active_plan.remaining_days < 8 ? 'EXPIRES IN '+$scope.settings.active_plan.remaining_days+' DAYS' : ($scope.settings.active_plan.status == "ACTIVE" ? 'UPGRADE' : $scope.settings.active_plan.status) ),
971						subscr_id : $scope.settings.active_plan.subscr_id,
972						payment_by : $scope.settings.active_plan.payment_by.toLowerCase(),
973						ob_id : $scope.settings.active_plan.ob_id,
974						platform : $scope.settings.active_plan.platform,
975						monthly_price : "$"+($scope.settings.active_plan.duration == 1 ? $scope.roundValue($scope.settings.active_plan.price) : $scope.roundValue($scope.settings.active_plan.price/12) )+"/mo" ,
976						renew_time : ($scope.settings.active_plan.duration == 1 ? 'Monthly' : 'Yearly'),
977						pages : Math.floor($scope.settings.remain_credits),
978						text : (!$scope.settings.active_plan && Math.floor($scope.settings.remain_credits) == 0 ? 'Select a plan or get a quote' : Math.floor($scope.settings.remain_credits) + ' credits'),
979						remain_fax : $scope.settings.active_plan.remain_fax_numbers,
980						ib_pages : $scope.settings.active_plan.ib_pages,
981						duration : $scope.settings.active_plan.duration,
982						isPrimary : $scope.settings.isPrimary
983	        		}        					
984        		}else if($scope.settings.active_plan.code.includes("ERP") || $scope.settings.active_plan.name == "ENTERPRISE"){
985        			$scope.leftbar = {
986        				plan : 'ERP',
987	        			planname : 'My Plan: Enterprise',
988	        			title : 'iFax Enterprise',
989						btn : ($scope.settings.active_plan.status == "ACTIVE" ? 'UPGRADE' : $scope.settings.active_plan.status),
990						status : $scope.settings.active_plan.status,
991						ob_txt : ($scope.settings.active_plan.status == "EXPIRING" && $scope.settings.active_plan.remaining_days < 8 ? 'EXPIRES IN '+$scope.settings.active_plan.remaining_days+' DAYS' : ($scope.settings.active_plan.status == "ACTIVE" ? 'UPGRADE' : $scope.settings.active_plan.status) ),
992						subscr_id : $scope.settings.active_plan.subscr_id,
993						payment_by : $scope.settings.active_plan.payment_by.toLowerCase(),
994						ob_id : $scope.settings.active_plan.ob_id,
995						platform : $scope.settings.active_plan.platform,
996						monthly_price : "$"+($scope.settings.active_plan.duration == 1 ? $scope.roundValue($scope.settings.active_plan.price) : $scope.roundValue($scope.settings.active_plan.price/12) )+"/mo" ,
997						renew_time : ($scope.settings.active_plan.duration == 1 ? 'Monthly' : 'Yearly'),
998						pages : Math.floor($scope.settings.remain_credits),
999						text : (!$scope.settings.active_plan && Math.floor($scope.settings.remain_credits) == 0 ? 'Select a plan or get a quote' : Math.floor($scope.settings.remain_credits) + ' credits'),
1000						remain_fax : $scope.settings.active_plan.remain_fax_numbers,
1001						ib_pages : $scope.settings.active_plan.ib_pages,
1002						duration : $scope.settings.active_plan.duration,
1003						isPrimary : $scope.settings.isPrimary
1004	        		}        					
1005        		}else if($scope.settings.active_plan.code.includes("FREEMIUM") || $scope.settings.active_plan.name == "FREE"){
1006        			$scope.leftbar = {
1007        				plan : 'FREE',
1008	        			planname : 'iFax Free Test',
1009	        			title : 'iFax Free Test',
1010						btn : ($scope.settings.active_plan.status == "ACTIVE" ? 'UPGRADE' : $scope.settings.active_plan.status),
1011						status : $scope.settings.active_plan.status,
1012						ob_txt : ($scope.settings.active_plan.status == "EXPIRING" && $scope.settings.active_plan.remaining_days < 8 ? 'EXPIRES IN '+$scope.settings.active_plan.remaining_days+' DAYS' : ($scope.settings.active_plan.status == "ACTIVE" ? 'UPGRADE' : $scope.settings.active_plan.status) ),
1013						subscr_id : $scope.settings.active_plan.subscr_id,
1014						payment_by : $scope.settings.active_plan.payment_by.toLowerCase(),
1015						ob_id : $scope.settings.active_plan.ob_id,
1016						platform : $scope.settings.active_plan.platform,
1017						monthly_price : "$"+($scope.settings.active_plan.duration == 1 ? $scope.roundValue($scope.settings.active_plan.price) : $scope.roundValue($scope.settings.active_plan.price/12) )+"/mo" ,
1018						renew_time : ($scope.settings.active_plan.duration == 1 ? 'Monthly' : 'Yearly'),
1019						pages : Math.floor($scope.settings.remain_credits),
1020						text : (!$scope.settings.active_plan && Math.floor($scope.settings.remain_credits) == 0 ? 'Select a plan or get a quote' : Math.floor($scope.settings.remain_credits) + ' credits'),
1021						remain_fax : $scope.settings.active_plan.remain_fax_numbers,
1022						ib_pages : $scope.settings.active_plan.ib_pages,
1023						duration : $scope.settings.active_plan.duration,
1024						isPrimary : $scope.settings.isPrimary
1025
1026	        		}        					
1027        		}
1028
1029        		if($scope.leftbar.plan != '' && $scope.showFlag){
1030        			$scope.showFlag = false;
1031
1032        			if(!ngurl.includes('reset_password') && !ngurl.includes('beforeyougo')){
1033        				setTimeout(function(){
1034		        		if($scope.my_login_type == ''){
1035		        			var fd = 'iFax Plus Activated';
1036		        			if($scope.leftbar.plan == 'PLUS'){
1037		        				fd = 'iFax Plus Activated';
1038		        			}else if($scope.leftbar.plan == 'PRO'){
1039		        				fd = 'iFax Pro Activated';
1040		        			}else if($scope.leftbar.plan == 'ERP'){
1041		        				fd = 'iFax Enterprise Activated';
1042		        			}
1043		        			$scope.showQuickPopup('.login-iframe');
1044		        			// $scope.showloginPopup(fd,'Please create an account so that you can access your subscription in the future.','','',1);
1045		        		}
1046		        		},1500);
1047        			}
1048        			
1049        		}else{
1050        			$scope.showFlag = false;
1051        		}
1052        		
1053
1054        		$scope.leftbar.ob_class = ($scope.settings.active_plan.status == "EXPIRING" ? 'red-color' : '');
1055        		$scope.leftbar.ob_class += ($scope.settings.active_plan.remaining_days < 8 ? '' : ' bigger_font_size');
1056        		        		
1057        	}else{
1058        		$scope.showFlag = false;
1059        		$scope.leftbar = {
1060        			plan : '',
1061        			planname : 'iFax Plans',
1062					btn : 'START',
1063					title : 'iFax Plans',
1064					pages : Math.floor($scope.settings.remain_credits),
1065					ob_txt : 'START',
1066					text : (!$scope.settings.active_plan.code && Math.floor($scope.settings.remain_credits) == 0 ? 'Select a plan or get a quote' : Math.floor($scope.settings.remain_credits) + ' credits'),
1067					status : ($scope.settings.past_plan.is_subscribed == 1) ? 'TRY IT' : 'TRY IT FREE',
1068					subscr_id : '',
1069					payment_by : '',
1070					monthly_price : '' ,
1071					renew_time : '',
1072					purchased_id : 0,
1073					remain_fax : 0,
1074					faxNumber : {},
1075					upgrade_plan : {},
1076					ib_pages : 0,
1077					duration : 0,
1078					ob_class : '',
1079					isPrimary : 0
1080        		}
1081        	}
1082        	console.log('pricing_script.allow_trial',pricing_script.allow_trial);
1083        	if($scope.leftbar.plan != '' && $scope.leftbar.plan == "ERP"){
1084        		$scope.currentPlan = "ERP";
1085        		$scope.buttonTextNew = "YOUR CURRENT PLAN";
1086        	}else{
1087        		if(pricing_script.allow_trial == 1){
1088	        		$scope.allowTrialNew = 1;
1089	        		$scope.buttonTextNew = "START FREE TRIAL";
1090	        	}else{
1091	        		$scope.allowTrialNew = 0;
1092	        		$scope.buttonTextNew = "START NOW";
1093	        	}	
1094        	}
1095
1096        	
1097        	if($scope.leftbar.plan != '' && $scope.leftbar.plan == "PLUS"){
1098        		$scope.currentPlanBasic = "PLUS";
1099        		$scope.buttonTextNewBasic = "YOUR CURRENT PLAN";
1100        	}else{
1101        		$scope.allowTrialNewBasic = 0;
1102        		$scope.buttonTextNewBasic = "START NOW";
1103        	}
1104
1105        	
1106        	if($scope.leftbar.plan != '' && $scope.leftbar.plan == "PRO"){
1107        		$scope.currentPlanPlus = "PRO";
1108        		$scope.buttonTextNewPlus = "YOUR CURRENT PLAN";
1109        	}else{
1110        		$scope.allowTrialNewPlus = 0;
1111        		$scope.buttonTextNewPlus = "START NOW";
1112        	}
1113
1114        	
1115
1116        	
1117
1118        	
1119        	$scope.allowTrial = 0;
1120        	if($scope.getCookie('fromFreePage')){
1121        		// console.log(ngurl);
1122        		if (ngurl.indexOf('/free-fax/') > -1 || ngurl.indexOf('/pay-per-fax-online') > -1 || ngurl.indexOf('/free-fax-cover-sheets') > -1 || ngurl.indexOf('/pricing') > -1){
1123        			if($scope.variantID != 2 && $scope.leftbar.plan == ''){
1124        				$scope.allowTrial = 0;	
1125        			}
1126        			
1127        		}
1128        	}else{
1129        		$scope.allowTrial = 0;	
1130        		$scope.allowTrialERP = 0;	
1131        		if(($scope.variantID == 2) && $scope.leftbar.plan == ''){
1132    				$scope.allowTrialERP = 1;	
1133    			}
1134        	}
1135
1136        	$scope.showNow = 1;
1137			
1138			// console.log('test',$scope.leftbar.plan,$scope.allowTrialERP)
1139
1140	              	
1141
1142        	// if (ngurl.indexOf('/pricing') > -1 || ngurl.indexOf('/plans') > -1 || ngurl.indexOf('/custom-quote') > -1)
1143			// {
1144			//   if($scope.leftbar.plan != ''){
1145	        // 		window.location.href = webappurl;
1146	        // 		return false;
1147	        // 	}
1148			// }
1149			
1150        	
1151        	if($scope.settings.isBlocked){
1152        		$scope.setCookie('isBlocked',$scope.settings.isBlocked);	
1153        	}
1154        	
1155        	if($scope.settings.fax_numbers.length > 0){
1156    			$scope.leftbar.faxNumber = {
1157        			faxNum :  $scope.settings.fax_numbers[0].fax_number,
1158        			faxlbl : $scope.settings.fax_numbers[0].fax_number,
1159        			ib_id : $scope.settings.fax_numbers[0].ib_id,
1160        			status : $scope.settings.fax_numbers[0].number_status,
1161        			remainDays : $scope.settings.fax_numbers[0].remaining_days,
1162        			text : ($scope.settings.fax_numbers[0].number_status == 'EXPIRING' && $scope.settings.fax_numbers[0].remaining_days < 8 ? 'EXPIRES IN '+$scope.settings.fax_numbers[0].remaining_days+' DAYS' : $scope.settings.fax_numbers[0].number_status)
1163        		}
1164        		$scope.leftbar.faxNumber.ib_class = ($scope.settings.fax_numbers[0].number_status == "EXPIRING" ? 'red-color' : '');
1165        		$scope.leftbar.faxNumber.ib_class += ($scope.settings.fax_numbers[0].remaining_days < 8 ? '' : ' bigger_font_size');
1166        		// share fax number from left bar
1167    			window.localStorage.setItem('number_purchase_faxnum',$scope.leftbar.faxNumber.faxNum);	
1168
1169    			
1170    		}else{
1171    			$scope.leftbar.faxNumber = {
1172    				text : 'GET ONE',
1173                    status : 'GET ONE',
1174    				ib_class : '',
1175    				faxlbl : 'Start receiving faxes'
1176    			}
1177    		}
1178
1179   //  		if(nglast_part == 'www.ifaxapp.com' || nglast_part == "HIOPQhrYTOxnaFGTQpeEo"){
1180
1181   //  			if($scope.my_login_type != ''){
1182	  //   			if(!$scope.settings.active_plan.code){
1183	  //   				$window.location.href = $scope.weburl + 'dashboard?pricing';
1184	  //       		}else{
1185	  //       			$window.location.href = $scope.weburl + 'dashboard';
1186	  //       		}
1187			// 	}
1188			// }
1189
1190    		$scope.leftbar.upgrade_plan = $scope.settings.upgrade_plan;
1191        	// console.log($scope.my_login_type);
1192    		if($scope.leftbar.plan != '' || $scope.my_login_type != ''){
1193    			$scope.showLoginButton = 2;
1194    		}else{
1195    			$scope.showLoginButton = 1;
1196    		}
1197
1198        })
1199	}
1200 
1201
1202    // console.log('$scope.variantID',$scope.variantID);
1203    if($scope.variantID == 2 || $scope.variantID == 3){
1204  		if($scope.variantID == 2){
1205  			$scope.allowTrialERP = 1;	
1206  		}else{
1207  			$scope.allowTrialERP = 0;	
1208  		}
1209  		
1210		jQuery('.plusplan').text($scope.getCookie('currency_symbol')+($scope.globalDuration == 12 ? '24.99' : '29.99')+' /mo');
1211		jQuery('.basicplan').text($scope.getCookie('currency_symbol')+($scope.globalDuration == 12 ? '12.49' : '14.99')+' /mo');
1212		jQuery('.basicplantooltip').attr('title',$scope.getCookie('currency_symbol')+'149.99/year');
1213		jQuery('.plusplantooltip').attr('title',$scope.getCookie('currency_symbol')+'299.99/year');	
1214		// $scope.changeDurationToggle('12');	
1215		// $scope.$apply();
1216	}
1217
1218    // var intervalId = setInterval(function () {
1219	//   var cookieValue = $scope.getCookie('_vis_opt_exp_1_combi');
1220	//   if (cookieValue !== undefined && cookieValue !== null && cookieValue !== '') {
1221	//   	$scope.variantID = $scope.getVWOCookie("1");
1222
1223	//   	if($scope.variantID == 2 || $scope.variantID == 3){
1224	//   		if($scope.variantID == 2){
1225	//   			$scope.allowTrialERP = 1;	
1226	//   		}else{
1227	//   			$scope.allowTrialERP = 0;	
1228	//   		}
1229	  		
1230	// 		jQuery('.plusplan').text($scope.getCookie('currency_symbol')+($scope.globalDuration == 12 ? '24.99' : '29.99')+' /mo');
1231	// 		jQuery('.basicplan').text($scope.getCookie('currency_symbol')+($scope.globalDuration == 12 ? '12.49' : '14.99')+' /mo');
1232	// 		jQuery('.basicplantooltip').attr('title',$scope.getCookie('currency_symbol')+'149.99/year');
1233	// 		jQuery('.plusplantooltip').attr('title',$scope.getCookie('currency_symbol')+'299.99/year');	
1234	// 		$scope.changeDurationToggle('12');	
1235	// 		$scope.$apply();
1236    // 	}
1237	//     if ($scope.variantID) {
1238	//         console.log("Variant ID for campaign 1: ", $scope.variantID);
1239	//     } else {
1240	//         console.log("No variant found for campaign 1.");
1241	//     } 
1242	//   	if($scope.variantID == '2'){
1243
1244	// 	  // for banner
1245	// 	  jQuery('.AB_testing .text').contents().filter(function() {
1246	// 	    return this.nodeType === 3; // only text nodes
1247	// 	  }).first().replaceWith('START FREE');
1248	// 	  jQuery('.AB_testing').attr('href','https://ifaxapp.com/signup/?plan=pro&bill=12&paid=0');  
1249
1250	// 	  // for header
1251	// 	  jQuery('.StartFree .text').contents().filter(function() {
1252	// 	    return this.nodeType === 3; // only text nodes
1253	// 	  }).first().replaceWith('START FREE');
1254	// 	  jQuery('.StartFree a').removeAttr('ng-click');
1255	// 	  jQuery('.StartFree a').attr('href','https://ifaxapp.com/signup/?plan=pro&bill=12&paid=0');  
1256
1257	// 	}else{
1258	// 	  // for banner
1259	// 	  jQuery('.AB_testing .text').contents().filter(function() {
1260	// 	    return this.nodeType === 3; // only text nodes
1261	// 	  }).first().replaceWith('START NOW');
1262
1263	// 	  jQuery('.AB_testing').attr('href','https://ifaxapp.com/signup/?plan=pro&bill=12&paid=1');
1264
1265	// 	  // for header
1266	// 	  jQuery('.StartFree .text').contents().filter(function() {
1267	// 	    return this.nodeType === 3; // only text nodes
1268	// 	  }).first().replaceWith('START NOW');
1269	// 	  jQuery('.StartFree a').removeAttr('ng-click');
1270	// 	  jQuery('.StartFree a').attr('href','https://ifaxapp.com/signup/?plan=pro&bill=12&paid=1'); 
1271	// 	}
1272	//     // console.log('Cookie found:', cookieValue);
1273	//     clearInterval(intervalId); // Stop the interval
1274	//     // You can call another function here if needed
1275	//   } else {
1276	//     // console.log('Waiting for cookie...');
1277	//   }
1278	// }, 500); // Check every 500ms
1279    
1280
1281	
1282
1283	$scope.getTelynexPrice = function(){
1284		
1285        	$scope.arrCountry = [{"id":"1","country_code":"33","country_isocode":"FR","country_name":"France","is_active":"1","created_date":"2016-04-04 01:58:38","updated_date":"2018-01-31 06:29:18","required_doc":"1","is_number_selection":"1","telnyxPrice":"0.65"},{"id":"2","country_code":"1","country_isocode":"CA","country_name":"Canada","is_active":"1","created_date":"2016-04-04 01:58:38","updated_date":"2018-01-31 06:29:18","required_doc":"0","is_number_selection":"1","telnyxPrice":"0.11"},{"id":"4","country_code":"61","country_isocode":"AU","country_name":"Australia","is_active":"1","created_date":"2016-04-04 01:58:38","updated_date":"2018-01-31 06:29:18","required_doc":"1","is_number_selection":"1","telnyxPrice":"6.08"},{"id":"5","country_code":"44","country_isocode":"GB","country_name":"United Kingdom","is_active":"1","created_date":"2016-04-04 01:58:38","updated_date":"2018-01-31 06:29:18","required_doc":"1","is_number_selection":"1","telnyxPrice":"0.60"},{"id":"6","country_code":"1","country_isocode":"US","country_name":"United States","is_active":"1","created_date":"2016-04-04 01:58:38","updated_date":"2018-01-31 06:29:18","required_doc":"0","is_number_selection":"1","telnyxPrice":"0.11"},{"id":"8","country_code":"49","country_isocode":"DE","country_name":"Germany","is_active":"1","created_date":"2016-04-04 01:58:38","updated_date":"2018-01-31 06:29:20","required_doc":"1","is_number_selection":"1","telnyxPrice":"0.65"},{"id":"9","country_code":"39","country_isocode":"IT","country_name":"Italy","is_active":"1","created_date":"2016-04-04 01:58:38","updated_date":"2018-01-31 06:29:20","required_doc":"1","is_number_selection":"1","telnyxPrice":"2.60"}];
1286        	$scope.arrCountry.map(function(item){
1287        		$scope.arrCountry[item.country_isocode]=item.telnyxPrice;
1288        	});
1289        
1290	}
1291
1292	$scope.getTelynexPrice();
1293
1294	$scope.create_temp_user_angular = function(isBLank = ''){
1295		var obj = {'cjEventId':$scope.cjevent}
1296		if(isBLank == ''){
1297			obj.userID = $scope.getUserID();
1298		}
1299		$http({
1300		method : 'POST',	
1301		url : $scope.apiurl+"ajax/create_temp_user_angular",	
1302		data :jQuery.param(obj),
1303        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
1304        }).then(function(response) {
1305        	// $scope.my_userID = response.data.uid;
1306        	$scope.uuid = response.data.uuid;
1307        	setTimeout(function(){
1308				$scope.getSettings();				        			
1309        	},300)
1310        })
1311	}
1312
1313	if(!$scope.uuid){
1314		$scope.create_temp_user_angular();
1315	}else{
1316		$scope.getSettings();
1317	}
1318	
1319
1320	$scope.signout = function(){
1321		// window.site_loader_show();	
1322		$http({
1323		method : 'POST',	
1324		url : $scope.apiurl+"signin/sign_out",	
1325		data :jQuery.param({uuid: $scope.getUserID(),user_type:$scope.getUserType(),app:'angular'}),
1326        // headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
1327        }).then(function(response) {
1328        	// window.site_loader_hide();
1329        	// alert(window.location+"?"+jQuery.param({'signout':'1'}));
1330        	window.location.href = window.location+"?"+jQuery.param({'signout':'1'});
1331        	
1332        })
1333
1334	}
1335	$scope.checkSubscirption = function(){
1336	     if(!$scope.settings.active_plan.code){
1337	        $scope.showWarningErrorPopup('iFax account not found for '+$scope.my_email+'. If you did not create an iFax account but have a subscription with an Apple iTunes, Google Play or Microsoft Pay account, you will need to cancel your subscription with those services directly.','Oops!','GOT IT','','no_subscr');	        
1338	        return false;
1339	    }else{
1340	    	if($scope.settings.active_plan.name == "PLUS"){
1341  				$scope.cancel_msg = "By cancelling your plan you will no longer be able to send faxes.";
1342  			}else{
1343  				$scope.cancel_msg = "By cancelling your plan you will lose your fax number(s) and no longer be able to send or receive faxes.";
1344  			}
1345  			// $scope.$apply();
1346	        $scope.ifax_fn_open_modal('#warning_modal');
1347	    }
1348	}
1349
1350	$scope.cancel_pro_subscription = function(){
1351
1352        
1353     	if($scope.leftbar.platform.toLowerCase() == "web"){
1354
1355			if($scope.settings.active_plan.code){
1356				if($scope.settings.active_plan.subscr_id){
1357					// window.site_loader_show();	
1358					$http.post($scope.apiurl+"ajax/cancelSubscriptionForAllPayment",{'subscr_id': $scope.leftbar.subscr_id,'payment_by' : $scope.leftbar.payment_by})  
1359					  .then(function(response) { 
1360					  		// window.site_loader_hide();
1361					  		if(response.data.status == '1'){
1362					  			
1363					  			$scope.ifax_fn_open_modal('#success_modal');
1364					  			// window.fn_success_msg(response.data.msg);		  			 		  			 
1365					  		}else{
1366					  			$scope.showWarningErrorPopup(response.data.msg,'Oops!','OK','','redirect'); 
1367					  		}				
1368					})
1369				}else{
1370					window.fn_error_msg("Suscription does not exist");
1371				}
1372			}else{
1373				window.fn_error_msg("Suscription does not exist");
1374			}
1375		}else{
1376			$scope.cancel_all_subscription();
1377			$scope.ifax_fn_open_modal('#cancel_subscr_modal');
1378			
1379		}
1380	}
1381
1382	$scope.cancel_all_subscription = function(){
1383
1384		
1385			if($scope.leftbar.platform.toLowerCase() == "macos" || $scope.leftbar.platform.toLowerCase() == "ios"){
1386				jQuery('.test').html('We have detected that your subscription is with Apple iTunes and not with iFax. App developers are only paid a sales commission by Apple approximately 4-6 weeks after the transaction.<br><br>Unfortunately, iFax is not able to manage or control your Apple iTunes subscription and you would need to contact Apple directly to request any amendments.');
1387				$scope.payment_url = 'https://support.apple.com/en-in/HT202039';
1388				$scope.payment_btn_text = 'REQUEST CANCELATION FROM APPLE';
1389                if($scope.leftbar.platform.toLowerCase() == "ios"){
1390                    $scope.payment_title = 'Apple Cancelation';    
1391                }else{
1392                    $scope.payment_title = 'Apple Cancelation';
1393                }
1394                
1395				// $scope.ifax_fn_open_modal('#cancel_subscr_modal');
1396			}else if($scope.leftbar.platform.toLowerCase() == "android"){
1397				jQuery('.test').html('We have detected that your subscription is with Google Play and not with iFax. App developers are only paid a sales commission by Google approximately 4-6 weeks after the transaction.<br><br>Unfortunately, iFax is not able to manage or control your Google Play subscription and you would need to contact Google directly to request any amendments.');
1398				$scope.payment_url = 'https://support.google.com/googleplay/answer/7018481?co=GENIE.Platform%3DAndroid&oco=1';
1399                $scope.payment_title = 'Google Cancelation';
1400                $scope.payment_btn_text = 'REQUEST CANCELATION FROM GOOGLE';
1401				// $scope.ifax_fn_open_modal('#cancel_subscr_modal');
1402			}else if($scope.leftbar.platform.toLowerCase() == "windows"){
1403				jQuery('.test').html('We have detected that your subscription is with Microsoft and n
1403ot with iFax. App developers are only paid a sales commission by Microsoft approximately 4-6 weeks after the transaction.<br><br>Unfortunately, iFax is not able to manage or control your Microsoft subscription and you would need to contact Microsoft directly to request any amendments.');
1404				$scope.payment_url = 'https://support.microsoft.com/en-us/help/4027815/microsoft-account-cancel-a-microsoft-subscription#v1h=tab01';
1405                $scope.payment_title = 'Microsoft Cancelation';
1406                $scope.payment_btn_text = 'REQUEST CANCELATION FROM MICROSOFT';
1407				// $scope.ifax_fn_open_modal('#cancel_subscr_modal');
1408			}else{
1409				jQuery('.test').html('You are about to cancel your unlimited faxing plan. There is no way to revert this.');
1410                $scope.payment_title = 'Cancelation Instructions';
1411				
1412			}
1413
1414		
1415	}
1416
1417	$scope.makeid = function(length) {
1418       var result           = '';
1419       var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
1420       var charactersLength = characters.length;
1421       for ( var i = 0; i < length; i++ ) {
1422          result += characters.charAt(Math.floor(Math.random() * charactersLength));
1423       }
1424       return result;
1425    }
1426	$scope.showWarningErrorPopup = function(msg,title='Oops!',btn = 'GOT IT!',close = '',action=''){
1427	    var close_div='';
1428	    if(close){
1429	        close_div = '<span class="cl_pop" style="position: absolute;right: 10px;top: 10px;cursor: pointer;padding: 5px;color: #a1a1a1;font-size:16px;"><i class="fa fa-close"></i></span>';
1430	    }
1431	    var btn_text = '';
1432	    if(btn != ''){
1433	        btn_text = '<a id="closeWarnPop1">'+btn+'</a>';
1434	    }
1435	    if(action == 'delete_number'){
1436	        btn_text = '<a id="n_number">NEW NUMBER</a><a id="m_plan" style="margin-right:10px;">MANAGE PLAN</a>';   
1437	    }else if(action == 'no_subscr'){
1438	        btn_text = '<a id="n_number">GOT IT</a><a id="m_plan" style="margin-right:10px;">DETAILS</a>'; 
1439	    }
1440
1441
1442	    var html = '<div class="fax--information verified_email_popup" style="z-index:99999999"><div class="warning-pop" style="height:200px;">'+close_div+'<h5>'+title+'</h5><p>'+msg+'</p>'+btn_text+'</div></div>';
1443	    jQuery('body').append(html);
1444	    jQuery('body .cl_pop').on('click', function(){    
1445	            jQuery('.fax--information').remove();
1446	     });
1447	    if(action == ''){
1448	        jQuery('body #closeWarnPop1').on('click', function(){    
1449	            jQuery('.fax--information').remove();
1450	       });
1451	    }else if(action == 'redirect'){
1452	        jQuery('body #closeWarnPop1').on('click', function(){ 
1453	            window.location.href = weburl+'dashboard?ctoken='+$scope.makeid(25);
1454	        })
1455	    }else if(action == 'survey'){
1456	        jQuery('body #closeWarnPop1').on('click', function(){ 
1457	            jQuery('.fax--information').remove();
1458	            $home = jQuery('[ng-controller="DashboardController"]').scope();
1459	            $home.ifax_fn_open_modal('#survey_model');
1460	        })
1461	    }else if(action == 'no_subscr'){
1462	        jQuery('body .cl_pop').on('click', function(){    
1463	            jQuery('.fax--information').remove();
1464	                // window.location.href = weburl+'purchase_fax_list';
1465	         });
1466	        
1467	        jQuery('body #m_plan').on('click', function(){ 
1468	            // jQuery('.fax--information').remove();
1469	            var a= document.createElement('a');
1470	            a.target= '_blank';
1471	            a.href= 'https://crowdedroad.zendesk.com/hc/en-us/articles/115002706112-How-do-I-cancel-an-auto-renewal-subscription';
1472	            a.click();
1473	            
1474	        })
1475	        jQuery('body #n_number').on('click', function(){ 
1476	            jQuery('.fax--information').remove();            
1477	        })
1478	    }
1479	    
1480	}
1481
1482	$scope.showQuickPopup = function(parent){
1483
1484	  if(parent == '.get-fax-iframe'){
1485	     window.top.location.href = weburl + 'fax-number';
1486	     return false;
1487	  }
1488
1489	  if(parent == '.send-fax-iframe'){
1490	     window.top.location.href = weburl + 'new-fax';
1491	     return false;
1492	  }
1493
1494	  if(parent == '.login-iframe' && !window.location.href.includes('beforeyougo')){
1495	     window.top.location.href = weburl + 'login';
1496	     return false;
1497	  }
1498
1499	  if(parent == '.contact-iframe'){
1500	     window.top.location.href = weburl + 'contact-support';
1501	     return false;
1502	  }
1503
1504	  
1505
1506	  jQuery('body').addClass('overflow-hidden-important');
1507	  jQuery(parent).addClass('iframe_animation');
1508	  if(parent == '.send-fax-iframe'){
1509	    jQuery('.newfax_overlay_blur').addClass('blur_fax_show');  
1510	  }
1511
1512	  jQuery('.newfax_overlay_blur').fadeIn(300);
1513	  jQuery('.tem_i'+parent).show();
1514	  // showActionSheet = setInterval(function(){
1515	  //       if($.cookie('showActionsheetPopup') == '1'){
1516	  //           jQuery(parent).addClass('show_action_sheet');
1517	  //       }else{
1518	  //           jQuery(parent).removeClass('show_action_sheet');
1519	  //       }
1520	        
1521	  //   },500)
1522	}
1523	$scope.closeQuickPopup = function(parent){
1524	  jQuery('body').removeClass('overflow-hidden-important');
1525	  jQuery(parent).removeClass('iframe_animation');
1526	  jQuery('.newfax_overlay_blur').fadeOut(300);
1527	  // if(parent == '.send-fax-iframe'){
1528	  	jQuery('.tem_i'+parent).hide();
1529	    jQuery('.newfax_overlay_blur').removeClass('blur_fax_show');  
1530	  // }
1531	  // if(showActionSheet){
1532	  //     clearInterval(showActionSheet);
1533	  // }
1534	}
1535
1536	$scope.isLoginCase = 1;
1537	$scope.startProcess = 0;
1538	$scope.inputType = "password";
1539	$scope.inputType1 = "password";
1540	$scope.toggleEye = function(){
1541		if ($scope.inputType == 'password'){
1542	      $scope.inputType = 'text';
1543	      $scope.toggleEyeFlag = 1;
1544		}else{
1545	      $scope.inputType = 'password'; 
1546	      $scope.toggleEyeFlag = 0;
1547		}
1548
1549		
1550	}
1551	$scope.toggleEyeConfirm = function(){
1552		if ($scope.inputType1 == 'password'){
1553	      $scope.inputType1 = 'text';
1554	      $scope.toggleEyeFlag1 = 1;
1555		}else{
1556	      $scope.inputType1 = 'password'; 
1557	      $scope.toggleEyeFlag1 = 0;
1558		}
1559
1560		
1561	}
1562	$scope.checkPassword = function(password){
1563
1564		if(!$scope.isLoginCase){
1565			var validLength = new RegExp('(?=.{10,})');
1566			var includeAlpha = new RegExp('(?=.*[a-zA-Z])');
1567			var includeNumber = new RegExp('(?=.*[0-9])');
1568			var includeSymbol = new RegExp('(?=.*[^A-Za-z0-9])');
1569
1570			if(!validLength.test(password) || !password){
1571				$scope.validLength = 0;
1572			}else{
1573				$scope.validLength = 1;
1574			}
1575			
1576			if(!includeAlpha.test(password) || !password){
1577				$scope.includeAlpha = 0;
1578			}else{
1579				$scope.includeAlpha = 1;
1580			}
1581
1582			if(!includeNumber.test(password) || !password){
1583				$scope.includeNumber = 0;
1584			}else{
1585				$scope.includeNumber = 1;
1586			}
1587
1588			if(!includeSymbol.test(password) || !password){
1589				$scope.includeSymbol = 0;
1590			}else{
1591				$scope.includeSymbol = 1;
1592			}
1593
1594			
1595		}else{
1596			jQuery('#password').css('border-color','#EAEDF2');
1597		}
1598
1599		
1600		
1601	}
1602	$scope.check_exist_user = function(email){
1603
1604		if(email == '' || !email){
1605			jQuery('#loader').hide();
1606			toastr.error('Please enter email')
1607    		return false;
1608    	}
1609
1610    	// if (/^\w+([\+.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/.test(email)){
1611		if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)){
1612
1613	    
1614	    }else{
1615	    	jQuery('#loader').hide();
1616	    	$scope.showErrorPopup(false,'Oops!','Please enter valid email address','error','OKAY');
1617	    	return false;
1618	  	}
1619	    
1620	  	$scope.startProcess = 1;
1621	    $http({
1622		method : 'GET',	
1623		url : "https://open.kickbox.com/v1/disposable/"+email,	
1624		}).then(function(response) {
1625			if(response.data.disposable == "true"){
1626				jQuery('#loader').hide();
1627				$scope.startProcess = 0;
1628				toastr.error('Please use a valid work email');
1629				return false;
1630			}else{
1631				const params = new Proxy(new URLSearchParams(window.location.search), {
1632				  get: (searchParams, prop) => searchParams.get(prop),
1633				});
1634				$scope.showLoader();
1635				$http({
1636				method : 'POST',	
1637				url : $scope.apiurl+"signin/check_exist_user",	
1638				data : jQuery.param({
1639					email: email,
1640					checkWorkEmail:params.checkWorkEmail == 1 ? 1 : 0
1641				}),
1642		        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
1643		        }).then(function(response) {
1644		        	$scope.startProcess = 0;
1645		        	$scope.hideLoader();
1646		        	jQuery('#loader').hide();
1647		        	if(response.data.code == "12001"){
1648		        		$scope.showErrorPopup(false,'Oops!',response.data.msg,'error','OKAY'); return false;
1649		        		
1650		        	}
1651		        	if(response.data.code == "421"){
1652		        		$scope.showErrorPopup(false,'Oops!',response.data.msg,'redirect','OPEN '+response.data.data.productName.toUpperCase(),'',response.data.data); return false;
1653		        		
1654		        	}
1655					if(response.data.code == "403"){
1656		        		$scope.showErrorPopup(false,'Oops!',response.data.msg,'error','OKAY'); return false;
1657		        		
1658		        	}
1659
1660		        	jQuery('.login-sec').hide();
1661		        	jQuery('.pass-sec').show();
1662
1663		        	$scope.password = "";
1664		        	$scope.inputType = "password";
1665		        	$scope.toggleEyeFlag = 0;
1666		        	$scope.validLength = 0;
1667		        	$scope.includeSymbol = 0;
1668		        	$scope.includeNumber = 0;
1669		        	$scope.includeAlpha = 0;
1670		        	$scope.cpassword = '';
1671		        	if(response.data.code == 0){
1672		        		// register case
1673		        		$scope.isLoginCase = 0;
1674		        		jQuery('.cpassword').show();
1675		        		// var compiledHtml =  $compile('<span>Sign up with '+email+' (<a class="edit-btn" ng-click="backTOLoginScreen()">edit</a>)</span>')($scope);
1676		        		var compiledHtml =  $compile('<span>Sign up with <a class="edit-btn" data-toggle="tooltip" data-placement="bottom" title="Edit your email" ng-click="backTOLoginScreen()">'+email+'</a></span>')($scope);
1677		        		jQuery('.signup_title').html(compiledHtml);
1678		        	}else{
1679						//login case
1680						$scope.isLoginCase = 1;
1681						jQuery('.cpassword').hide();
1682		        		// var compiledHtml =  $compile('<span>Enter a password for <br> '+email+' (<a class="edit-btn" ng-click="backTOLoginScreen()">edit</a>)</span>')($scope);
1683		        		var compiledHtml =  $compile('<span>Enter a password for <a class="edit-btn" data-toggle="tooltip" data-placement="bottom" title="Edit your email" ng-click="backTOLoginScreen()">'+email+'</a></span>')($scope);
1684		        		jQuery('.signup_title').html(compiledHtml);
1685
1686		        		
1687		        	}
1688
1689		        	setTimeout(function(){
1690		        		if($scope.isLoginCase==1){
1691		        			jQuery('input[id="password"]').focus();
1692		        		}else{
1693		        			jQuery('input[id="firstname"]').focus();
1694		        		}
1695		        		
1696		        	},100)
1697		        })
1698			}
1699        })
1700
1701    	
1702    }
1703
1704    $scope.ssoScreen = function(){
1705    	jQuery('.login-sec').hide();
1706		jQuery('.sso-sec').show();
1707    }
1708
1709    $scope.backTOLoginScreen = function(){
1710		jQuery('.pass-sec').hide();
1711		jQuery('.forget-sec').hide();
1712		jQuery('.sso-sec').hide();
1713    	jQuery('.login-sec').show();
1714        	
1715    }
1716
1717    $scope.checkEnableSSO = function(){
1718    	var obj = {
1719    		email : $scope.email
1720    	}
1721    	obj = $scope.encryptRequest(obj);
1722    	$scope.showLoader();
1723    	$http({
1724				method : 'POST',	
1725				url : $scope.apiurl+"ajax/checkEnableSSO",	
1726				data : jQuery.param({
1727					data: obj
1728				}),
1729		        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
1730		    }).then(function(response) {
1731		    	$scope.hideLoader();
1732		    	// console.log(response.data)
1733		    	if(response.data.code){
1734		    		window.top.location.href = response.data.result.login_url;
1735		    	}else{
1736		    		toastr.error(response.data.message); 	
1737		    	}
1738		    })
1739    }
1740
1741    $scope.openForgetScreen = function(){
1742    	jQuery('.pass-sec').hide();
1743    	jQuery('.forget-sec').show();
1744    }
1745    $scope.update_temp_user = function(data){
1746    	var obj = {
1747    			app : 'angular',
1748    			usertype : 'signin',
1749    			guestid : data.guest_id,
1750    			uid : data.user_id,
1751    			fid : '',
1752    			login_type : data.login_type    			
1753    		}
1754
1755    		
1756    		obj = $scope.encryptRequest(obj);
1757			$scope.startProcess = 1;
1758    		$scope.showLoader();
1759    		$http({
1760				method : 'POST',	
1761				url : $scope.apiurl+"ajax/update_temp_user",	
1762				data : jQuery.param({
1763					data: obj
1764				}),
1765		        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
1766		    }).then(function(response) {
1767		    		if(response.data.code == "1"){
1768		    			$scope.setCookie('A2F', 1);
1769		        		$scope.create_temp_user_angular(1);
1770
1771		        		setTimeout(function(){
1772		        			const params = new Proxy(new URLSearchParams(window.location.search), {
1773							  get: (searchParams, prop) => searchParams.get(prop),
1774							});
1775							// Get the value of "some_key" in eg "https://example.com/?some_key=some_value"
1776							if(params.redirect){
1777								window.location.href = params.redirect;
1778							}else{
1779								window.location.href = $scope.webappurl;
1780							}
1781		        		},1000)
1782
1783		        	}else{
1784		        		$scope.hideLoader();
1785		        		$scope.startProcess = 0;
1786		        		const params = new Proxy(new URLSearchParams(window.location.search), {
1787						  get: (searchParams, prop) => searchParams.get(prop),
1788						});
1789						// Get the value of "some_key" in eg "https://example.com/?some_key=some_value"
1790						if(params.redirect){
1791							window.location.href = params.redirect;
1792						}else{
1793							window.location.href = $scope.webappurl;
1794						}
1795		        	}
1796		   	})
1797    }
1798
1799    $scope.social_signin = function(obj){
1800    	
1801    	obj = $scope.encryptRequest(obj);
1802    	$scope.showLoader();
1803    	$http({
1804				method : 'POST',	
1805				url : $scope.apiurl+"signin/social_signin",	
1806				data : jQuery.param({
1807					data: obj
1808				}),
1809		        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
1810		    }).then(function(response) {
1811		    	$scope.hideLoader();
1812	        	if(response.data.status == "success"){
1813
1814					if(response.data.newSignup == 1){
1815						window.dataLayer = window.dataLayer || [];
1816						window.dataLayer.push({
1817						event: 'signup_complete',
1818						user_type: 'free',
1819						user_id: response.data.user_id
1820						});	
1821					}	
1822
1823	        		if(response.data.isSubUser){
1824	        			$scope.setCookie('_subUserID', response.data.subUserID);	
1825	        		}
1826	        		
1827				      $scope.setCookie('_userID', response.data.user_id);
1828					 if(response.data.show_invitation_popup){ $scope.setCookie('upgradeAmplifyPopup', 1); } 
1829				      $scope.setCookie('_email', response.data.email);
1830				      $scope.setCookie('_social_login', response.data.social_login);
1831				      if (response.data.name) {
1832				        $scope.setCookie('_name', response.data.name);
1833				      }
1834				      if (response.data.avtar && response.data.avtar != null) {
1835				        $scope.setCookie('_avatar', response.data.avtar);
1836				      }
1837				      var obj = {
1838				      	  user_id : response.data.user_id,
1839				      	  guest_id : response.data.guest_id,
1840				      	  login_type : 'nlogin'
1841				      }
1842				      $scope.update_temp_user(obj);
1843	        	}else{
1844	        		if(response.data.status != "blocked"){
1845	        			toastr.error(response.data.message); 	
1846	        		}
1847	        		return false;
1848	        		
1849	        	}
1850	        })
1851    }
1852
1853    $scope.clickLogin = function(){
1854
1855
1856    	if($scope.isLoginCase == 1){
1857    		if($scope.email == ''){
1858    			$scope.showErrorPopup(false,'Oops!','Please enter email','error','OKAY'); return false;
1859	    		
1860	    	}
1861	    	if($scope.password == ''){
1862	    		$scope.showErrorPopup(false,'Oops!','Please enter password','error','OKAY'); return false;
1863	    		
1864	    	}
1865
1866    		//login api
1867
1868    		var obj = {
1869    			email : $scope.email,
1870    			password : $scope.password,
1871    			app : 'angular',
1872    			uuid : $scope.uuid,
1873    			app_name : 'ifax',
1874    			'login-type' : 'nlogin',
1875    			'user-type' : 'guest',
1876    			ipaddress : $scope.getCookie('ipaddress'),
1877    			timezone : $scope.getCookie('_client_timezone')
1878    		}
1879
1880    		
1881    		obj = $scope.encryptRequest(obj);
1882    		$scope.startProcess = 1;
1883    		$scope.showLoader();
1884    		$http({
1885				method : 'POST',	
1886				url : $scope.apiurl+"signin/sign_in",	
1887				data : jQuery.param({
1888					data: obj
1889				}),
1890		        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
1891		    }).then(function(response) {
1892		    	$scope.startProcess = 0;
1893		    	$scope.hideLoader();
1894	        	if(response.data.status == "success"){
1895	        		  if(response.data.isSubUser){
1896		        			$scope.setCookie('_subUserID', response.data.subUserID);	
1897		        		}
1898				      $scope.setCookie('_userID', response.data.user_id);
1899					  if(response.data.show_invitation_popup){ $scope.setCookie('upgradeAmplifyPopup', 1); } 
1900				      $scope.setCookie('_email', response.data.email);
1901				      $scope.setCookie('_social_login', response.data.social_login);
1902				      if (response.data.name) {
1903				        $scope.setCookie('_name', response.data.name);
1904				      }
1905				      if (response.data.avtar && response.data.avtar != null) {
1906				        $scope.setCookie('_avatar', response.data.avtar);
1907				      }
1908				      var obj = {
1909				      	  user_id : response.data.user_id,
1910				      	  guest_id : response.data.guest_id,
1911				      	  login_type : 'nlogin'
1912				      }
1913				      $scope.update_temp_user(obj);
1914	        	}else{
1915	        		if(response.data.status != "blocked"){
1916	        			$scope.password = '';
1917	        			jQuery('#password').css('border-color','red');
1918	        			toastr.error(response.data.message); 	
1919	        		}
1920	        		return false;
1921	        	}
1922		   	})
1923    	}else{
1924    		if(!$scope.firstname || $scope.firstname == ''){
1925
1926	    		$scope.showErrorPopup(false,'Oops!','Please enter first name','error','OKAY'); return false;
1927	    	}
1928	    	if($scope.firstname.length < 2){
1929	    		$scope.showErrorPopup(false,'Oops!','First name must be at least 2 characters long','error','OKAY');
1930	    		return false;
1931	    	}
1932	    	if(!$scope.lastname || $scope.lastname == ''){
1933	    		$scope.showErrorPopup(false,'Oops!','Please enter last name','error','OKAY'); return false;
1934	    		
1935	    	}
1936	    	if($scope.lastname.length < 2){
1937	    		$scope.showErrorPopup(false,'Oops!','Last name must be at least 2 characters long','error','OKAY'); return false;
1938	    	}
1939    		if($scope.email == ''){
1940	    		$scope.showErrorPopup(false,'Oops!','Please enter email','error','OKAY'); return false;
1941	    		
1942	    	}
1943	    	if($scope.password == ''){
1944	    		$scope.showErrorPopup(false,'Oops!','Please enter password','error','OKAY'); return false;
1945	    		
1946	    	}
1947	    	
1948    		if($scope.password.length < 10){
1949    			$scope.showErrorPopup(false,'Oops!','Password must be at least 10 characters long','error','OKAY'); return false;
1950    			
1951    		}
1952
1953    		var strongPassword = new RegExp('(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])(?=.{10,})');
1954
1955    		if(!strongPassword.test($scope.password)){
1956    			$scope.showErrorPopup(false,'Oops!','The password is too weak. Please use alphanumeric characters with at least one special character.','error','OKAY'); return false;
1957    			
1958    		}
1959    		if($scope.cpassword == ''){
1960    			$scope.showErrorPopup(false,'Oops!','Please enter confirm password','error','OKAY'); return false;	    		
1961	    	}
1962    		if($scope.password != $scope.cpassword){
1963    			$scope.showErrorPopup(false,'Oops!','Your passwords do not match','error','OKAY'); return false;    			
1964    		}
1965
1966    		// register api
1967    		var obj = {
1968    			firstname : $scope.firstname,
1969    			lastname : $scope.lastname,
1970    			email : $scope.email,
1971    			password : $scope.password,
1972    			app : 'angular',
1973    			uuid : $scope.uuid,
1974    			app_name : 'ifax',
1975    			'login-type' : 'nlogin',
1976    			'user-type' : 'guest',
1977    			ipaddress : $scope.getCookie('ipaddress'),
1978    			timezone : $scope.getCookie('_client_timezone'),
1979    			referralUnique : $scope.getCookie('ifax_referral'),
1980    			emailUnique : $scope.getCookie('ifax_referral_token')
1981    		}
1982
1983    		
1984    		obj = $scope.encryptRequest(obj);
1985    		$scope.startProcess = 1;
1986    		$scope.showLoader();
1987    		$http({
1988				method : 'POST',	
1989				url : $scope.apiurl+"signin/sign_up",	
1990				data : jQuery.param({
1991					data: obj
1992				}),
1993		        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
1994		    }).then(function(response) {
1995		    	$scope.startProcess = 0;
1996		    	$scope.hideLoader();
1997	        	if(response.data.status == "success"){
1998						window.dataLayer = window.dataLayer || [];
1999						window.dataLayer.push({
2000						event: 'signup_complete',
2001						user_type: 'free',
2002						user_id: response.data.user_id
2003						});	
2004	        		  if(response.data.isSubUser){
2005		        			$scope.setCookie('_subUserID', response.data.subUserID);	
2006		        		}
2007				      $scope.setCookie('_userID', response.data.user_id);
2008					  if(response.data.show_invitation_popup){ $scope.setCookie('upgradeAmplifyPopup', 1); } 
2009				      $scope.setCookie('_email', response.data.email);
2010				      $scope.setCookie('_social_login', response.data.social_login);
2011				      if (response.data.name) {
2012				        $scope.setCookie('_name', response.data.name);
2013				      }
2014				      if (response.data.avtar && response.data.avtar != null) {
2015				        $scope.setCookie('_avatar', response.data.avtar);
2016				      }
2017				      var obj = {
2018				      	  user_id : response.data.user_id,
2019				      	  guest_id : response.data.guest_id,
2020				      	  login_type : 'nlogin'
2021				      }
2022				      $scope.update_temp_user(obj);
2023	        	}else{
2024	        		if(response.data.status != "blocked"){
2025	        			toastr.error(response.data.message); 	
2026	        		}
2027	        		return false;
2028	        	}
2029		   	})
2030    	}
2031
2032
2033    }
2034
2035    $scope.loginWithMS = function(){
2036        var d = new Date().getTime();
2037        var open = window.open('https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=61af4893-b769-40a4-80a7-d61984aebb48&response_type=code&redirect_uri=https://ifaxapp.com/&response_mode=query&scope=https://graph.microsoft.com/user.read&state=' + d, 'newwindow', 'width=480,height=600');
2038
2039        if(open){
2040            var intval = setInterval(function(){
2041                var token = jsGetCookie('linkedin_token');
2042                if(token){
2043                    var state = jsGetCookie('linkedin_state');    
2044                    // console.log(token);
2045                    open.close();
2046                    clearInterval(intval);
2047
2048                    var obj = {
2049                    	linkedin_token : token,
2050                    	linkedin_state : state
2051                    }
2052                    obj = $scope.encryptRequest(obj);
2053
2054		    		$http({
2055						method : 'POST',	
2056						url : $scope.apiurl+"ajax/authAzureUser",	
2057						data : jQuery.param({
2058							data: obj
2059						}),
2060				        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
2061				    }).then(function(response) {
2062			        	if(response.data.status == "1"){
2063			        		var obj = {
2064						        app : 'angular',
2065						        app_name : 'ifax',
2066						        login_by : 'Azure',
2067						        f_name : response.data.result.firstname,
2068						        l_name : response.data.result.lastname,
2069						        user_type : 'guest',
2070						        avatar : response.data.result.avatar,
2071						        fax_id : '',
2072						        uuid : $scope.uuid,
2073						        email : response.data.result.email,
2074						        social_id : $scope.encryptRequest(response.data.result.email) + CryptoJS.SHA256(response.data.result.email),
2075						        ipaddress : $scope.getCookie('ipaddress'),
2076						        timezone : $scope.getCookie('_client_timezone'),
2077						        referralUnique : $scope.getCookie('ifax_referral'),
2078    							emailUnique : $scope.getCookie('ifax_referral_token')
2079						      }
2080			        		$scope.social_signin(obj);
2081			        	}else{
2082			        		toastr.error(response.data.msg);
2083			        	}
2084			        })
2085
2086                    
2087                }
2088                
2089            },1000);
2090        }
2091    }
2092
2093
2094    $scope.loginWithGoogle = function(){
2095        var d = new Date().getTime();
2096        var open = window.open('https://accounts.google.com/o/oauth2/v2/auth?client_id=924789033676-cm7ts09sujq300n5d2md93tsgvcndlvq.apps.googleusercontent.com&redirect_uri=https://www.ifaxapp.com/&response_type=code&scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email&prompt=consent&state='+d, 'newwindow', 'width=480,height=600');
2097
2098        if(open){
2099            var intval = setInterval(function(){
2100                var token = jsGetCookie('linkedin_token');
2101                if(token){
2102                    var state = jsGetCookie('linkedin_state');    
2103                    // console.log(token);
2104                    open.close();
2105                    clearInterval(intval);
2106
2107                    var obj = {
2108                    	linkedin_token : token,
2109                    	linkedin_state : state
2110                    }
2111                    obj = $scope.encryptRequest(obj);
2112
2113		    		$http({
2114						method : 'POST',	
2115						url : $scope.apiurl+"ajax/authGmailUser",	
2116						data : jQuery.param({
2117							data: obj
2118						}),
2119				        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
2120				    }).then(function(response) {
2121			        	if(response.data.status == "1"){
2122			        		var obj = {
2123						        app : 'angular',
2124						        app_name : 'ifax',
2125						        login_by : 'Google',
2126						        f_name : response.data.result.firstname,
2127						        l_name : response.data.result.lastname,
2128						        user_type : 'guest',
2129						        avatar : response.data.result.avatar,
2130						        fax_id : '',
2131						        uuid : $scope.uuid,
2132						        email : response.data.result.email,
2133						        social_id : $scope.encryptRequest(response.data.result.email) + CryptoJS.SHA256(response.data.result.email),
2134						        ipaddress : $scope.getCookie('ipaddress'),
2135						        timezone : $scope.getCookie('_client_timezone'),
2136						        referralUnique : $scope.getCookie('ifax_referral'),
2137    							emailUnique : $scope.getCookie('ifax_referral_token')
2138						      }
2139			        		$scope.social_signin(obj);
2140			        	}else{
2141			        		toastr.error(response.data.msg);
2142			        	}
2143			        })
2144
2145                    
2146                }
2147                
2148            },1000);
2149        }
2150    }
2151
2152    $scope.SendForgetPasswordLink = function(){
2153    	$scope.startProcess = 1;
2154    	$scope.showLoader();
2155    	$http({
2156			method : 'POST',	
2157			url : $scope.apiurl+"signin/forget_password",	
2158			data : jQuery.param({
2159				email: $scope.email
2160			}),
2161	        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
2162	    }).then(function(response) {
2163	    	$scope.startProcess = 0;
2164	    	$scope.hideLoader();
2165	    	if(response.data.status == 1){
2166	    		toastr.success(response.data.message);
2167	    		$scope.backTOLoginScreen();
2168	    	}else{
2169	    		toastr.error(response.data.message);
2170	    	}
2171	    }).catch(function(error){
2172			$scope.startProcess = 0;
2173	    	$scope.hideLoader();
2174			if(error.status == "429"){
2175				toastr.error("Too many attempts. Please wait and try again.");;
2176			}
2177			
2178		})
2179		
2180    }
2181
2182    $scope.getCountryList = function(){
2183    	$http({
2184			method : 'GET',	
2185			url : "https://www.ifaxapp.com/wp-content/themes/jumpstart-child/country.json",
2186	    }).then(function(response) {
2187	    	$scope.countries = response.data;
2188	    })
2189    }
2190
2191    $scope.openCountry = function(OB){
2192    	jQuery('.contact_form_modal').addClass('show');
2193    	$scope.flagOB = OB;
2194    }
2195
2196    $scope.assignFreemiumWeb = function(){
2197    	// if($scope.getUserType() != 'user'){
2198    		// var url = btoa(weburl+'plans?callFun=assignFreemiumWeb');
2199    		window.location.href = weburl+'/login/?checkWorkEmail=1&redirect='+webappurl+'plan/'+btoa('free');
2200    		return false;
2201    	// }
2202
2203    	var obj = {
2204    		usertype : $scope.getUserType(),
2205    		userID : $scope.getUserID(),
2206    		subUserID : $scope.getCookie('_subUserID')   		
2207    		
2208    	}
2209    	
2210    	obj = $scope.encryptRequest(obj);
2211    	$http({
2212			method : 'POST',	
2213			url : $scope.apiurl+"ajax/assignFreemiumWeb",	
2214			data : jQuery.param({
2215				data: obj
2216			}),
2217	        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
2218	    }).then(function(response) {
2219	    	window.location.href = webappurl;
2220	    	return false;
2221	    })
2222    }
2223    if (ngurl.indexOf('/pricing') > -1 && ngurl.indexOf('/login') == -1){
2224    	setTimeout(function(){
2225	    	if(params1.callFun == "assignFreemiumWeb"){
2226		    	$scope.assignFreemiumWeb();
2227		    }
2228	    },500)
2229    }
2230    
2231    
2232
2233
2234
2235
2236    $scope.getDestinationPrice = function(destination = 'US',qty = '2',price = ''){
2237
2238    	var obj = {
2239    		app : 'angular',
2240    		usertype : $scope.getUserType(),
2241    		userID : $scope.getUserID(),
2242    		subUserID : '',
2243    		localcode : 'US',
2244    		destination : destination,
2245    		faxQuality : qty,
2246    		
2247    	}
2248    	if(price){
2249    		obj.price = price;
2250    	}
2251
2252    	obj = $scope.encryptRequest(obj);
2253    	$http({
2254			method : 'POST',	
2255			url : $scope.apiurl+"ajax/getDestinationPrice",	
2256			data : jQuery.param({
2257				data: obj
2258			}),
2259	        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
2260	    }).then(function(response) {
2261	    	if($scope.flagOB == 1){
2262	    		$scope.erp.tmpOBPrice = response.data.result.newPrice;		    		
2263	    	}else{
2264	    		$scope.erp.tmpIBPrice = response.data.result.newPrice;	    		
2265	    	}
2266
2267	    	$scope.changeDuration();
2268	    })
2269    }
2270
2271    $scope.getOCRPrice = function(price){
2272    	price += (price * 50 / 100).toFixed(2);
2273    	return price;
2274    }
2275
2276    $scope.changeUserAcc = function(flag){
2277    	if(flag == '+'){
2278			$scope.noofuser++;
2279
2280			if($scope.noofuser > 0){
2281				$scope.erp.subAccountPrice = 199.90;
2282			}
2283		}else{
2284			if($scope.noofuser == 0){
2285				return false;
2286			}
2287			$scope.noofuser--;
2288			if($scope.noofuser == 0){
2289					
2290			}
2291		}
2292		$scope.erp.teamsubaccount = $scope.noofuser;
2293		$scope.changeDuration();
2294
2295    }
2296
2297    $scope.getAmountForSubUser = function(){
2298    	if($scope.erp.teamsubaccount < 4){
2299    		return 16.66;
2300    	}else if($scope.erp.teamsubaccount < 7){
2301    		return 14.99;
2302    	}else if($scope.erp.teamsubaccount < 11){
2303    		return 14.16;
2304    	}else{
2305    		return 12.49;
2306    	}
2307    }
2308
2309    $scope.plusPlanTooltiptext = function(){
2310    	if($scope.variantID == 2 || $scope.variantID == 3){
2311    		return $scope.getCookie('currency_symbol')+'299.99/year';
2312    	}else{
2313    		return $scope.getCookie('currency_symbol')+'199.99/year';
2314    	}
2315    	
2316    }
2317
2318    $scope.plusPlantext = function(){
2319    	// console.log('plusPlantext',$scope.variantID)
2320    		if($scope.variantID == 2 || $scope.variantID == 3){
2321    			 
2322    			return $scope.getCookie('currency_symbol')+($scope.globalDuration == 12 ? '24.99' : '29.99')+' /mo';
2323	    	}else{
2324	    		return $scope.getCookie('currency_symbol')+($scope.globalDuration == 12 ? '16.67' : '19.99')+' /mo';
2325	    	}
2326
2327    	
2328    }
2329    $scope.basicPlanTooltiptext = function(){
2330    	if($scope.variantID == 2 || $scope.variantID == 3){
2331    		return $scope.getCookie('currency_symbol')+'149.99/year';
2332    	}else{
2333    		return $scope.getCookie('currency_symbol')+'99.99/year';
2334    	}
2335    	
2336    }
2337    $scope.basicPlantext = function(){
2338    	// console.log('basicPlantext',$scope.variantID)
2339    		if($scope.variantID == 2 || $scope.variantID == 3){
2340	    		return $scope.getCookie('currency_symbol')+($scope.globalDuration == 12 ? '12.49' : '14.99')+' /mo';
2341	    	}else{
2342	    		return $scope.getCookie('currency_symbol')+($scope.globalDuration == 12 ? '8.33' : '9.99')+' /mo';
2343	    	}
2344    	
2345    	
2346    }
2347    $scope.changeDuration = function(){
2348    	
2349    	// if($scope.erp.send_pages <= 1000){
2350    	// 	$scope.erp.unitOBprice = ($scope.variantID == 2 || $scope.variantID == 3) ? 0.04 : $scope.variantID == 4 ? 0.05 : 0.035;
2351    	// }else if($scope.erp.send_pages >= 1001 && $scope.erp.send_pages <= 2500){
2352    	// 	$scope.erp.unitOBprice = 0.03;
2353    	// }else if($scope.erp.send_pages >= 2501 && $scope.erp.send_pages <= 5000){
2354    	// 	$scope.erp.unitOBprice = 0.028;
2355		// }else if($scope.erp.send_pages >= 5001 && $scope.erp.send_pages <= 20000){
2356		// 	$scope.erp.unitOBprice = 0.025;
2357    	// }else if($scope.erp.send_pages >= 20001 && $scope.erp.send_pages <= 50000){
2358    	// 	$scope.erp.unitOBprice = 0.02;
2359    	// }else if($scope.erp.send_pages >= 50001 && $scope.erp.send_pages <= 100000){
2360    	// 	$scope.erp.unitOBprice = 0.018;
2361    	// }else if($scope.erp.send_pages >= 100001 && $scope.erp.send_pages <= 500000){
2362    	// 	$scope.erp.unitOBprice = 0.015;
2363    	// }else{
2364    	// 	$scope.erp.unitOBprice = 0.015;
2365    	// }
2366
2367    	if($scope.erp.send_pages <= 1000){
2368    		$scope.erp.unitOBprice = ($scope.variantID == 2 || $scope.variantID == 3) ? 0.04 : $scope.variantID == 4 ? 0.05 : 0.035;
2369    	}else if($scope.erp.send_pages >= 1001 && $scope.erp.send_pages <= 2500){
2370    		$scope.erp.unitOBprice = 0.034;
2371    	}else if($scope.erp.send_pages >= 2501 && $scope.erp.send_pages <= 5000){
2372    		$scope.erp.unitOBprice = 0.032;
2373		}else if($scope.erp.send_pages >= 5001 && $scope.erp.send_pages <= 20000){
2374			$scope.erp.unitOBprice = 0.028;
2375    	}else if($scope.erp.send_pages >= 20001 && $scope.erp.send_pages <= 50000){
2376    		$scope.erp.unitOBprice = 0.023;
2377    	}else if($scope.erp.send_pages >= 50001 && $scope.erp.send_pages <= 100000){
2378    		$scope.erp.unitOBprice = 0.02;
2379    	}else if($scope.erp.send_pages >= 100001 && $scope.erp.send_pages <= 500000){
2380    		$scope.erp.unitOBprice = 0.017;
2381    	}else{
2382    		$scope.erp.unitOBprice = 0.017;
2383    	}
2384
2385
2386    	if($scope.erp.faxQuality == 1){
2387    		$scope.erp.unitOBprice = ($scope.erp.unitOBprice - ($scope.erp.unitOBprice * 10 /100)).toFixed(4);
2388    	}else if($scope.erp.faxQuality == 3){
2389    		$scope.erp.unitOBprice = ($scope.erp.unitOBprice + ($scope.erp.unitOBprice * 35 /100)).toFixed(4);	    		
2390    	}else{
2391    		$scope.erp.unitOBprice = $scope.erp.unitOBprice;
2392    	}
2393    	
2394    	if($scope.erp.receive_pages < 3000){
2395    		$scope.erp.unitIBprice = 0.03;
2396    	}else if($scope.erp.receive_pages >= 3000 && $scope.erp.receive_pages < 7501){
2397    		$scope.erp.unitIBprice = 0.025;
2398    	}else{
2399    		$scope.erp.unitIBprice = 0.02;
2400    	}
2401
2402    	if($scope.erp.teamsubaccount < 4){
2403    		$scope.erp.subAccountPrice = 19.99;
2404    	}else if($scope.erp.teamsubaccount >= 4 && $scope.erp.teamsubaccount < 7){
2405    		$scope.erp.subAccountPrice = 17.99;
2406    	}else if($scope.erp.teamsubaccount >= 7 && $scope.erp.teamsubaccount < 11){
2407    		$scope.erp.subAccountPrice = 16.99;
2408    	}else{
2409    		$scope.erp.subAccountPrice = 14.99;
2410    	}
2411    	
2412    	$scope.amount = 0;
2413    	if($scope.erp.duration == 12){
2414    		if($scope.erp.send_pages){
2415    			$scope.amount += parseInt($scope.erp.send_pages) * parseFloat($scope.erp.unitOBprice) * 10;	
2416    		}
2417    		if($scope.erp.receive_pages){
2418    			$scope.amount += parseInt($scope.erp.receive_pages) * parseFloat($scope.erp.unitIBprice) * 10; 	
2419    		}
2420    		
2421    		if($scope.erp.teamsubaccount){
2422    			$scope.amount += parseInt($scope.erp.teamsubaccount) * parseFloat($scope.erp.subAccountPrice) * 10;	
2423    		}
2424    		if($scope.erp.fax_numbers){
2425    			$scope.amount += (parseInt($scope.erp.fax_numbers) - 1) * parseFloat($scope.erp.faxNumberPrice) * 10;	
2426    		}
2427    		
2428    		$scope.amount += parseInt($scope.erp.api) ? parseFloat($scope.erp.apiPrice) * 10 : 0;
2429    		$scope.amount += parseInt($scope.erp.enableBranding) ? parseFloat($scope.erp.brandPrice) * 10 : 0;
2430
2431    		if($scope.erp.faxOCROB && $scope.erp.send_pages){
2432    			$scope.amount += parseInt($scope.erp.send_pages) * parseFloat($scope.erp.faxOCRPriceOB) * 10;
2433    		}
2434    		if($scope.erp.faxOCR && $scope.erp.receive_pages){
2435    			$scope.amount += parseInt($scope.erp.receive_pages) * parseFloat($scope.erp.faxOCRPrice) * 10;
2436    		}
2437    		// $scope.total_txt = "$"+$scope.amount.toFixed(2)+"/yr ($"+($scope.amount/12).toFixed(2)+"/mo)";
2438    		
2439    		$scope.total_txt = ($scope.amount/12).toFixed(2)+' /mo';
2440    	}else{
2441    		if($scope.erp.send_pages){
2442    			$scope.amount += parseInt($scope.erp.send_pages) * parseFloat($scope.erp.unitOBprice);	
2443    		}
2444    		if($scope.erp.receive_pages){
2445    			$scope.amount += parseInt($scope.erp.receive_pages) * parseFloat($scope.erp.unitIBprice); 	
2446    		}
2447    		
2448    		if($scope.erp.teamsubaccount){
2449    			$scope.amount += parseInt($scope.erp.teamsubaccount) * parseFloat($scope.erp.subAccountPrice);
2450    		}
2451    		if($scope.erp.fax_numbers){
2452    			$scope.amount += (parseInt($scope.erp.fax_numbers) - 1) * parseFloat($scope.erp.faxNumberPrice);	
2453    		}
2454    		if($scope.erp.faxOCROB && $scope.erp.send_pages){
2455    			$scope.amount += parseInt($scope.erp.send_pages) * parseFloat($scope.erp.faxOCRPriceOB);
2456    		}
2457    		if($scope.erp.faxOCR && $scope.erp.receive_pages){
2458    			$scope.amount += parseInt($scope.erp.receive_pages) * parseFloat($scope.erp.faxOCRPrice);
2459    		}
2460    		$scope.amount += parseInt($scope.erp.api) ? parseFloat($scope.erp.apiPrice) : 0;
2461    		$scope.amount += parseInt($scope.erp.enableBranding) ? parseFloat($scope.erp.brandPrice) : 0;
2462
2463    		$scope.total_txt = (Math.ceil($scope.amount) - 0.01).toFixed(2)+' /mo';
2464    	}
2465    	// console.log($scope.amount)
2466    	if($scope.erp.duration == 12 && $scope.amount > 2000){
2467    		$scope.erp.is_free_product = 0;
2468    	}else if($scope.erp.duration == 1 && $scope.amount > 200){
2469    		$scope.erp.is_free_product = 0;
2470    	}else{
2471    		$scope.erp.is_free_product = 1;
2472    	}
2473
2474    	
2475    }
2476
2477    $scope.getListPrice = function(page,fax){
2478    	if(fax > 0){
2479    		var send_pages = parseInt(page/2);
2480    		var receive_pages = parseInt(page/2);	
2481    	}else{
2482    		var send_pages = parseInt(page);
2483    		var receive_pages = 0;
2484    	}
2485    	
2486    	var fax_numbers = parseInt(fax);
2487    	// if(send_pages < 3000){
2488    		var unitOBprice = ($scope.variantID == 2 || $scope.variantID == 3)? 0.04 : $scope.variantID == 4 ? 0.05 : 0.03;
2489
2490    	// }
2490else if(send_pages >= 3000 && send_pages < 7501){
2491    	// 	var unitOBprice = 0.025;
2492    	// }else{
2493    	// 	var unitOBprice = 0.02;
2494    	// }
2495    	
2496    	
2497    	if(receive_pages < 3000){
2498    		var unitIBprice = 0.03;
2499    	}else if(receive_pages >= 3000 && receive_pages < 7501){
2500    		var unitIBprice = 0.025;
2501    	}else{
2502    		var unitIBprice = 0.02;
2503    	}
2504
2505    	if($scope.erp.teamsubaccount < 4){
2506    		$scope.erp.subAccountPrice = 19.99;
2507    	}else if($scope.erp.teamsubaccount >= 4 && $scope.erp.teamsubaccount < 7){
2508    		$scope.erp.subAccountPrice = 17.99;
2509    	}else if($scope.erp.teamsubaccount >= 7 && $scope.erp.teamsubaccount < 11){
2510    		$scope.erp.subAccountPrice = 16.99;
2511    	}else{
2512    		$scope.erp.subAccountPrice = 14.99;
2513    	}
2514    	var amount = 0;
2515    	if($scope.erp.duration == 12){
2516    		if(send_pages){
2517    			amount += parseInt(send_pages) * parseFloat(unitOBprice) * 10;	
2518    		}
2519    		if(receive_pages){
2520    			amount += parseInt(receive_pages) * parseFloat(unitIBprice) * 10; 	
2521    		}
2522    		
2523    		if($scope.erp.teamsubaccount){
2524    			amount += parseInt($scope.erp.teamsubaccount) * parseFloat($scope.erp.subAccountPrice) * 10;	
2525    		}
2526    		if(fax_numbers){
2527    			amount += (parseInt(fax_numbers) - 1) * parseFloat($scope.erp.faxNumberPrice) * 10;	
2528    		}
2529    		
2530    		return (amount/12).toFixed(2);
2531    		
2532    	}else{
2533    		if(send_pages){
2534    			amount += parseInt(send_pages) * parseFloat(unitOBprice);	
2535    		}
2536    		if(receive_pages){
2537    			amount += parseInt(receive_pages) * parseFloat(unitIBprice); 	
2538    		}
2539    		
2540    		if($scope.erp.teamsubaccount){
2541    			amount += parseInt($scope.erp.teamsubaccount) * parseFloat($scope.erp.subAccountPrice);
2542    		}
2543    		if(fax_numbers){
2544    			amount += (parseInt(fax_numbers) - 1) * parseFloat($scope.erp.faxNumberPrice);	
2545    		}
2546
2547    		return amount.toFixed(2);
2548    		
2549    	}
2550    	
2551    }
2552
2553    $scope.changeOCR = function(type){
2554    	if(type == 'manual'){
2555    		$scope.erp.OCRtext = "Manual";
2556    		$scope.erp.faxOCROB = 0;
2557    		$scope.erp.faxOCR = 0;
2558    		$scope.erp.faxOCRPrice = 0;
2559      		$scope.erp.faxOCRPriceOB = 0;
2560      		$scope.erp.faxOCRPages = 0;
2561      		$scope.erp.OCRtextprice = "Pay-as-you-go ($0.40/page)";
2562    	}else if(type == 'all'){
2563    		$scope.erp.OCRtext = "Auto: All Pages";
2564    		$scope.erp.faxOCROB = 1;
2565    		$scope.erp.faxOCR = 1;
2566    		$scope.erp.faxOCRPrice = parseFloat($scope.getOCRPrice($scope.erp.tmpIBPrice)) / 2;
2567      		$scope.erp.faxOCRPriceOB = parseFloat($scope.getOCRPrice($scope.erp.tmpOBPrice)) / 2;
2568      		var pages = 0;
2569      		if($scope.erp.send_pages) pages += parseInt($scope.erp.send_pages);
2570      		if($scope.erp.receive_pages) pages += parseInt($scope.erp.receive_pages);
2571      		$scope.erp.faxOCRPages = pages;
2572      		$scope.erp.OCRtextprice = pages+' pages/mo ($'+((parseFloat($scope.erp.faxOCRPrice)+parseFloat($scope.erp.faxOCRPriceOB))/2 )+'/page)';
2573    	}else if(type == 'inbound'){
2574    		$scope.erp.OCRtext = "Auto: Inbound";
2575    		$scope.erp.faxOCROB = 0;
2576    		$scope.erp.faxOCR = 1;
2577    		$scope.erp.faxOCRPages = $scope.erp.receive_pages;
2578    		$scope.erp.faxOCRPrice = parseFloat($scope.getOCRPrice($scope.erp.tmpIBPrice))/2;
2579      		$scope.erp.faxOCRPriceOB = 0;
2580    		$scope.erp.OCRtextprice = $scope.erp.receive_pages+' pages/mo ($'+parseFloat($scope.erp.faxOCRPrice)+'/page)';
2581    	}
2582
2583    	$scope.changeDuration();
2584
2585    	$scope.ocrOPEN = 0;
2586    }
2587
2588    const params1 = new Proxy(new URLSearchParams(window.location.search), {
2589	  get: (searchParams, prop) => searchParams.get(prop),
2590	});
2591
2592	if(ngurl.indexOf("/custom-quote") > -1){
2593		$scope.noofuser = params1.user ? params1.user : 0;
2594	}
2595
2596    
2597
2598    $scope.erp = {
2599    	is_free_product : 1,
2600    	duration : 12,
2601    	send_pages : 1000,
2602    	receive_pages : 1000,
2603    	tmpOBPrice : 0.03,
2604    	tmpIBPrice : 0.03,
2605    	teamsubaccount : (params1.user ? parseInt(params1.user) : 0),
2606    	fax_numbers : 1,
2607    	subAccountPrice : 19.99,
2608    	faxNumberPrice : 6.99,
2609    	apiPrice : 9.99,
2610    	brandPrice : 19.99,
2611    	OCRtextprice : "Pay-as-you-go ($0.40/page)",
2612    	autosentpagestopup : 1,
2613    	autoreceivepagestopup : 1
2614    };
2615
2616    
2617    $scope.ocrOPEN = 0;
2618    $scope.changeOCR('manual');
2619    $scope.more = 0;
2620    $scope.destination = {};
2621
2622    $scope.selectQuality = function(qty){
2623    	var perprice = 0.03;
2624    	if($scope.erp.send_pages < 3000){
2625    		perprice = 0.03;
2626    	}else if($scope.erp.send_pages >= 3000 && $scope.erp.send_pages < 7501){
2627    		perprice = 0.025;
2628    	}else{
2629    		perprice = 0.02;
2630    	}
2631    	
2632    	if(qty == 1){
2633    		$scope.erp.faxQuality = 1;
2634    		$scope.erp.faxQualityFlag = 0;
2635    		var price = (perprice - (perprice * 10/100)).toFixed(4);
2636    	}else if(qty == 3){
2637    		$scope.erp.faxQuality = 3;
2638    		$scope.erp.faxQualityFlag = 0;
2639    		var price = (perprice + (perprice * 35/100)).toFixed(4);
2640
2641    	}else{
2642    		$scope.erp.faxQuality = 2;
2643    		$scope.erp.faxQualityFlag = 0;
2644    		var price = perprice;
2645    	}
2646    	
2647    	$scope.flagOB = 1;
2648
2649    	$scope.getDestinationPrice($scope.destination.TerritoryCode,$scope.erp.faxQuality,price);
2650    }
2651
2652    $scope.selectCountry = function(item){
2653    	var price;
2654    	if($scope.flagOB == 1){
2655    		$scope.destination = item;	
2656    		$scope.destinationOB = item;	
2657
2658    		var perprice = 0.03;
2659	    	if($scope.erp.send_pages < 3000){
2660	    		perprice = 0.03;
2661	    	}else if($scope.erp.send_pages >= 3000 && $scope.erp.send_pages < 7501){
2662	    		perprice = 0.025;
2663	    	}else{
2664	    		perprice = 0.02;
2665	    	}
2666
2667	    	if($scope.erp.faxQuality == 1){
2668	    		var price = (perprice - (perprice * 10 /100)).toFixed(4);
2669	    	}else if($scope.erp.faxQuality == 3){
2670	    		var price = (perprice + (perprice * 35 /100)).toFixed(4);	    		
2671	    	}else{
2672	    		var price = perprice;
2673	    	}
2674
2675	    	
2676    	}else{
2677    		$scope.destination = item;
2678    		$scope.destinationIB = item;	
2679    	}
2680    	
2681    	$scope.getDestinationPrice($scope.destination.TerritoryCode,$scope.erp.faxQuality,price);
2682    	jQuery('.contact_form_modal').removeClass('show');
2683    	$scope.searchCountry = '';
2684    }
2685
2686
2687    $scope.purchaseERP = function(){
2688
2689    	if($scope.selectedNumbers > 0){
2690    		$scope.erp.send_pages = parseInt($scope.selectedPages);
2691    		$scope.erp.receive_pages = 0;
2692    		$scope.erp.fax_numbers = parseInt($scope.selectedNumbers);
2693    	}else{
2694    		$scope.erp.send_pages = parseInt($scope.selectedPages);
2695    		$scope.erp.receive_pages = 0;
2696    		$scope.erp.fax_numbers = parseInt($scope.selectedNumbers);
2697    	}
2698
2699    	$scope.erp.teamsubaccount = parseInt($scope.selectedUsers)  - 1;
2700    	
2701
2702    	if($scope.erp.duration == 12){
2703    		if($scope.amount < 200){
2704    			$scope.showUpgradeWarning('iFax Professional starts at $200.00 per year. For cheaper plans we would suggest trying the iFax Basic or iFax Plus plans.')
2705    			// toastr.error('iFax Professional starts at $200.00 per year. For cheaper plans we would suggest trying the iFax Basic or iFax Plus plans.');
2706    			return false;
2707    		}
2708    	}else{
2709    		if($scope.amount < 20){
2710    			$scope.showUpgradeWarning('iFax Professional starts at $20.00 per month. For cheaper plans we would suggest trying the iFax Basic or iFax Plus plans.');
2711    		// toastr.error('iFax Professional starts at $20.00 per month. For cheaper plans we would suggest trying the iFax Basic or iFax Plus plans.');
2712    		return false;
2713    		}
2714    	}
2715
2716    	if($scope.variantID == 2){
2717    		$scope.erp.is_free_product = 1;
2718    	}else{
2719    		$scope.erp.is_free_product = 0;
2720    	}
2721
2722    	// pricing_script.allow_trial this variable declared in function.php.
2723    	if(pricing_script.allow_trial == '1'){
2724    		$scope.erp.is_free_product = 1;
2725    	}
2726
2727    	var obj = {
2728    	  incrementPagesIB: $scope.erp.autoreceivepagestopup ? Math.round((20 * $scope.erp.receive_pages) / 100) : 0,
2729	      incrementPagesOB: $scope.erp.autosentpagestopup ? Math.round((20 * $scope.erp.send_pages) / 100) : 0,
2730	      api: $scope.erp.api == 1 ? 1 : 0,
2731	      teamsubaccount: $scope.erp.teamsubaccount > 0 ? $scope.erp.teamsubaccount : 0,
2732	      fax_numbers: $scope.erp.fax_numbers,
2733	      firstFreeFaxNumber : 1,
2734	      unitPriceFaxNumber : $scope.erp.faxNumberPrice,
2735	      port_numbers: 0,
2736	      receive_pages: $scope.erp.receive_pages,
2737	      duration: $scope.erp.duration,
2738	      send_pages: $scope.erp.send_pages,
2739	      userID: $scope.getUserID(),
2740	      usertype: $scope.getUserType(),
2741	      is_free_product: $scope.erp.is_free_product,
2742	      subUserID: '',
2743	      enableBranding: $scope.erp.enableBranding ? 1 : 0,
2744	      brandingPrice: 19.99,
2745	      faxOCRPrice: $scope.erp.faxOCRPrice,
2746	      faxOCRPriceOB: $scope.erp.faxOCRPriceOB,
2747	      app: 'angular',
2748	      faxQuality: $scope.erp.faxQuality,
2749	      faxOCR : $scope.erp.faxOCR,
2750	      faxOCROB : $scope.erp.faxOCROB,
2751	      faxOCRPages : $scope.erp.faxOCRPages,
2752	      unitPriceOB : ($scope.variantID == 2 || $scope.variantID == 3) ? 0.04 : $scope.variantID == 4 ? 0.05 : $scope.erp.unitOBprice,
2753	      free_days : ($scope.allowTrial ? 3 : $scope.erp.is_free_product ? 7 : 0),
2754	      discountPercentage: $scope.erp.duration == 1 ? 0 : 16.7, 
2755    	}
2756
2757
2758
2759    	if($scope.erp.send_pages > 1000){
2760    		obj.unitPriceOB = $scope.erp.unitOBprice;
2761    	}
2762
2763    	
2764    	var base64 = btoa(JSON.stringify(obj));
2765
2766
2767
2768    	if($scope.getUserType() != "user"){
2769
2770    		window.location.href = weburl+'/login?checkWorkEmail='+(obj.is_free_product == 1 ? '1' : '0')+'&redirect='+webappurl+'professional/'+base64;
2771    		return false;
2772    	}else{
2773    		window.location.href = webappurl+'professional/'+base64;	
2774    		return false;
2775    	}
2776    	
2777    	
2778
2779    }
2780
2781    
2782    $scope.changeDurationToggle = function(duration = '1'){
2783    	if(duration == '12') {
2784	        // annual
2785	        jQuery('.basic .oe_price_div,.plus .oe_price_div').show();
2786	        jQuery('.basic .amount_sec .text,.plus .amount_sec .text,.professional .amount_sec .text').show();
2787
2788	        jQuery('.basic .package_amount').html('$8.33');
2789	        jQuery('.plus .package_amount').html('$16.67');
2790	        jQuery('.price_month_ttl').removeClass('active');
2791	        jQuery('.discount_span').addClass('discount_active');
2792	        jQuery('.price_year_ttl').addClass('active');
2793
2794	        // jQuery('.price_block.professional').removeClass('fadediv');
2795	    }else{
2796	        jQuery('.basic .oe_price_div,.plus .oe_price_div').hide();
2797	        jQuery('.basic .amount_sec .text1,.plus .amount_sec .text1,.professional .amount_sec .text1').hide();
2798
2799	        jQuery('.basic .package_amount').html('$9.99');
2800	        jQuery('.plus .package_amount').html('$19.99');
2801	        jQuery('.price_month_ttl').addClass('active');
2802	        jQuery('.price_year_ttl').removeClass('active');
2803	        jQuery('.discount_span').removeClass('discount_active');
2804	        
2805	        // jQuery('.price_block.professional').addClass('fadediv'); 
2806	        
2807	        // monthy
2808	    }
2809    	$scope.globalDuration = duration;
2810
2811    	$scope.erp.duration = parseInt(duration);
2812
2813    	$scope.erp.fax_numbers = parseInt($scope.selectedNumbers);
2814    	if($scope.selectedNumbers){
2815    		$scope.erp.send_pages = parseInt($scope.selectedPages);
2816    		$scope.erp.receive_pages = 0;
2817    	}else{
2818    		$scope.erp.send_pages = parseInt($scope.selectedPages);
2819    		$scope.erp.receive_pages = 0;
2820    	}
2821    	// console.log($scope.erp);
2822    	$scope.changeDuration();
2823    	// checkBox = document.getElementById('duration');
2824	    // Check if the element is selected/checked
2825	    
2826	       
2827	}
2828
2829
2830	$scope.showUpgradeWarning = function(desc){
2831		$scope.modal_description = desc;
2832		jQuery('.custom_quote_modal').modal();
2833	}
2834
2835	$scope.redirectOnPricing = function(){
2836		window.location.href = weburl + 'pricing/';
2837		return false;
2838	}
2839
2840	$scope.redirectOnlogin = function(){
2841		 if($scope.getUserType() != 'user'){
2842    		window.location.href = weburl+'/login/?redirect='+weburl+'beforeyougo/';
2843    		return false;
2844    	}
2845	}
2846
2847	$scope.checkLogin = function(page,isWebapp = 0){
2848		 if($scope.getUserType() != 'user'){
2849		 	if(isWebapp){
2850		 		window.location.href = weburl+'/login/?redirect='+webappurl+page+'/';
2851    			return false;
2852		 	}else{
2853		 		window.location.href = weburl+'/login/?redirect='+weburl+page+'/';
2854    			return false;	
2855		 	}
2856    		
2857    	}
2858	}
2859
2860
2861
2862	if (window.location.href.includes('custom-quote')) {
2863        jQuery(document).on("click", function(event){
2864            var $trigger = jQuery(".fielddropdown");
2865            // console.log($trigger.has(event.target).length);
2866            if($trigger !== event.target && !$trigger.has(event.target).length){
2867                jQuery(".fielddropdown").removeClass("open");  
2868                $scope.erp.faxQualityFlag = 0;
2869                $scope.$apply();
2870            }            
2871        });
2872        jQuery(document).on("click", function(event){
2873            var $trigger = jQuery(".manual-selector");
2874            // console.log($trigger.has(event.target).length);
2875            if($trigger !== event.target && !$trigger.has(event.target).length){
2876                jQuery(".manual-selector").removeClass("open");  
2877                $scope.ocrOPEN = 0;
2878                $scope.$apply();
2879            }            
2880        });
2881    }
2882
2883    if (window.location.href.includes('pricing')) {
2884        jQuery(document).on("click", function(event){
2885            var $trigger = jQuery(".fielddropdown.faxDrp");
2886            // console.log($trigger.has(event.target).length);
2887            if($trigger !== event.target && !$trigger.has(event.target).length){
2888                jQuery(".fielddropdown.faxDrp").removeClass("open");  
2889                $scope.erp.erpFaxFlag = 0;
2890                $scope.$apply();
2891            }            
2892        });
2893
2894        jQuery(document).on("click", function(event){
2895            var $trigger = jQuery(".fielddropdown.pageDrp");
2896            // console.log($trigger.has(event.target).length);
2897            if($trigger !== event.target && !$trigger.has(event.target).length){
2898                jQuery(".fielddropdown.pageDrp").removeClass("open");  
2899                $scope.erp.erpPageFlag = 0;
2900                $scope.$apply();
2901            }            
2902        });
2903        
2904    }
2905
2906
2907    $scope.checkout = function(plan){
2908
2909    	if($scope.leftbar.plan == "ERP"){
2910    		if($scope.leftbar.isPrimary == 1){
2911    			if(confirm("You are currently on the Professional plan. Would you like to downgrade it?")){
2912	    			if($scope.globalDuration == 12) {
2913				       var dur = '12';  
2914				    }else{
2915				      var dur = '01';
2916				    }
2917				    
2918				    if($scope.getUserType() != 'user'){
2919			    		window.location.href = weburl+'/login/?redirect='+webappurl+'plan/'+btoa(plan+'-'+dur+'-'+$scope.allowTrial);
2920			    		return false;
2921			    	}else{
2922			    		window.location.href = webappurl+'plan/'+btoa(plan+'-'+dur+'-'+$scope.allowTrial);
2923			    		return false;	
2924			    	}
2925	    		}else{
2926	    			return false;
2927	    		}
2928    		}else{
2929    			alert("You are currently on the Professional plan. To downgrade your plan, please contact your iFax account owner or admin.");
2930    			return false;
2931    		}
2932    		
2933    	}else{
2934
2935    		if(plan == "plus" && ($scope.variantID == 2 || $scope.variantID == 3)){
2936    			var obj = {
2937		    	  duration: $scope.globalDuration,
2938			      userID: $scope.getUserID(),
2939			      usertype: $scope.getUserType(),
2940			      is_free_product: ($scope.allowTrial > 0 ? 1 : 0),
2941			      app: 'angular',
2942			      free_days : ($scope.allowTrial > 0 ? 3 : 0),
2943			      code: ($scope.allowTrial > 0 ? 'TRIAL_' : '')+'IFAX_WEB_PRO_'+($scope.globalDuration == 1 ? '01' : '12')+'_'+($scope.globalDuration == 1 ? '29.99' : '299.99')
2944		    	}
2945		    	
2946		    	var base64 = btoa(JSON.stringify(obj));
2947
2948		    	if($scope.getUserType() != "user"){
2949
2950		    		window.location.href = weburl+'/login/?redirect='+webappurl+'plus/'+base64;
2951		    		return false;
2952		    	}else{
2953		    		window.location.href = webappurl+'plus/'+base64;	
2954		    		return false;
2955		    	}
2956    		}else if(plan == "basic" && ($scope.variantID == 2 || $scope.variantID == 3)){
2957    			var obj = {
2958		    	  duration: $scope.globalDuration,
2959			      userID: $scope.getUserID(),
2960			      usertype: $scope.getUserType(),
2961			      is_free_product: ($scope.allowTrial > 0 ? 1 : 0),
2962			      app: 'angular',
2963			      free_days : ($scope.allowTrial > 0 ? 3 : 0),
2964			      code: ($scope.allowTrial > 0 ? 'TRIAL_' : '')+'IFAX_WEB_PLUS_'+($scope.globalDuration == 1 ? '01' : '12')+'_'+($scope.globalDuration == 1 ? '14.99' : '149.99')
2965		    	}
2966		    	
2967		    	var base64 = btoa(JSON.stringify(obj));
2968
2969		    	if($scope.getUserType() != "user"){
2970
2971		    		window.location.href = weburl+'/login/?redirect='+webappurl+'plus/'+base64;
2972		    		return false;
2973		    	}else{
2974		    		window.location.href = webappurl+'plus/'+base64;	
2975		    		return false;
2976		    	}
2977    		}else{
2978    			if($scope.globalDuration == 12) {
2979			       var dur = '12';  
2980			    }else{
2981			      var dur = '01';
2982			    }
2983			    
2984			    if($scope.getUserType() != 'user'){
2985		    		window.location.href = weburl+'/login/?redirect='+webappurl+'plan/'+btoa(plan+'-'+dur+'-'+$scope.allowTrial);
2986		    		return false;
2987		    	}else{
2988		    		window.location.href = webappurl+'plan/'+btoa(plan+'-'+dur+'-'+$scope.allowTrial);
2989		    		return false;	
2990		    	}
2991    		}
2992
2993
2994    		
2995    	}
2996	    
2997	    
2998
2999	}
3000
3001	if (jQuery(window).width() < 1300 && (window.location.href.includes('pricing') || window.location.href.includes('plans'))) {
3002        
3003    //     setTimeout(function(){
3004    //       $scope.carousel = jQuery('.price_slider').owlCarousel({
3005    //         loop:false,
3006    //         margin: 0,
3007    //         nav:false,
3008    //         items:3,
3009    //         responsive:{
3010    //             0:{
3011    //                 items:1
3012    //             },
3013    //             700:{
3014    //                 items:2
3015    //             },
3016    //             992:{
3017    //                 items:3
3018    //             }
3019    //         }
3020    //     });
3021          
3022    //       $scope.carousel.trigger('to.owl.carousel', [3, 500]);
3023    //     	setTimeout(function(){
3024    //     		$scope.carousel.on('changed.owl.carousel', function(event) {
3025		  //       	if($scope.noofuser > 0){
3026		  //       		$scope.carousel.trigger('to.owl.carousel', [3, 500]);	
3027		  //       	}
3028				    
3029				// })
3030    //     	},0)
3031        	
3032    //     },100)
3033
3034        
3035    }
3036    	
3037    $scope.selectPages = function(page){
3038    	$scope.selectedPages = page;
3039    	$scope.erp.erpPageFlag = 0;
3040    	$scope.erp.fax_numbers = parseInt($scope.selectedNumbers);
3041    	if($scope.selectedNumbers){
3042    		$scope.erp.send_pages = parseInt($scope.selectedPages);
3043    		$scope.erp.receive_pages = 0;
3044    	}else{
3045    		$scope.erp.send_pages = parseInt($scope.selectedPages);
3046    		$scope.erp.receive_pages = 0;
3047    	}
3048    	
3049    	$scope.changeDuration();
3050    }
3051
3052    $scope.viewPages = function(page,duration){
3053    	var price = 0;
3054    	var pages = 0;
3055   	
3056
3057    	if(page == 500) price = (duration == 1 ? 19.99 : 16.67);
3058    	if(page > 500){
3059    		$scope.erp.send_pages = parseInt(page);
3060    		$scope.erp.receive_pages = parseInt(page/2);
3061    		
3062	    	// if($scope.erp.send_pages <= 1000){
3063	    	// 	perprice = ($scope.variantID == 2 || $scope.variantID == 3) ? 0.04 : $scope.variantID == 4 ? 0.05 : 0.035;
3064	    	// }else if($scope.erp.send_pages >= 1001 && $scope.erp.send_pages <= 2500){
3065	    	// 	perprice = 0.03;
3066	    	// }else if($scope.erp.send_pages >= 2501 && $scope.erp.send_pages <= 5000){
3067	    	// 	perprice = 0.028;
3068    		// }else if($scope.erp.send_pages >= 5001 && $scope.erp.send_pages <= 20000){
3069    		// 	perprice = 0.025;
3070	    	// }else if($scope.erp.send_pages >= 20001 && $scope.erp.send_pages <= 50000){
3071	    	// 	perprice = 0.02;
3072	    	// }else if($scope.erp.send_pages >= 50001 && $scope.erp.send_pages <= 100000){
3073	    	// 	perprice = 0.018;
3074	    	// }else if($scope.erp.send_pages >= 100001 && $scope.erp.send_pages <= 500000){
3075	    	// 	perprice = 0.015;
3076	    	// }else{
3077	    	// 	perprice = 0.015;
3078	    	// }
3079
3080	    	if($scope.erp.send_pages <= 1000){
3081	    		perprice = ($scope.variantID == 2 || $scope.variantID == 3) ? 0.04 : $scope.variantID == 4 ? 0.05 : 0.035;
3082	    	}else if($scope.erp.send_pages >= 1001 && $scope.erp.send_pages <= 2500){
3083	    		perprice = 0.034;
3084	    	}else if($scope.erp.send_pages >= 2501 && $scope.erp.send_pages <= 5000){
3085	    		perprice = 0.021;
3086    		}else if($scope.erp.send_pages >= 5001 && $scope.erp.send_pages <= 20000){
3087    			perprice = 0.028;
3088	    	}else if($scope.erp.send_pages >= 20001 && $scope.erp.send_pages <= 50000){
3089	    		perprice = 0.023;
3090	    	}else if($scope.erp.send_pages >= 50001 && $scope.erp.send_pages <= 100000){
3091	    		perprice = 0.020;
3092	    	}else if($scope.erp.send_pages >= 100001 && $scope.erp.send_pages <= 500000){
3093	    		perprice = 0.017;
3094	    	}else{
3095	    		perprice = 0.017;
3096	    	}
3097
3098
3099	    	if(duration == 12){
3100	    		price = (page * perprice * 10 / 12).toFixed(2);	
3101	    	}else{
3102	    		price = (page * perprice).toFixed(2);	
3103	    	}
3104	    	
3105	    	
3106	    	// price = $scope.getListPrice(page,$scope.selectedNumbers);
3107	    	
3108    	}
3109
3110    	return "<h5>"+$scope.getCookie('currency_symbol')+price+"</h5><p>"+page.toLocaleString('en-US')+" pages /mo</p>";
3111
3112
3113    }
3114
3115    $scope.viewPricePerPage = function(page,duration){
3116    	var price = 0;
3117    	var pages = 0;
3118   	
3119    	if($scope.variantID == 2 || $scope.variantID == 3){
3120	    	if(page == 500){
3121	    		perprice = (duration == 12 ? 0.049 : 0.059);	    		
3122	    	}else if(page == 200){
3123	    		perprice = (duration == 12 ? 0.062 : 0.074);
3124			} 
3125	    	
3126    	}else{
3127    		if(page == 500){
3128	    		perprice = (duration == 12 ? 0.033 : 0.039);	    		
3129	    	}else if(page == 200){
3130	    		perprice = (duration == 12 ? 0.041 : 0.049);
3131			}
3132    	}
3133
3134    	if(page > 500){
3135    		$scope.erp.send_pages = parseInt(page);
3136    		$scope.erp.receive_pages = parseInt(page/2);
3137    		
3138	    	// if($scope.erp.send_pages <= 1000){
3139	    	// 	perprice = ($scope.variantID == 2 || $scope.variantID == 3) ? 0.04 : $scope.variantID == 4 ? 0.05 : 0.035;
3140	    	// }else if($scope.erp.send_pages >= 1001 && $scope.erp.send_pages <= 2500){
3141	    	// 	perprice = 0.03;
3142	    	// }else if($scope.erp.send_pages >= 2501 && $scope.erp.send_pages <= 5000){
3143	    	// 	perprice = 0.028;
3144    		// }else if($scope.erp.send_pages >= 5001 && $scope.erp.send_pages <= 20000){
3145    		// 	perprice = 0.025;
3146	    	// }else if($scope.erp.send_pages >= 20001 && $scope.erp.send_pages <= 50000){
3147	    	// 	perprice = 0.02;
3148	    	// }else if($scope.erp.send_pages >= 50001 && $scope.erp.send_pages <= 100000){
3149	    	// 	perprice = 0.018;
3150	    	// }else if($scope.erp.send_pages >= 100001 && $scope.erp.send_pages <= 500000){
3151	    	// 	perprice = 0.015;
3152	    	// }else{
3153	    	// 	perprice = 0.015;
3154	    	// }
3155
3156	    	if($scope.erp.send_pages <= 1000){
3157	    		perprice = ($scope.variantID == 2 || $scope.variantID == 3) ? 0.04 : $scope.variantID == 4 ? 0.05 : 0.035;
3158	    	}else if($scope.erp.send_pages >= 1001 && $scope.erp.send_pages <= 2500){
3159	    		perprice = 0.034;
3160	    	}else if($scope.erp.send_pages >= 2501 && $scope.erp.send_pages <= 5000){
3161	    		perprice = 0.032;
3162    		}else if($scope.erp.send_pages >= 5001 && $scope.erp.send_pages <= 20000){
3163    			perprice = 0.028;
3164	    	}else if($scope.erp.send_pages >= 20001 && $scope.erp.send_pages <= 50000){
3165	    		perprice = 0.023;
3166	    	}else if($scope.erp.send_pages >= 50001 && $scope.erp.send_pages <= 100000){
3167	    		perprice = 0.02;
3168	    	}else if($scope.erp.send_pages >= 100001 && $scope.erp.send_pages <= 500000){
3169	    		perprice = 0.017;
3170	    	}else{
3171	    		perprice = 0.017;
3172	    	}
3173
3174
3175	    	if(duration == 12){
3176	    		price = (page * perprice * 10 / 12).toFixed(2);	
3177	    		perprice = price/page;
3178	    	}else{
3179	    		price = (page * perprice).toFixed(2);	
3180	    	}
3181	    	
3182	    	
3183	    	// price = $scope.getListPrice(page,$scope.selectedNumbers);
3184	    	
3185    	}
3186    	
3187    	return "<h5>"+(perprice*100).toFixed(1).replace(/\.?0+$/, '')+"¢/pg</h5>";
3188
3189
3190    }
3191
3192    $scope.selectNumber = function(number){
3193    	$scope.selectedNumbers = parseInt(number);
3194    	$scope.erp.erpFaxFlag = 0;
3195    	$scope.erp.fax_numbers = parseInt($scope.selectedNumbers);
3196    	if($scope.selectedNumbers){
3197    		$scope.erp.send_pages = parseInt($scope.selectedPages);
3198    		$scope.erp.receive_pages = 0;
3199    	
3200    		if($scope.getCookie('country_code') == "US"){
3201				if($scope.selectedNumbers <= 9){
3202		            $scope.erp.faxNumberPrice = 4.99;
3203		        }else if($scope.selectedNumbers >= 10 && $scope.selectedNumbers <= 49){
3204		            $scope.erp.faxNumberPrice = 3.99;
3205		        }else if($scope.selectedNumbers >= 50 && $scope.selectedNumbers <= 99){
3206		            $scope.erp.faxNumberPrice = 2.99;
3207		        }else if($scope.selectedNumbers >= 100 && $scope.selectedNumbers <= 499){
3208		            $scope.erp.faxNumberPrice = 1.99;
3209		        }else{
3210		            $scope.erp.faxNumberPrice = 0.99;
3211		        }
3212			}
3213    	}else{
3214    		$scope.erp.send_pages = parseInt($scope.selectedPages);
3215    		$scope.erp.receive_pages = 0;
3216    	}
3217
3218    	// console.log('$scope.erp.faxNumberPrice',$scope.erp.faxNumberPrice)
3219    	
3220    	$scope.changeDuration();
3221    }
3222
3223
3224
3225    $scope.viewNumbers = function(number,duration){
3226    	
3227    		var faxNumberPrice = 6.99;
3228	    	if($scope.arrCountry[$scope.getCookie('country_code')]){
3229	    		faxNumberPrice = $scope.arrCountry[$scope.getCookie('country_code')];
3230	    		faxNumberPrice = parseFloat(faxNumberPrice) + parseFloat(faxNumberPrice*20/100);
3231	    		// console.log('price with 20% margin',faxNumberPrice);
3232	    		if(faxNumberPrice < 6.99){
3233	    			faxNumberPrice = 6.99;
3234	    		}
3235	    	}
3236
3237	    	var price = 0;
3238	    	var numbers = 0;
3239	   		var price = 0;
3240			$scope.erp.fax_numbers = parseInt(number);
3241			if($scope.getCookie('country_code') == "US"){
3242	    		if($scope.erp.fax_numbers <= 9){
3243	                faxNumberPrice = 4.99;
3244	            }else if($scope.erp.fax_numbers >= 10 && $scope.erp.fax_numbers <= 49){
3245	                faxNumberPrice = 3.99;
3246	            }else if($scope.erp.fax_numbers >= 50 && $scope.erp.fax_numbers <= 99){
3247	                faxNumberPrice = 2.99;
3248	            }else if($scope.erp.fax_numbers >= 100 && $scope.erp.fax_numbers <= 499){
3249	                faxNumberPrice = 1.99;
3250	            }else{
3251	                faxNumberPrice = 0.99;
3252	            }
3253	    	}
3254
3255	    	// console.log('faxNumberPrice',faxNumberPrice,$scope.erp.fax_numbers)
3256			$scope.erp.fax_number_price = (duration == 1 ? faxNumberPrice : faxNumberPrice*10);
3257			if(duration == 12){
3258				price = ((parseInt(number) * $scope.erp.fax_number_price)/12).toFixed(2);
3259				if(parseInt(number) == 1){
3260					// price = (parseFloat(price) + parseFloat(0.01)).toFixed(2);
3261				}
3262			}else{
3263				price = (parseInt(number) * $scope.erp.fax_number_price).toFixed(2);	
3264			}
3265	    	
3266			// price = $scope.getListPrice($scope.selectedPages,number);
3267			return "<h5>"+$scope.getCookie('currency_symbol')+price+" /mo</h5><p>"+number+ (number == 1 ? ' number' : ' numbers')+"</p>";
3268    	
3269    	
3270    }
3271
3272
3273    $scope.page_list = [1000, 1500, 2000, 2500, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000];
3274    $scope.fax_list = [0,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40, 50];
3275
3276    $scope.checkReferral = function(){
3277    	jQuery('.error-msg').css('display','none');
3278        var flag = 1;
3279        var code = '';
3280        jQuery('.input').each(function(item){
3281            if(!jQuery(this).val()){
3282                flag = 0;
3283                jQuery('.error-msg').css('display','block');
3284            }else{
3285            	code +=jQuery(this).val();
3286            }
3287        })
3288        if(flag){
3289        	$http({
3290			method : 'POST',	
3291			url : $scope.apiurl+"ajax/checkReferral",	
3292			data :jQuery.param({code: code}),
3293	        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
3294	        }).then(function(response) {
3295	        	if(response.data.code){
3296	        		window.location.href = "https://www.ifaxapp.com/login/?checkWorkEmail=1&redirect=https://web.ifaxapp.com/professional/eyJpbmNyZW1lbnRQYWdlc0lCIjowLCJpbmNyZW1lbnRQYWdlc09CIjoyMDAsImFwaSI6MCwidGVhbXN1YmFjY291bnQiOjAsImZheF9udW1iZXJzIjoxLCJmaXJzdEZyZWVGYXhOdW1iZXIiOjEsInVuaXRQcmljZUZheE51bWJlciI6Ni45OSwicG9ydF9udW1iZXJzIjowLCJyZWNlaXZlX3BhZ2VzIjowLCJkdXJhdGlvbiI6MTIsInNlbmRfcGFnZXMiOjEwMDAsInVzZXJJRCI6IjhJYkxOSGN1IiwidXNlcnR5cGUiOiJndWVzdCIsImlzX2ZyZWVfcHJvZHVjdCI6MSwic3ViVXNlcklEIjoiIiwiZW5hYmxlQnJhbmRpbmciOjAsImJyYW5kaW5nUHJpY2UiOjE5OS45LCJmYXhPQ1JQcmljZSI6MCwiZmF4T0NSUHJpY2VPQiI6MCwiYXBwIjoiYW5ndWxhciIsImZheE9DUiI6MCwiZmF4T0NST0IiOjAsImZheE9DUlBhZ2
3296VzIjowfQ==";   		
3297	        	}else{
3298	        		 jQuery('.error-msg').css('display','block');
3299	        	}
3300	        })
3301             
3302        }
3303
3304	}
3305
3306
3307	// $scope.sliderValue = 18466;
3308
3309
3310
3311	$scope.durationNew = 12;
3312	$scope.pagesNew = 200;
3313	$scope.pagesNewRange = 1;
3314	$scope.license_list = [1,2,3,5,10,15,20,30,50,100];
3315	$scope.subAccountLimit = 1;
3316	$scope.basicPlanAmt = $scope.getCookie('currency_symbol')+"12.49/mo";
3317	$scope.plusPlanAmt = $scope.getCookie('currency_symbol')+'24.99/mo';
3318	$scope.disabledBasic = 0;
3319	$scope.disabledPlus = 0;
3320	$scope.erp.additionalPrice_price = 0;
3321	$scope.currentTab = "app";
3322	$scope.selectedNumbers = 0;
3323
3324
3325	$scope.selectNumberNew = function(number){
3326    	$scope.selectedNumbers = parseInt(number);
3327    	$scope.erp.erpFaxFlag = 0;
3328    	$scope.erp.fax_numbers = parseInt($scope.selectedNumbers);
3329
3330    	
3331    	if($scope.selectedNumbers){
3332    		$scope.erp.send_pages = parseInt($scope.selectedPages);
3333    		$scope.erp.receive_pages = 0;
3334    	
3335    		if($scope.getCookie('country_code') == "US"){
3336				if($scope.selectedNumbers <= 9){
3337		            $scope.erp.faxNumberPrice = 4.99;
3338		        }else if($scope.selectedNumbers >= 10 && $scope.selectedNumbers <= 49){
3339		            $scope.erp.faxNumberPrice = 3.99;
3340		        }else if($scope.selectedNumbers >= 50 && $scope.selectedNumbers <= 99){
3341		            $scope.erp.faxNumberPrice = 2.99;
3342		        }else if($scope.selectedNumbers >= 100 && $scope.selectedNumbers <= 499){
3343		            $scope.erp.faxNumberPrice = 1.99;
3344		        }else{
3345		            $scope.erp.faxNumberPrice = 0.99;
3346		        }
3347			}
3348    	}else{
3349    		$scope.erp.send_pages = parseInt($scope.selectedPages);
3350    		$scope.erp.receive_pages = 0;
3351    	}
3352
3353    	$scope.flagNumber = false;
3354
3355    	// console.log('$scope.erp.faxNumberPrice',$scope.erp.faxNumberPrice)
3356    	
3357    	$scope.changeDurationToggleNew($scope.globalDuration);
3358    	
3359    }
3360
3361
3362
3363    $scope.viewNumbersNew = function(number,duration){
3364    	var faxNumberPrice = 6.99;
3365    	if($scope.arrCountry[$scope.getCookie('country_code')]){
3366    		faxNumberPrice = $scope.arrCountry[$scope.getCookie('country_code')];
3367    		faxNumberPrice = parseFloat(faxNumberPrice) + parseFloat(faxNumberPrice*20/100);
3368    		// console.log('price with 20% margin',faxNumberPrice);
3369    		if(faxNumberPrice < 6.99){
3370    			faxNumberPrice = 6.99;
3371    		}
3372    	}
3373
3374    	var price = 0;
3375    	var numbers = 0;
3376   		var price = 0;
3377		$scope.erp.fax_numbers = parseInt(number);
3378		if($scope.getCookie('country_code') == "US"){
3379    		if($scope.erp.fax_numbers <= 9){
3380                faxNumberPrice = 4.99;
3381            }else if($scope.erp.fax_numbers >= 10 && $scope.erp.fax_numbers <= 49){
3382                faxNumberPrice = 3.99;
3383            }else if($scope.erp.fax_numbers >= 50 && $scope.erp.fax_numbers <= 99){
3384                faxNumberPrice = 2.99;
3385            }else if($scope.erp.fax_numbers >= 100 && $scope.erp.fax_numbers <= 499){
3386                faxNumberPrice = 1.99;
3387            }else{
3388                faxNumberPrice = 0.99;
3389            }
3390    	}
3391
3392    	// console.log('faxNumberPrice',faxNumberPrice,$scope.erp.fax_numbers)
3393		$scope.erp.fax_number_price = (duration == 1 ? faxNumberPrice : faxNumberPrice*10);
3394		if(duration == 12){
3395			price = ((parseInt(number) * $scope.erp.fax_number_price)/12).toFixed(2);
3396			if(parseInt(number) == 1){
3397				// price = (parseFloat(price) + parseFloat(0.01)).toFixed(2);
3398			}
3399		}else{
3400			price = (parseInt(number) * $scope.erp.fax_number_price).toFixed(2);	
3401		}
3402    	
3403		// price = $scope.getListPrice($scope.selectedPages,number);
3404		return "<h5>"+number+ (number == 1 ? ' number' : ' numbers')+"</h5><p>"+$scope.getCookie('currency_symbol')+price+"/mo</p>";
3405    }
3406
3407	$scope.changeDurationToggleNew = function(duration){
3408		$scope.durationNew = duration;
3409		$scope.globalDuration = duration;
3410		$scope.erp.duration = duration;
3411		if(duration == 12){
3412			$scope.basicPlanAmt = $scope.getCookie('currency_symbol')+'12.49/mo';
3413			$scope.plusPlanAmt = $scope.getCookie('currency_symbol')+'24.99/mo';
3414			$scope.basicPlanAmt12 = $scope.getCookie('currency_symbol')+'149.99/year';
3415			$scope.plusPlanAmt12 = $scope.getCookie('currency_symbol')+'299.99/year';			
3416			$scope.basicPlanAmtGrand = $scope.getCookie('currency_symbol')+'14.49/mo';
3417			$scope.plusPlanAmtGrand = $scope.getCookie('currency_symbol')+'29.99/mo';
3418		}else{
3419			$scope.basicPlanAmt = $scope.getCookie('currency_symbol')+'14.99/mo';
3420			$scope.plusPlanAmt = $scope.getCookie('currency_symbol')+'29.99/mo';
3421			$scope.basicPlanAmt12 = $scope.getCookie('currency_symbol')+'14.99/mo';
3422			$scope.plusPlanAmt12 = $scope.getCookie('currency_symbol')+'29.99/mo';			
3423			$scope.basicPlanAmtGrand = $scope.getCookie('currency_symbol')+'14.49/mo';
3424			$scope.plusPlanAmtGrand = $scope.getCookie('currency_symbol')+'29.99/mo';
3425		}
3426		
3427		$scope.erp.send_pages = $scope.pagesNew;
3428		$scope.erp.teamsubaccount = $scope.subAccountLimit;
3429		$scope.erp.fax_numbers = $scope.selectedNumbers;
3430
3431		if($scope.selectedNumbers > 0 || $scope.subAccountLimit > 1 || $scope.currentTab != 'app' || $scope.erp.send_pages > 200){
3432    		$scope.disabledBasic = 1;
3433    	}else{
3434    		$scope.disabledBasic = 0;
3435    	}
3436
3437    	if($scope.selectedNumbers > 1 || $scope.subAccountLimit > 1 || $scope.currentTab != 'app' || $scope.erp.send_pages > 500){
3438    		$scope.disabledPlus = 1;
3439    	}else{
3440    		$scope.disabledPlus = 0;
3441    	}
3442
3443
3444    	if($scope.pagesNew == 200){
3445			$scope.pagesNewPricePerPage = $scope.globalDuration == 12 ? 0.062 : 0.075;	
3446		}else if($scope.pagesNew == 500){
3447			$scope.pagesNewPricePerPage = $scope.globalDuration == 12 ? 0.05 : 0.06;				
3448		}else if($scope.pagesNew == 1000){
3449			$scope.pagesNewPricePerPage = $scope.globalDuration == 12 ? 0.033 : 0.04;				
3450		}else if($scope.pagesNew == 5000){
3451			$scope.pagesNewPricePerPage = $scope.globalDuration == 12 ? 0.025 : 0.03;			
3452		}else if($scope.pagesNew == 10000){
3453			$scope.pagesNewPricePerPage = $scope.globalDuration == 12 ? 0.020 : 0.025;
3454		}else if($scope.pagesNew == 50000){
3455			$scope.pagesNewPricePerPage = $scope.globalDuration == 12 ? 0.014 : 0.02;
3456		}else if($scope.pagesNew == 100000){
3457			$scope.pagesNewPricePerPage = $scope.globalDuration == 12 ? 0.012 : 0.015;			
3458		}else if($scope.pagesNew == 500000){
3459			$scope.pagesNewPricePerPage = $scope.globalDuration == 12 ? 0.01 : 0.012;			
3460		}else if($scope.pagesNew == 1000000){
3461			$scope.pagesNewPricePerPage = 'CONTACT SALES';			
3462		}
3463
3464
3465		if($scope.erp.send_pages <= 1000){
3466			$scope.erp.send_pages = 1000;
3467    		$scope.erp.unitOBprice = 0.04;
3468    	}else if($scope.erp.send_pages >= 1001 && $scope.erp.send_pages <= 2500){
3469    		$scope.erp.unitOBprice = 0.035;
3470    	}else if($scope.erp.send_pages >= 2501 && $scope.erp.send_pages <= 5000){
3471    		$scope.erp.unitOBprice = 0.030;
3472		}else if($scope.erp.send_pages >= 5001 && $scope.erp.send_pages <= 20000){
3473			$scope.erp.unitOBprice = 0.025;
3474    	}else if($scope.erp.send_pages >= 20001 && $scope.erp.send_pages <= 50000){
3475    		$scope.erp.unitOBprice = 0.02;
3476    	}else if($scope.erp.send_pages >= 50001 && $scope.erp.send_pages <= 100000){
3477    		$scope.erp.unitOBprice = 0.015;
3478    	}else if($scope.erp.send_pages >= 100001 && $scope.erp.send_pages <= 500000){
3479    		$scope.erp.unitOBprice = 0.012;
3480    	}else{
3481    		$scope.erp.unitOBprice = 0.01;
3482    	}
3483
3484
3485    	if($scope.erp.receive_pages < 3000){
3486    		$scope.erp.unitIBprice = 0.03;
3487    	}else if($scope.erp.receive_pages >= 3000 && $scope.erp.receive_pages < 7501){
3488    		$scope.erp.unitIBprice = 0.025;
3489    	}else{
3490    		$scope.erp.unitIBprice = 0.02;
3491    	}
3492    	
3493    	if($scope.erp.teamsubaccount < 4){
3494    		$scope.erp.subAccountPrice = 19.99;
3495    	}else if($scope.erp.teamsubaccount >= 4 && $scope.erp.teamsubaccount < 7){
3496    		$scope.erp.subAccountPrice = 17.99;
3497    	}else if($scope.erp.teamsubaccount >= 7 && $scope.erp.teamsubaccount < 11){
3498    		$scope.erp.subAccountPrice = 16.99;
3499    	}else{
3500    		$scope.erp.subAccountPrice = 14.99;
3501    	}
3502
3503    	$scope.amount = 0;
3504    	if($scope.erp.duration == 12){
3505    		if($scope.erp.send_pages){
3506    			$scope.amount += parseInt($scope.erp.send_pages) * parseFloat($scope.erp.unitOBprice) * 10;	
3507    		}
3508    		
3509    		if($scope.erp.teamsubaccount){
3510    			$scope.amount += (parseInt($scope.erp.teamsubaccount) - 1) * parseFloat($scope.erp.subAccountPrice) * 10;	
3511    		}
3512    		if($scope.erp.fax_numbers){
3513    			$scope.amount += (parseInt($scope.erp.fax_numbers) - 1) * parseFloat($scope.erp.faxNumberPrice) * 10;	
3514    		}
3515    		
3516    		$scope.amount += parseInt($scope.erp.api) ? parseFloat($scope.erp.apiPrice) * 10 : 0;
3517    		$scope.amount += parseInt($scope.erp.enableBranding) ? parseFloat($scope.erp.brandPrice) * 10 : 0;
3518
3519    		$scope.proPlanAmt12 = $scope.getCookie('currency_symbol')+(Math.ceil($scope.amount) - 0.01).toLocaleStr
3519ing('en-US',{
3520    minimumFractionDigits: 2,
3521    maximumFractionDigits: 2
3522  })+'/year';
3523    		$scope.proPlanAmt = $scope.getCookie('currency_symbol')+($scope.amount/12).toLocaleString('en-US',{
3524    minimumFractionDigits: 2,
3525    maximumFractionDigits: 2
3526  })+'/mo';
3527    		$scope.proPlanAmtGrand = $scope.getCookie('currency_symbol')+(Math.ceil($scope.amount/10)- 0.01).toLocaleString('en-US',{
3528    minimumFractionDigits: 2,
3529    maximumFractionDigits: 2
3530  })+'/mo';
3531    		
3532    	}else{
3533    		if($scope.erp.send_pages){
3534    			$scope.amount += parseInt($scope.erp.send_pages) * parseFloat($scope.erp.unitOBprice);	
3535    		}
3536    		
3537    		if($scope.erp.teamsubaccount){
3538    			$scope.amount += (parseInt($scope.erp.teamsubaccount) - 1) * parseFloat($scope.erp.subAccountPrice);
3539    		}
3540    		if($scope.erp.fax_numbers){
3541    			$scope.amount += (parseInt($scope.erp.fax_numbers) - 1) * parseFloat($scope.erp.faxNumberPrice);	
3542    		}
3543    		
3544    		$scope.amount += parseInt($scope.erp.api) ? parseFloat($scope.erp.apiPrice) : 0;
3545    		$scope.amount += parseInt($scope.erp.enableBranding) ? parseFloat($scope.erp.brandPrice) : 0;
3546
3547    		$scope.proPlanAmt = $scope.getCookie('currency_symbol')+(Math.ceil($scope.amount) - 0.01).toLocaleString('en-US',{
3548    minimumFractionDigits: 2,
3549    maximumFractionDigits: 2
3550  })+'/mo';
3551    		$scope.proPlanAmt12 = $scope.getCookie('currency_symbol')+(Math.ceil($scope.amount) - 0.01).toLocaleString('en-US',{
3552    minimumFractionDigits: 2,
3553    maximumFractionDigits: 2
3554  })+'/mo';
3555    		$scope.proPlanAmtGrand = $scope.getCookie('currency_symbol')+(Math.ceil($scope.amount) - 0.01).toLocaleString('en-US',{
3556    minimumFractionDigits: 2,
3557    maximumFractionDigits: 2
3558  })+'/mo';
3559    		
3560    	}
3561
3562    	console.log($scope.erp.send_pages,$scope.erp.unitOBprice,$scope.proPlanAmt,$scope.proPlanAmt12);
3563 	 
3564	}
3565
3566	
3567	$scope.pagesNewPricePerPage = 0.075;
3568	$scope.flagTeam = true;
3569	$scope.flagNumber= true;
3570	$scope.changeDurationToggleNew(12);
3571	$scope.changePagesNew = function(pages){
3572		$scope.pagesNewRange = pages;
3573		if(pages == '1'){
3574			$scope.pagesNew = 200;
3575		}else if(pages == '2'){
3576			$scope.pagesNew = 500;
3577		}else if(pages == '3'){
3578			$scope.pagesNew = 1000;
3579		}else if(pages == '4'){
3580			$scope.pagesNew = 5000;
3581		}else if(pages == '5'){
3582			$scope.pagesNew = 10000;
3583		}else if(pages == '6'){
3584			$scope.pagesNew = 50000;
3585		}else if(pages == '7'){
3586			$scope.pagesNew = 100000;
3587		}else if(pages == '8'){
3588			$scope.pagesNew = 500000;
3589		}else if(pages == '9'){
3590			$scope.pagesNew = 1000000;
3591		}
3592
3593		$scope.changeDurationToggleNew($scope.globalDuration);		
3594
3595		// if($scope.globalDuration == 12){
3596		// 	// DON'T DELETE. this code added due to reflact tooltip content
3597		// 	$scope.globalDuration = 1;
3598		// 	setTimeout(function(){
3599		// 		$scope.globalDuration = 12;	
3600		// 		$scope.$apply();
3601		// 	},0)			
3602		// }
3603	}
3604
3605
3606
3607	$scope.selectLicense = function(number){
3608
3609		$scope.subAccountLimit = parseInt(number);
3610		$scope.erp.erpPageFlag = 0;
3611    	// $scope.erp.subAccountLimit = parseInt($scope.subAccountLimit);
3612    	if($scope.subAccountLimit){
3613
3614	        if($scope.subAccountLimit >= 1 && $scope.subAccountLimit <= 3){
3615                $scope.erp.additionalPrice = 19.99;
3616            }else if($scope.subAccountLimit >= 4 && $scope.subAccountLimit <= 6){
3617                $scope.erp.additionalPrice = 17.99;
3618            }else if($scope.subAccountLimit >= 7 && $scope.subAccountLimit <= 10){
3619                $scope.erp.additionalPrice = 16.99;
3620            }else if($scope.subAccountLimit >= 11){
3621                $scope.erp.additionalPrice = 14.99;
3622            }else{
3623                $scope.erp.additionalPrice = 19.99;
3624            }
3625			
3626    	}
3627
3628    	defaultPrice = ($scope.globalDuration == 1 ? $scope.erp.additionalPrice : $scope.erp.additionalPrice*10);
3629    	if($scope.globalDuration == 12){
3630			price = ((parseInt(number-1) * defaultPrice)/12).toFixed(2);			
3631		}else{
3632			price = (parseInt(number-1) * defaultPrice).toFixed(2);	
3633		}
3634		$scope.erp.additionalPrice_price = price.replace(/\.?0+$/, '');
3635		$scope.flagTeam = false;
3636    	$scope.changeDurationToggleNew($scope.globalDuration);
3637    	 
3638    }
3639
3640
3641
3642    $scope.viewLicenses = function(number,duration){
3643    	
3644    	var price = 0;
3645    	var numbers = 0;
3646   		number = parseInt(number);
3647		if(number >= 1 && number <= 3){
3648            $scope.erp.additionalPrice = 19.99;
3649        }else if(number >= 4 && number <= 6){
3650            $scope.erp.additionalPrice = 17.99;
3651        }else if(number >= 7 && number <= 10){
3652            $scope.erp.additionalPrice = 16.99;
3653        }else if(number >= 11){
3654            $scope.erp.additionalPrice = 14.99;
3655        }else{
3656            $scope.erp.additionalPrice = 19.99;
3657        }
3658        var defaultPrice = (duration == 1 ? $scope.erp.additionalPrice : $scope.erp.additionalPrice*10);
3659		if(duration == 12){
3660			price = ((parseInt(number - 1) * defaultPrice)/12);			
3661		}else{
3662			price = (parseInt(number - 1) * defaultPrice);	
3663		}
3664    	
3665		// price = $scope.getListPrice($scope.selectedPages,number);
3666		if(number == 1){
3667			return "<h5>"+number+ (number == 1 ? ' license' : ' licenses')+"</h5><p>Included free</p>";
3668		}else{
3669			return "<h5>"+number+ (number == 1 ? ' license' : ' licenses')+"</h5><p>"+$scope.getCookie('currency_symbol')+price.toLocaleString('en-US', {
3670    minimumFractionDigits: 2,
3671    maximumFractionDigits: 2
3672  })+"/mo</p>";	
3673		}
3674		
3675    }
3676
3677    $scope.checkoutPlan = function(plan){
3678    	if(plan == "basic"){
3679    		if($scope.currentPlanBasic == "PLUS"){
3680	    		return false
3681	    	}
3682    		if($scope.globalDuration == 1){
3683    			window.location.href = "https://www.ifaxapp.com/signup?plan=basic&bill=1&source=pricing";
3684    			return false;
3685    		}else{
3686    			window.location.href = "https://www.ifaxapp.com/signup?plan=basic&bill=12&source=pricing";
3687    			return false;
3688    		}
3689    	}else if(plan == "plus"){
3690    		if($scope.currentPlanPlus == "PRO"){
3691	    		return false
3692	    	}
3693    		if($scope.globalDuration == 1){
3694    			window.location.href = "https://www.ifaxapp.com/signup?plan=plus&bill=1&source=pricing";
3695    			return false;
3696    		}else{
3697    			window.location.href = "https://www.ifaxapp.com/signup?plan=plus&bill=12&source=pricing";
3698    			return false;
3699    		}
3700    	}
3701    }
3702
3703    $scope.purchaseERPNew = function(){
3704
3705    	if($scope.currentPlan == "ERP"){
3706    		return false
3707    	}
3708
3709    		$scope.erp.is_free_product = 0;
3710    	if($scope.selectedNumbers > 0){
3711    		$scope.erp.send_pages = parseInt($scope.pagesNew);
3712    		$scope.erp.receive_pages = 0;
3713    		$scope.erp.fax_numbers = parseInt($scope.selectedNumbers);
3714    	}else{
3715    		$scope.erp.send_pages = parseInt($scope.pagesNew);
3716    		$scope.erp.receive_pages = 0;
3717    		$scope.erp.fax_numbers = 1
3718    	}
3719
3720    	if($scope.erp.send_pages < 1000){
3721    		$scope.erp.send_pages = 1000;
3722    	}
3723
3724    	$scope.erp.teamsubaccount = parseInt($scope.subAccountLimit)  - 1;
3725    	$scope.erp.duration = $scope.globalDuration;
3726
3727    	// if($scope.erp.duration == 12){
3728    	// 	if($scope.amount < 300){
3729    	// 		$scope.showUpgradeWarning('iFax Professional starts at $300.00 per year. For cheaper plans we would suggest trying the iFax Basic or iFax Plus plans.')
3730    	// 		// toastr.error('iFax Professional starts at $200.00 per year. For cheaper plans we would suggest trying the iFax Basic or iFax Plus plans.');
3731    	// 		return false;
3732    	// 	}
3733    	// }else{
3734    	// 	if($scope.amount < 30){
3735    	// 		$scope.showUpgradeWarning('iFax Professional starts at $30.00 per month. For cheaper plans we would suggest trying the iFax Basic or iFax Plus plans.');
3736    	// 	// toastr.error('iFax Professional starts at $20.00 per month. For cheaper plans we would suggest trying the iFax Basic or iFax Plus plans.');
3737    	// 	return false;
3738    	// 	}
3739    	// }
3740
3741    	// if($scope.variantID == 2){
3742    	// 	$scope.erp.is_free_product = 1;
3743    	// }else{
3744    	// 	$scope.erp.is_free_product = 0;
3745    	// }
3746
3747    	// pricing_script.allow_trial this variable declared in function.php.
3748    	
3749    	if($scope.allowTrialNew == '1'){
3750    		$scope.erp.is_free_product = 1;
3751    	}
3752
3753    	var obj = {
3754    	  incrementPagesIB: $scope.erp.autoreceivepagestopup ? Math.round((20 * $scope.erp.receive_pages) / 100) : 0,
3755	      incrementPagesOB: $scope.erp.autosentpagestopup ? Math.round((20 * $scope.erp.send_pages) / 100) : 0,
3756	      api: $scope.erp.api == 1 ? 1 : 0,
3757	      teamsubaccount: $scope.erp.teamsubaccount > 0 ? $scope.erp.teamsubaccount : 0,
3758	      fax_numbers: $scope.erp.fax_numbers,
3759	      firstFreeFaxNumber : 1,
3760	      unitPriceFaxNumber : $scope.erp.faxNumberPrice,
3761	      port_numbers: 0,
3762	      receive_pages: $scope.erp.receive_pages,
3763	      duration: $scope.erp.duration,
3764	      send_pages: $scope.erp.send_pages,
3765	      userID: $scope.getUserID(),
3766	      usertype: $scope.getUserType(),
3767	      is_free_product: $scope.erp.is_free_product,
3768	      subUserID: '',
3769	      enableBranding: $scope.erp.enableBranding ? 1 : 0,
3770	      brandingPrice: 19.99,
3771	      faxOCRPrice: $scope.erp.faxOCRPrice,
3772	      faxOCRPriceOB: $scope.erp.faxOCRPriceOB,
3773	      app: 'angular',
3774	      faxQuality: $scope.erp.faxQuality,
3775	      faxOCR : $scope.erp.faxOCR,
3776	      faxOCROB : $scope.erp.faxOCROB,
3777	      faxOCRPages : $scope.erp.faxOCRPages,
3778	      unitPriceOB : ($scope.variantID == 2 || $scope.variantID == 3) ? 0.04 : $scope.variantID == 4 ? 0.05 : $scope.erp.unitOBprice,
3779	      free_days : ($scope.allowTrial ? 3 : $scope.erp.is_free_product ? 3 : 0),
3780	      discountPercentage: $scope.erp.duration == 1 ? 0 : 16.7, 
3781    	}
3782
3783
3784
3785    	if($scope.erp.send_pages > 1000){
3786    		obj.unitPriceOB = $scope.erp.unitOBprice;
3787    	}
3788
3789    	
3790    	var base64 = btoa(JSON.stringify(obj));
3791
3792		window.location.href = weburl+'/login?checkWorkEmail='+(obj.is_free_product == 1 ? '1' : '0')+'&redirect='+webappurl+'professional/'+base64;
3793		return false;
3794		
3795
3796    }
3797    $scope.feature = [
3798				{
3799					"text" : "HIPAA, SOC 2 & ISO 27001",
3800					"icon" : "tick",
3801					"tooltip" :"",
3802					"badge":"shield"					
3803				},
3804				{
3805					"text" : "Cover pages & fax templates",
3806					"icon" : "tick",
3807					"tooltip" :"",
3808					"badge":""					
3809				},
3810				{
3811					"text" : "Schedule Faxes",
3812					"icon" : "tick",
3813					"tooltip" :"",
3814					"badge":""					
3815				},
3816				
3817				{
3818					"text" : "Team inbox and assignment",
3819					"icon" : "tick",
3820					"tooltip" :"Invite your team with our user licenses to collaborate with managing fax documents",
3821					"badge":""					
3822				},
3823				{
3824					"text" : "Smart Folders with Google Drive/Dropbox/OneDrive",
3825					"icon" : "tick",
3826					"tooltip" :"Integrate documents and folders from iFax into your Google Drive or Dropbox folders.",
3827					"badge":""					
3828				},
3829				{
3830					"text" : "Annotate, split and merge",
3831					"icon" : "tick",
3832					"tooltip" :"Annotate fax documents",
3833					"badge":""					
3834				},
3835				{
3836					"text" : "Branded WebFax page",
3837					"icon" : "tick",
3838					"tooltip" :"Link to a branded page that allows your customers to easily fax you online for free",
3839					"badge":""					
3840				},
3841				{
3842					"text" : "Fax by email",
3843					"icon" : "tick",
3844					"tooltip" :"Send a fax directly from your email.",
3845					"badge":""					
3846				},
3847				{
3848					"text" : "EHR Integrations and 6000+ apps",
3849					"icon" : "tick",
3850					"tooltip" :"",
3851					"badge":""					
3852				},
3853				{
3854					"text" : "Single Sign-on (SSO)",
3855					"icon" : "tick",
3856					"tooltip" :"",
3857					"badge":""					
3858				},
3859				{
3860					"text" : "24/7 live chat and email support",
3861					"icon" : "tick",
3862					"tooltip" :"",
3863					"badge":""					
3864				},
3865				{
3866					"text" : "OCR, data extraction and AI",
3867					"icon" : "dollar",
3868					"tooltip" :"<div class='item'><strong>Character Recognition:</strong><span class='text'>Use optical Character Recognition (OCR) to convert your faxes searchable text.</span></div><div class='item'><strong>Data Extraction:</strong><span class='text'>Use Natural Language Processing (NLP) to extract info into structured data fields.</span></div><div class='item'><strong>Generative AI Chat:</strong><span class='text'>Use natural chat to generate content from any fax or document.</span></div>",
3869					"badge":""					
3870				}
3871	    	];
3872    $scope.erpFeature = [
3873	    		{
3874					"text" : "Premium Support - 24/7 phone & enterprise SLAs",
3875					"icon" : "tick",
3876					"tooltip" :"",
3877					"badge":""					
3878				},
3879				{
3880					"text" : "Advanced admin controls and security",
3881					"icon" : "",
3882					"tooltip" :"",
3883					"badge":""					
3884				},
3885				{
3886					"text" : "Enterprise-grade access management",
3887					"icon" : "",
3888					"tooltip" :"",
3889					"badge":""					
3890				},
3891				{
3892					"text" : "Unlimited automation",
3893					"icon" : "",
3894					"tooltip" :"",
3895					"badge":""					
3896				},
3897				{
3898					"text" : "Multiple sites (up to 150)",
3899					"icon" : "",
3900					"tooltip" :"",
3901					"badge":""					
3902				},
3903				{
3904					"text" : "24/7 live chat and phone support",
3905					"icon" : "",
3906					"tooltip" :"",
3907					"badge":""					
3908				},
3909				{
3910					"text" : "99.95% uptime SLA",
3911					"icon" : "",
3912					"tooltip" :"",
3913					"badge":""					
3914				}
3915	    	];
3916    $scope.tab = function(tab){
3917    	$scope.currentTab = tab;
3918    	if(tab == "api"){
3919    		$scope.feature = [
3920				{
3921					"text" : "Fully HIPAA compliant",
3922					"icon" : "",
3923					"tooltip" :"",
3924					"badge":""					
3925				},
3926				{
3927					"text" : "Multiple file format support",
3928					"icon" : "",
3929					"tooltip" :"",
3930					"badge":""					
3931				},
3932				{
3933					"text" : "SSO (Single Sign-On) support",
3934					"icon" : "",
3935					"tooltip" :"",
3936					"badge":""					
3937				},
3938				{
3939					"text" : "Encrypted fax transmission",
3940					"icon" : "",
3941					"tooltip" :"",
3942					"badge":""					
3943				},
3944				{
3945					"text" : "Custom sender ID & branding",
3946					"icon" : "",
3947					"tooltip" :"",
3948					"badge":""					
3949				},
3950				{
3951					"text" : "SLA-backed reliability",
3952					"icon" : "",
3953					"tooltip" :"",
3954					"badge":""					
3955				},
3956				{
3957					"text" : "High-speed fax delivery",
3958					"icon" : "",
3959					"tooltip" :"",
3960					"badge":""					
3961				},
3962				{
3963					"text" : "Fax retries & delivery confirmations",
3964					"icon" : "",
3965					"tooltip" :"",
3966					"badge":""					
3967				},
3968				{
3969					"text" : "Webhooks & callback support",
3970					"icon" : "",
3971					"tooltip" :"",
3972					"badge":""					
3973				},
3974				{
3975					"text" : "Audit logs & reporting",
3976					"icon" : "",
3977					"tooltip" :"",
3978					"badge":""					
3979				},
3980				{
3981					"text" : " API for sending and receiving, AI and data extraction",
3982					"icon" : "",
3983					"tooltip" :"",
3984					"badge":""					
3985				},
3986				{
3987					"text" : "RESTful API with JSON responses",
3988					"icon" : "",
3989					"tooltip" :"",
3990					"badge":""					
3991				},
3992				{
3993					"text" : "Multi-user access & role-based permissions",
3994					"icon" : "",
3995					"tooltip" :"",
3996					"badge":""					
3997				},
3998				{
3999					"text" : "Dedicated customer support",
4000					"icon" : "",
4001					"tooltip" :"",
4002					"badge":""					
4003				}
4004				// {
4005				// 	"text" : "Premium Support – 24/7/ phone & enterprise SLAs",
4006				// 	"icon" : "dollar",
4007				// 	"tooltip" :"",
4008				// 	"badge":""					
4009				// }
4010			];
4011			$scope.erpFeature = [
4012	    		{
4013					"text" : "Unlimited automation",
4014					"icon" : "",
4015					"tooltip" :"",
4016					"badge":""					
4017				},
4018				{
4019					"text" : "Multiple sites (up to 150)",
4020					"icon" : "",
4021					"tooltip" :"",
4022					"badge":""					
4023				},
4024				{
4025					"text" : "24/7 live chat and phone support",
4026					"icon" : "",
4027					"tooltip" :"",
4028					"badge":""					
4029				},
4030				{
4031					"text" : "99.95% uptime SLA",
4032					"icon" : "",
4033					"tooltip" :"",
4034					"badge":""					
4035				},
4036				{
4037					"text" : "Advanced admin controls and security",
4038					"icon" : "",
4039					"tooltip" :"",
4040					"badge":""					
4041				},
4042				{
4043					"text" : "Enterprise-grade access management",
4044					"icon" : "",
4045					"tooltip" :"",
4046					"badge":""					
4047				}
4048			];
4049    	}else if(tab == "broadcast"){
4050    		$scope.feature = [
4051				{
4052					"text" : "Contact List Management",
4053					"icon" : "",
4054					"tooltip" :"",
4055					"badge":""					
4056				},
4057				{
4058					"text" : "Automatic Retries",
4059					"icon" : "",
4060					"tooltip" :"",
4061					"badge":""					
4062				},
4063				{
4064					"text" : "Audit Logs & Reporting",
4065					"icon" : "",
4066					"tooltip" :"",
4067					"badge":""					
4068				},
4069				{
4070					"text" : "Dynamic Merge Fields",
4071					"icon" : "",
4072					"tooltip" :"",
4073					"badge":""					
4074				},
4075				{
4076					"text" : "Multi-User Access",
4077					"icon" : "",
4078					"tooltip" :"",
4079					"badge":""					
4080				},
4081				{
4082					"text" : "Real-Time Delivery Tracking",
4083					"icon" : "",
4084					"tooltip" :"",
4085					"badge":""					
4086				},
4087				{
4088					"text" : "Opt-Out List Management via QR Code",
4089					"icon" : "",
4090					"tooltip" :"",
4091					"badge":""					
4092				},
4093				// {
4094				// 	"text" : "Premium Support – 24/7/ phone & enterprise SLAs",
4095				// 	"icon" : "dollar",
4096				// 	"tooltip" :"",
4097				// 	"badge":""					
4098				// },
4099				{
4100					"text" : "Customizable QR Codes for Conversion Tracking",
4101					"icon" : "",
4102					"tooltip" :"",
4103					"badge":""					
4104				}
4105			]
4106    		$scope.erpFeature = [
4107	    		{
4108					"text" : "Unlimited automation rule runs",
4109					"icon" : "",
4110					"tooltip" :"",
4111					"badge":""					
4112				},
4113				{
4114					"text" : "Multiple sites (up to 150)",
4115					"icon" : "",
4116					"tooltip" :"",
4117					"badge":""					
4118				},
4119				{
4120					"text" : "24/7 live chat and phone support",
4121					"icon" : "",
4122					"tooltip" :"",
4123					"badge":""					
4124				},
4125				{
4126					"text" : "99.95% uptime SLA",
4127					"icon" : "",
4128					"tooltip" :"",
4129					"badge":""					
4130				},
4131				{
4132					"text" : "Advanced admin controls and security",
4133					"icon" : "",
4134					"tooltip" :"",
4135					"badge":""					
4136				},
4137				{
4138					"text" : "Enterprise-grade access management",
4139					"icon" : "",
4140					"tooltip" :"",
4141					"badge":""					
4142				}
4143			];
4144    	}else{
4145    		$scope.feature = [
4146				{
4147					"text" : "HIPAA, SOC 2 & ISO 27001",
4148					"icon" : "tick",
4149					"tooltip" :"",
4150					"badge":"shield"					
4151				},
4152				{
4153					"text" : "Cover pages & fax templates",
4154					"icon" : "tick",
4155					"tooltip" :"",
4156					"badge":""					
4157				},
4158				{
4159					"text" : "Schedule Faxes",
4160					"icon" : "tick",
4161					"tooltip" :"",
4162					"badge":""					
4163				},
4164				
4165				{
4166					"text" : "Team inbox and assignment",
4167					"icon" : "tick",
4168					"tooltip" :"Invite your team with our user licenses to collaborate with managing fax documents",
4169					"badge":""					
4170				},
4171				{
4172					"text" : "Smart Folders with Google Drive/Dropbox/OneDrive",
4173					"icon" : "tick",
4174					"tooltip" :"Integrate documents and folders from iFax into your Google Drive or Dropbox folders.",
4175					"badge":""					
4176				},
4177				{
4178					"text" : "Annotate, split and merge",
4179					"icon" : "tick",
4180					"tooltip" :"Annotate fax documents",
4181					"badge":""					
4182				},
4183				{
4184					"text" : "Branded WebFax page",
4185					"icon" : "tick",
4186					"tooltip" :"Link to a branded page that allows your customers to easily fax you online for free",
4187					"badge":""					
4188				},
4189				{
4190					"text" : "Fax by email",
4191					"icon" : "tick",
4192					"tooltip" :"Send a fax directly from your email.",
4193					"badge":""					
4194				},
4195				{
4196					"text" : "EHR Integrations and 6000+ apps",
4197					"icon" : "tick",
4198					"tooltip" :"",
4199					"badge":""					
4200				},
4201				{
4202					"text" : "Single Sign-on (SSO)",
4203					"icon" : "tick",
4204					"tooltip" :"",
4205					"badge":""					
4206				},
4207				{
4208					"text" : "24/7 live chat and email support",
4209					"icon" : "tick",
4210					"tooltip" :"",
4211					"badge":""					
4212				},
4213				{
4214					"text" : "OCR, data extraction and AI",
4215					"icon" : "dollar",
4216					"tooltip" :"<div class='item'><strong>Character Recognition:</strong><span class='text'>Use optical Character Recognition (OCR) to convert your faxes searchable text.</span></div><div class='item'><strong>Data Extraction:</strong><span class='text'>Use Natural Language Processing (NLP) to extract info into structured data fields.</span></div><div class='item'><strong>Generative AI Chat:</strong><span class='text'>Use natural chat to generate content from any fax or document.</span></div>",
4217					"badge":""					
4218				}
4219	    	];
4220
4221	    	$scope.erpFeature = [
4222	    		{
4223					"text" : "Premium Support - 24/7 phone & enterprise SLAs",
4224					"icon" : "tick",
4225					"tooltip" :"",
4226					"badge":""					
4227				},
4228				{
4229					"text" : "Advanced admin controls and security",
4230					"icon" : "",
4231					"tooltip" :"",
4232					"badge":""					
4233				},
4234				{
4235					"text" : "Enterprise-grade access management",
4236					"icon" : "",
4237					"tooltip" :"",
4238					"badge":""					
4239				},
4240				{
4241					"text" : "Unlimited automation rule runs",
4242					"icon" : "",
4243					"tooltip" :"",
4244					"badge":""					
4245				},
4246				{
4247					"text" : "Multiple sites (up to 150)",
4248					"icon" : "",
4249					"tooltip" :"",
4250					"badge":""					
4251				},
4252				{
4253					"text" : "24/7 live chat and phone support",
4254					"icon" : "",
4255					"tooltip" :"",
4256					"badge":""					
4257				},
4258				{
4259					"text" : "99.95% uptime SLA",
4260					"icon" : "",
4261					"tooltip" :"",
4262					"badge":""					
4263				}
4264	    	];
4265    	}
4266    	$scope.changeDurationToggleNew($scope.globalDuration);
4267    }
4268
4269    $scope.viewPricePerLicense = function(license,duration){
4270    	var price = 0;
4271    	var perprice = 0;
4272   	
4273    	if(license > 0){
4274    		var licesesNumber = parseInt(license);
4275    		
4276	    	if(licesesNumber >= 1 && licesesNumber <= 3){
4277                perprice = 19.99;
4278            }else if(licesesNumber >= 4 && licesesNumber <= 6){
4279                perprice = 17.99;
4280            }else if(licesesNumber >= 7 && licesesNumber <= 10){
4281                perprice = 16.99;
4282            }else if(licesesNumber >= 11){
4283                perprice = 14.99;
4284            }else{
4285                perprice = 19.99;
4286            }
4287
4288
4289	    	if(duration == 12){
4290	    		price = (license * perprice * 10 / 12).toFixed(2);	
4291	    		perprice = price/license;
4292	    	}else{
4293	    		price = (license * perprice).toFixed(2);		    		
4294	    	}
4295	    	
4296	    	
4297	    	// price = $scope.getListPrice(page,$scope.selectedNumbers);
4298	    	
4299    	}
4300    	
4301    	if(license == 1){
4302    		return "<h5>Free</h5>";	
4303    	}else{
4304    		return "<h5>$"+(perprice).toFixed(2).replace(/\.?0+$/, '')+"/user</h5>";	
4305    	}
4306
4307    }
4308
4309    $scope.viewPricePerNumber = function(number,duration){
4310    	var price = 0;
4311    	var perprice = 6.99;
4312
4313    	if($scope.arrCountry[$scope.getCookie('country_code')]){
4314    		perprice = $scope.arrCountry[$scope.getCookie('country_code')];
4315    		perprice = parseFloat(perprice) + parseFloat(perprice*20/100);
4316    		if(perprice < 6.99){
4317    			perprice = 6.99;
4318    		}
4319    	}
4320   	
4321    	if(number > 0 && $scope.getCookie('country_code') == "US"){
4322    		var number = parseInt(number);
4323    		
4324	    	if(number <= 9){
4325                perprice = 4.99;
4326            }else if(number >= 10 && number <= 49){
4327                perprice = 3.99;
4328            }else if(number >= 50 && number <= 99){
4329                perprice = 2.99;
4330            }else if(number >= 100 && number <= 499){
4331                perprice = 1.99;
4332            }else{
4333                perprice = 0.99;
4334            }
4335
4336
4337	    	// if(duration == 12){
4338	    	// 	price = (number * perprice * 10 / 12).toFixed(2);	
4339	    	// 	perprice = price/number;
4340	    	// }else{
4341	    	// 	price = (number * perprice).toFixed(2);		    		
4342	    	// }
4343	    	
4344	    	
4345	    	// price = $scope.getListPrice(page,$scope.selectedNumbers);
4346	    	
4347    	}else{
4348    		if(number == 0){
4349    			perprice = 0;	
4350    		}
4351    		
4352    	}
4353
4354    	if(duration == 12){
4355    		perprice = (perprice*10)/12; 
4356    	}
4357    	
4358    	return "<h5>$"+(perprice).toFixed(2).replace(/\.?0+$/, '')+"/no</h5>";
4359
4360
4361    }
4362
4363
4364    $scope.redirectOnContactSales = function(){
4365    	
4366    	$scope.setCookie('trackFeature',$scope.currentTab);
4367
4368    	if($scope.pagesNew < 1000){
4369    		$scope.setCookie('pagesFromPricingPage','Less than 1,000');
4370    	}else if($scope.pagesNew >= 1000 && $scope.pagesNew <= 4999){
4371    		$scope.setCookie('pagesFromPricingPage','1,000 - 4,999');
4372    	}else if($scope.pagesNew >= 5000 && $scope.pagesNew <= 9999){
4373    		$scope.setCookie('pagesFromPricingPage','5,000 - 9,999');
4374    	}else if($scope.pagesNew >= 10000 && $scope.pagesNew <= 19999){
4375    		$scope.setCookie('pagesFromPricingPage','10,000 - 19,999');
4376    	}else if($scope.pagesNew >= 20000 && $scope.pagesNew <= 49000){
4377    		$scope.setCookie('pagesFromPricingPage','20,000 - 49,000');
4378    	}else{
4379    		$scope.setCookie('pagesFromPricingPage','50,000+');    		
4380    	}
4381
4382    	window.location.href = "/contact-sales";
4383    	return false;    	
4384    }
4385
4386    $scope.taglineForNumber = function(selectedNumbers = ''){
4387    	return selectedNumbers == 1 ? ' • '+selectedNumbers+' Number' : selectedNumbers > 1 ? ' • '+selectedNumbers+' Numbers' : '';
4388    }
4389    $scope.taglineForLicense = function(subAccountLimit = ''){
4390    	return subAccountLimit == 1 ? ' • '+subAccountLimit+' License' : subAccountLimit > 1 ? ' • '+subAccountLimit+' Licenses' : '';
4391    }
4392
4393    $scope.smartGalleryListArr = [];
4394    $scope.smartGalleryCategoryArr = [];
4395	$scope.smartGalleryList = function(category = '',slug = ''){
4396		if(!slug){
4397			var obj = {
4398	    		categoryIds : category
4399	    	}
4400		}else{
4401			var obj = {
4402	    		slug : slug
4403	    	}
4404		}
4405
4406		obj.userID = $scope.getUserID();
4407		obj.usertype = $scope.getUserType();
4408		console.log(obj);
4409    	obj = $scope.encryptRequest(obj);
4410    	// $scope.showLoader();
4411    	return $http({
4412			method : 'POST',	
4413			url : $scope.apiurl+"ajax/smartGalleryTemplateList",	
4414			data : jQuery.param({
4415				data: obj
4416			}),
4417	        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
4418	    }).then(function(response) {
4419	    	// $scope.hideLoader();
4420	    	/*if(response.data.code){
4421	    		$scope.smartGalleryListArr = response.data.result;
4422	    		 return $scope.smartGalleryListArr;
4423	    	}else {
4424			      $scope.smartGalleryListArr = [];
4425			      return [];
4426		    }*/
4427	    })
4428	}    
4429
4430	$scope.smartGalleryCategory = function(){
4431		
4432		var obj = {}
4433
4434		obj.userID = $scope.getUserID();
4435		obj.usertype = $scope.getUserType();
4436    	obj = $scope.encryptRequest(obj);
4437    	// $scope.showLoader();
4438    	$http({
4439			method : 'POST',	
4440			url : $scope.apiurl+"ajax/smartTemplateCategories",	
4441			data : jQuery.param({
4442				data: obj
4443			}),
4444	        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
4445	    }).then(function(response) {
4446	    	// $scope.hideLoader();
4447	    	/*if(response.data.code){
4448	    		$scope.smartGalleryCategoryArr = response.data.result;
4449	    	}*/
4450	    })
4451	} 
4452
4453	$scope.redirectOnDetail = function(slug){
4454		window.location.href = 'detail?slug='+slug;
4455	}
4456    // const pdfUrl = 'https://ontheline.trincoll.edu/images/bookdown/sample-local-pdf.pdf';
4457
4458	// $scope.pdfPreview = function(){
4459	  	  
4460	// 	 // let path = $location.path(); 
4461  	// 	 // let templateName = path.split('/').pop();
4462  	// 	 let templateName = ref.slug;
4463  	// 	 $scope.previewLoader = 1;
4464  	// 	  $scope.smartGalleryList('',templateName).then(function(smartGalleryListArr) {
4465  	// 	  	 $scope.previewLoader = 0;
4466  	// 	  	 if(!smartGalleryListArr || smartGalleryListArr.length == 0){
4467  	// 	  	 	window.location.href = '/templates';
4468  	// 	  	 	return false;
4469  	// 	  	 }   
4470
4471	// 	     const pdfUrl = smartGalleryListArr[0].s3OriginalFileUrl; // your PDF file
4472	// 		 const container = document.getElementById('pdfContainer');
4473
4474	// 		  // 🟢 Your JSON data
4475	// 		  const annotations = JSON.parse(smartGalleryListArr[0].annotations);
4476	// 		  console.log(annotations)
4477	// 		  // 🧩 Render PDF sequentially (ensures correct order)
4478	// 		  pdfjsLib.getDocument(pdfUrl).promise.then(async function (pdfDoc) {
4479	// 		    console.log(`PDF loaded (${pdfDoc.numPages} pages)`);
4480
4481	// 		    for (let pageNum = 1; pageNum <= pdfDoc.numPages; pageNum++) {
4482	// 		      await renderPage(pdfDoc, pageNum);
4483	// 		    }
4484	// 		  });
4485
4486	// 		  async function renderPage(pdfDoc, pageNum) {
4487	// 		    const page = await pdfDoc.getPage(pageNum);
4488	// 		    const scale = 1.5;
4489	// 		    const viewport = page.getViewport({ scale });
4490
4491	// 		    const pageDiv = document.createElement('div');
4492	// 		    pageDiv.className = 'pdf-page';
4493	// 		    container.appendChild(pageDiv);
4494
4495	// 		    const canvas = document.createElement('canvas');
4496	// 		    pageDiv.appendChild(canvas);
4497	// 		    const ctx = canvas.getContext('2d');
4498	// 		    canvas.width = viewport.width;
4499	// 		    canvas.height = viewport.height;
4500
4501	// 		    // Render the PDF page
4502	// 		    await page.render({ canvasContext: ctx, viewport: viewport }).promise;
4503	// 		    console.log(`Rendered page ${pageNum}`);
4504
4505	// 		    // Add annotations after render
4506	// 		    drawAnnotations(pageDiv, annotations, pageNum);
4507	// 		  }
4508
4509	// 		  function drawAnnotations(pageDiv, annotations, pageNum) {
4510	// 		    const pageObj = annotations.find(a => parseInt(a.page) === pageNum);
4511	// 		    if (!pageObj) return;
4512
4513	// 		    const canvas = pageDiv.querySelector('canvas');
4514	// 		    const canvasWidth = canvas.width;
4515	// 		    const canvasHeight = canvas.height;
4516
4517	// 		    pageObj.fields.forEach(field => {
4518	// 		      // Convert fixed px width/height → relative %
4519	// 		      const widthPercent = (field.width / canvasWidth) * 100;
4520	// 		      const heightPercent = (field.height / canvasHeight) * 100;
4521
4522	// 		      const div = document.createElement('div');
4523	// 		      div.className = 'annotation-input';
4524	// 		      div.style.left = field.left;
4525	// 		      div.style.top = field.top;
4526	// 		      div.style.width = widthPercent + '%';
4527	// 		      div.style.height = heightPercent + '%';
4528	// 		      div.innerHTML = `<span>${field.key ? field.key : field.original_name}</span>`;
4529	// 		      pageDiv.appendChild(div);
4530	// 		    });
4531	// 		  }
4532		  
4533  	// 	  })
4534  	// 	    // end $timeout
4535	// }
4536	$scope.previewLoader = 1;
4537	$scope.pdfPreview = function(url,annotation) {
4538		
4539			
4540
4541		    const pdfUrl = url;
4542		    const container = document.getElementById('pdfContainer');
4543		    const annotations = JSON.parse(atob(annotation));
4544		    console.log(annotations)
4545		    pdfjsLib.getDocument(pdfUrl).promise.then(async function(pdfDoc) {
4546		    	$scope.previewLoader = 0;
4547		    	$scope.$apply();
4548		      for (let pageNum = 1; pageNum <= pdfDoc.numPages; pageNum++) {
4549		        await renderPage(pdfDoc, pageNum);
4550		      }
4551		    });
4552
4553		    async function renderPage(pdfDoc, pageNum) {
4554		      const page = await pdfDoc.getPage(pageNum);
4555		      const scale = 1.5;
4556		      const viewport = page.getViewport({ scale });
4557
4558		      const pageDiv = document.createElement('div');
4559		      pageDiv.className = 'pdf-page';
4560		      pageDiv.style.position = 'relative';
4561		      pageDiv.style.marginBottom = '20px';
4562		      container.appendChild(pageDiv);
4563
4564		      const canvas = document.createElement('canvas');
4565		      pageDiv.appendChild(canvas);
4566		      const ctx = canvas.getContext('2d');
4567		      canvas.width = viewport.width;
4568		      canvas.height = viewport.height;
4569
4570		      await page.render({ canvasContext: ctx, viewport: viewport }).promise;
4571		      drawAnnotations(pageDiv, annotations, pageNum);
4572		    }
4573
4574		    function drawAnnotations(pageDiv, annotations, pageNum) {
4575		  const pageObj = annotations.find(a => parseInt(a.page) === pageNum);
4576		  if (!pageObj) return;
4577
4578		  const canvas = pageDiv.querySelector('canvas');
4579		  const canvasWidth = canvas.width;
4580		  const canvasHeight = canvas.height;
4581		  const canvasRect = canvas.getBoundingClientRect();
4582
4583		  // Ensure container is relative
4584		  canvas.style.position = 'relative';
4585		  pageDiv.style.position = 'relative';
4586
4587		  pageObj.fields.forEach(field => {
4588		    // Convert width/height px → %
4589		    const widthPercent = (field.width / canvasWidth) * 100;
4590		    const heightPercent = (field.height / canvasHeight) * 100;
4591
4592		    // Create element
4593		    let el;
4594
4595		    if (field.type === 'text' || field.originalType === 'signature') {
4596		      el = document.createElement('div');
4597		      el.className = 'annotation-input';
4598		      el.innerHTML = `<span>${field.key || field.original_name}</span>`;
4599		    }
4600
4601		    else if (field.type === 'img' ) {
4602		      el = document.createElement('img');
4603		      el.src = field.value || '';
4604		      el.alt = field.original_name || 'Image';
4605		      el.className = 'annotation-image';
4606		      el.style.objectFit = 'contain';
4607		    }
4608
4609		    else if (field.type === 'QR') {
4610		      el = document.createElement('img');
4611		      el.src = field.value || 
4612		        `https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${encodeURIComponent(field.urlType || 'https://ifaxapp.com')}`;
4613		      el.alt = 'QR Code';
4614		      el.className = 'annotation-image';
4615		      el.style.objectFit = 'contain';
4616		    }
4617
4618		    if (el) {
4619		      el.style.position = 'absolute';
4620		      el.style.left = field.left;
4621		      el.style.top = field.top;
4622		      el.style.width = widthPercent + '%';
4623		      el.style.height = heightPercent + '%';
4624		      // el.style.border = '1px solid #bfe5ff';
4625		      // el.style.borderRadius = '5px';
4626		      el.style.background = 'rgba(173,216,230,0.2)';
4627		      el.style.color = '#0a93e8';
4628		      el.style.display = 'flex';
4629		      el.style.alignItems = 'center';
4630		      el.style.justifyContent = 'center';
4631		      el.style.fontSize = '13px';
4632		      el.style.textAlign = 'center';
4633		      el.style.pointerEvents = 'none';
4634
4635		      // Append directly on top of canvas (fixes offset issue)
4636		      canvas.parentNode.appendChild(el);
4637		    }
4638		  });
4639		}
4640  
4641	};
4642
4643	
4644
4645})
4646
4647function jsSetCookie(cname, cvalue, exdays){
4648  const d = new Date();
4649  d.setTime(d.getTime() + (exdays*24*60*60*1000));
4650  let expires = "expires="+ d.toUTCString();
4651  document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
4652}
4653function read_policy(){
4654    jsSetCookie('cookie_policy','1');
4655    jQuery(".cookie_txt_main").hide();
4656}
4657function getScope(ctrlName) {
4658    var sel = 'div[ng-controller="' + ctrlName + '"]';
4659    return angular.element(sel).scope();
4660}
4661
4662function notificationFun(notification){
4663	// console.log(notification)
4664	var $home = getScope('controllers');
4665	// console.log(notification.isNotDisplayed());
4666	// console.log(notification.isSkippedMoment());
4667	if (notification.isDisplayed()) {
4668        
4669        $home.defaultGoogle = true;
4670        if(notification.isSkippedMoment()) {
4671        }
4672        // continue with another identity provider.
4673    } else {
4674      $home.defaultGoogle = false;
4675    }
4676
4677    $home.$apply();
4678}
4679
4680function handleGgOneTap(resp) {
4681    // console.log('handleGgOneTap ', resp);
4682
4683    var $home = getScope('controllers');
4684    $home.handleGgOneTap(resp);
4685  }
4686

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.