﻿/// <reference path="jquery-1.2.3.min.js" />
function GetSuggestionShows(_Url, _Id) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetShows",
        data: "{'_UserId':'" + _Id + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#dataSug').html(msg.d);
        },
        error: function (msg) {
            $('#dataSug').html(msg.d);
        }
    });
}


function GetUpdates(_Url, _Page) {

    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetUpdates",
        data: "{'_Page':'" + _Page + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (_Page == 0)
                $('#divData').html(msg.d);
            else
                $('#divData').append(msg.d);
            _Page += 1;
            $('#more1').removeClass('loadingControl');
            $('#more1').addClass('more');
            //            $(('#' + _Para).replace(/,/g, ', #')).removeClass('loading');
            //            $(('#' + _Para).replace(/,/g, ', #')).addClass('selected');
        },
        error: function (msg) {
            $('#more1').removeClass('loadingControl');
            $('#divData').html(msg.d);
        }
    });
}

function Groups(_Url, _Para, _Page) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/Groups",
        data: "{'_Para':'" + _Para + "','_Page':'" + _Page + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (_Page == 0)
                $('#divData').html(msg.d);
            else
                $('#divData').append(msg.d);
            $(('#' + _Para).replace(/,/g, ', #')).removeClass('loading');
            $(('#' + _Para).replace(/,/g, ', #')).addClass('selected');
        },
        error: function (msg) {
            $('#divData').html(msg.d);
        }
    });
}

function ReviewLike(_Url, _AutoId, _Para) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/ReviewLike",
        data: "{'_Para':'" + _Para + "','_AutoId':'" + _AutoId + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        },
        error: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        }
    });
}

function GetSuggestion(_Url, _Para, _Page) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetSuggestion",
        data: "{'_Para':'" + _Para + "','_Page':'" + _Page + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (_Page == 0)
                $('#divData').html(msg.d);
            else
                $('#divData').append(msg.d);
            $(('#' + _Para).replace(/,/g, ', #')).removeClass('loading');
            $(('#' + _Para).replace(/,/g, ', #')).addClass('selected');
        },
        error: function (msg) {
            $('#divData').html(msg.d);
        }
    });
}

function GetPraise(_Url, _PraId, _MovId) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetPraise",
        data: "{'_PraId':'" + _PraId + "','_MovId':'" + _MovId + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (_PraId == 0)
                $('#divPraise').html(msg.d);
            else {
                $('#divPraise').html(msg.d);
            }
        },
        error: function (msg) {
            $('#divData').html(msg.d);
        }
    });
}

function InsertReview(_Url, _Id, _Type, _Summary, _ScheduleId, _Rate, _Review) {
    MessageBox("Processing....");
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/InsertReview",
        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "','_Summary':'" + _Summary.replace(/'/g, "&#39;").replace(/"/g, "&#34;") + "','_ScheduleId':'" + _ScheduleId + "','_Rate':'" + _Rate + "','_Review':'" + _Review.replace(/'/g, "&#39;").replace(/"/g, "&#34;") + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
            window.location.href = $('#ancShow').attr('href');
        },
        error: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        }
    });
}

//function getReviews(_Url, _Par, _ShowId){

//    $.ajax({
//        type: "POST",
//        url: _Url + "iDubba.asmx/getReviews",
//        data: "{'_Par':'" + _Par + "','_ShowId':'"+_ShowId+"'}",
//        dataType: "json",
//        contentType: "application/json; charset=utf-8",
//        success: function (msg) {
//            MessageBox(msg.d);
//            Timeout(1000);
//        },
//        error: function (msg) {
//            MessageBox(msg.d);
//            Timeout(1000);
//        }
//    });
//}

function getSearchResult(_url, _search, _type, _page) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getSearchResult",
        data: "{'_search':'" + _search + "','_url':'" + _url + "','_type':'" + _type + "','_page':'" + _page + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (_type == "0")
                $("#lbl_count").html(msg.d)
            else if (_type == "1" && _page == 0)
                $('#divDat').html(msg.d);
            else if (_type == "1" && _page > 0)
                $('#divDat').append(msg.d);
            Timeout(1000);
        },
        error: function (msg) {
            $('#divDat').html(msg.d);
            Timeout(1000);
        }
    });
}

function GetComments(_Url, _Id, _Type, _CommentType, _page) {
    $('#more1').addClass('loadingControl');
    $('#more1').removeClass('more');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetComments",
        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "','_CommentType':'" + _CommentType + "','_page':'" + _page + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (_page == 0)
                $('#divData').html(msg.d);
            else
                $('#divData').append(msg.d);
            _page += 1;
            $('#more1').removeClass('loadingControl');
            $('#more1').addClass('more');
        },
        error: function (msg) {
            $('#more1').removeClass('loadingControl');
            $('#divData').html(msg.d);
        }
    });
}

