﻿
$(document).ready(function () {

    $.ajaxSetup({
        // Disable caching of AJAX responses */ 
        cache: false
    });

    //    $.getJSON('/Home/GetList', function (data) {
    //        alert('here');
    //        $("#news").fillSelect(data);
    //    });
    $.getJSON('/Home/SimpleNewsFeed/', function (response) {
        //alert(data['0'].toString());
        $.each(response.Data, function (i, item) {
            //alert(item.Headline);
            $("#news").append("<li class='title'><a href='#'>" + item.Headline + "</a></li>");

        });

    });

    $.getJSON('/Home/RandomSponsorImage', function (data) {
        //alert(data.Data.Id + ':' + data.Data.Name + ':' + data.Data.Path + ':' + data.Data.Direction + ':' + data.Data.Size);
        if (data.Data.Path != null && data.Data.Path.length > 0) {
            $("#imgSponsor").attr("src", data.Data.Path);

            if (data.Data.Direction.indexOf("width") >= 0) {
                $("#imgSponsor").attr("width", 300);
            }
            else {
                $("#imgSponsor").attr("height", 150);
            }
            $("#imgSponsor").attr("alt", data.Data.Name + " Image");
            //$("#imgSponsor").show();
            $("#imgName").hide();
            $("#imgSponsor").removeAttr("style");
        }
        else {
            $("#imgName").html(data.Data.Name);
            $("#imgSponsor").hide();
            $("#imgName").show('slow');
        }

        //alert($(".inner").html());
    });




});

//$.fn.clearSelect = function () {
//    return this.each(function () {
//        if (this.tagName == 'SELECT')
//            this.options.length = 0;
//    });
//} 


//$.fn.fillSelect = function (data) {
//    return this.clearSelect().each(function () {
//        if (this.tagName == 'SELECT') {
//            var dropdownList = this;
//            $.each(data, function (index, optionData) {
//                var option = new Option(optionData.Text, optionData.Value);

//                if ($.browser.msie) {
//                    dropdownList.add(option);
//                }
//                else {
//                    dropdownList.add(option, null);
//                }
//            });
//        }
//    });
//}
