﻿$(function() {
    for (i = 0; i < $("#bannerContainer .banner").size() / 2; i++) {
        $("#bannerContainer .banner").slice(2 * i, 2 * (i + 1)).wrapAll("<div class='bannerGroup' />");
    }

    $("#bannerContainer .bannerGroup").hide();
    $("#bannerContainer .bannerGroup:eq(0)").show();
    if ($("#bannerContainer .banner").size() > 2) {
        slideshow(0);
    }

//    if (($.browser.version == "6.0") || ($.browser.version == "7.0")) {
//        if ($.cookie("upgrade") == null) {
//            bodyHeight = $(document).height();
//            $("#upgrade").css({
//                "width": "100%",
//                "height": "50px",
//                "background-color": "#666666",
//                "color": "white",
//                "line-height": "50px",
//                "vertical-align": "middle",
//                "padding-left": "10px",
//                "top": bodyHeight
//            });
//            $("#upgrade").delay(500).show().fadeTo(100, 0.7).animate({ "top": "-=50" }, "slow");
//        } else {
//            $("#upgrade").hide();
//        }
//    }

//    $("#closeUpMsg").click(function() {
//        $("#upgrade").animate({ "top": bodyHeight }, "fast").hide("fast");
//        var date = new Date();
//        date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
//        $.cookie("upgrade", 1, { expires: date });
//    });

//    $("#ctl00_ContentPlaceHolder1_newsRSS").click(function(event) {
//        event.stopPropagation();
//    });

//    $("#ctl00_ContentPlaceHolder1_avisoRSS").click(function(event) {
//        event.stopPropagation();
//    });

//        $("#closeBtn").click(function() {
//            $("#mpContainer").hide();
//            $("#moviePic").html("");
//        });

//        $("#m1,#vIcon").click(function() {
//            $("#moviePic").html($("#mp1").html());
//            $("#mpTitle").text($("#mp1").attr("title"));
//            $("#mpContainer").show("fast");
//        });

//        $("#m2,#pIcon").click(function() {
//            $("#moviePic").html($("#mp2").html());
//            $("#mpTitle").text($("#mp2").attr("title"));
//            $("#mpContainer").hide().show("fast");
//        });
//        
//        $("#cIcon").click(function() {
//            location.href=$("#ctl00_ContentPlaceHolder1_webcamLink").attr("href");
//        });
});

function slideshow(i) {
    $("#bannerContainer .bannerGroup").eq(i).delay(6000).fadeOut(500, function() {
    if (i < $("#bannerContainer .bannerGroup").size()-1) {
            $("#bannerContainer .bannerGroup").eq(i + 1).fadeIn("fast");
            slideshow(i + 1);
        } else {
        $("#bannerContainer .bannerGroup:eq(0)").fadeIn("fast");
            slideshow(0);
        }
    });
}