function GetMyDubba(_Url, _para) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetMyDubba",
        data: "{'_para':'" + _para + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#divData').html(msg.d);
        },
        error: function (msg) {
            $('#divData').html(msg.d);
        }
    });
}
function getDivUpdate(_Url, _para) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/getDivUpdate",
        data: "{'_para':'" + _para + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#DivUpdate').html(msg.d);
        },
        error: function (msg) {
            $('#DivUpdate').html(msg.d);
        }
    });
}
function AddMyDubba(_Url, _UserId, _Id, _Type) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/AddDubba",
        data: "{'_UserId':'" + _UserId + "','_Id':'" + _Id + "','_Type':'" + _Type + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        },
        error: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        }
    });
}

function SetShowReminder(_Url, _UserId, _Id, _Type, _ScheduleId) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/SetShowReminder",
        data: "{'_UserId':'" + _UserId + "','_Id':'" + _Id + "','_Type':'" + _Type + "','_ScheduleId':'" + _ScheduleId + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        },
        error: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        }
    });
}

function SetFlag(_Url, _Type, _ScheduleId) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/SetFlag",
        data: "{'_Type':'" + _Type + "','_ScheduleId':'" + _ScheduleId + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
            $("#lbl_flag").css("display", "block");
        },
        error: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        }
    });
}

function InsertRate(_Url, _Id, _Type, _Score) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/InsertRate",
        data: "{'_Type':'" + _Type + "','_Id':'" + _Id + "','_Score':'" + _Score + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        },
        error: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        }
    });
}

function SetTuneIn(_Url, _UserId, _Id, _Type, _ScheduleId) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/SetTuneIn",
        data: "{'_UserId':'" + _UserId + "','_Id':'" + _Id + "','_Type':'" + _Type + "','_ScheduleId':'" + _ScheduleId + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        },
        error: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        }
    });
}

function AddVotes(_PraId, _UserId, _MovId) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/AddVotes",
        data: "{'_PraId':'" + _PraId + "','_UserId':'" + _UserId + "','_MovId':'" + _MovId + "','}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        },
        error: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        }
    });
}

function InsertUserNotification(_Url, _UserId, _ScheduleId, _Type) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/InsertUserNotification",
        data: "{'_UserId':'" + _UserId + "','_Type':'" + _Type + "','_ScheduleId':'" + _ScheduleId + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {

            MessageBox(msg.d);
            $('#' + _ScheduleId).hide();
            Timeout(500);
        },
        error: function (msg) {
            MessageBox(msg.d);
            Timeout(500);
        }
    });
}

function InsertReact(_Url, _ScheduleId, _ShowId, _Value) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/InsertReact",
        data: "{'_ScheduleId':'" + _ScheduleId + "','_ShowId':'" + _ShowId + "','_Value':'" + _Value + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            Timeout(1000);
            $('#' + _ShowId).html('added');
            getBadges(_Url, '14', '1');
            __doPostBack('callPostBack', "");
        },
        error: function (msg) {
            Timeout(50);
        }
    });
}

function InsertComment(_Url, _UserId, _Id, _ScheduleId, _FB, _TW) {
    if ($("#comment").val() == 'your comment..' || $("#comment").val() == '') {
        MessageBox("Please enter comment.");
        Timeout(2000);
        return;
    }

    var _f = $('#' + _FB).is(':checked');
    var _t = $('#' + _TW).is(':checked');

    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/InsertComment",
        data: "{'_Comment':'" + $("#comment").val().replace(/'/g, "&#39;") + "','_UserId':'" + _UserId + "','_Type':'1','_Id':'" + _Id + "','_ScheduleId':'" + _ScheduleId + "', '_f':'" + _f + "', '_t':'" + _t + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            Timeout(500);
            $('#' + _Id).html('added');
            $('.modalBackground').hide();
            $('.window').hide();
            getBadges(_Url, '12', '1');
        },
        error: function (msg) {
            Timeout(500);
        }
    });
}

function InsertUserReminder(_Url, _Id, _Type) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/InsertUserReminder",
        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        },
        error: function (msg) {
            MessageBox(msg.d);
            Timeout(1000);
        }
    });
}

function GetSchedule(_Url, _Id, _Type) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetSchedule",
        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#divSchedule').html(msg.d);
        },
        error: function (msg) {
            $('#divSchedule').html(msg.d);
        }
    });
}

function SetTime(_Url, _Time, _ShowId, _UserId, _par) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/SetTime",
        data: "{'_Time':'" + _Time + "','_ShowId':'" + _ShowId + "','_UserId':'" + _UserId + "','_par':'" + _par + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            Timeout(1000);
            $('#' + _ShowId).html('added');
            getBadges(_Url, '15', '1');
            __doPostBack('callPostBack', "");
        },
        error: function (msg) {
            Timeout(50);
        }
    });
}

function GetCrazyAlert(_AreaId, _Url) {
    $('#divCrazyAlert').addClass('loading');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetCrazyAlert",
        data: "{'_AreaId':'" + _AreaId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divCrazyAlert').removeClass('loading');
            $('#divCrazyAlert').html(msg.d);
        }
    });
}
function GetiAlerts(_AreaId, _Url, _Active) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/GetAlerts',
        data: "{'_AreaId':'" + _AreaId + "','_Active':'" + _Active + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divIalert').removeClass('loading');
            $('#divAlerts').html(msg.d);
            Timeout(50);
        },
        error: function (msg) {
            Timeout(50);
        }
    });
}

