﻿$("document").ready(function () {

    var iconsObj = $(".icons");
    var iconIndex = 0;
    var timer = "";
    $("#b1").click(function () {
        increaseOpacity(this, 'Content/Images/creativeImg.png', 'Solutions/CreativeServices');
    });

    $("#b2").click(function () {
        increaseOpacity(this, 'Content/Images/networkImg.png', 'Solutions/Network');
    });

    $("#b3").click(function () {
        increaseOpacity(this, 'Content/Images/softwareImg.png', 'Solutions/CustomSoftware');
    });

    $("#b4").click(function () {
        increaseOpacity(this, 'Content/Images/mobileImg.png', 'Solutions/MobileDevelopment');

    });

    function increaseOpacity(thisObj, imageUrl, redirectLocation) {
        window.clearInterval(timer)
        var selectedIndex = iconsObj.index($(thisObj).parent());
        iconIndex = selectedIndex;

        if ($.browser.msie) {
            $("#nonflash").css('background-image', 'url(' + imageUrl + ')');
        } else {
            $("#nonflash").css({ 'background-image': 'url(' + imageUrl + ')', "opacity": "0.01" });
            $("#nonflash").animate({ "opacity": 1 }, 1000);
        }

        $("#nonflash .viewfull").attr("href", redirectLocation);

        iconsObj.each(function (index) {
            var iconCount = parseFloat(index) + 1
            var iconUrl = (index == selectedIndex) ? 'Content/Images/icon' + iconCount + '_select.png' : 'Content/Images/icon' + iconCount + '.png';
            $(this).find("img").attr('src', iconUrl);
        });
        start_Int();
    }

    var times = iconsObj.length;
    $("#b1").trigger("click");


    function start_Int() {
        timer = setInterval(function () {
            iconIndex = (iconsObj.eq(iconIndex + 1).length == 0) ? 0 : iconIndex + 1;
            iconsObj.eq(iconIndex).find("img").trigger("click");
        }, 5000);
    }

});							   
