PageSourceSearch

https://streaming.latw.org/js/themes/loginpopup.js

js latw.org collected 2026-09-24 17:15:26 UTC 116,995 bytes, 2,727 lines download raw bytes

1var reload = 0;
2var login_object = '';
3var isGuestUser = 0;
4var guestDownloadType = 0;
5function loader(selector, status) {
6    if ($(selector).length > 0) {
7        if (status == true)
8            $(selector).show();
9        else
10            $(selector).hide();
11    }
12}
13function playMovie(obj) {
14    if (typeof (obj) == "undefined") {
15        var permalink = $('#content-permalink').val();
16        var stream_id = $('#stream_id').val();
17        if (stream_id !== '') {
18            permalink = permalink + '/stream/' + stream_id;
19        }
20    } else {
21        var permalink = $(obj).attr("data-content-permalink");
22        var movie_unique_id = $(obj).attr("data-movie_id"); //ER - 70595
23        var content_types_id = $(obj).attr("data-ctype"); //ER - 70595
24    }
25    var url = HTTP_ROOT + "/" + Player_Page + "/" + permalink;
26
27    var tmedia = 2;
28    var datatargetmedia = $(obj).attr('data-targetmedia');
29    if (typeof datatargetmedia !== typeof undefined && datatargetmedia !== false) {
30        tmedia = datatargetmedia;
31    }
32
33    if (supportOptionalContent) {
34        playVideoNew(permalink, tmedia);
35    } else {
36        //ER - 70595 - Starts
37        if(typeof(otp_authorize_content_access) != "undefined" && otp_authorize_content_access == 1){
38            openGenerateOtpModal('', '', movie_unique_id, permalink, content_types_id, url);
39        }else{
40            window.location.href = url;
41        }
42        //ER - 70595 - Ends
43    }
44}
45function download_content(obj) {
46    var ctype = $(obj).attr("data-ctype");
47    if (typeof (obj) == "undefined") {
48        var permalink = $('#content-permalink').val();
49    } else {
50        var permalink = $(obj).attr("data-content-permalink");
51    }
52    if (parseInt(ctype) == 6) {
53        var purl = HTTP_ROOT + "/user/DownloadMultipartContent/vlink/" + permalink;
54        $.post(purl, function (downloadarray) {
55            var jsonarray = jQuery.parseJSON(downloadarray);
56            if (jsonarray.error) {
57                if (jsonarray.errorType !== typeof undefined && jsonarray.errorType == 'guestuser') {
58                    location.reload();
59                } else {
60                    alert("Download not accomplished!!");
61                    window.setTimeout(function () {
62                        location.reload()
63                    }, 2000);
64                }
65            } else {
66                $('.loader_download').show().delay(15000).fadeOut();    // ER: 21403                        
67                $.each(jsonarray, function (key, value) {
68                    download_files([{download: value}]);
69                });
70            }
71        });
72    } else {
73        var url = HTTP_ROOT + "/user/DownloadContent/vlink/" + permalink;
74//        window.location.href = url;
75        window.open(url, '_blank');
76    }
77}
78function showPpvPlans(obj, onCloseNotRefresh) {
79    if (typeof (onCloseNotRefresh) === "undefined") {
80        onCloseNotRefresh = 0;
81    } else {
82        onCloseNotRefresh = 1;
83    }
84    var purchase_type = "show";
85    var movie_id = $(obj).attr("data-movie_id");
86    var isppv = 0;
87    var is_ppv_bundle = 0;
88    var isadv = 0;
89
90    isadv = $(obj).attr('data-isadv');
91    if (typeof isadv !== typeof undefined && isadv !== false) {
92
93    } else {
94        isppv = $(obj).attr('data-isppv');
95        is_ppv_bundle = $(obj).attr('data-is_ppv_bundle');
96        isadv = 0;
97    }
98
99    var url = HTTP_ROOT + "/userMonetizationPlans/getMonetizationMethods";
100    $.post(url, {'movie_id': movie_id, 'purchase_type': purchase_type, 'isppv': isppv, 'is_ppv_bundle': is_ppv_bundle, 'isadv': isadv, 'onCloseNotRefresh': onCloseNotRefresh}, function (res) {
101        if (parseInt(res) === 1) {
102            var permalink = $(obj).attr("data-content-permalink");
103            var purl = HTTP_ROOT + "/" + Player_Page + "/" + permalink;
104            if (supportOptionalContent) {
105                playVideoNew(permalink, 2);
106            } else {
107                window.location.href = purl;
108            }
109        } else {
110            reload = 1;
111            $("#ppvModal").html(res).modal('hide');
112            $('#loader').hide();
113            if (parseInt(is_plan_error)) {
114                $("#ppvModal").html(res).modal('show');
115                $('#loader-ppv').hide();
116            }
117        }
118    });
119}
120
121function getVoucherGeneralInfoGuest(obj, onCloseNotRefresh) {
122    if (typeof (onCloseNotRefresh) === "undefined") {
123        onCloseNotRefresh = 0;
124    } else {
125        onCloseNotRefresh = 1;
126    }
127    $('#loader').show();
128    var purchase_type = "show";
129    var isppv = 0;
130    var is_ppv_bundle = 0;
131    var isadv = 0;
132    var movie_id;
133    var season;
134    var permalink;
135    var url = HTTP_ROOT + "/userVoucher/GetVoucherDownloadContentGuest";
136
137    movie_id = $(obj).attr("data-movie_id");
138    permalink = $(obj).attr("data-content-permalink");
139    isadv = $(obj).attr('data-isadv');
140    isppv = $(obj).attr('data-isppv');
141    is_ppv_bundle = $(obj).attr('data-is_ppv_bundle');
142    purchase_type = $(obj).attr('data-purchase_type');
143    if (typeof purchase_type !== typeof undefined && purchase_type !== false) {
144        if (purchase_type === "season" && $("#series").length) {
145            season = $("#series").val();
146            if (parseInt(season)) {
147                permalink += "/season/" + season;
148            }
149        }
150    }
151    var purl = HTTP_ROOT + "/user/DownloadContent/vlink/" + permalink;
152    $.post(url, {'movie_id': movie_id, 'season': season, 'purchase_type': purchase_type, 'isppv': isppv, 'is_ppv_bundle': is_ppv_bundle, 'isadv': isadv, 'onCloseNotRefresh': 1}, function (res) {
153        if (parseInt(res) === 1) {
154            if ($("#generalInfoModal").length > 0) {
155                $("#generalInfoModal").modal('hide');
156                $('#loader').hide();
157            }
158            window.location.href = purl;
159        } else {
160            if ($("#generalInfoModal").length > 0) {
161                $("#generalInfoModal").modal('hide');
162                $('#loader').hide();
163            }
164            $("#ppvModal").html(res).modal('show');
165            $('#loader').hide();
166        }
167    });
168}
169
170function getVoucherGeneralInfo(guest_id) {
171    if (typeof (onCloseNotRefresh) === "undefined") {
172        onCloseNotRefresh = 0;
173    } else {
174        onCloseNotRefresh = 1;
175    }
176    $('#loader').show();
177    var purchase_type = "show";
178    var isppv = 0;
179    var is_ppv_bundle = 0;
180    var isadv = 0;
181    var movie_id;
182    var season;
183    var permalink;
184    var url = HTTP_ROOT + "/userVoucher/GetVoucherDownloadContent";
185    var movie_id = $('#movie_id').val();
186    var permalink = $('#content-permalink').val();
187    if ($('#season_id').length) {
188        purchase_type = "season";
189        season = $('#season_id').val();
190        if (parseInt(season)) {
191            permalink += "/season/" + season;
192        }
193    }
194    if ($("#isadv").length) {
195        isadv = $("#isadv").val();
196    }
197    if ($("#is_ppv_bundle").length) {
198        is_ppv_bundle = $("#is_ppv_bundle").val();
199    }
200    var purl = HTTP_ROOT + "/user/DownloadContent/vlink/" + permalink;
201    $.post(url, {'guest_id': guest_id, 'movie_id': movie_id, 'season': season, 'purchase_type': purchase_type, 'isppv': isppv, 'is_ppv_bundle': is_ppv_bundle, 'isadv': isadv, 'onCloseNotRefresh': 1}, function (res) {
202        if (parseInt(res) === 1) {
203            if ($("#generalInfoModal").length > 0) {
204                $("#generalInfoModal").modal('hide');
205                $('#loader').hide();
206            }
207            window.location.href = purl;
208        } else {
209            if ($("#generalInfoModal").length > 0) {
210                $("#generalInfoModal").modal('hide');
211                $('#loader').hide();
212            }
213            $("#ppvModal").html(res).modal('show');
214            $('#loader').hide();
215        }
216    });
217}
218
219//Play Library User Content without any Monetisation Check
220function libraryUserPricing(obj) {
221    console.log('libraryUserPricing');
222    var permalink = '';
223    if (typeof (obj) === "undefined") {
224        var id = $('#movie_stream_id').val();
225        var movie_id = $('#movie_id').val();
226        var content_type = $('#content-type').val();
227        var permalink = $('#content-permalink').val();
228
229        if ($('#stream_id').length && $('#stream_id').val()) {
230            var stream_id = $('#stream_id').val();
231            permalink += '/stream/' + $('#stream_id').val();
232        }
233    } else {
234        var movie_id = $(obj).attr("data-movie_id");
235        var permalink = $(obj).attr("data-content-permalink");
236        var stream_id = $.trim($(obj).attr("data-stream_id"));/*42536*/
237        var content_type = $(obj).attr('data-ctype');
238        if (stream_id) {
239            permalink += '/stream/' + stream_id;
240        }
241    }
242    var url = HTTP_ROOT + "/userMonetizationPlans/getLibraryUserPrice";
243    $.ajax({
244        url: url,
245        data: {'movie_id': movie_id, 'stream_id': stream_id, 'permalink': permalink, 'content_type': content_type},
246        method: "post",
247        dataType: "json",
248        async: false,
249        success: function (res) {
250            console.log('priceAjax', res);
251            if (res.status == 'success') {
252                $.ajax({
253                    url: HTTP_ROOT + "/userMonetizationPlans/libraryPrecheckout",
254                    method: "post",
255                    dataType: "json",
256                    async: true,
257                    beforeSend: function () {
258                    $('#loader').show();
259                    },
260                    success: function (ress) {
261                        $('#loader').hide();
262                        if (ress.status == 'success') { 
263                            $(".precheckout_response_price").html(ress.response_price);
264                            $(".precheckout_response_price_value").val(ress.response_price);/*42536*/
265                            $(".precheckout_response_feedback").html(ress.response_feedback);
266                            if(ress.response_url){/*44062*/
267                            $(".precheckout_response_url").attr("href", ress.response_url);
268                            } else { 
269                                $('.precheckout_response_url').contents().unwrap();
270                            }/*44062*/
271                            $('#hidden_librarypermalink').val(permalink);
272                            $('#precheckout-success-modal').modal('show');
273            } else {
274                            $(".precheckout_response_feedback").html(ress.response_feedback);
275                            if(ress.response_url){/*44062*/
276                            $(".precheckout_response_url").attr("href", ress.response_url);
277                            } else { 
278                                $('.precheckout_response_url').contents().unwrap();
279                            }/*44062*/
280                            $('#precheckout-failure-modal').modal('show');
281                        }                            
282                    }
283                });
284                //window.location.href = HTTP_ROOT + "/" + Player_Page 
284+ "/" + permalink;
285            } else {
286                 if (res.status == 'play') { /*42536*/
287                    window.location.href = HTTP_ROOT + "/" + Player_Page + "/" + permalink; 
288                 } else {
289                window.location = HTTP_ROOT + '/';
290             }/*42536*/
291            }
292        }
293    });
294}
295
296function getPpvPlans(obj, onCloseNotRefresh) { 
297    if (typeof (onCloseNotRefresh) === "undefined") {
298        onCloseNotRefresh = 0;
299    } else {
300        onCloseNotRefresh = 1;
301    }
302    $('#loader').show();
303    var purchase_type = "show";
304    var id;
305    var isppv = 0;
306    var is_ppv_bundle = 0;
307    var isadv = 0;
308    var movie_id;
309    var season;
310    var permalink;
311    var download_type = guestDownloadType;
312    var content_type;
313    if (typeof (isGuestUser) === "undefined") {
314        var isGuestUser = window.isGuestUser;
315    }
316    
317    var can_download = $(obj).attr("data-download");
318    if (can_download != 0){
319    $('<input type="hidden" id="downloadVal" value="'+$.trim($("#isDownload").val())+'">').insertAfter(".playbtn");
320    }
321   
322    var url = HTTP_ROOT + "/userMonetizationPlans/getMonetizationMethods";
323    if (typeof (obj) === "undefined") {
324        var id = $('#movie_stream_id').val();
325        var movie_id = $('#movie_id').val();
326        content_type = $('#content-type').val();
327        var permalink = $('#content-permalink').val();
328        if ($('#stream_id').length && $('#stream_id').val()) {
329            permalink += '/stream/' + $('#stream_id').val();
330        }
331        if ($('#season_id').length && $('#season_id').val()) {
332            purchase_type = "season";
333            season = $('#season_id').val();
334            if (parseInt(season)) {
335                permalink += "/season/" + season;
336            }
337        }
338        /*if(typeof isGuestUser !== typeof undefined && isGuestUser===1){
339         permalink += "/is_guest_user/" + isGuestUser;
340         }*/
341        if ($("#isppv").length && $.trim($("#isppv").val())) {
342            isppv = $("#isppv").val();
343        }
344        if ($("#isadv").length) {
345            isadv = $("#isadv").val();
346        }
347        if ($("#is_ppv_bundle").length) {
348            is_ppv_bundle = $("#is_ppv_bundle").val();
349        }
350    } else {
351        id = $(obj).attr("data-id");
352        movie_id = $(obj).attr("data-movie_id");
353        permalink = $(obj).attr("data-content-permalink");
354        var stream_id = $.trim($(obj).attr("data-stream_id"));
355        isadv = $(obj).attr('data-isadv');
356        isppv = $(obj).attr('data-isppv');
357        content_type = $(obj).attr('data-ctype');
358        is_ppv_bundle = $(obj).attr('data-is_ppv_bundle');
359        purchase_type = $(obj).attr('data-purchase_type');
360        if (typeof purchase_type !== typeof undefined && purchase_type !== false) {
361            if (purchase_type === "season" && $("#series").length) {
362                season = $("#series").val();
363                if (parseInt(season)) {
364                    permalink += "/season/" + season;
365                }
366            }
367            if (stream_id) {
368                permalink += '/stream/' + stream_id;
369            }
370        }
371        if ($(obj).attr("data-is_guest_user")) {
372            var isGuestUser = $(obj).attr("data-is_guest_user");
373        }
374    }
375
376    var is_instafeez = 0;
377
378    if (PAYMENT_GATEWAY === 'instafeez' && parseInt(content_type) !== 3) {
379        is_instafeez = 1;
380    }
381
382    if ((typeof ($(obj).attr('data-download')) !== typeof undefined && ($(obj).attr('data-download')) !== false) || (isGuestUser === 1 && download_type != 0) || $.trim($("#isDownload").val())) {
383        if (isGuestUser) {
384            permalink += "/is_guest_user/" + isGuestUser;
385        }
386        if ($(obj).attr('data-download')) {
387            download_type = $(obj).attr('data-download');
388        }
389        if (parseInt(content_type) == 6) {
390            var purl = HTTP_ROOT + "/user/DownloadMultipartContent/vlink/" + permalink;
391        } else {
392            var purl = HTTP_ROOT + "/user/DownloadContent/vlink/" + permalink;
393        }
394    } else {
395        var purl = HTTP_ROOT + "/" + Player_Page + "/" + permalink;
396    }
397    var datatargetmedia = $(obj).attr('data-targetmedia');
398    var tmedia = ((parseInt(content_type) == 1) || (parseInt(content_type) == 3)) ? 2 : 0;
399    if (typeof datatargetmedia !== typeof undefined && datatargetmedia !== false) {
400        tmedia = datatargetmedia;
401    }
402   // console.log('getPpvPlans---' + purl);
403    //ER 27707 Start . Only set async value false for Mac and Iphone Safari browser
404    /*
405    $.post(url, {'download_type': download_type, 'movie_id': movie_id, 'season': season, 'purchase_type': purchase_type, 'instafeez': is_instafeez, 'isppv': isppv, 'is_ppv_bundle': is_ppv_bundle, 'isadv': isadv, isGuestUser: isGuestUser, 'onCloseNotRefresh': 1}, function (res) {
406        if (parseInt(res) === 1) {
407            if (parseInt(content_type) == 5 && parseInt(download_type) == 0) {
408                playAudioNew(id, tmedia);
409            } else if (parseInt(content_type) == 6 && parseInt(download_type) == 0) {
410                playMultipartAudio(id, 0);
411            } else {
412                if (parseInt(content_type) == 6) {
413                    $.post(purl, function (downloadarray) {
414                        var jsonarray = jQuery.parseJSON(downloadarray);
415                        if (jsonarray.error) {
416                            if (jsonarray.errorType !== typeof undefined && jsonarray.errorType == 'guestuser') {
417                                location.reload();
418                            } else {
419                                alert("Download not accomplished!!");
420                                window.setTimeout(function () {
421                                    location.reload()
422                                }, 2000);
423                            }
424                        } else {
425                            $('.loader_download').show().delay(15000).fadeOut(); // ER: 21403
426                            $.each(jsonarray, function (key, value) {
427                                download_files([{download: value}]);
428                            });
429                        }
430                    });
431                } else {
432                    if (supportOptionalContent) {
433                        playVideoNew(permalink, tmedia);
434                    } else {
435                        window.location.href = purl;
436                    }
437                }
438            }
439        } else {
440            if ($("#loginModal").length > 0) {
441                $("#loginModal").modal('hide');
442                $('#loader').hide();
443            }
444            if (PAYMENT_GATEWAY === 'instafeez' && parseInt(content_type) !== 3) {
445                var obj = new instafeez();
446                obj.processCard(res);
447            } else {
448                reload = 1;
449                $("#ppvModal").html(res).modal('hide');
450                $('#loader').hide();
451
452                if (parseInt(is_plan_error)) {
453                    $("#ppvModal").html(res).modal('show');
454                    $('#loader-ppv').hide();
455                }
456            }
457        }
458     });*/
459    $.ajax({
460        url: url,
461        data: {'download_type': download_type, 'movie_id': movie_id, 'season': season, 'purchase_type': purchase_type, 'instafeez': is_instafeez, 'isppv': isppv, 'is_ppv_bundle': is_ppv_bundle, 'isadv': isadv, isGuestUser: isGuestUser, 'onCloseNotRefresh': 1, 'onMonetizationCheck': 1,'download_data': $("#downloadVal").val()},
462        method: "post",
463        async: false,
464        success: function (res) {
465            
466            console.log("Test ..");
467            
468            console.log(res);
469            
470            if(parseInt(res) === 10) {
471                 window.location.href = HTTP_ROOT+'/user/activate';
472            }
473            if (parseInt(res) === 1) {
474                if (parseInt(content_type) == 5 && parseInt(download_type) == 0) {
475                    playAudioNew(id, tmedia);
476                } else if (parseInt(content_type) == 6 && parseInt(download_type) == 0) {
477                    playMultipartAudio(id, 0);
478                } else {
479                    if (parseInt(content_type) == 6) {
480                        $.post(purl, function (downloadarray) {
481                            var jsonarray = jQuery.parseJSON(downloadarray);
482                            if (jsonarray.error) {
483                                if (jsonarray.errorType !== typeof undefined && jsonarray.errorType == 'guestuser') {
484                                    location.reload();
485                                } else {
486                                    alert("Download not accomplished!!");
487                                    window.setTimeout(function () {
488                                        location.reload()
489                                    }, 2000);
490                                }
491                            } else {
492                                $('.loader_download').show().delay(15000).fadeOut(); // ER: 21403
493                                $.each(jsonarray, function (key, value) {
494                                    download_files([{download: value}]);
495                                });
496                            }
497                        });
498                    } else {
499                        if (supportOptionalContent) {
500                            playVideoNew(permalink, tmedia);
501                        } else {
502                            if(download_type || $("#downloadVal").val()){ //39375
503                                window.open(purl, '_blank');
504                            }else{
505                                //49098 starts
506                                //console.log('redirect: '+purl);
507                                //window.location.href = purl;
508                                //return false;
509                                //46095 starts
510                                setTimeout(function () {
511                                    //ER - 70595 - starts
512                                    if(typeof(otp_authorize_content_access) != "undefined" && otp_authorize_content_access == 1){
513                                        openGenerateOtpModal('', '', movie_id, permalink, content_type, purl); //ER - 70595
514                                    }else{
515                                        window.location.href = purl;
516                                    }
517                                    //ER - 70595 - ends
518                                }, 500);
519                                return false;
520                                //46095 ends
521                                //49098 ends
522                            }
523                              if($('#content-permalink').val() != undefined){
524                              window.location = HTTP_ROOT + '/' + $('#content-permalink').val();
525                        }
526                    }
527                }
528                }
529            } else {
530                //52108
531                if ($('#sso_with_miniorange_shopify_recharge').val() !== typeof undefined && $('#sso_with_miniorange_shopify_recharge').val() == 1) {
532                 $("#recharge-subscribe-modal").modal('show');
533                } else { //52108
534                if ($("#loginModal").length > 0) {
535                    $("#loginModal").modal('hide');
536                    $('#loader').hide();
537                }
538                if (PAYMENT_GATEWAY === 'instafeez' && parseInt(content_type) !== 3) {
539                    var obj = new instafeez();
540                    obj.processCard(res);
541                } else {
542                    reload = 1;
543                    $("#ppvModal").html(res).modal('hide');
544                    $('#loader').hide();
545
546                    if (parseInt(is_plan_error)) {
547                        $("#ppvModal").html(res).modal('show');
548                        $('#loader-ppv').hide();
549                    }
550                }
551                }//52108
552            }
553        }
554    });
555    //ER 27707 End
556}
557
558function download_files(files) {
559    function download_next(i) {
560        if (i >= files.length) {
561            return;
562        }
563        var url = files[i].download;
564        var filename = url.substring(url.lastIndexOf("/") + 1).split("?")[0];
565        var xhr = new XMLHttpRequest();
566        xhr.open('GET', url, true);
567        xhr.responseType = 'blob';
568        xhr.onload = function () {
569            var a = document.createElement('a');
570            a.href = window.URL.createObjectURL(xhr.response);
571            a.download = filename;
572            a.style.display = 'none';
573            document.body.appendChild(a);
574            a.click();
575            delete a;
576        };
577        xhr.send();
578        setTimeout(function () {
579            window.URL.revokeObjectURL(xhr.response);
580        }, 100); // cleanup
581        setTimeout(function () {
582            download_next(i + 1);
583        }, 500);
584    }
585    // Initiate the first download.
586    download_next(0);
587}
588
589function episodeplayMovie(obj) {
590    $('#loader').hide();
591    if (typeof (obj) == "undefined") {
592        var movie_id = $('#movie_id').val();
593        var stream_id = $('#stream_id').val();
594        var permalink = $('#content-permalink').val();
595    } else {
596        var movie_id = $(obj).attr("data-movie_id");
597        var stream_id = $.trim($(obj).attr("data-stream_id"));
598        var permalink = $(obj).attr("data-content-permalink");
599        var content_types_id = $(obj).attr("data-ctype"); //ER - 70595
600    }
601    var fseasonID = $(obj).attr("data-season_id");
602    var SeasonID = '';
603    var sId = '';
604    if ($("#series").val()) {
605        var season = $("#series").val();
606        SeasonID = '/season/' + season;
607        sId = season;
608    } else {
609        SeasonID = '/season/' + fseasonID;
610        sId = fseasonID;
611    }
612    if (stream_id !== '') {
613        if (supportOptionalContent) {
614            if(content_type==3){//32446
615                playAllVideoAuto(permalink, 2, stream_id,0,index_val);
616            }else{
617            playVideoNew(permalink, 2, stream_id, sId);
618            }
619            
620        } else {
621            //ER - 70595 - Starts
622            if(typeof(otp_authorize_content_access) != "undefined" && otp_authorize_content_access == 1){
623                var url = HTTP_ROOT + "/" + Player_Page + "/" + permalink + '/stream/' + stream_id + SeasonID;
624                openGenerateOtpModal('', stream_id, movie_id, permalink, content_types_id, url);
625            }else{
626                window.location.href = HTTP_ROOT + "/" + Player_Page + "/" + permalink + '/stream/' + stream_id + SeasonID;
627            }
628            //ER - 70595 - Ends
629        }
630    } else {
631        if (supportOptionalContent) {
632             if(content_type==3){//32446
633                playAllVideoAuto(permalink, 2, stream_id,0,index_val);
634        } else {
635               playVideoNew(permalink, 2, stream_id, sId);
636        }
637        } else {
638            //ER - 70595 - Starts
639           if(typeof(otp_authorize_content_access) != "undefined" && otp_authorize_content_access == 1){
640                var url = HTTP_ROOT + '/Player_Page/' + permalink;
641                openGenerateOtpModal('', '', movie_id, permalink, content_types_id, url);
642            }else{
643                window.location.href = HTTP_ROOT + '/Player_Page/' + permalink;
644            }
645            //ER - 70595 - Ends
646        }
647    }
648}
649//Er - 70595 - Starts - [email protected]
650function openGenerateOtpModal(stream_id = '', stream_embed_id = '', movie_unique_id = '', permalink = '', content_types_id = '', redirect_link = ''){
651    var url = HTTP_ROOT + "/media/otpAuthorizationContent";
652    $('#loader_popup').show();
653    $.ajax({
654        url: url,
655        data: {'movie_unique_id': movie_unique_id, 'stream_id': stream_id, 'stream_embed_id' : stream_embed_id, 'permalink' : permalink, 'content_types_id' : content_types_id, 'redirect_link' : redirect_link},
656        method: "post",
657        async: false,
658        success: function (res) {
659            if(res == 0){
660                window.location.href = redirect_link;
661            }else{
662                $('#loader_popup').hide();
663                $("#generateOtpModal").html(res).modal('show');
664            }
665        }
666    });
667}
668//Er - 70595 - Ends
669
670function episodegetPpvPlans(obj, onCloseNotRefresh) {
671    if (typeof (onCloseNotRefresh) === "undefined") {
672        onCloseNotRefresh = 0;
673    } else {
674        onCloseNotRefresh = 1;
675    }
676    $('#loader').show();
677    var purchase_type = "episode";
678    var url = HTTP_ROOT + "/userMonetizationPlans/getMonetizationMethods";
679    var isppv = 0;
680    var is_ppv_bundle = 0;
681    var movie_id;
682    var stream_id;
683    var permalink;
684    var isadv = 0;
685    var audio_id;
686    var content_type;
687    var is_obj;
688    var index_val = 0;//ER :: 25423
689    if (typeof (isGuestUser) === "undefined") {
690        var isGuestUser = window.isGuestUser;
691    }
692    if (typeof (obj) === "undefined") {
693        audio_id = $('#movie_stream_id').val();
694        content_type = $('#content-type').val();
695        movie_id = $('#movie_id').val();
696        stream_id = $('#stream_id').val();
697        permalink = $('#content-permalink').val();
698        if($('#indexval').val()!="" && typeof ($('#indexval').val()) !== "undefined"){
699            index_val = $('#indexval').val();
700        }
701
702        if ($("#is_ppv_bundle").length) {
703            is_ppv_bundle = $("#is_ppv_bundle").val();
704        }
705        if ($("#isadv").length) {
706            isadv = $("#isadv").val();
707        }
708        is_obj = 1;
709    } else {
710        audio_id = $(obj).attr("data-id");
711        movie_id = $(obj).attr("data-movie_id");
712        stream_id = $(obj).attr("data-stream_id");
713        permalink = $(obj).attr("data-content-permalink");
714        isppv = $(obj).attr('data-isppv');
715        is_ppv_bundle = $(obj).attr('data-is_ppv_bundle');
716        isadv = $(obj).attr('data-isadv');
717        content_type = $(obj).attr('data-ctype');
718        is_obj = 0;
719        index_val = $(obj).attr('data-indexval');//ER :: 25423
720        if ($(obj).attr("data-is_guest_user")) {
721            var isGuestUser = $(obj).attr("data-is_guest_user");
722        }
723    }
724    //ER 27707 Start . Only set async value false for Mac and Iphone Safari browser
725    /*$.post(url, {'movie_id': movie_id, 'stream_id': stream_id, 'purchase_type': purchase_type, 'isppv': isppv, 'is_ppv_bundle': is_ppv_bundle, 'isadv': isadv, isGuestUser: isGuestUser, 'onCloseNotRefresh': onCloseNotRefresh}, function (res) {
726        $('#loader').show();
727        if (parseInt(res) === 1) {
728            if (audio_id) {
729                if (is_obj == 1) {
730                    setSessionForAODContent(content_type, audio_id);
731                    location.reload();
732                } else {
733                    if (parseInt(content_type) == 5) {
734                        playAudioNew(audio_id);
735                    } else if (parseInt(content_type) == 6) {
736                        playMultipartAudio(audio_id, index_val); //ER :: 25423
737                    }
738                }
739            } else {
740                if (stream_id !== '') {
741                    if (supportOptionalContent) {
742                        playVideoNew(permalink, 2, stream_id);
743                    } else {
744                        window.location.href = HTTP_ROOT + "/" + Player_Page 
744+ "/" + permalink + '/stream/' + stream_id;
745                    }
746                } else {
747                    if (supportOptionalContent) {
748                        playVideoNew(permalink, 2);
749                    } else {
750                        window.location.href = HTTP_ROOT + "/" + Player_Page + "/" + permalink;
751                    }
752                }
753            }
754        } else {
755            reload = 1;
756            $("#ppvModal").html(res).modal('hide');
757            $('#loader').hide();
758
759            if (parseInt(is_plan_error)) {
760                $("#ppvModal").html(res).modal('show');
761                $('#loader-ppv').hide();
762            }
763        }
764     });*/
765    $.ajax({
766        url: url,
767        data: {'movie_id': movie_id, 'stream_id': stream_id, 'purchase_type': purchase_type, 'isppv': isppv, 'is_ppv_bundle': is_ppv_bundle, 'isadv': isadv, isGuestUser: isGuestUser, 'onCloseNotRefresh': onCloseNotRefresh, 'onMonetizationCheck': 1},
768        method: "post",
769        async: false,
770        success: function (res) {
771            if(parseInt(res) === 10) {
772                window.location.href = HTTP_ROOT+'/user/activate';
773            }
774            $('#loader').show();
775            if (parseInt(res) === 1) {
776                if (audio_id) {
777                    if (is_obj == 1) {
778                        setSessionForAODContent(content_type, audio_id);
779                        location.reload();
780                    } else {
781                        if (parseInt(content_type) == 5) {
782                            playAudioNew(audio_id);
783                        } else if (parseInt(content_type) == 6) {
784                            playMultipartAudio(audio_id, index_val); //ER :: 25423
785                        }
786                    }
787                } else {
788                    if (stream_id !== '') {
789                        if (supportOptionalContent) {
790                            if(content_type==3){//32446
791                                playAllVideoAuto(permalink, 2, stream_id,0,index_val);
792                            }else{
793                            playVideoNew(permalink, 2, stream_id);
794                            }
795                            
796                        } else {
797                            //ER - 70595 - Starts
798                            if(typeof(otp_authorize_content_access) != "undefined" && otp_authorize_content_access == 1){
799                                var redirect_link = HTTP_ROOT + "/" + Player_Page + "/" + permalink + '/stream/' + stream_id;
800                                openGenerateOtpModal('',stream_id, movie_id, permalink, content_type, redirect_link);
801                            }else{
802                                window.location.href = HTTP_ROOT + "/" + Player_Page + "/" + permalink + '/stream/' + stream_id;
803                            }
804                            //ER - 70595 - Ends
805                        }
806                    } else {
807                        if (supportOptionalContent) {
808                            if(content_type==3){//32446
809                                playAllVideoAuto(permalink, 2, stream_id,0,index_val);
810                            }else{
811                            playVideoNew(permalink, 2);
812                            }
813                        } else {
814                            //ER - 70595 - starts
815                            if(typeof(otp_authorize_content_access) != "undefined" && otp_authorize_content_access == 1){
816                                var redirect_link = HTTP_ROOT + '/Player_Page/' + permalink;
817                                openGenerateOtpModal('',stream_id, movie_id, permalink, content_type, redirect_link);
818                            }else{
819                                window.location.href = HTTP_ROOT + '/Player_Page/' + permalink;
820                            }
821                            //ER - 70595 - Ends
822                        }
823                    }
824                }
825            } else {
826                //52108
827                if ($('#sso_with_miniorange_shopify_recharge').val() !== typeof undefined && $('#sso_with_miniorange_shopify_recharge').val() == 1) {
828                 $("#recharge-subscribe-modal").modal('show');
829                } else { //52108
830                reload = 1;
831                $("#ppvModal").html(res).modal('hide');
832                $('#loader').hide();
833
834                if (parseInt(is_plan_error)) {
835                    $("#ppvModal").html(res).modal('show');
836                    $('#loader-ppv').hide();
837                }
838                }//52108
839            }
840        }});
841    //ER 27707 End
842}
843$(document).ready(function () {
844
845//    18112 [Sweta M]
846    if (content_type == 5 && (dl_type == 0)) {
847        playAudioNew(audio_id);
848    } else if (content_type == 6 && (dl_type == 0)) {
849        playMultipartAudio(audio_id, 0);
850    } else {
851        if (typeof (guest_user_id) !== "undefined" && parseInt(guest_user_id) > 0 && dl_permalink) {
852            dl_permalink += '/is_guest_user/1';
853        }
854        if (content_type == 6 && dl_type != 0) {
855            var purl = HTTP_ROOT + "/user/DownloadMultipartContent/vlink/" + dl_permalink;
856        } else if (dl_type != 0) {
857            var purl = HTTP_ROOT + "/user/DownloadContent/vlink/" + dl_permalink;
858            var downloadCount = 1;
859            if (downloadCount == 1 && dl_type != 0) {
860                dl_type = 0;
861                content_type = false;
862                audio_id = false;
863                downloadCount++;
864                window.location.href = purl;
865                return false;
866            }
867        }
868        console.log(purl);
869        if (content_type == 6 && dl_type !== typeof undefined && dl_type == 2) {
870            $.post(purl, function (downloadarray) {
871                var jsonarray = jQuery.parseJSON(downloadarray);
872                if (jsonarray.error) {
873                    if (jsonarray.errorType !== typeof undefined && jsonarray.errorType == 'guestuser') {
874                        //alert(jsonarray.msg);
875                    } else {
876                        alert("Download not accomplished!!");
877                        window.setTimeout(function () {
878                            location.reload()
879                        }, 2000);
880                    }
881                } else {
882                    $('.loader_download').hide();
883                    $('.download_loader').show().delay(15000).fadeOut();
884                    $.each(jsonarray, function (key, value) {
885                        download_files([{download: value}]);
886                    });
887                }
888            });
889        }
890    }
891
892    if ((parseInt(login_field) == 1)) {
893        $("#username").attr('type', 'text');
894        $('<input type="hidden" class="login_field" value="1" />').insertAfter("#login_form");
895    }
896    var showconfirm = '';
897    var showconfirmsessionid = '';
898    var showconfirm = $('#show_season_confirm').val();
899    var showconfirmsessionid = $('#show_season_confirm_sessionid').val();
900    var seasonId = $('#seasonId').val();
901    var episodeId = $('#episodeId').val();
902    var embedId = $('#embedId').val();
903    var episode = $('#episode').val();
904    var permalink = $('#permalink').val();
905    var ppv_watchpopup_time = $('#ppv_watchpopup_time').val();
906    console.log(ppv_watchpopup_time);
907    
908    if (ppv_watchpopup_time > 0){
909        var timeInterval = ppv_watchpopup_time;
910    }
911    else{
912        var timeInterval = '5000';
913    }
914    
915    if ($('#time_interval_set').length > 0) {
916        timeInterval = $('#time_interval_set').val();
917    }
918    var content_name = $('#content_name').val();
919    if (showconfirm != '' && showconfirmsessionid != '' && typeof (showconfirm) != 'undefined' && typeof (showconfirmsessionid) != 'undefined' && showconfirm === showconfirmsessionid) {
920        var contName = content_name;
921        if (parseInt(seasonId)) {
922            contName = contName + '-' + JSLANGUAGE.season + seasonId;
923        }
924        if (parseInt(episodeId)) {
925            contName = contName + '-' + episode;
926        }
927
928        $('#modalmsg').html(contName);
929
930        $("#showseasonconfirmpopup").modal('show');
931        var initial;
932        initial = window.setTimeout(function () {
933            uri = '';
934            var streamid = '';
935            var sId = '';
936            if (parseInt(seasonId)) {
937                uri = permalink + '/season/' + seasonId;
938                sId = seasonId;
939            }
940
941            if (parseInt(episodeId)) {
942                uri = uri + '/stream/' + embedId;
943                streamid = embedId;
944            }
945            var content_id = $('#content_id').val();
946
947            var url = HTTP_ROOT + "/user/SeasonShowConfirm/";
948            $('.loader_confirm').show();
949            $.post(url, {'showconfirmsessionid': showconfirmsessionid}, function (res) {
950                if (res) {
951                    $('.loader_confirm').hide();
952                    if (uri !== "") {
953                        if (supportOptionalContent) {
954                            playVideoNew(permalink, 2, streamid, sId);
955                        } else {
956                            window.location.href = HTTP_ROOT + '/' + Player_Page 
956+ '/' + uri;
957                        }
958                    } else {
959                        if (supportOptionalContent) {
960                            playVideoNew(permalink, 2);
961                        } else {
962                            window.location.href = HTTP_ROOT + '/' + Player_Page + '/' + permalink;
963                        }
964                    }
965                }
966            });
967        }, timeInterval);
968
969        /* ER 44327 */
970        if($('#meeting_type').length && $('#meeting_type').val()==1){
971            $('#auto_play_msg').html('');
972            /* ER 45357 */
973            $('#watchnowShowseasonconfirm').hide();
974           /* ER 45357 */
975            clearTimeout(initial);
976        }
977        /* ER 44327 */
978
979    }
980    $("#dismisShowseasonconfirm, #closeShowseasonconfirm").click(function () {
981        clearTimeout(initial);
982        var url = HTTP_ROOT + "/user/SeasonShowConfirm/";
983        $('.loader_confirm').show();
984        $.post(url, {'showconfirmsessionid': showconfirmsessionid}, function (res) {
985            if (res == 1) {
986                $('.loader_confirm').hide();
987                $("#showseasonconfirmpopup").modal('hide');
988            }
989        });
990    });
991    $("#watchnowShowseasonconfirm").click(function () {
992        uri = '';
993        var streamid = '';
994        var sId = '';
995        if (parseInt(seasonId)) {
996            uri = permalink + '/season/' + seasonId;
997            sId = seasonId;
998        }
999
1000        if (parseInt(episodeId)) {
1001            uri = uri + '/stream/' + embedId;
1002            streamid = embedId;
1003        }
1004        var content_id = $('#content_id').val();
1005
1006        var url = HTTP_ROOT + "/user/SeasonShowConfirm/";
1007        $('.loader_confirm').show();
1008        $.post(url, {'showconfirmsessionid': showconfirmsessionid}, function (res) {
1009            if (res) {
1010                $('.loader_confirm').hide();
1011                if (uri !== "") {
1012                    if (supportOptionalContent) {
1013                        playVideoNew(permalink, 2, streamid, sId);
1014                    } else {
1015                        window.location.href = HTTP_ROOT + '/' + Player_Page + '/' + uri;
1016                    }
1017                } else {
1018                    if (supportOptionalContent) {
1019                        playVideoNew(permalink, 2);
1020                    } else {
1021                        window.location.href = HTTP_ROOT + '/' + Player_Page + '/' + permalink;
1022                    }
1023                }
1024            }
1025        });
1026    });
1027    //#Mantis : 18523 [SwetaM]
1028    $('body').on('click', '.playbtn, .playnowbtn, .playAudioContent, .btn.btn-lg.btn-primary, .btn.as-btn-accent.as-btn-md, .play_audio_episodes', function (e) {
1029        $('#loader').show();
1030        var chk_login = $(this).attr('data-api_available');
1031        var chk_registeration = $(this).attr('data-chk_register');
1032        var content_title = $(this).attr('data-content_title');
1033        var movie_id = $(this).attr('data-movie_id');
1034        var permalink = $(this).attr("data-content-permalink");
1035        var stream_id = $(this).attr('data-stream_id');
1036        var indexval = $(this).attr('data-indexval');
1037        var season_id;
1038        login_object = $(this);
1039        var purchase_type = $(this).attr('data-purchase_type');
1040        if (typeof purchase_type !== typeof undefined && purchase_type !== false) {
1041            if (purchase_type === 'season' && $("#series").length) {
1042                season_id = $("#series").val();
1043                if (parseInt(season_id)) {
1044                    permalink += "/season/" + season_id;
1045                }
1046            }
1047        } else if (parseInt(stream_id)) {
1048            permalink += '/stream/' + stream_id;
1049        }
1050        var isppv = $(this).attr('data-isppv');
1051        var is_ppv_bundle = $(this).attr('data-is_ppv_bundle');
1052        var isadv = $(this).attr('data-isadv');
1053        $.cookie("movie_id", movie_id, {path: '/'});
1054        $.cookie("is_ppv", isppv, {path: '/'});
1055        $.cookie("permalink", permalink, {path: '/'});
1056        if (typeof isadv !== typeof undefined && isadv !== false) {
1057
1058        } else {
1059            isadv = 0;
1060        }
1061
1062        var permalink = $(this).attr("data-content-permalink");
1063        var contentTypePermalink = $(this).attr("data-content-type-permalink");
1064        var isDownload = $(this).attr("data-download");
1065        var data_audio_id = $(this).attr("data-id");
1066        var data_content_type = $(this).attr("data-ctype");
1067
1068        $('#loginModal').on('show.bs.modal', function (e) {
1069            $('#loader').hide();
1070            $('#chk_register').val(chk_registeration);
1071            $("#movie_id").val(movie_id);
1072            $("#content_title").val(content_title);
1073            if ($("#season_id").length) {
1074                $("#season_id").val(season_id);
1075            }
1076            $("#stream_id").val(stream_id);
1077            $("#movie_stream_id").val(data_audio_id);
1078            $("#content-type").val(data_content_type);
1079            $("#isppv").val(isppv);
1080            $("#is_ppv_bundle").val(is_ppv_bundle);
1081            $("#isadv").val(isadv);
1082            $('#content-permalink').val(permalink);
1083            $('#content-type-permalink').val(contentTypePermalink);
1084            $('#indexval').val(indexval);
1085            if (typeof isDownload !== typeof undefined && isDownload !== false) {
1086                if ($('#isDownload').length == 0) {
1087                    $(".popup_bottom").append('<input type="hidden" id="isDownload" value="">');
1088                }
1089                $('#isDownload').val(isDownload);
1090            } else {
1091                $('#isDownload').val('');
1092            }
1093        });
1094
1095        $('#generalInfoModal').on('show.bs.modal', function (e) {
1096            $('#loader').hide();
1097            $('#chk_register').val(chk_registeration);
1098            $("#movie_id").val(movie_id);
1099            $("#content_title").val(content_title);
1100            if ($("#season_id").length) {
1101                $("#season_id").val(season_id);
1102            }
1103            $("#stream_id").val(stream_id);
1104            $("#isppv").val(isppv);
1105            $("#is_ppv_bundle").val(is_ppv_bundle);
1106            $("#isadv").val(isadv);
1107            $("#general_info").val(1);
1108            $('#content-permalink').val(permalink);
1109            $('#content-type-permalink').val(contentTypePermalink);
1110            if (typeof isDownload !== typeof undefined && isDownload !== false) {
1111                $('#isDownload').val(isDownload);
1112            } else {
1113                $('#isDownload').val('');
1114            }
1115        });
1116    });
1117
1118    //62706 - start
1119    var valid_num_reg = /^[1-9][0-9]*$/;
1120    $.validator.addMethod("validPhoneNumber", function (value, element) {
1121        return this.optional(element) || valid_num_reg.test(value);
1122    }, JSLANGUAGE.valid_mobile_number);
1123    //62706 - end
1124
1125    $('#login_form').validate({
1126        rules: {
1127            "LoginForm[email]": {
1128                required: true,
1129                email: $(".login_field").length <= 0
1130            },
1131            "LoginForm[password]": {
1132                required: true,
1133            },
1134            "LoginForm[mobile_number]": {
1135                required: true,
1136                number: true,
1137                validPhoneNumber: false //62706
1138            }
1139        },
1140        messages: {
1141            "LoginForm[email]": {
1142                required: JSLANGUAGE.email_required,
1143                email: JSLANGUAGE.valid_email
1144            },
1145            "LoginForm[mobile_number]": {
1146                required: JSLANGUAGE.mobile_number_required,/*28147*/
1147                number: JSLANGUAGE.valid_mobile_number //62706
1148            },
1149            "LoginForm[password]": {
1150                required: JSLANGUAGE.password_required,
1151            },
1152        },
1153        submitHandler: function (form) {
1154            window.isGuestUser = 0;
1155            $.ajax({
1156                url: HTTP_ROOT + "/user/ajaxlogin",
1157                data: $('#login_form').serialize(),
1158                type: 'POST',
1159                dataType: "json",
1160                beforeSend: function () {
1161                    $('#login_loading').show();
1162                    $('#loader_login').show();
1163                },
1164                success: function (data) {
1165                    $('input[name=csrfToken]').val(data.csrfToken);
1166                    $('#login_loading').hide();
1167                    $('#loader_login').hide();
1168					$('#login_errors').hide();
1169					if(data.login == 'invalid_token'){
1170						$('#login_errors').html('');
1171                        $('#login_errors').show();
1172					}else if (data.login == 'success') {
1173                        if ($.trim($("#add_to_fav").val())) {
1174                            $('#login_loading').show();
1175                            $('#loader_login').show();
1176                            var content_type = $.trim($("#content_type").val());
1177                            if (content_type == 1) {
1178                                var content_id = $.trim($("#stream_id").val());
1179                            } else {
1180                                var content_id = $.trim($("#movie_id").val());
1181                            }
1182                            addToFavList(content_id, content_type, false, 1);
1183                        } else {
1184                            $('#login_errors').html("");
1185                            if ($.trim($("#movie_id").val())) {
1186                                $('#loginModal').modal('hide');
1187                                //  ER 82067 start only for classic template 
1188                                if ($.trim($("#theme_type").val()) === 'classic-byod' && ($.trim($("#content_type_id").val()) === '5' || $.trim($("#content_type_id").val()) === '6')) { 
1189                                    var newaudio_url = $('#content-permalink').val();
1190                                    window.location = HTTP_ROOT + '/' + newaudio_url;
1191                                    exit();           
1192                                 }
1193                                // ER 82067 end only for classic template
1194                                if ($.trim($("#isDownload").val())) {
1195                                    //getVoucherGeneralInfoGuest(login_object);
1196                                    if(parseInt($("#isppv").val()) || parseInt($("#is_ppv_bundle").val()) || parseInt($("#isadv").val())){
1197                                        getPpvPlans();
1198                                } else {
1199                                    download_content(login_object);
1200                                    window.location = HTTP_ROOT + '/' + $('#content-permalink').val();
1201                                            }
1202                                } else {
1203                                    if ($("#chkPlay").val()) {
1204                                        chkPlayPerimission();
1205                                    } else if (parseInt($("#isppv").val()) || parseInt($("#is_ppv_bundle").val()) || parseInt($("#isadv").val())) {
1206                                        if ($.trim($("#stream_id").val()) === 0) {
1207                                            getPpvPlans();
1208                                        } else {
1209                                            episodegetPpvPlans();
1210                                        }
1211                                    } else {
1212                                        /* ER 24063 [Abhinandan] : Start*/
1213                                        var ctype = $.trim($("#stream_id").val());
1214                                        if ($.trim(ctype) == 0 || $.trim(ctype) == '0') {
1215                                            var audio_url = $('#content-permalink').val();
1216                                            window.location = HTTP_ROOT + '/' + audio_url;
1217                                        } else {
1218                                            playMovie();
1219                                        }
1220                                        /* ER 24063 [Abhinandan] : End*/
1221                                    }
1222                                }
1223                            } else {
1224                                var redirectUrl = decodeURIComponent(getCookie('redirectToPreviousPage'));
1225                                if ($('#loginModal').length && $('#loginModal').css('display') == 'block') {
1226                                    location.reload();
1227                                } else {
1228                                    if ($.trim(data.action) != '') {
1229                                        window.location = data.action;
1230                                    } else if (redirectUrl) {
1231                                        window.location = redirectUrl
1232                                    } else {
1233                                        window.location = HTTP_ROOT + '/';
1234                                    }
1235                                }
1236                            }
1237                        }
1238                    } else if ($.trim(data.login) == 'error_limit_login') {
1239                        $('#login_errors').html(data.msg);
1240                        $('#login_errors').show();
1241                        $("#logout_all").modal('show');
1242                    } else if ($.trim(data.login) == 'account_not_activated') {
1243                        $('#login_errors').html(data.msg);
1244                        $('#login_errors').show();
1245                        //ER 64476 : resend activation email button on login screens start
1246                        resendlinkmsg = "Resend the activation link";
1247                        document.getElementById("resend_link").innerHTML = resendlinkmsg;
1248                        //ER 64476 : resend activation email button on login screens end
1249                    //ER 64148 Start
1250                    } else if (data.status == 215 || data.status == "215"){
1251                        window.location.href = data.http_redirect;
1252                    //ER 64148 End
1253                    //ER 67845 Start
1254                    } else if ($.trim(data.login) == 'device_limit_exceed') {
1255                        $('#login_errors').html(data.msg);
1256                        $('#login_errors').show();
1257                        $("#logout_all").modal('show');
1258                    //ER 67845 End 
1259                    }else {    
1260                        if( $('#mobile_registration').val()==1){ /*28147*/ //63629
1261                        $('#login_errors').html(JSLANGUAGE.incorrect_phone_or_password);
1262                        } else {
1263                        $('#login_errors').html(JSLANGUAGE.incorrect_email_or_password); } /*28147*/
1264                        $('#login_errors').show();
1265                    }
1266                },
1267                complete: function () {
1268                    $('#loader_login').hide();
1269                    $('#login_loading').hide();
1270                }
1271            });
1272        }
1273    });
1274
1275    $('#lib_login_form').validate({
1276        rules: {
1277            "LibraryLoginForm[username]": {
1278                required: true,
1279            },
1280            "LibraryLoginForm[password]": {
1281                required: true,
1282            }
1283        },
1284        messages: {
1285            "LibraryLoginForm[username]": {
1286                required: JSLANGUAGE.username_required,
1287            },
1288            "LibraryLoginForm[password]": {
1289                required: JSLANGUAGE.password_required,
1290            },
1291        },
1292        submitHandler: function (form) {
1293            $.ajax({
1294                url: HTTP_ROOT + "/login/libraryAuth",
1295                data: $('#lib_login_form').serialize(),
1296                type: 'POST',
1297                dataType: "json",
1298                beforeSend: function () {
1299                    $('#lib_login_loading').show();
1300                    $('#loader_login').show();
1301                },
1302                success: function (data) {
1303                    $('input[name=csrfToken]').val(data.csrfToken);
1304                    $('#lib_login_loading').hide();
1305                    $('#loader_login').hide();
1306                    if (data.status == 'success') { //39145
1307                        $('#loginModal').modal('hide');
1308                        $(".response_username").html(data.response_username);
1309                        $(".response_feedback").html(data.response_feedback);
1310                        if(data.response_url){/*44062*/
1311                        $(".success_response_url").attr("href", data.response_url);
1312                        } else { 
1313                             $('.success_response_url').contents().unwrap();
1314                        }/*44062*/
1315                        $("#hidden_redirecturl").val(data.redirect_url);
1316                        $("#libraryselected").text($('#lib-name').html());
1317                        $('#success-modal').modal('show');
1318                            } else {
1319                        $('#loginModal').modal('hide');
1320                        $(".response_username").html(data.response_username);
1321                        $(".response_feedback").html(data.response_feedback);
1322                        if(data.response_url){/*44062*/
1323                        $(".response_url").attr("href", data.response_url);
1324                        } else { 
1325                            $('.response_url').contents().unwrap();
1326                        }/*44062*/
1327                        $('#failure-modal').modal('show');
1328                    }//39145
1329                },
1330                complete: function () {
1331                    $('#loader_login').hide();
1332                    $('#lib_login_loading').hide();
1333                }
1334            });
1335        }
1336    });
1337
1338    $("#login_errors").on('click', '#session_reset', function () {
1339        var user_id = $("#session_reset_user_id").val();
1340        var studio_id = $("#session_reset_studio_id").val();
1341        $.ajax({
1342            url: HTTP_ROOT + "/user/logoutAll",
1343            data: {user_id: user_id, studio_id: studio_id},
1344            type: 'POST',
1345            beforeSend: function () {
1346                $("#reset_session_loader").show();
1347            },
1348            success: function () {
1349                $("#reset_session_loader").hide();
1350                $("#login_errors #logout_all").modal('hide');
1351                $("#login_errors").html(JSLANGUAGE.logged_out_from_all_devices);
1352            },
1353            complete: function () {
1354                window.location.href = window.location.href;
1355            }
1356        });
1357    });
1358
1359    $('#generalinfo_form').validate({
1360        rules: {
1361            "data[name]": {
1362                required: true,
1363                minlength: 1
1364            },
1365            "data[email]": {
1366                required: true,
1367                email: true
1368            }
1369        },
1370        messages: {
1371            "data[name]": {
1372                required: JSLANGUAGE.full_name_required,
1373                minlength: JSLANGUAGE.name_minlength
1374            },
1375            "data[email]": {
1376                required: JSLANGUAGE.email_required,
1377                email: JSLANGUAGE.valid_email
1378            },
1379        },
1380        submitHandler: function (form) {
1381            $.ajax({
1382                url: HTTP_ROOT + "/user/SaveGeneralInfoUser",
1383                data: $('#generalinfo_form').serialize(),
1384                type: 'POST',
1385                dataType: "json",
1386                beforeSend: function () {
1387                    $('#loader_general').show();
1388                },
1389                success: function (data) {
1390                    $('#loader_general').hide();
1391                    if ($.trim(data.login) == 'success') {
1392                        if ($.trim($("#movie_id").val())) {
1393                            if (parseInt($("#isppv").val()) || parseInt($("#is_ppv_bundle").val())) {
1394                                var guest_id = $.trim(data.guest_id);
1395                                getVoucherGeneralInfo(guest_id);
1396                                $('#loader_general').hide();
1397                            } else {
1398                                playMovie();
1399                                $('#loader_general').hide();
1400                            }
1401                        } else {
1402                            location.reload();
1403                        }
1404
1405                    }
1406                },
1407                complete: function () {
1408                    $('#loader_general').hide();
1409                    $('#loader_general').hide();
1410                }
1411            });
1412        }
1413    });
1414    var nospecialchar = /^[~@$^"'(),!<>().+=[\]{}|\\,.:-]|(?:[~@$^"'(),!<>().+=[\]{}
1414|\\,.:-])/;
1415    $.validator.addMethod("letterOnly", function (value, element) {
1416        return this.optional(element) || !nospecialchar.test(value);
1417
1418    }, JSLANGUAGE.valid_text);
1419    $('#register_form').validate({
1420        rules: {
1421            "data[name]": {
1422                required: true,
1423                letterOnly: false,
1424                minlength: 1
1425            },
1426            "data[email]": {
1427                required: true,
1428                email: true
1429            },
1430            "data[mobile_number]": {
1431                required: true,
1432                number: true,
1433                minlength:7,//48366
1434                maxlength : 17,//48366
1435                validPhoneNumber: true //62706
1436            },
1437            "data[password]": {
1438                required: true,
1439                minlength: 6
1440            },
1441            "data[confirm_password]": {
1442                required: true,
1443                equalTo: "#join_password"
1444            },
1445            //37432 starts
1446            "data[contact_number]": {
1447                required: true,
1448                digits: true
1449            }
1450            //37432 ends
1451            
1452        },
1453        messages: {
1454            "data[name]": {
1455                required: JSLANGUAGE.full_name_required,
1456                minlength: JSLANGUAGE.name_minlength
1457            },
1458            "data[email]": {
1459                required: JSLANGUAGE.email_required,
1460                email: JSLANGUAGE.valid_email
1461            },
1462            "data[mobile_number]": {
1463                required: JSLANGUAGE.mobile_number_required,
1464                number: JSLANGUAGE.valid_mobile_number //62706
1465            },
1466            "data[password]": {
1467                required: JSLANGUAGE.password_required,
1468                minlength: JSLANGUAGE.password_minlength
1469            },
1470            "data[confirm_password]": {
1471                required: JSLANGUAGE.valid_confirm_password,
1472                equalTo: JSLANGUAGE.password_donot_match,
1473            },
1474            //37432 starts
1475            "data[contact_number]": {
1476                required: JSLANGUAGE.valid_phone_number,
1477                digits: JSLANGUAGE.enter_correct_phone
1478            }
1479            //37432 ends
1480        },
1481        submitHandler: function (form) {
1482            $('#register_loading').show();
1483            $('#loader_register').show();
1484            var email = $.trim($('#register_form').find("input[type='email']").val());
1485            login_fields = [];
1486            $('#register_form .login_field').each(function () {
1487                pushToArray(this.id, this.value);
1488            });
1489            $.post(HTTP_ROOT + "/user/checkemail", {'email': email, 'formdata': login_fields}, function (res) {
1490                res = JSON.parse(res);
1491                if (parseInt(res.isExists) === 1) {
1492                    $('#register_loading').hide();
1493                    $('#loader_register').hide();
1494                    if ($.trim(res.field_name) == 'email_address') {
1495                        if($.trim(res.field_specific) == 'not_domain_email') {
1496                            msg = JSLANGUAGE.allowed_domain_email;
1497                        } else {
1498                            msg = JSLANGUAGE.email_exists_us;
1499                        }
1500                    } else if ($.trim(res.field_name) == 'email') { //48366
1501                        msg = JSLANGUAGE.email_exists_us;
1502                    } else  {
1503                        msg = JSLANGUAGE.value_exists;
1504                    }
1505                    $('<label id="' + res.field_name + '-error" class="error" for="' + res.field_name + '">' + msg + '</label>').insertAfter("#" + $.trim(res.field_name));
1506                    return false;
1507                } else {
1508                    //37432 starts
1509                    if($("#contact_number").length > 0){
1510                        var is_contact_exist=false;
1511                    $.ajax({
1512                            url: HTTP_ROOT + "/user/checkMobile?mobile_number="+$("#contact_number").val(),                        
1513                            success: function (res) {
1514                                if (res == 1) {
1515                                    var msg = JSLANGUAGE.mobile_number_exists_us;
1516                                    $('<label id="contact-number-error" 
1516class="error" for="contact_number">'+msg+'</label>').insertAfter("#"+$.trim("contact_number"));
1517                                    $('#register_loading').hide();
1518                                    $('#loader_register').hide();
1519                                    is_contact_exist = true;
1520                                }                            
1521                            },
1522                            async: false
1523                        });
1524                        if(is_contact_exist)
1525                            return false;
1526                    }                        
1527                    //37432 ends
1528                    if($("#mobile_number").length > 0){//48366
1529                        var is_contact_exist=false;
1530                    $.ajax({
1531                            url: HTTP_ROOT + "/user/checkMobile?mobile_number="+$("#mobile_number").val(),                        
1532                            success: function (res) {
1533                                if (res == 1) {
1534                                    var msg = JSLANGUAGE.mobile_number_exists_us;
1535                                    $('<label id="mobile_number-error" class="error" for="mobile_number">'+msg+'</label>').insertAfter("#"+$.trim("mobile_number"));
1536                                    $('#register_loading').hide();
1537                                    $('#loader_register').hide();
1538                                    is_contact_exist = true;
1539                                }                            
1540                            },
1541                            async: false
1542                        });
1543                        if(is_contact_exist)
1544                            return false;
1545                    }
1546                    if( $('#enabled_otp').val()==1){
1547                        var sendotp=ValidatePopOtp();
1548                        if(sendotp){
1549                    $.ajax({
1550                        url: HTTP_ROOT + "/user/ajaxregister",
1551                        data: $('#register_form').serialize(),
1552                        type: 'POST',
1553                        dataType: "json",
1554                        success: function (data) {
1555                            $('#register_loading').hide();
1556                            $('#loader_register').hide();
1557                            if ($.trim(data.login) == 'success') {
1558                                if ($.trim($("#add_to_fav").val())) {
1559                                    $('#login_loading').show();
1560                                    $('#loader_login').show();
1561                                    var content_type = $.trim($("#content_type").val());
1562                                    if (content_type == 1) {
1563                                        var content_id = $.trim($("#stream_id").val());
1564                                    } else {
1565                                        var content_id = $.trim($("#movie_id").val());
1566                                    }
1567                                    addToFavList(content_id, content_type, false, 1);
1568                                } else {
1569                                    $('#register-btn').attr("disabled", "disabled");
1570                                    if ($.trim($("#movie_id").val())) {
1571                                        if ($.trim($("#isDownload").val())) {
1572                                        if(parseInt($("#isppv").val()) || parseInt($("#is_ppv_bundle").val()) || parseInt($("#isadv").val())){
1573                                                getPpvPlans();
1574                                        } else {
1575                                                download_content(login_object);
1576                                                window.location = HTTP_ROOT + '/' + $('#content-permalink').val();
1577                                            }
1578                                            //getVoucherGeneralInfoGuest(login_object);
1579                                            //download_content();
1580                                        } else {
1581                                            if (parseInt($("#isadv").val()) || parseInt($("#isppv").val()) || parseInt($("#is_ppv_bundle").val())) {
1582                                                if ($.trim($("#stream_id").val()) === 0) {
1583                                                    getPpvPlans();
1584                                                } else {
1585                                                    episodegetPpvPlans();
1586                                                }
1587                                                $('#loader_register').hide();
1588                                                $('#register_loading').hide();
1589                                            } else {
1590                                                playMovie();
1591                                                $('#register_loading').hide();
1592                                            }
1593                                        }
1594                                    } else {
1595                                        location.reload();
1596                                    }
1597                                }
1598                            } else if ($.trim(data.register) == 'success') {
1599                                if (data.code != 202) {
1600                                    $('#register_errors').show();
1601                                    $('#register_errors').html(JSLANGUAGE.api_subscribe_failed);
1602                                } else {
1603                                    var url = HTTP_ROOT + "/user/register";
1604                                    window.location.href = url;
1605                                }
1606                            } else if ($.trim(data.register) == 'error') {
1607                                $('#register_errors').show();
1608                                $('#register_errors').html(data.message);
1609                            } else if ($.trim(data.login) == 'error') {
1610                                $('#register_errors').show();
1611                                $('#register_errors').html(JSLANGUAGE.email_exists_us);
1612                            } else if ($.trim(data.login) == 'account_not_activated') {
1613                                $('#register_errors').html(data.msg);
1614                                $('#register_errors').show();
1615                            } else {
1616                                $('#register_errors').show();
1617                                $('#register_errors').html(JSLANGUAGE.saving_error);
1618                            }
1619                        },
1620                        complete: function () {
1621                            $('#loader_register').hide();
1622                            $('#register_loading').hide();
1623                        }
1624                    });
1625                }
1626                    } else {
1627                    //48366
1628                    $.ajax({
1629                        url: HTTP_ROOT + "/user/ajaxregister",
1630                        data: $('#register_form').serialize(),
1631                        type: 'POST',
1632                        dataType: "json",
1633                        success: function (data) {
1634                            $('#register_loading').hide();
1635                            $('#loader_register').hide();
1636                            if ($.trim(data.login) == 'success') {
1637                                if ($.trim($("#add_to_fav").val())) {
1638                                    $('#login_loading').show();
1639                                    $('#loader_login').show();
1640                                    var content_type = $.trim($("#content_type").val());
1641                                    if (content_type == 1) {
1642                                        var content_id = $.trim($("#stream_id").val());
1643                                    } else {
1644                                        var content_id = $.trim($("#movie_id").val());
1645                                    }
1646                                    addToFavList(content_id, content_type, false, 1);
1647                                } else {
1648                                    $('#register-btn').attr("disabled", "disabled");
1649                                    if ($.trim($("#movie_id").val())) {
1650                                        if ($.trim($("#isDownload").val())) {
1651                                        if(parseInt($("#isppv").val()) || parseInt($("#is_ppv_bundle").val()) || parseInt($("#isadv").val())){
1652                                                getPpvPlans();
1653                                        } else {
1654                                                download_content(login_object);
1655                                                window.location = HTTP_ROOT + '/' + $('#content-permalink').val();
1656                                            }
1657                                            //getVoucherGeneralInfoGuest
1657(login_object);
1658                                            //download_content();
1659                                        } else {
1660                                            if (parseInt($("#isadv").val()) || parseInt($("#isppv").val()) || parseInt($("#is_ppv_bundle").val())) {
1661                                                if ($.trim($("#stream_id").val()) === 0) {
1662                                                    getPpvPlans();
1663                                                } else {
1664                                                    episodegetPpvPlans();
1665                                                }
1666                                                $('#loader_register').hide();
1667                                                $('#register_loading').hide();
1668                                            } else {
1669                                                playMovie();
1670                                                $('#register_loading').hide();
1671                                            }
1672                                        }
1673                                    } else {
1674                                        location.reload();
1675                                    }
1676                                }
1677                            } else if ($.trim(data.register) == 'success') {
1678                                if (data.code != 202) {
1679                                    $('#register_errors').show();
1680                                    $('#register_errors').html(JSLANGUAGE.api_subscribe_failed);
1681                                } else {
1682                                    var url = HTTP_ROOT + "/user/register";
1683                                    window.location.href = url;
1684                                }
1685                            } else if ($.trim(data.register) == 'error') {
1686                                $('#register_errors').show();
1687                                $('#register_errors').html(data.message);
1688                            } else if ($.trim(data.login) == 'error') {
1689                                $('#register_errors').show();
1690                                $('#register_errors').html(JSLANGUAGE.email_exists_us);
1691                            } else if ($.trim(data.login) == 'account_not_activated') {
1692                                $('#register_errors').html(data.msg);
1693                                $('#register_errors').show();
1694                            } else {
1695                                $('#register_errors').show();
1696                                $('#register_errors').html(JSLANGUAGE.saving_error);
1697                            }
1698                        },
1699                        complete: function () {
1700                            $('#loader_register').hide();
1701                            $('#register_loading').hide();
1702                        }
1703            });
1704        }
1705                }
1706    });
1707        }
1708    });
1709
1710    $('#login-loading').hide();
1711    $('.loginbtn').click(function () {
1712        var frm = $(this).closest('form');
1713        frm.validate({
1714            rules: {
1715                "LoginForm[email]": {
1716                    required: true,
1717                    email: true
1718                },
1719                "LoginForm[mobile_number]": {
1720                    required: true,
1721                    number: true,
1722                },
1723                "LoginForm[password]": {
1724                    required: true,
1725                },
1726            },
1727            messages: {
1728                "LoginForm[email]": {
1729                    required: JSLANGUAGE.email_required,
1730                    email: JSLANGUAGE.valid_email
1731                },
1732                "LoginForm[mobile_number]": {
1733                    required: JSLANGUAGE.mobile_number_required,
1734                },
1735                "LoginForm[password]": {
1736                    required: JSLANGUAGE.password_required,
1737                },
1738            },
1739            submitHandler: function (form) {
1740                $.ajax({
1741                    url: HTTP_ROOT + "/user/ajaxlogin",
1742                    data: frm.serialize(),
1743                    type: 'POST',
1744                    dataType: "json",
1745                    beforeSend: function () {
1746                        $('#login-loading').show();
1747                        $('#loader_login').show();
1748                    },
1749                    success: function (data) {
1750                        $('input[name=csrfToken]').val(data.csrfToken);
1751                        $('#login-loading').hide();
1752                        $('#loader').hide();
1753                        $('#login_errors').hide(); 
1754                        
1755                        if(data.login == 'invalid_token'){
1756			
1757                            $('#login_errors').html('');
1758			    $('#login_errors').show();
1759			}else if (data.login == 'success') {
1760                            var redirectUrl = decodeURIComponent(getCookie('redirectToPreviousPage'));
1761                            if ($.trim(data.action) != '') {
1762                                window.location = data.action;
1763                            } else if (redirectUrl) {
1764                                window.location = redirectUrl
1765                            } else {
1766                                location.reload();
1767                            }
1768                        } else {
1769                            frm.find('.loginerror').html(JSLANGUAGE.incorrect_email_or_password).show();
1770                            frm.find('.loginerror').show();
1771                        }
1772                    },
1773                    complete: function () {
1774                        $('#login-loading').hide();
1775
1776                    }
1777                });
1778            }
1779        });
1780    });
1781
1782    $('.registerbtn').click(function () {
1783        var frm = $(this).closest('form');
1784        frm.validate({
1785            rules: {
1786                "data[name]": {
1787                    required: true,
1788                    letterOnly: false,
1789                    minlength: 1
1790                },
1791                "data[email]": {
1792                    required: true,
1793                    email: true
1794                },
1795                "data[password]": {
1796                    required: true,
1797                    minlength: 6
1798                },
1799            },
1800            messages: {
1801                "data[name]": {
1802                    required: JSLANGUAGE.full_name_required,
1803                    minlength: JSLANGUAGE.name_minlength
1804                },
1805                "data[email]": {
1806                    required: JSLANGUAGE.email_required,
1807                    email: JSLANGUAGE.valid_email
1808                },
1809                "data[password]": {
1810                    required: JSLANGUAGE.password_required,
1811                    minlength: JSLANGUAGE.password_minlength
1812                },
1813            },
1814            submitHandler: function (form) {
1815                $('#register-loading').show();
1816                $('#loader_register').show();
1817                var email = $.trim($('.registerbtn').find("input[type='email']").val());
1818                login_fields = [];
1819                $('.registerbtn .login_field').each(function () {
1820                    pushToArray(this.id, this.value);
1821                });
1822                $.post(HTTP_ROOT + "/user/checkemail", {'email': email, 'formdata': login_fields}, function (res) {
1823                    res = JSON.parse(res);
1824                    if (parseInt(res.isExists) === 1) {
1825                        $('#register-loading').hide();
1826                        $('#loader_register').hide();
1827                        if ($.trim(res.field_name) == 'email_address') {
1828                            msg = JSLANGUAGE.email_exists_us;
1829                        } else {
1830                            msg = JSLANGUAGE.value_exists;
1831                        }
1832                        $('<label id="' + res.field_name + '-error" class="error" for="' + res.field_name + '">' + msg + '</label>').insertAfter("#" + $.trim(res.field_name));
1833                        return false;
1834                    } else {
1835                        $.ajax({
1836                            url: HTTP_ROOT + "/user/ajaxregister",
1837                            data: frm.serialize(),
1838                            type: 'POST',
1839                            dataType: "json",
1840                            success: function (data) {
1841                                $('#register-loading').hide();
1842                                $('#loader_register').hide();
1843                                if (data.login == 'success') {
1844                                    if ($.trim($("#movie_id").val())) {
1845                                        if ($.trim($("#isDownload").val())) {
1846                                            window.location = HTTP_ROOT + '/' + $('#content-permalink').val();
1847                                            //getVoucherGeneralInfoGuest
1847(login_object);
1848                                            download_content();
1849                                        } else {
1850                                            if (parseInt($("#isppv").val()) || parseInt($("#is_ppv_bundle").val())) {
1851                                                $('#loader_register').hide();
1852                                                if ($.trim($("#stream_id").val()) === 0) {
1853                                                    getPpvPlans();
1854                                                } else {
1855                                                    episodegetPpvPlans();
1856                                                }
1857                                            } else {
1858                                                $('#loader_register').hide();
1859                                                playMovie();
1860                                            }
1861                                        }
1862                                    } else {
1863                                        location.reload();
1864                                    }
1865                                } else {
1866                                    frm.find('.registererror').html(data.message);
1867                                    frm.find('.registererror').show();
1868                                }
1869                            },
1870                            complete: function () {
1871                                $('#loader_register').hide();
1872                                $('#register-loading').hide();
1873                            }
1874                        });
1875                    }
1876                });
1877            }
1878        });
1879    });
1880    //for register popup 
1881    $('#register_step').validate({
1882        rules: {
1883            "data[name]": {
1884                required: true,
1885                minlength: 1
1886            },
1887            "data[email]": {
1888                required: true,
1889                email: true
1890            },
1891            "data[password]": {
1892                required: true,
1893                minlength: 6
1894            },
1895            "data[confirm_password]": {
1896                required: true,
1897                equalTo: "#join_passwords"
1898            }
1899        },
1900        messages: {
1901            "data[name]": {
1902                required: JSLANGUAGE.full_name_required,
1903                minlength: JSLANGUAGE.name_minlength
1904            },
1905            "data[email]": {
1906                required: JSLANGUAGE.email_required,
1907                email: JSLANGUAGE.valid_email
1908            },
1909            "data[password]": {
1910                required: JSLANGUAGE.password_required,
1911                minlength: JSLANGUAGE.password_minlength
1912            },
1913            "data[confirm_password]": {
1914                required: JSLANGUAGE.valid_confirm_password,
1915                equalTo: JSLANGUAGE.password_donot_match,
1916            },
1917        },
1918        submitHandler: function (form) {
1919            $('#register_loading').show();
1920            $('#loader_register').show();
1921            var email = $.trim($('#register_step').find("input[type='email']").val());
1922            login_fields = [];
1923            $('#register_step .login_field').each(function () {
1924                pushToArray(this.id, this.value);
1925            });
1926            $.post(HTTP_ROOT + "/user/checkemail", {'email': email, 'formdata': login_fields}, function (res) {
1927                res = JSON.parse(res);
1928                if (parseInt(res.isExists) === 1) {
1929                    $('#register_loading').hide();
1930                    $('#loader_register').hide();
1931                    if ($.trim(res.field_name) == 'email_address') {
1932                        msg = JSLANGUAGE.email_exists_us;
1933                    } else {
1934                        msg = JSLANGUAGE.value_exists;
1935                    }
1936                    $('<label id="' + res.field_name + '-error" class="error" for="' + res.field_name + '">' + msg + '</label>').insertAfter("#" + $.trim(res.field_name));
1937                    return false;
1938                } else {
1939                    $.ajax({
1940                        url: HTTP_ROOT + "/user/ajaxregister",
1941                        data: $('#register_step').serialize(),
1942                        type: 'POST',
1943                        dataType: "json",
1944                        success: function (data) {
1945                            $('#register_loading').hide();
1946                            $('#loader_register').hide();
1947                            if ($.trim(data.login) == 'success') {
1948                                if ($.trim(data.action) != '') {
1949                                    window.location = data.action;
1950                                }
1951                            } else if ($.trim(data.login) == 'account_not_activated') {
1952                                $('#register_error').show();
1953                                $('#register_error').html(data.msg);
1954
1955                            } else if ($.trim(data.login) == 'error') {
1956                                $('#register_error').show();
1957                                $('#register_error').html(JSLANGUAGE.email_exists_us);
1958                            } else {
1959                                $('#register_error').show();
1960                                $('#register_error').html(JSLANGUAGE.saving_error);
1961                            }
1962                        },
1963                        complete: function () {
1964                            $('#loader_register').hide();
1965                            $('#register_loading').hide();
1966                        }
1967                    });
1968                }
1969            });
1970        }
1971    });
1972    $(".close").click(function () {
1973        $("#movie_id").val('');
1974        $("#stream_id").val('');
1975        $("#add_to_fav").val('');
1976        $("#content_type").val('');
1977        $("#fav_input").remove();
1978        $(".modal-backdrop").remove();
1979        showLogin();
1980    });
1981    $('body').on('click', '.addtofav', function (e) {
1982        var fav_status = $(this).attr('data-fav_status');
1983        var login_status = $(this).attr('data-login_status');
1984        var content_id = $(this).attr('data-content_id');
1985        var content_type = $(this).attr('data-content_type');
1986        var action = 1;
1987        if (login_status == 1) {
1988            if ($(this).find('.fa').hasClass('fa-heart-o')) {
1989                $(this).find('.fa').removeClass('fa-heart-o');
1990                $(this).find('.fa').addClass('fa-heart');
1991                $(this).find('#favtext').html(JSLANGUAGE.added_to_fav);
1992            } else {
1993                $(this).find('.fa').removeClass('fa-heart');
1994                $(this).find('.fa').addClass('fa-heart-o');
1995                $(this).find('#favtext').html(JSLANGUAGE.add_to_fav);
1996            }
1997            addToFavList(content_id, content_type, true, fav_status);
1998        } else {
1999            $("#loginModal").modal('show');
2000            var input_field = '<div id="fav_input"><input type="hidden" name="add_to_fav" id="add_to_fav" value="1" /><input type="hidden" name="content_type" id="content_type" value="' + content_type + '" /></div>';
2001            $("#loginModal .popup_bottom").append(input_field);
2002            if (content_type == 1) {
2003                $("#stream_id").val(content_id);
2004            } else {
2005                $("#movie_id").val(content_id);
2006            }
2007        }
2008    });
2009    $('body').on('click', '.delete-fab', function (e) {
2010        var url = HTTP_ROOT + "/user/deletefromfavlist/";
2011        var content_id = $(this).attr('data-content_id');
2012        var content_type = $(this).attr('data-content_type');
2013        var action = 0;
2014        if ($.trim(content_type) == "") {
2015            content_type = 0;
2016        }
2017        $.post(url, {'content_id': content_id, 'content_type': content_type, 'login_status': true, 'action': action}, function (res) {
2018            location.reload();
2019        });
2020        $(this).parent().parent().remove();
2021    });
2022    $('body').on('click', '.facebook_login', function (e) {
2023        var w_left = (screen.width / 4);
2024        var w_top = (screen.height / 4);
2025        var url = $(this).attr('data-url');
2026        var is_popup = $(this).attr('data-login');
2027        $.cookie("is_popup", is_popup, {path: '/'});
2028        $.cookie("current_url", '' + window.location, {path: '/'});
2029        window.open('' + url + '', 'targetWindow', 'toolbar=no,titlebar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=900,height=500,top=' 
2029+ w_top + ',left=' + w_left + '');
2030    });
2031
2032    $('#otp_form').validate({
2033        rules: {
2034            "LoginForm[email]": {
2035                required: true,
2036                email: true
2037            },
2038            "LoginForm[password]": {
2039                required: true,
2040            },
2041            "LoginForm[mobile_number]": {
2042                required: true,
2043                number: true
2044            }
2045        },
2046        messages: {
2047            "LoginForm[email]": {
2048                required: JSLANGUAGE.email_required,
2049                email: JSLANGUAGE.valid_email
2050            },
2051            "LoginForm[mobile_number]": {
2052                required: JSLANGUAGE.mobile_number_required,
2053            },
2054            "LoginForm[password]": {
2055                required: JSLANGUAGE.password_required,
2056            }
2057        },
2058        submitHandler: function (form) {
2059            var url = "/user/ajaxlogin";
2060            $.ajax({
2061                url: HTTP_ROOT + url,
2062                data: $('#otp_form').serialize(),
2063                type: 'POST',
2064                dataType: "json",
2065                beforeSend: function () {
2066                    $('#login_loading').show();
2067                    $('#loader_login').show();
2068                },
2069                success: function (data) {
2070                    $('input[name=csrfToken]').val(data.csrfToken);
2071                    $('#login_loading').hide();
2072                    $('#loader_login').hide();
2073                    $('#login_errors').hide();
2074					if(data.login == 'invalid_token'){
2075						$('#login_errors').html('');
2076                        $('#login_errors').show();
2077					}else if (data.login == 'success') {
2078                        if ($.trim($("#add_to_fav").val())) {
2079                            $('#login_loading').show();
2080                            $('#loader_login').show();
2081                            var content_type = $.trim($("#content_type").val());
2082                            if (content_type == 1) {
2083                                var content_id = $.trim($("#stream_id").val());
2084                            } else {
2085                                var content_id = $.trim($("#movie_id").val());
2086                            }
2087                            addToFavList(content_id, content_type, false, 1);
2088                        } else {
2089                            $('#login_errors').html("");
2090                            if ($.trim($("#movie_id").val())) {
2091                                $('#loginModal').hide();
2092                                if ($("#chkPlay").val()) {
2093                                    chkPlayPerimission();
2094                                } else if (parseInt($("#isppv").val()) || parseInt($("#is_ppv_bundle").val()) || parseInt($("#isadv").val())) {
2095                                    if ($.trim($("#stream_id").val()) === 0) {
2096                                        getPpvPlans();
2097                                    } else {
2098                                        episodegetPpvPlans();
2099                                    }
2100                                } else {
2101                                    playMovie();
2102                                }
2103                            } else {
2104                                var redirectUrl = decodeURIComponent(getCookie('redirectToPreviousPage'));
2105                                if ($('#loginModal').length && $('#loginModal').css('display') == 'block') {
2106                                    location.reload();
2107                                } else {
2108                                    if ($.trim(data.action) != '') {
2109                                        window.location = data.action;
2110                                    } else if (redirectUrl) {
2111                                        window.location = redirectUrl
2112                                    } else {
2113                                        window.location = HTTP_ROOT + '/';
2114                                    }
2115                                }
2116                            }
2117                        }
2118                    } else if ($.trim(data.login) == 'error_limit_login') {
2119                        $('#login_errors').html(data.msg);
2120                        $('#login_errors').show();
2121                        $("#logout_all").modal('show');
2122                    } else if ($.trim(data.LoginForm_OTP) == 3) {
2123                        $('#login_success').hide();
2124                        $('#login_errors').html(JSLANGUAGE.otp_expired);
2125                        $('#login_errors').show();
2126                    } else if ($.trim(data.LoginForm_OTP) == 4) {
2127                        $('#login_success').hide();
2128                        $('#login_errors').html(JSLANGUAGE.incorrect_login_credential);
2129                        $('#login_errors').show();
2130                    } else if ($.trim(data.LoginForm_OTP) == 5) {
2131                        $('#login_success').hide();
2132                        $('#login_errors').html(JSLANGUAGE.generate_otp_msg);
2133                        $('#login_errors').show();
2134                    } else if ($.trim(data.LoginForm_OTP) == 6) {
2135                        $('.sub_title').html(JSLANGUAGE.subscribe_login_msg);
2136                        $('#playchkModal').modal('show');
2137                    } else if ($.trim(data.LoginForm_OTP) == 7) {
2138                        $('#login_success').hide();
2139                        $('#login_errors').html(JSLANGUAGE.subscribe_null);
2140                        $('#login_errors').show();
2141                    } else {
2142                        alert(data.LoginForm_OTP);
2143                        $('#login_errors').html(JSLANGUAGE.incorrect_email_or_password);
2144                        $('#login_errors').show();
2145                    }
2146                },
2147                complete: function () {
2148                    $('#loader_login').hide();
2149                    $('#login_loading').hide();
2150                }
2151            });
2152        }
2153    });
2154
2155    $(".sub-popup-close").click(function () {
2156        if (parseInt(reload)) {
2157            location.reload();
2158        }
2159        reload = 0;
2160        $(".modal-backdrop").remove();
2161    });
2162    $('#resend_otp').attr("disabled", true);/*28147*/
2163    if( $('#sms_otp_enabled').val()==1){
2164        $('#email').removeAttr('name');
2165        $('#email').removeAttr('required');
2166    }/*28147*/
2167});
2168function addToFavList(content_id, content_type, login_status, action) {
2169    var url = HTTP_ROOT + "/user/addtofavlist/";
2170    $.post(url, {'content_id': content_id, 'content_type': content_type, 'login_status': login_status, 'action': action}, function (res) {
2171        if ($.trim(res) == "success") {
2172            if (login_status) {
2173                location.reload();
2174                return res;
2175            } else {
2176                window.location.href = window.location.href;
2177            }
2178        }
2179    });
2180}
2181function showLogin() {
2182    $("#register_form_div").hide();
2183    $("#library_login_form_div").hide();
2184    $("#login_form_div").show();
2185}
2186
2187function showRegister() {
2188    if( $('#sms_otp_enabled').val()==1){/*28147*/
2189    $("input#email_address").after(' <input class="form-control" placeholder="Enter your email id" type="email" title="Please fill out this field.">');
2190    $('#email_address').remove();
2191    }/*28147*/
2192    $("#login_form_div").hide();
2193    $("#library_login_form_div").hide();
2194    $("#register_form_div").show();
2195}
2196
2197function showLibrary(id,name,from='') {
2198    $("#lib-name").text(name);
2199    $("#hidden_library_id").val(id);
2200    $("#register_form_div").hide();
2201    $("#login_form_div").hide();
2202    $("#library_login_form_div").show();
2203}
2204function callshowLibrary(id) {
2205    if(id){
2206        showLibrary(id,$( "#selectlibrary option:selected" ).text());
2207    }
2208}
2209function chkPlayPerimission(obj) {
2210    $('#subscribe_success').hide();
2211    if (typeof (obj) == "undefined") {
2212        var movie_id = $('#movie_id').val();
2213        var stream_id = $('#stream_id').val();
2214        var permalink = $('#content-permalink').val();
2215        var content_title = $('#content_title').val();
2216    } else {
2217        var movie_id = $(obj).attr("data-movie_id");
2218        var stream_id = $.trim($(obj).attr("data-stream_id"));
2219        var permalink = $(obj).attr("data-content-permalink");
2220        var purchase_type = $(obj).attr("data-purchase_type");
2221        var content_title = $(obj).attr("data-content_title");
2222        var content_type = $(obj).attr("data-ctype");
2223    }
2224    $('#play_loading').show();
2225    $('#playchk_div').hide();
2226    var url = HTTP_ROOT + "/user/chkPemission/";
2227    $.post(url, {'movie_id': movie_id, 'purchase_type': purchase_type, 'stream_id': stream_id, 'content_title': content_title, 'content_type': content_type}, function (response) {
2228        $('#play_loading').hide();
2229        if ($.trim(response) === 'noaccess') {
2230            $('#playchkModal').modal('show');
2231            $('#playchk_div').show();
2232            return false;
2233        } else {
2234            $("#playchkModal").modal('hide');
2235            if (stream_id !== '') {
2236                permalink = permalink + '/stream/' + stream_id;
2237            }
2238            var url = HTTP_ROOT + "/" + Player_Page + "/" + permalink;
2239            if (supportOptionalContent) {
2240                playVideoNew(permalink, 2);
2241            } else {
2242                window.location.href = url;
2243            }
2244        }
2245    });
2246
2247}
2248
2249function subscribe() {
2250    var mob = $("#username").val();
2251    $('#subscribe_loading').show();
2252    $("#sub_btn").attr("disabled", "disabled");
2253    $("#cancel_btn").attr("disabled", "disabled");
2254    var url = HTTP_ROOT + "/user/subscribe/";
2255    $.post(url, {'mobile_number': mob}, function (response) {
2256        $('#subscribe_loading').hide();
2257        $("#sub_btn").removeAttr("disabled");
2258        $("#cancel_btn").removeAttr("disabled");
2259        reload = 1;
2260        if ($.trim(response.code) == '202') {
2261            $('#subscribe_errors').hide();
2262            $('#subscribe_success').show();
2263            $('#subscribe_success').html(JSLANGUAGE.api_subscribe_msg);
2264        } else {
2265            $('#subscribe_success').hide();
2266            $('#subscribe_errors').show();
2267            $('#subscribe_errors').html(JSLANGUAGE.api_subscribe_failed);
2268        }
2269
2270        setTimeout(function () {
2271            $('#playchkModal').modal('hide');
2272            location.reload();
2273            $(".modal-backdrop").remove();
2274        }, 5000);
2275    }, 'json');
2276}
2277function generateOtp() {
2278    $('[name="LoginForm[otp]"]').rules('remove');
2279    $('#new_otp').val('');
2280    var x = $("#otp_form").valid();
2281    if (x) {
2282        var otp = $('#otp').val();
2283        if (otp) {
2284            var url = '/user/generatOtp';
2285            $.ajax({
2286                url: url,
2287                data: $('#otp_form').serialize(),
2288                type: 'POST',
2289                dataType: "json",
2290                beforeSend: function () {
2291                    $('#login_loading').show();
2292                },
2293                success: function (data) {
2294                    if (data.otp == 'success') {
2295                        $('#login_errors').hide();
2296                        $('#login_success').html(data.msg);
2297                        $('#login_success').show();
2298                        $('#is_generateotp').val(1);
2299                        $('#otp_btn').html(JSLANGUAGE.resend_otp);
2300                    } else if (data.otp == 'failed') {
2301                        $('#login_errors').html(data.msg);
2302                        $('#login_errors').show();
2303                        $('#login_success').hide();
2304                        $('#is_generateotp').val('');
2305                    } else {
2306                        $('#login_errors').html(data.msg);
2307                        $('#login_errors').show();
2308                        $('#login_success').hide();
2309                    }
2310                },
2311                complete: function () {
2312                    $('#login_loading').hide();
2313                }
2314            });
2315        }
2316    }
2317
2318}
2319
2320function validateOTPLogin() {
2321    $('[name="LoginForm[otp]"]').rules('add', {
2322        required: true,
2323        number: true,
2324        messages: {
2325            required: JSLANGUAGE.otp_required
2326        }
2327    });
2328    $("#otp_form").submit();
2329}
2330/**
2331 * @method openid_connect_login is used for openid_connect_login
2332 * @author prakash
2333 * @return {undefined}
2334 */
2335function openid_connect_login(obj) {
2336    var w_width = 0;
2337    var w_height = 0;
2338    if (screen.width >= 1280) {
2339        w_width = (screen.width / 3);
2340    } else if (screen.width >= 768) {
2341        w_width = (screen.width / 2);
2342    } else {
2343        w_width = 400;
2344    }
2345    if (screen.height > 1200) {
2346        w_height = (screen.height / 2);
2347    } else if (screen.height > 700) {
2348        w_height = 500;
2349    } else {
2350        w_height = 400;
2351    }
2352    var w_left = (screen.width - w_width) / 2;
2353    var w_top = (screen.height - w_height) / 2;
2354    var is_popup = $(obj).attr('data-login');
2355    $.cookie("is_popup", is_popup);
2356    $.cookie("current_url", '' + window.location);
2357    var url = HTTP_ROOT + "/openidConnect/OpenidConnectlogin";
2358    window.open(url, 'targetWindow', 'toolbar=no,titlebar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + w_width + ',height=' + w_height + ',top=' + w_top + ',left=' + w_left + '');
2359}
2360/**
2361 * @method openid_connect_signup is used for openid_connect_signup
2362 * @author prakash
2363 * @return {undefined}
2364 */
2365function openid_connect_signup(obj) {
2366    var w_width = 0;
2367    var w_height = 0;
2368    if (screen.width >= 1280) {
2369        w_width = (screen.width / 3);
2370    } else if (screen.width >= 768) {
2371        w_width = (screen.width / 2);
2372    } else {
2373        w_width = screen.width;
2374    }
2375    if (screen.height > 1200) {
2376        w_height = (screen.height / 2);
2377    } else if (screen.height > 700) {
2378        w_height = 500;
2379    } else {
2380        w_height = screen.height;
2381    }
2382    var w_left = (screen.width - w_width) / 2;
2383    var w_top = (screen.height - w_height) / 2;
2384    var is_popup = $(obj).attr('data-login');
2385    $.cookie("is_popup", is_popup);
2386    $.cookie("current_url", '' + window.location);
2387    var url = HTTP_ROOT + "/openidConnect/OpenidConnectSignup";
2388    window.open(url, 'targetWindow', 'toolbar=no,titlebar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + w_width + ',height=' + w_height + ',top=' + w_top + ',left=' + w_left + '');
2389}
2390/**
2391 * @method oauth_signup is used for sso with OAuth 2.0
2392 * @author [email protected]
2393 * @return {undefined}
2394 */
2395function oauth_signup(type) {
2396    var w_width = 0;
2397    var w_height = 0;
2398    if (screen.width >= 1280) {
2399        w_width = (screen.width / 3);
2400    } else if (screen.width >= 768) {
2401        w_width = (screen.width / 2);
2402    } else {
2403        w_width = screen.width;
2404    }
2405    if (screen.height > 1200) {
2406        w_height = (screen.height / 2);
2407    } else if (screen.height > 700) {
2408        w_height = 500;
2409    } else {
2410        w_height = screen.height;
2411    }
2412    var w_left = (screen.width - w_width) / 2;
2413    var w_top = (screen.height - w_height) / 2;
2414    $.cookie("current_url", '' + window.location);
2415    var url = HTTP_ROOT + "/oauthSso/OauthSignup/sso_identity_provider/"+type;
2416    window.open(url, 'targetWindow', 'toolbar=no,titlebar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + w_width + ',height=' + w_height + ',top=' + w_top + ',left=' + w_left + '');
2417}
2418function fun_logout(permalink, logout_url) {
2419    if (logout_url) {
2420        var xhr = new XMLHttpRequest();
2421        xhr.onreadystatechange = function () {
2422            window.location.href = permalink;
2423        };
2424        xhr.open('GET', logout_url, true);
2425        xhr.withCredentials = true;
2426        xhr.send(null);
2427    } else {
2428        window.location.href = permalink;
2429    }
2430}
2431function getCookie(cname) {
2432    var name = cname + "=";
2433    var ca = document.cookie.split(';');
2434    for (var i = 0; i < ca.length; i++) {
2435        var c = ca[i];
2436        while (c.charAt(0) == ' ')
2437            c = c.substring(1);
2438        if (c.indexOf(name) == 0)
2439            return c.substring(name.length, c.length);
2440    }
2441    return "";
2442}
2443
2444//For Single part content audio
2445function playAudioNew(id, targetMedia) {
2446    $('.load-container').show();
2447    var action_url = HTTP_ROOT + "/site/getaudiofile/";
2448    $.ajax({
2449        url: action_url,
2450        data: {"audio_id": id},
2451        method: "post",
2452        async: false,
2453        dataType: "json",
2454        success: function (res) {
2455            AP.destroy();
2456            //res = JSON.parse(res);
2457            res = res;
2458            var resdata = new Array();
2459            resdata = res.data;
2460            var action = 'add';
2461            var index = 0;
2462            var title = resdata[index].title;
2463            muviAudioMusicPlayerObj = [];
2464            updateQueueList(resdata, action, index, '');
2465            $('.art-desc h6').html(title);
2466            $('.load-container').hide();
2467            if (supportOptionalContent == 1) {
2468                $('.vdo-frm .poster-cover img').attr("src", resdata[index].audio_poster);
2469                if (resdata[index].video_url && resdata[index].video_url.length) {
2470                    $('.vdo-frm #vdo-ifraim').prop('src', resdata[index].video_url + '/mediaPlayer/1/targetMedia/'+targetMedia);
2471                    $('.vdo-frm').removeClass("_no-vdo");
2472                } else {
2473                    $('.vdo-frm').addClass("_no-vdo");
2474                }
2475                if (targetMedia == 2) {
2476                    $('#ap').addClass("_vdo-on");
2477                    globalAudio.pause();
2478                    globalAudio.currentTime = 0;
2479                }
2480            }
2481        }
2482    });
2483}
2484//For Multipart audio play
2485function playMultipartAudio(audio_id, index) {
2486	//ER 26822 [Abhinandan] : If condition were added
2487	if ($('#ap:visible').length != 0 && muviAudioMusicPlayerObj[index] != undefined && muviAudioMusicPlayerObj[index].movie_id != undefined && muviAudioMusicPlayerObj[index].movie_id == audio_id) {
2488		window.AP.play(index);
2489	} else {
2490		$('.load-container').show();
2491		var action_url = HTTP_ROOT + "/site/GetAllAudioFile/";
2492		//ER 27707 Start.Only set async value false for Mac and Iphone Safari browser
2493		/*$.post(action_url, {"audio_id": audio_id}, function (res) {
2494			var is_content = 1;
2495			audioPlay(res, index, is_content);
2496		 });*/
2497		$.ajax({
2498			url: action_url,
2499			data: {"audio_id": audio_id},
2500			method: "post",
2501			async: false,
2502			dataType: "json",
2503			success: function (res) {
2504				var is_content = 1;
2505				audioPlay(res, index, is_content,1);//29976
2506			}
2507		});
2508	}
2509    //ER 27707 End
2510}
2511function setSessionForAODContent(content_type, audio_id) {
2512    var action_url = HTTP_ROOT + "/site/setSessionForAODContent/";
2513    $.post(action_url, {"content_type": content_type, "audio_id": audio_id}, function (res) {
2514//        Not required any response as we are only setting session.
2515    });
2516}
2517function loginGuestUser() {
2518    if ($.trim($("#movie_id").val())) {
2519        if (parseInt($("#isadv").val())) {
2520            $('#login_errors').html("You need to register in the system to access a Pre-Order content.");
2521        } else {
2522            $('#loginModal').hide();
2523            window.isGuestUser = 1;
2524            if ($.trim($("#isDownload").val())) {
2525                window.guestDownloadType = $.trim($("#isDownload").val());
2526                getPpvPlans();
2527                //window.location = HTTP_ROOT + '/' + $('#content-permalink').val();
2528                //console.log($('#content-permalink').val());
2529                //getVoucherGeneralInfoGuest(login_object);
2530                //download_content();
2531            } else {
2532                if ($("#chkPlay").length && $("#chkPlay").val()) {
2533                    chkPlayPerimission();
2534                } else if (parseInt($("#isppv").val()) || parseInt($("#is_ppv_bundle").val())) {
2535                    if ($.trim($("#stream_id").val()) === 0) {
2536                        getPpvPlans();
2537                    } else {
2538                        episodegetPpvPlans();
2539                    }
2540                } else if (parseInt($("#isadv").val())) {
2541                    $('#login_errors').html("You need to register in the system to access a Pre-Order content.");
2542                } else {
2543                    playMovie();
2544                }
2545            }
2546        }
2547    } else {
2548        var redirectUrl = decodeURIComponent(getCookie('redirectToPreviousPage'));
2549        if ($('#loginModal').length && $('#loginModal').css('display') == 'block') {
2550            location.reload();
2551        } else {
2552            if ($.trim(data.action) != '') {
2553                window.location = data.action;
2554            } else if (redirectUrl) {
2555                window.location = redirectUrl
2556            } else {
2557                window.location = HTTP_ROOT + '/';
2558            }
2559        }
2560    }
2561}
2562//23619:Generic|Forgot password section: Login popup is displaying after clicking the forgot password link from login popup page[Start]
2563function modelClose() {
2564    $('#loginModal').modal('hide');
2565}
2566//23619:Generic|Forgot password section: Login popup is displaying after clicking the forgot password link from login popup page[End]
2567/*39145 :To include three processes for third party users */
2568function precheckoutLibrary() {
2569    $('#success-modal').modal('hide');
2570    if ($.trim($("#add_to_fav").val())) {
2571        var content_type = $.trim($("#content_type").val());
2572        if (content_type == 1) {
2573            var content_id = $.trim($("#stream_id").val());
2574        } else {
2575            var content_id = $.trim($("#movie_id").val());
2576        }
2577        addToFavList(content_id, content_type, false, 1);
2578    } else {
2579        $('#lib_login_errors').html("");
2580        if ($.trim($("#movie_id").val())) {
2581            libraryUserPricing();
2582        } else {
2583            var redirectUrl = decodeURIComponent(getCookie('redirectToPreviousPage'));
2584            if ($('#loginModal').length && $('#loginModal').css('display') == 'block') {
2585                location.reload();
2586            } else {
2587                window.location = HTTP_ROOT + '/';
2588            }
2589        }
2590    }
2591}
2592
2593function proceedtoLibraryCheckout() {
2594    $('#precheckout-success-modal').modal('hide');
2595    var precheckout_response_price=$(".precheckout_response_price_value").val();/*42536*/
2596    $(".proceedcheckout_price").html(precheckout_response_price);
2597    $('#proceedcheckout-modal').modal('show');
2598}
2599
2600function checkoutLibrary(obj) {
2601     $('#proceedcheckout-modal').modal('hide');
2602    $.ajax({
2603            url: HTTP_ROOT + "/userMonetizationPlans/libraryCheckout",
2604            method: "post",
2605            dataType: "json",
2606            async: true,
2607            success: function (ress) {
2608                $('#loader_login').hide();
2609                if (ress.status == 'success') { 
2610                    $(".checkout_response_price").html(ress.response_price);
2611                    $(".checkout_response_feedback").html(ress.response_feedback);
2612                    if(ress.response_url){/*44062*/
2613                    $(".checkout_response_url").attr("href", ress.response_url);
2614                    } else { 
2615                         $('.checkout_response_url').contents().unwrap();
2616                    }/*44062*/
2617                    $('#checkout-success-modal').modal('show');
2618                } else {
2619                    $(".checkout_response_feedback").html(ress.response_feedback);
2620                    if(ress.response_url){/*44062*/
2621                    $(".checkout_response_url").attr("href", ress.response_url);
2622                    } else { 
2623                         $('.checkout_response_url').contents().unwrap();
2624                    }/*44062*/
2625                    $('#checkout-failure-modal').modal('show');
2626                }                            
2627            }
2628        });
2629}
2630
2631function proceedtoplay() {
2632    var permalink = '';
2633    if (typeof (obj) === "undefined") {
2634        var permalink = $('#content-permalink').val();
2635        if ($('#stream_id').length && $('#stream_id').val()) {
2636            permalink += '/stream/' + $('#stream_id').val();
2637        }
2638    } 
2639    if(typeof (permalink) === "undefined"){
2640        permalink=$('#hidden_librarypermalink').val();
2641    }
2642    window.location.href = HTTP_ROOT + "/" + Player_Page + "/" + permalink;
2643}
2644/*39145 :To include three processes for third party users */
2645
2646/*
2647 * @purpose: To get custom field acooring to user group
2648 * @ER: #48268:Admin will be able to create end user types and manage their access rights
2649 * @auther: sanjib <[email protected]>
2650 * @return: html 
2651 */
2652function getCustomFields(chkCustomField){ 
2653    var user_group = $('#user_group').val();
2654    var chkCustomProfile = $('#chkCustomProfile').val();
2655    $.post(HTTP_ROOT + "/user/getCustomFiled", {'user_group': user_group,'chkCustomProfile':chkCustomProfile,'register_popup':1}, function (res) {
2656        $("#custom_field_for_registration_popup").html(res);
2657         removeEmailAdressforMobile();//48366
2658    }); 
2659}
2660
2661//48366
2662function registerAllowEmail() {
2663    var mobile_number = $("#mobile_number").val();
2664    var email_address = $("#email").val();
2665    var mobile_country_code = $("#mobile_country_code").val();
2666    if(!isNaN(mobile_number) && mobile_number.length > 0){
2667    if(!isNaN(mobile_number) && mobile_number.length > 6 && mobile_number.length < 16){
2668        $("#mobile_number-error").remove();
2669        $('#send_otp').attr("disabled", false);
2670        if (mobile_country_code == "") { 
2671            $('<label id="mobile_number-error" class="error" for="mobile_number">' + JSLANGUAGE.country_code_required + '</label>').insertAfter("#mobile_number");
2672            return false;
2673        } else { $(".email").val(mobile_number + '[email protected]'); }
2674        } else {
2675             $("#mobile_number-error").remove();
2676            $('<label id="mobile_number-error" class="error" for="mobile_number">' + JSLANGUAGE.valid_phone_number + '</label>').insertAfter("#mobile_number");
2677            return false; 
2678    }
2679    }
2680    if($("#email").val()!="" && typeof $("#email").val() != "undefined"){ $(".email").val($("#email").val());
2681    } else{ $(".email").val(mobile_number+'[email protected]'); }
2682}
2683function ValidatePopOtp() {
2684    var mobile_number=$("#mobile_number").val();
2685    var email_address=$("#email").val();
2686    var otp=$("#otp").val();
2687    var bool = false; 
2688    $.ajax({
2689        url: HTTP_ROOT + '/api/ValidateOtp',
2690        type: "POST",
2691        async: false,
2692        data: {otp:otp, phone_no:mobile_number,email:email_address},          
2693        success: function (data) {
2694            if(data.code==200){
2695                bool = true;
2696            } else {
2697            $('#register_loading').hide();
2698            $('#loader_register').hide();
2699            $('#otp-error').hide();
2700            var msg=data.msg;
2701            $('<label id="otp-error" class="error" for="send_otp">'+msg+'</label>').insertAfter("#otp");
2702            return false;
2703            bool = false;
2704            }
2705        }
2706    }); 
2707    return bool;
2708}
2709//48366
2710
2711/*
2712 * @purpose: resend activation email to registered enduser
2713 * @ER: 64476 : resend activation email button on login screens start
2714 * @auther: [email protected]
2715 */
2716function resendActivationLink() {
2717    var email = $('#username').val();
2718    $.ajax({
2719        url: HTTP_ROOT + '/user/resendActivationLink',
2720        data: {email: email},
2721        success: function () {
2722            setTimeout(() => {
2723                window.location.reload();
2724            }, 1000);
2725        }
2726    });
2727}

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.