//function AddToMyDubba(_Id, _Type, _ActId, _Url, _lst) {
//    MessageBox('Processing....');
//    $.ajax({
//        type: "POST",
//        url: _Url + "iDubba.asmx/AddToMydubba",
//        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "','_ActId':'" + _ActId + "'}",
//        contentType: "application/json; charset=utf-8",
//        dataType: "json",
//        success: function (msg) {
//            if (msg.d == "2")
//                MessageBox("Please login to add to mydubba.");
//            else {
//                MessageBox(msg.d);
//                $('#' + _lst).css('display', 'none');
//            }
//            Timeout(2500);
//        }
//    });
//}

function RemoveMyDubba(_Id, _Type, _ActId, _Url, _lst) {
    var a = confirm('Removing a show from "My Dubba" doesn\'t stop the show appearing elsewhere. However it affects your future recommendations!');
    if (a == false) return;
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/RemoveMyDubba",
        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "','_ActId':'" + _ActId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#' + _lst).css('display', 'none');
            Timeout(2500);
        }
    });
}

function DoNotRecommend(_Id, _Type, _Url, _li) {
    var a = confirm('This show will never be Suggested again! Although you can find/search for it elsewhere on site.');
    if (a == false) return;
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/DoNotRecommend",
        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#' + _li).css('display', 'none');
        }
    });
}

function SetReminder(_Id, _Type, _ActId, _Url, _SchId, _IsSMSSet, _Timer) {
    if (_IsSMSSet == false) {
        var a = confirm('Set SMS reminder for ' + (_Type == 1 ? "Show" : "Movie") + '?');
        if (a == false) return;
    }

    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/SetReminder",
        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "','_ActId':'" + _ActId + "','_SchId':'" + _SchId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {

            if (msg.d == "1")
                MessageBox("Reminder is already set.");
            else if (msg.d == "2")
                MessageBox("Please login to set reminder.");
            else if (msg.d == "3")
                MessageBox("Update your mobile number.");
            else {
                MessageBox(msg.d);
                $("#" + _Timer).attr("src", _Url + "images/alarm-clock-2.png");
            }
            Timeout(2500);
        }
    });
}

function TuneIn(_Id, _Type, _ActId, _Url, _SchId, _elm) {
    if ($('#' + _elm).is(':checked') == true) {
        var a = confirm('Do you want to tune in to the ' + (_Type == 1 ? "show" : "movie") + '?');
        if (a == false) {
            $('#' + _elm).attr('checked', false);
            return;
        }
    }
    else if ($('#' + _elm).is(':checked') == false) {
        var a = confirm('Do you want to remove tuned ' + (_Type == 1 ? "show" : "movie") + '?');
        if (a == false) {
            $('#' + _elm).attr('checked', true);
            return;
        }
    }

    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/TuneIn",
        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "','_ActId':'" + _ActId + "','_SchId':'" + _SchId + "','_OnOff':'" + $('#' + _elm).is(':checked') + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            if (msg.d == "2") {
                MessageBox("Please login to TuneIn.");
                $('#' + _elm).attr('checked', false);
            }
            else {
                MessageBox(msg.d);
            }
            Timeout(2500);
        },
        error: function (msg) {
            Timeout(1000);
        }
    });
}
function TuneIn2(_Id, _Type, _ActId, _Url, _SchId, _elm) {
    if ($('#' + _elm).is(':checked') == false) {
        var a = confirm('Do you want to tune in to the ' + (_Type == 1 ? "show" : "movie") + '?');
        if (a == false) {
            $('#' + _elm).attr('checked', true);
            return;
        }
    }
    else if ($('#' + _elm).is(':checked') == true) {
        var a = confirm('Do you want to remove tuned ' + (_Type == 1 ? "show" : "movie") + '?');
        if (a == false) {
            $('#' + _elm).attr('checked', false);
            return;
        }
    }

    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/TuneIn",
        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "','_ActId':'" + _ActId + "','_SchId':'" + _SchId + "','_OnOff':'" + ($('#' + _elm).is(':checked') == false ? true : false) + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            if (msg.d == "2")
                MessageBox("Please login to set reminder.");
            else {
                MessageBox(msg.d);
            }
            Timeout(2500);
        },
        error: function (msg) {
            Timeout(1000);
        }
    });
}

function UserActivity(_ShowId, _Type) {
    $.ajax({
        type: "POST",
        url: "iDubba.asmx/PostToIdubba",
        data: "{'ShowId':'" + _ShowId + "','Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divShow').html(msg.d);
        }
    });
}

function MyDubba(_Sch, _GenreId, _SortId, _Count, _Active, _Url, _Type) //_Type for 1:Show, 
{
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetMyDubbaDetail",
        data: "{'_Sch':'" + _Sch + "','_GenreId':'" + _GenreId + "','_SortId':'" + _SortId + "','_Count':'" + _Count + "','_Active':'" + _Active + "','_Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divData').html(msg.d);
            Timeout(500);
        },
        error: function (msg) {
            Timeout(500);
        }
    });
}

