﻿function GetCategoryProduct() {
    $.ajax({
        type: "POST",
        url: "ProductService.svc/LoadProductCategoryLanding",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
            $('#divAjaxLoading').html(msg.d);

        },
        error: function (xhr, status, error) {

        }
    });
}


function LoadProductCategoryTypewise() {
var CategoryName="Bar-Body Wash";
var subProductNeed="Cool Refreshing Scent";
var subProductType="";
    $.ajax({
        type: "POST",
        url: "ProductService.svc/LoadProductCategoryTypewise",
		data: "{\"CategoryName\" : \"" + CategoryName + "\",\"subProductNeed\" : \"" + subProductNeed + "\",\"subProductType\" : \"" + subProductType + "\"}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
            $('#divAjaxLoading').html(msg.d);

        },
        error: function (xhr, status, error) {

        }
    });
}


function LoadCategoryLanding() {

var subCategoryName="Lotions";
    $.ajax({
        type: "POST",
        url: "ProductService.svc/LoadCategoryLanding",
		data: "{\"subCategoryName\" : \"" + subCategoryName +"\"}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
            $('#divAjaxLoading').html(msg.d);

        },
        error: function (xhr, status, error) {

        }
    });
}

function GetArticleAndAdvice() {

var subCategoryName="Lotions";
    $.ajax({
        type: "POST",
        url: "ProductService.svc/GetArticleAndAdvice",
		data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
            $('#divAjaxLoading').html(msg.d);

        },
        error: function (xhr, status, error) {

        }
    });
}

function FilterArticles() {

var subCategoryName="productCategory";
    $.ajax({
        type: "POST",
        url: "ProductService.svc/FilterArticles",
		data: "{\"productCategory\" : \"" + subCategoryName +"\"}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
            $('#divAjaxLoading').html(msg.d);

        },
        error: function (xhr, status, error) {

        }
    });
}

function GetFilteredVideosList() {

var subCategoryName="Bar/Body Wash";
    $.ajax({
        type: "POST",
        url: "ProductService.svc/GetFilteredVideosList",
		data: "{\"category\" : \"" + subCategoryName +"\"}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
            $('#divAjaxLoading').html(msg.d);

        },
        error: function (xhr, status, error) {

        }
    });
}

function GetVideosList() {


    $.ajax({
        type: "POST",
        url: "ProductService.svc/GetVideosList",
		data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
            $('#divAjaxLoading').html(msg.d);

        },
        error: function (xhr, status, error) {

        }
    });
}


function GetDoveScienceList() {

var productCategory="Bar/Body Wash";
    $.ajax({
        type: "POST",
        url: "ProductService.svc/GetDoveScienceList",
			data: "{\"productCategory\" : \"" + productCategory +"\"}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
            $('#divAjaxLoading').html(msg.d);

        },
        error: function (xhr, status, error) {

        }
    });
}


function GetSelfEsteemList() {

var productCategory="For Girls";
    $.ajax({
        type: "POST",
        url: "ProductService.svc/GetSelfEsteemList",
			data: "{\"productCategory\" : \"" + productCategory +"\"}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
            $('#divAjaxLoading').html(msg.d);

        },
        error: function (xhr, status, error) {

        }
    });
}

function GetSelfVideo() {

var productCategory="Videos";
    $.ajax({
        type: "POST",
        url: "ProductService.svc/GetSelfEsteemList",
	   data: "{\"productCategory\" : \"" + productCategory +"\"}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
            $('#divAjaxLoading').html(msg.d);
        },
        error: function (xhr, status, error) {

        }
    });
}


