///do not delete the following line. It is for Intellisense.
/// <reference path="~/js/jquery-1.3.2-vsdoc.js" />


//feedback stuff
$(document).ready(function() {
    $.ajaxSetup({ cache: false });
    $.getJSON("/survey/websitefeebackjson", function(data) {
        if (data != null) {
            $(document.body).append('<div id="dialog" ></div><input id="closedialog" name="closedialog"  type="button" style="display:none"/>');
            $(document.body).append('<div id="feedbackButton" class="feedback-button"><a href="#" class="dialog-link" ><img src="/images/nav_customercare.png" alt="Website Feedback" /></a></div>');

            // Dialog
            $('#dialog').dialog({
                modal: true,
                autoOpen: false,
                width: 800,
                height: 600,
                resizable: true,
                zIndex: 50001,
                resizable: false

            });


            // Dialog Link
            $('.dialog-link').click(function() {

                $("#dialog").html('<iframe src="/survey/open/' + data.ID + '" id="modalIframeId" width="100%" height="100%"  marginWidth="0" marginHeight="0" frameBorder="0" scrolling="auto" />').dialog('open');


                return false;
            });

            $('#closedialog').click(function() {
                $('#dialog').dialog("close");

            });
        }
    });
});


function runfeeds(jsonPath, divID, loading, showPosted) {       
    $.getJSON(jsonPath, function(json) {
        $("#" + loading).fadeOut(10).remove();
        $.each(json, function(i, item) {
            link = $("<a></a>").attr("href", item.Link).html(item.Text).css("display", "none");
            link.addClass("jsonBlogPost");
            listItem = $("<li></li>").html(link);
            if (item.ImageAlt != null && item.ImageAlt != "" && showPosted) {
                span = $(" <span></span>").addClass("posted").html("&nbsp;" + item.ImageAlt);
                listItem.append(span);
            }
            listItem.appendTo("#" + divID);
        });
        //fade all posts in
        $(".jsonBlogPost").fadeIn(10);
    });       
}