function MyExplore(_Sch, _GenreId, _SortId, _Count, _Active, _Type, _Url, _Key, _ChannelId) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetExplore",
        data: "{'_Sch':'" + _Sch + "','_GenreId':'" + _GenreId + "','_SortId':'" + _SortId + "','_Count':'" + _Count + "','_Active':'" + _Active + "','_Type':'" + _Type + "','_Key':'" + _Key.replace(/'/g, "&#39;") + "','_ChannelId':'" + _ChannelId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divExploreData').html(msg.d);
            Timeout(500);
        }
    });
}

function GetTuneIn(_SortId, _Active, _Type, _Url, _ChannelId) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetTuneIn",
        data: "{'_SortId':'" + _SortId + "','_Active':'" + _Active + "','_Type':'" + _Type + "','_ChannelId':'" + _ChannelId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divData').html(msg.d);
            Timeout(2000);
        }
    });
}

function GetTuneIn2(_SortId, _Active, _Type, _Url, _ChannelId) {
    $('#TabHeader').addClass('loading');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetTuneIn2",
        data: "{'_SortId':'" + _SortId + "','_Active':'" + _Active + "','_Type':'" + _Type + "','_ChannelId':'" + _ChannelId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divData').html(msg.d);
            $('#TabHeader').removeClass('loading');
        }
    });
}

function Listings(_Count, _Active, _Url, _Type) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetListings",
        data: "{'_Count':'" + _Count + "','_Active':'" + _Active + "','_Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divNavigation').html(msg.d);
            Timeout(1000);
        },
        error: function (msg) {
            Timeout(1000);
        }
    });
}

function MessageBox(_Msg) {
    $('#message_box').css({ display: 'block', "z-index": 999 });
    $("#message_box").html(_Msg);
    $('#message_box').animate({ top: "0px", opacity: 1 }, { queue: false, duration: 1000 });
}

function Timeout(_Timeout) {
    setTimeout(function () { $('#message_box').animate({ top: "0px", opacity: 0 }, "slow"); $('#message_box').css({ "z-index": -999 }); }, _Timeout);
}
function popTimeout(_Timeout) {
    setTimeout(function () {
        $('#message_box').animate({ top: "0px", opacity: 0 }, "slow");
        $('#message_box').css({ "z-index": -1 });
        __doPostBack('callPostBack', "");
    }, _Timeout);
}
//function FillDropDown(_Path ,_Url)
//{
//    $.ajax({
//        type: "POST",
//        url: _Url+"iDubba.asmx/FillDropDown",
//        data: "{_Type: " + _Path+ "}",
//        contentType: "application/json; charset=utf-8",
//        dataType: "json",
//        async: true,
//        success: function Success(data) {
//        printGenre(data.d);
//        }
//    });
//}
//function printGenre(data) {
//    $("select[name$=CboCategory1] > option").remove();
//    for (var i = 0; i < data.length; i++) {
//    $("select[name$=CboCategory1]").append(

//    $("<option></option>").val(data[i].GenreId).html(data[i].Gen)
//    );}
//}

function FillDropDown(_Type, _Url) {
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/FillDropDown",
        data: "{_Type: " + _Type + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divGenre').html(msg.d); //
            $('#ctl00_cboSelect').msDropDown();
        }
    });
}

function UserWall(_Show, _Channel, _Feel, _Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/UserWall",
        data: "{'_Show':'" + _Show.replace(/'/g, "&#39;") + "','_Channel':'" + _Channel.replace(/'/g, "&#39;") + "','_Feel':'" + _Feel.replace(/'/g, "&#39;") + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            if (msg.d == "2")
                MessageBox("Please login to post facebook status.");
            else {
                MessageBox(msg.d);
            }
            Timeout(2500);
        },
        error: function (msg) {
            Timeout(1000);
        }
    });
}



function Vite(_Show, _Channel, _Feel, _Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/UserWall",
        data: "{'_Show':'" + _Show.replace(/'/g, "&#39;") + "','_Channel':'" + _Channel.replace(/'/g, "&#39;") + "','_Feel':'" + _Feel.replace(/'/g, "&#39;") + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            if (msg.d == "2")
                MessageBox("Please login to post facebook status.");
            else {
                MessageBox(msg.d);
            }
            Timeout(2500);
        },
        error: function (msg) {
            Timeout(1000);
        }
    });
}

function lookup(_Url, inputString) {
    if (inputString.length == 0) {
        $('#suggestions').fadeOut(); // Hide the suggestions box
    } else {
        $('#suggestions').fadeIn();
        $('#suggestions').html("<p id='searchresults' style='padding:0; margin:0;text-align:left;'><span class='category'>Loading...</span></p>");
        $.ajax({
            type: "POST",
            url: _Url + "iDubba.asmx/Search",
            data: "{'queryString':'" + inputString.replace(/'/g, "&#39;") + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                // Show the suggestions box
                $('#suggestions').html(msg.d); // Fill the suggestions box
            },
            error: function (msg) {
                $('#suggestions').fadeOut(); // Hide the suggestions box
            }
        });
    }
}

function PostCommentReviewActivity(_UserId, _Url, _CommId, _Type) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/PostCommentReviewActivity",
        data: "{'_CommId':'" + _CommId + "','_UserId':'" + _UserId + "','_Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            MessageBox(msg.d);
            Timeout(2500);
        },
        error: function (msg) {
            Timeout(1000);
        }
    });
}