function RenderStoreLocator() {
    var zipCode = $('.storetxt').val();
    var theControl = document.getElementById("retailerList");
    var currentRecords = $('#<%=HiddenFieldCurrentPageCount.ClientID %>').val();
    alert(currentRecords);
    theControl.style.visibility = "hidden";
    theControl.style.display = "none";
    var divIDAjax = document.getElementById("divAjaxLoading1");    
    divIDAjax.style.display = 'block';
    var divIDMapCanvas = document.getElementById("map_canvas");
    divIDMapCanvas.style.display = 'none';
    $.ajax({
        type: "POST",
        url: "/ProductService.svc/LoadStoreDetails",
        data: "{\"ZipCode\" : \"" + zipCode + "\",\"currentRecords\" : \"" + currentRecords + "\"}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            $('#divAjaxLoading1').html(msg.d);
            var divSection = document.getElementById("sectionDiv");
            divSection.style.display = 'block';
        },
        error: function (xhr, status, error) {
        }
    });
}

    function GetAllSearchedDataList() {

        var searchText = "Bar";
        $.ajax({
            type: "POST",
            url: "ProductService.svc/GetAllSearchedDataList",
            data: "{\"searchText\" : \"" + searchText + "\"}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                alert(msg.d);
                $('#divAjaxLoading').html(msg.d);

            },
            error: function (xhr, status, error) {

            }
        });
    }


    function GetSearchedProductsList() {

        var searchText = "Bar";
        var pageNumber = 1;
        $.ajax({
            type: "POST",
            url: "ProductService.svc/GetSearchedProductsList",
            data: "{\"searchText\" : \"" + searchText + "\",\"pageNumber\" : \"" + pageNumber + "\"}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                alert(msg.d);
                $('#divAjaxLoading').html(msg.d);

            },
            error: function (xhr, status, error) {

            }
        });
    }


    function GetSearchedVideosList() {

        var searchText = "Bar";
        var pageNumber = 1;
        $.ajax({
            type: "POST",
            url: "ProductService.svc/GetSearchedVideosList",
            data: "{\"searchText\" : \"" + searchText + "\",\"pageNumber\" : \"" + pageNumber + "\"}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                alert(msg.d);
                $('#divAjaxLoading').html(msg.d);

            },
            error: function (xhr, status, error) {

            }
        });
    }


    function GetSearchedArticleList() {

        var searchText = "Bar";
        var pageNumber = 1;
        $.ajax({
            type: "POST",
            url: "ProductService.svc/GetSearchedArticleList",
            data: "{\"searchText\" : \"" + searchText + "\",\"pageNumber\" : \"" + pageNumber + "\"}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                alert(msg.d);
                $('#divAjaxLoading').html(msg.d);

            },
            error: function (xhr, status, error) {

            }
        });
    }

    function GetGamesnQuizzesList() {

        var searchText = "Bar";
        var pageNumber = 1;
        $.ajax({
            type: "POST",
            url: "ProductService.svc/GetGamesnQuizzesList",
            data: "",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                alert(msg.d);
                $('#divAjaxLoading').html(msg.d);

            },
            error: function (xhr, status, error) {

            }
        });
    }

    function LoadPrintCoupon() {
        var selectedCoupon = '';
        var returnValue = false;
        //10401000256- Atwork Ticket
        var arrInput = document.getElementsByTagName("input");
        for (i = 0; i < arrInput.length; i++) {
            if (arrInput[i].type == 'checkbox') {
                if (arrInput[i].checked) {
                    selectedCoupon = selectedCoupon + arrInput[i].id + "~";
                   // window.open("/Redirect.aspx?couponid=" + arrInput[i].id);
                }

            }
        }
        //10401000256- Atwork Ticket
        if (selectedCoupon.length > 0) {
            //window.location.href = $('.CouponPage').val();
            //Atwork ticket start-> 10402000008
            document.getElementById('PrintError').style.display = "none";
            //Atwork ticket end-> 10402000008
            window.location.href = "/Redirect.aspx?couponid=" + selectedCoupon;
            returnValue = true;
        }
        else {
            //Atwork ticket start-> 10402000008
            document.getElementById('PrintError').style.display = "block";
            //Atowork ticket end-> 10402000008
            returnValue = false;
        }
        return returnValue;
    }
    $(document).ready(function () {


        $(".register").click(function (e) {
            e.preventDefault();
            var link = $(this),
            couponID = LoadCouponUnRegisterUser();
            if (couponID != "") {
                $.colorbox({ iframe: true, "href": link.attr("href") + "?couponid=" + couponID, height: 400, width: 400 })

            }

        })

        function LoadCouponUnRegisterUser() {
            var selectedCoupon = '';
            var returnValue = false;
            var arrInput = document.getElementsByTagName("input");
            for (i = 0; i < arrInput.length; i++) {
                if (arrInput[i].type == 'checkbox') {
                    if (arrInput[i].checked) {
                        selectedCoupon = selectedCoupon + arrInput[i].id + "~";
                    }

                }
            }
            if (selectedCoupon.length > 0) {
                //Atwork ticket start-> 10402000008
                document.getElementById('PrintError').style.display = "none";
                //Atwork ticket end-> 10402000008
                returnValue = selectedCoupon;
            }
            else {
                //Atwork ticket start-> 10402000008
                document.getElementById('PrintError').style.display = "block";
                //Atwork ticket end->  10402000008
                returnValue = false;
            }
            return returnValue;

        }
    })

    $(document).ready(function () {
        $(".registerSwap").click(function (e) {
            e.preventDefault();
            var link = $(this);
            $.colorbox({ iframe: true, "href": link.attr("href"), scrolling: false, height: 455, width: 380 })
        })
    })

