﻿$(function() {
    // script reworked. html now exists within the master page to improve cross-browser compatability

/*
    
    Embedded AJAX LINK CLICK within AJAX Success to provide for IE shortcomming
*/
    // event cal click
    $("a.elink").click(function(e) { // FF - IE - CHROME - SAFARI
        e.preventDefault();
        $(".boxcontent").html("");
        $('html, body').animate({ scrollTop: 0 }, 'fast'); // scroll page to top
        $(".overlay").show(0);
        $(".overlay").animate({ opacity: 0 }, 0);
        $(".overlay").animate({ opacity: 0.3 }, 500);
        $(".box").show(0);
        $(".box").animate({ opacity: 0 }, 0);
        $(".box").animate({ opacity: 1 }, 500);
        $(".boxcontrol").show(0);
        $(".boxcontrol").animate({ opacity: 0 }, 0);
        $(".boxcontrol").animate({ opacity: 1 }, 500);
        $("body").addClass("ovfhide");
        $.ajax({
            type: "POST", // use method POST
            url: "Search/JQuery/UZKNTelephone.asmx/getEventByID",
            data: "{'key': '" + $(this).attr("id") + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(data) {
                var thtml = data.d;
                $(".boxcontent").html(thtml);
                $(".loading").remove();
                closebtn = $(".boxclose");
            },
            error: function() {

            }
        });
    });
    // overlay click
    $(".overlay").click(function(e) { // FF - IE - CHROME - SAFARI
        $(".overlay").animate({ opacity: 0 }, 500);
        $(".box").animate({ opacity: 0 }, 500);
        $(".boxcontrol").animate({ opacity: 0 }, 500);
        $("body").removeClass("ovfhide");
        setTimeout(function() {
            $(".overlay").hide(0);
            $(".box").hide(0);
            $(".boxcontrol").hide(0);
        }, 500);
    });
    // close button click
    $(".boxclose").click(function(e) { // FF - IE - CHROME - SAFARI
        e.preventDefault();
        $(".overlay").animate({ opacity: 0 }, 500);
        $(".box").animate({ opacity: 0 }, 500);
        $(".boxcontrol").animate({ opacity: 0 }, 500);
        $("body").removeClass("ovfhide");
        setTimeout(function() {
            $(".overlay").hide(0);
            $(".box").hide(0);
            $(".boxcontrol").hide(0);
        }, 500);
    });
    /* ====== Get Events For Today ======= */
    $.ajax({ // FF - IE - CHROME - SAFARI
        type: "POST", // use method POST
        url: "Search/JQuery/UZKNTelephone.asmx/getEventsForToday", // path to web service
        data: "{'key': 'key'}", // data to post
        contentType: "application/json; charset=utf-8", // content type
        dataType: "json", // data type
        success: function(data) { // on success
            $(".ajaxone").html("");
            $(".ajaxone").append(data.d); // add data to target
            $(".ajaxone a").click(function(e) { // FF - CHROME - SAFARI
                e.preventDefault();
                $(".boxcontent").html("");
                $('html, body').animate({ scrollTop: 0 }, 'fast'); // scroll page to top
                $(".overlay").show(0);
                $(".overlay").animate({ opacity: 0 }, 0);
                $(".overlay").animate({ opacity: 0.3 }, 500);
                $(".box").show(0);
                $(".box").animate({ opacity: 0 }, 0);
                $(".box").animate({ opacity: 1 }, 500);
                $(".boxcontrol").show(0);
                $(".boxcontrol").animate({ opacity: 0 }, 0);
                $(".boxcontrol").animate({ opacity: 1 }, 500);
                $("body").addClass("ovfhide");
                $.ajax({
                    type: "POST", // use method POST
                    url: "Search/JQuery/UZKNTelephone.asmx/getEventByID",
                    data: "{'key': '" + $(this).attr("id") + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(data) {
                        var thtml = data.d;
                        $(".boxcontent").html(thtml);
                        $(".loading").remove();
                    },
                    error: function() {

                    }
                });
            });
        },
        error: function() { // on failure

        }
    });
    /* get forthcoming events */
    $.ajax({ // FF - IE - CHROME - SAFARI
        type: "POST", // use method POST
        url: "Search/JQuery/UZKNTelephone.asmx/getForthcomingEvents", // path to web service
        data: "{'key': 'key'}", // data to post
        contentType: "application/json; charset=utf-8", // content type
        dataType: "json", // data type
        success: function(data) { // on success
            $(".ajaxtwo").html("");
            $(".ajaxtwo").append(data.d); // add data to target
            $(".ajaxtwo a").click(function(e) { // FF - CHROME - SAFARI
                e.preventDefault();
                $(".boxcontent").html("");
                $('html, body').animate({ scrollTop: 0 }, 'fast'); // scroll page to top
                $(".overlay").show(0);
                $(".overlay").animate({ opacity: 0 }, 0);
                $(".overlay").animate({ opacity: 0.3 }, 500);
                $(".box").show(0);
                $(".box").animate({ opacity: 0 }, 0);
                $(".box").animate({ opacity: 1 }, 500);
                $(".boxcontrol").show(0);
                $(".boxcontrol").animate({ opacity: 0 }, 0);
                $(".boxcontrol").animate({ opacity: 1 }, 500);
                $("body").addClass("ovfhide");
                $.ajax({
                    type: "POST", // use method POST
                    url: "Search/JQuery/UZKNTelephone.asmx/getEventByID",
                    data: "{'key': '" + $(this).attr("id") + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(data) {
                        var thtml = data.d;
                        $(".boxcontent").html(thtml);
                        $(".loading").remove();
                    },
                    error: function() {

                    }
                });
            });
        },
        error: function() { // on failure

        }
    });


});