function GetCrazyEventPost(_Active, _Type, _Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetCrazyEventPost",
        data: "{'_Active':'" + _Active + "','_Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divEvent').html(msg.d);
            Timeout(2000);
        },
        error: function (msg) {
            Timeout(50);
        }
    });
}

function GetCrazyEventComment(_Active, _PostId, _Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetCrazyEventComment",
        data: "{'_Active':'" + _Active + "','_PostId':'" + _PostId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divComment').html(msg.d);
            Timeout(2000);
        },
        error: function (msg) {
            Timeout(1000);
        }
    });
}
function PostCrazyEventCommentFlag(_UserId, _Url, _AutoId) {
    if (_UserId == '-1') return;

    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/PostCrazyEventCommentFlag",
        data: "{'_AutoId':'" + _AutoId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            if (msg.d == "2")
                MessageBox("Please login to flag.");
            else {
                MessageBox(msg.d);
            }
            setTimeout(function () { $('#message_box').animate({ top: "0px", opacity: 0 }, "slow"); }, 5000);
        },
        error: function (msg) {
            setTimeout(function () { $('#message_box').animate({ top: "0px", opacity: 0 }, "slow"); }, 500);
        }
    });
}
function PostCrazyEventActivity(_UserId, _Url, _PostId, _Type) {
    if (_UserId == '-1') return;

    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/PostCrazyEventActivity",
        data: "{'_PostId':'" + _PostId + "','_Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            if (msg.d == "2")
                MessageBox("Please login.");
            else {
                MessageBox(msg.d);
            }
            setTimeout(function () { $('#message_box').animate({ top: "0px", opacity: 0 }, "slow"); }, 5000);
            if (_Type == "1")
                __doPostBack('callPostBack', "");
        },
        error: function (msg) {
            setTimeout(function () { $('#message_box').animate({ top: "0px", opacity: 0 }, "slow"); }, 500);
        }
    });
}

function GetRumours(_Active, _Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetRumours",
        data: "{'_Active':'" + _Active + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divRumours').html(msg.d);
            Timeout(1000);
        }
    });
}

function GetShowSuggestion(_Active, _Url) {
    $('#divShow').addClass('loading');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetShowSuggestion",
        data: "{'_Active':'" + _Active + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divShowSuggestion').html(msg.d);
            $('#divShow').removeClass('loading');
        }
    });
}
function GetMovieSuggestion(_Active, _Url) {
    $('#divMovie').addClass('loading');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetMovieSuggestion",
        data: "{'_Active':'" + _Active + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divMovieSuggestion').html(msg.d);
            $('#divMovie').removeClass('loading');
        }
    });
}
function GetQuickView(_ShowTime, _Url) {
    $('#datacontent').addClass('loading');
    var _Type = $("#hdType").val();
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/GetQuickView',
        data: "{'_Type':'" + _Type + "','_ShowTime':'" + _ShowTime + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#datacontent').removeClass('loading');
            $('#divQuickView').html(msg.d);
        }
    });
}
function GetMashup(_Url) {
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/GetMashup',
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#Mashup').html(msg.d);
        }
    });
}
function Rating(_Id, _Type, _Val, _Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/Rating',
        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "','_Val':'" + _Val + "','_Url':'" + _Url + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            if (msg.d == "2")
                MessageBox("Please login to rate.");
            else {
                MessageBox(msg.d);
            }
            Timeout(2500);
        },
        error: function (msg) {
            Timeout(1000);
        }
    });
}
function onLogin_Click(_Url) {
    var pass = $('#Password').val();
    var email = $('#Email').val();

    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/Login',
        data: "{'_Email':'" + email + "','_Pass':'" + pass + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            if (msg.d != "")
                $('#errorLogin').html(msg.d);
            else
                __doPostBack('callPostBack', "");
        }
    });
}
function FriendConnect(_SenderId, _ReceiverId, _Type, _Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/FriendConnect',
        data: "{'_SenderId':'" + _SenderId + "', '_ReceiverId':'" + _ReceiverId + "', '_Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            __doPostBack('callPostBack', "");
        }
    });
}
function RemovePost(_PostId, _Type, _Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/RemovePost',
        data: "{'_PostId':'" + _PostId + "', '_Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            window.location.reload();
        }
    });
}
function RemoveCrazyAlert(_PostId, _Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/RemoveCrazyAlert',
        data: "{'_PostId':'" + _PostId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            __doPostBack('callPostBack', "");
        }
    });
}
function PostCrazyEvent(_Url, _EventId, _Celebrity, _Description, _Channel, _Date, _Time) {
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/PostCrazyEvent',
        data: "{'_EventId':'" + _EventId + "', '_Celebrity':'" + _Celebrity.replace(/'/g, "&#39;").replace(/"/g, '&#34;') + "', '_Description':'" + _Description.replace(/'/g, "&#39;").replace(/"/g, '&#34;') + "', '_Channel':'" + _Channel + "', '_Date':'" + _Date + "', '_Time':'" + _Time + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            __doPostBack('callPostBack', "");

        }
    });
}
function ShareCrazyAlert(_Url, _FB, _TW, _Share) {
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/ShareCrazyAlert',
        data: "{'_FB':'" + _FB + "', '_TW':'" + _TW + "', '_Share':'" + _Share + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            __doPostBack('callPostBack', "");
        }
    });
}
function PostCrazyQuiz(_Url, _QuizId, _OptionId) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/PostCrazyQuiz',
        data: "{'_QuizId':'" + _QuizId + "','_OptionId':'" + _OptionId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            //__doPostBack('callPostBack', "");
            if (msg.d == "Time out to play.") {
                MessageBox(msg.d);
                Timeout(500);
            }
            else {
                fnPopUpQuiz('#popCrazyQuizMsg');
                $('#pQuiz').html(msg.d);
                Timeout(50);
            }
        }
    });
}
function ShareCrazyQuiz(_Url, _FB, _TW, _Share) {
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/ShareCrazyQuiz',
        data: "{'_FB':'" + _FB + "', '_TW':'" + _TW + "', '_Share':'" + _Share + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            __doPostBack('callPostBack', "");
        }
    });
}
function GetQuiz(_Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/GetQuiz',
        data: "{'_Type':'1'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divQuiz').html(msg.d);
            Timeout(50);
        }
    });
}
function GetHistory(_Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/GetHistory',
        data: "{'_Type':'2'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divQuiz').html(msg.d);
            Timeout(50);
        }
    });
}
function GetReactions(_Url, _SearchText, _Type, _Id) {
    $('#divData').html('');
    $('#divData').addClass('loading');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/GetReaction',
        data: "{'_Type':'" + _Type + "','_Id':'" + _Id + "','_SearchText':\"" + _SearchText + "\"}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divData').removeClass('loading');
            $('#divData').html(msg.d);
        },
        error: function (msg) {
            $('#divData').removeClass('loading');
        }
    });
}
function GetActivity(_Url, _Id, _Type) {
    $('#divData').html('');
    $('#divData').addClass('loading');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/GetActivity',
        data: "{'_Id':'" + _Id + "','_Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divData').removeClass('loading');
            $('#divData').html(msg.d);
        },
        error: function (msg) {
            $('#divData').removeClass('loading');
        }
    });
}
function GetDetail(_Url, _Id, _Type) {
    $('#divData').html('');
    $('#divData').addClass('loading');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/GetDetail',
        data: "{'_Type':'" + _Type + "','_Id':'" + _Id + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divData').removeClass('loading');
            $('#divData').html(msg.d);
        },
        error: function (msg) {
            $('#divData').removeClass('loading');
        }
    });
}
function CrazyTeamQuiz(_Url, _TeamId) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/CrazyTeamQuiz',
        data: "{'_TeamId':'" + _TeamId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            fnPopUpQuiz('#popTeam')
            Timeout(50);
        }
    });
}
function FacebookShare(_Url, _Share) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/FacebookShare',
        data: "{'_Share':'" + _Share.replace(/'/g, "&#39;").replace(/"/g, '&#34;') + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            Timeout(50);
        },
        error: function (msg) {
            Timeout(50);
        }
    });
}

function FacebookShare(_Url, _Share) {
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/FacebookShare',
        data: "{'_Share':'" + _Share.replace(/'/g, "&#39;").replace(/"/g, '&#34;') + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            Timeout(50);
        },
        error: function (msg) {
            Timeout(50);
        }
    });
}

function TwitterShare(_Url, _Share) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/TwitterShare',
        data: "{'_Share':'" + _Share.replace(/'/g, "&#39;").replace(/"/g, '&#34;') + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            Timeout(50);
        },
        error: function (msg) {
            Timeout(50);
        }
    });
}
function Feedback(_Url, _Issue, _Email, _Feedback, _Type) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + 'iDubba.asmx/Feedback',
        data: "{'_Issue':'" + _Issue + "','_Email':'" + _Email + "','_Feedback':'" + _Feedback.replace(/'/g, "&#39;").replace(/"/g, '&#34;') + "','_Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            Timeout(50);
            $('#maskfeedback').hide();
            $('.window').hide();
            $.cookie("anewsletter", "1", { expires: 7 });
        },
        error: function (msg) {
            Timeout(50);
            $('#maskfeedback').hide();
            $('.window').hide();
            $.cookie("anewsletter", "1", { expires: 7 });
        }
    });
}

function GetRecom(_UserId, _ShowId, _Type, _Url) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _Url + "iDubba.asmx/GetRecom",
        data: "{'_UserId':'" + _UserId + "','_ShowId':'" + _ShowId + "','_Type':'" + _Type + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            __doPostBack('callPostBack', "");
        }
    });
}

// getPageScroll() by quirksmode.com
function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
        xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
        xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
        xScroll = document.body.scrollLeft;
    }
    return new Array(xScroll, yScroll)
}

// Adapted from getPageSize() by quirksmode.com
function getPageHeight() {
    var windowHeight
    if (self.innerHeight) {	// all except Explorer
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowHeight = document.body.clientHeight;
    }
    return windowHeight
}

function getBadges(_url, _actId, _type) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getBadges",
        data: "{'_actId':'" + _actId + "','_type':'" + _type + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (msg.d != "") {
                $('#bdgContain').html(msg.d);
                getModal('#popBadge', '');
            }
        },
        error: function (msg) {

        }
    });
}
function insertMyDubba(_url, _para, _elem, _actId, _mobile) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/insertMyDubba",
        data: "{'_para':'" + _para + "','_mobile':'" + _mobile + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            //$('#dataSug').html(msg.d);
            Timeout(500);
            getBadges(_url, _actId, '1');
            $(_elem).html(msg.d);
            getDivUpdate(_url, 1);
        },
        error: function (msg) {
            //$('#dataSug').html(msg.d);
            Timeout(50);
        }
    });
}
function insertSocialReminder(_url, _para, _elem, _actId, _email, _facebook, _twitter) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/insertSocialReminder",
        data: "{'_para':'" + _para + "','_email':'" + _email + "','_facebook':'" + _facebook + "','_twitter':'" + _twitter + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            MessageBox('Reminder set successfully.');
            Timeout(2000);
        },
        error: function (msg) {
            Timeout(500);
        }
    });
}

function followFriends(_url, _followingId, _elem) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/followFriends",
        data: "{'_followingId':'" + _followingId + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            MessageBox('Following');
            Timeout(500);
            $(_elem).html('');
            if (msg.d != "") {
                $('#bdgContain').html(msg.d);
                getModal('#popBadge', '');
            }
        },
        error: function (msg) {
            Timeout(50);
        }
    });
}
/////// START CRR /////////
var _page = 1;
function getCRR(_url, _type, _ctype, _id, _twitterKey) {
    $('#more1').addClass('loading');
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getCRR",
        data: "{'_ctype':'" + _ctype + "','_type':'" + _type + "','_id':'" + _id + "','_page':'" + _page + "','_twitterKey':\"" + _twitterKey + "\"}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            Timeout(50);
            $('#more1').removeClass('loading');
            $('#divData').html(msg.d);
            _page += 1;
        },
        error: function () { Timeout(50); $('#more').removeClass('loading'); }
    });
}

function insertCRR(_url, _ctype, _type, _id, _fb, _tw, _twitterKey, _ctrl, _scheduleId) {
    if ($("#reaction").val() == '') {
        MessageBox("Please enter reaction.");
        Timeout(5000);
        return;
    }
    var f = $('#' + _fb).is(':checked');
    var t = $('#' + _tw).is(':checked');

    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/insertCRR",
        data: "{'_text':'" + $("#reaction").val().replace(/'/g, "&#39;").replace(/"/g, "&#34;") + "','_ctype':'" + _ctype + "','_type':'" + _type + "','_id':'" + _id + "','_fb':'" + f + "','_tw':'" + t + "','_scheduleId':'" + _scheduleId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            Timeout(500);
            getCRR(_url, _type, _ctype, _id, _twitterKey);
            $("#reaction").val('');
            if (msg.d != "") {
                $('#bdgContain').html(msg.d);
                getModal('#popBadge', _ctrl);
            }
        },
        error: function (msg) {
            Timeout(500);
        }
    });
}
function removeCRR(_url, _id, _type, _elem) {
    MessageBox('Processing....');
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/removeCRR",
        data: "{'_type':'" + _type + "','_id':'" + _id + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            Timeout(500);
            $("#" + _elem).css('display', 'none');
        },
        error: function (msg) {
            Timeout(500);
        }
    });
}
/////////// END CRR //////////


///////// COTROLS ///////////
function getChannels(_url, _para) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getChannels",
        data: "{'_para':'" + _para + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#divChannels ul').html(msg.d);
            $(('#' + _para).replace(/,/g, ', #')).addClass('selected');
            $(('#' + _para).replace(/,/g, ', #')).removeClass('loading');
        },
        error: function (msg) {
            $('#divChannels ul').html(msg.d);
        }
    });
}
function getTags(_url, _para) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getTags",
        data: "{'_para':'" + _para + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#divTags').html(msg.d);
            $(('#' + _para).replace(/,/g, ', #')).addClass('selected');
            $(('#' + _para).replace(/,/g, ', #')).removeClass('loading');
        },
        error: function (msg) {
            $('#divTags ul').html(msg.d);
        }
    });
}
function getGenres(_url, _para) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getGenres",
        data: "{'_para':'" + _para + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#divGenres ul').html(msg.d);
            $(('#' + _para).replace(/,/g, ', #')).removeClass('loading');
            $(('#' + _para).replace(/,/g, ', #')).addClass('selected');
        },
        error: function (msg) {
            $('#divGenres ul').html(msg.d);
        }
    });
}
function getOneDayShow(_url, _type) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getOneDayShow",
        data: "{'_type':'" + _type + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#popOneDayShow').html(msg.d);
        },
        error: function (msg) {
            $('#popOneDayShow').html(msg.d);
        }
    });
}
function getShowVs(_url, _type, _show) {
    // Save Liked Show   
    insertShowLiked(_url, _show);

    if ($('#ctl00_hdShow').val() != '' && $('#ctl00_hdShow').val() != undefined)
        _show = _show == "" ? $('#ctl00_hdShow').val() : $('#ctl00_hdShow').val() + "," + _show;

    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getShowVs",
        data: "{'_type':'" + _type + "','_show':'" + _show + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#divVs').html(msg.d);
        },
        error: function (msg) {
            $('#divVs').html(msg.d);
        }
    });
}
function updateOneDayShow(_url, _type, _val, _fb, _tw, _text, _path) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/updateOneDayShow",
        data: "{'_type':'" + _type + "','_val':'" + _val + "','_fb':'" + _fb + "','_tw':'" + _tw + "','_text':'" + _text + "','_path':'" + _path + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#spanError').val('submitted successfully');
        }
    });
}
/////////// END CONTROLS///////////


/////////// Timings ///////////////
function getTiming(_url, _para, _page, _elem) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getTimings",
        data: "{'_para':'" + _para + "','_page':'" + _page + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (_page == 0)
                $('#divData').html(msg.d);
            else
                $('#divData').append(msg.d);
            $(('#' + _para).replace(/,/g, ', #')).removeClass('loading');
            $(('#' + _para).replace(/,/g, ', #')).addClass('selected');

            var _type = $('#mnuBar li.selected').map(function () {
                return this.id;
            }).get().join(',');
            getNotification(_url, 'timing', _type, _elem);
        },
        error: function (msg) {
            $('#divData').html(msg.d);
        }
    });
}
/////////// END Timings ////////////////

/////////// USER ///////////////
function getUserRecommendation(_url, _type, _page) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getUserRecommendation",
        data: "{'_type':'" + _type + "','_page':'" + _page + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (_type == "1") {
                if (_page == 0)
                    $('#divShows').html(msg.d);
                else
                    $('#divShows').append(msg.d);
            }
            else if (_type == "2") {
                if (_page == 0)
                    $('#divMovies').html(msg.d);
                else
                    $('#divMovies').append(msg.d);
            }
        },
        error: function (msg) {
            $('#divMovies').html('Unable to show recommendations, Please try <a href="' + _url + '/timings/">timings</a> page.');
        }
    });
}
function insertShowLiked(_url, _showId) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/insertShowLiked",
        data: "{'_showId':'" + _showId + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {

        },
        error: function (msg) {

        }
    });
}
function getGroupFriends(_url, _groId, _userId, _page) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getGroupFriends",
        data: "{'_groId':'" + _groId + "','_userId':'" + _userId + "','_page':'" + _page + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (_page == 0)
                $('#divGroups ul').html(msg.d);
            else
                $('#divGroups ul').append(msg.d);
        },
        error: function (msg) {

        }
    });
}
/////////// END USER ////////////////


function missingProgram(_url, _show, _channel, _type) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/missingProgram",
        data: "{'_show':'" + _show.replace(/'/g, "&#39;") + "','_channel':'" + _channel.replace(/'/g, "&#39;") + "','_type':'" + _type + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('.modalBackground').hide();
            $('#popMissing').hide();
        },
        error: function (msg) {

        }
    });
}
function getNotification(_url, _page, _type, _elem) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getNotification",
        data: "{'_page':'" + _page + "','_type':'" + _type + "','_elem':'" + _elem + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#' + _elem).html(msg.d);
        },
        error: function (msg) {

        }
    });
}
function insertNotification(_url, _page, _type, _elem) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/insertNotification",
        data: "{'_page':'" + _page + "','_type':'" + _type + "','_elem':'" + _elem + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#' + _elem).html(msg.d);
        },
        error: function (msg) {

        }
    });
}
function shoutBadge(_url) {

    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/shoutBadge",
        data: "{'_name':'" + $('#pBadge').text() + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            $('#' + _elem).html(msg.d);
        },
        error: function (msg) {

        }
    });
}

function lookup(_Url, inputString) {
    if (inputString.length == 0) {
        $('#suggestions').fadeOut(); // Hide the suggestions box
    } else {
        $('#suggestions').fadeIn();
        $('#suggestions').html("<p id='searchresults' style='padding:0; margin:0;text-align:left;'><span class='category'>Loading...</span></p>");
        $.ajax({
            type: "POST",
            url: _Url + "iDubba.asmx/Search",
            data: "{'_queryString':'" + inputString.replace("'", "&#39;") + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                // Show the suggestions box
                $('#suggestions').html(msg.d); // Fill the suggestions box
            },
            error: function (msg) {
                $('#suggestions').fadeOut(); // Hide the suggestions box
            }
        });
    }
}

//////////// Browse /////////////
function getBrowse(_url, _para, _page, _elem) {
    $.ajax({
        type: "POST",
        url: _url + "iDubba.asmx/getBrowse",
        data: "{'_para':'" + _para + "','_page':'" + _page + "'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            if (_page == 0)
                $('#divData').html(msg.d);
            else
                $('#divData').append(msg.d);
            $(('#' + _para).replace(/,/g, ', #')).removeClass('loading');
            $(('#' + _para).replace(/,/g, ', #')).addClass('selected');

            var _type = $('#mnuBar li.selected').map(function () {
                return this.id;
            }).get().join(',');
            getNotification(_url, 'timing', _type, _elem);
        },
        error: function (msg) {
            $('#divData').html(msg.d);
        }
    });
}
/////////////// End Browse
