if (document.images) {
    //navigation
    pic1 = new Image(1023, 638);
    pic1.src = "images/top_LongShadow.jpg";
    pic2 = new Image(1, 638);
    pic2.src = "images/top_repeat.jpg";
    pic3 = new Image(120, 85);
    pic3.src = "images/nav_services_on.png";
    pic4 = new Image(120, 85);
    pic4.src = "images/nav_services_off.png";
    pic5 = new Image(120, 85);
    pic5.src = "images/nav_portfolio_on.png";
    pic6 = new Image(120, 85);
    pic6.src = "images/nav_portfolio_off.png";
    pic7 = new Image(120, 85);
    pic7.src = "images/nav_company_on.png";
    pic8 = new Image(120, 85);
    pic8.src = "images/nav_company_off.png";
    pic9 = new Image(120, 85);
    pic9.src = "images/nav_contact_on.png";
    pic10 = new Image(120, 85);
    pic10.src = "images/nav_contact_off.png";
    //index
    pic11 = new Image(745, 280);
    pic11.src = "images/HERO_1_75.jpg";
    pic12 = new Image(745, 280);
    pic12.src = "images/HERO_2_75.jpg";
    pic13 = new Image(745, 280);
    pic13.src = "images/HERO_3_75.jpg";
    pic14 = new Image(745, 280);
    pic14.src = "images/HERO_4_75.jpg";
    pic15 = new Image(228, 138);
    pic15.src = "images/portfolio/thumbs/thb_windows.jpg";
    pic16 = new Image(228, 138);
    pic16.src = "images/portfolio/thumbs/thb_incentives.jpg";
    pic17 = new Image(228, 138);
    pic17.src = "images/portfolio/thumbs/thb_retail.jpg";
    //services
    pic18 = new Image(186, 280);
    pic18.src = "images/Sustainable_ON.jpg";
    pic19 = new Image(186, 280);
    pic19.src = "images/Sustainable_OFF.jpg";
    pic20 = new Image(186, 280);
    pic20.src = "images/Creative_ON.jpg";
    pic21 = new Image(186, 280);
    pic21.src = "images/Creative_OFF.jpg";
    pic22 = new Image(186, 280);
    pic22.src = "images/UXDEV_ON.jpg";
    pic23 = new Image(186, 280);
    pic23.src = "images/UXDEV_OFF.jpg";
    pic24 = new Image(186, 280);
    pic24.src = "images/Marketing_ON.jpg";
    pic25 = new Image(186, 280);
    pic25.src = "images/Marketing_OFF.jpg";
    //portfolio
    pic26 = new Image(186, 125);
    pic26.src = "images/portfolio/Sustainable_NS_ON.jpg";
    pic27 = new Image(186, 125);
    pic27.src = "images/portfolio/Sustainable_NS_OFF.jpg";
    pic28 = new Image(186, 125);
    pic28.src = "images/portfolio/Creative_NS_ON.jpg";
    pic29 = new Image(186, 125);
    pic29.src = "images/portfolio/Creative_NS_OFF.jpg";
    pic30 = new Image(186, 125);
    pic30.src = "images/portfolio/UXDEV_NS_ON.jpg";
    pic31 = new Image(186, 125);
    pic31.src = "images/portfolio/UXDEV_NS_OFF.jpg";
    pic32 = new Image(186, 125);
    pic32.src = "images/portfolio/Marketing_NS_ON.jpg";
    pic33 = new Image(186, 125);
    pic33.src = "images/portfolio/Marketing_NS_OFF.jpg";
    //company
    pic34 = new Image(186, 125);
    pic34.src = "images/company/What_we_do_ON.jpg";
    pic35 = new Image(186, 125);
    pic35.src = "images/company/What_we_do_OFF.jpg";
    pic36 = new Image(186, 125);
    pic36.src = "images/company/announcements_ON.jpg";
    pic37 = new Image(186, 125);
    pic37.src = "images/company/announcements_OFF.jpg";
    pic38 = new Image(186, 125);
    pic38.src = "images/company/Meet_the_team_ON.jpg";
    pic39 = new Image(186, 125);
    pic39.src = "images/company/Meet_the_team_OFF.jpg";
    pic40 = new Image(186, 125);
    pic40.src = "images/portfolio/Marketing_NS_ON.jpg";
    pic41 = new Image(186, 125);
    pic41.src = "images/company/Whitepapers_and_RandD_OFF.jpg";
    //community
    pic42 = new Image(248, 125);
    pic42.src = "images/community/News_and_Events_ON.jpg";
    pic43 = new Image(248, 125);
    pic43.src = "images/community/News_and_Events_OFF.jpg";
    pic44 = new Image(248, 125);
    pic44.src = "images/community/Outreach_ON.jpg";
    pic45 = new Image(248, 125);
    pic45.src = "images/community/Outreach_OFF.jpg";
    pic46 = new Image(248, 125);
    pic46.src = "images/community/See_us_in_action_ON.jpg";
    pic47 = new Image(248, 125);
    pic47.src = "images/community/See_us_in_action_OFF.jpg";
    //contact
    pic48 = new Image(626, 384);
    pic48.src = "images/Contact_postcard.jpg";

}

        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null && sender != 0) {
                appSource = sender.getHost().Source;
            }

            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
                return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";

            errMsg += "Code: " + iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " + args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
 




function theRotator() {
    //Set the opacity of all images to 0
    $('div#rotator ul li').css({ opacity: 0.0 });

    //Get the first image and display it (gets set to full opacity)
    $('div#rotator ul li:first').css({ opacity: 1.0 });

    //Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('rotate()', 12000);

}

function rotate() {
    //Get the first image
    var current = ($('div#rotator ul li.show') ? $('div#rotator ul li.show') : $('div#rotator ul li:first'));

    //Get next image, when it reaches the end, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') : current.next()) : $('div#rotator ul li:first'));

    //Set the fade in effect for the next image, the show class has higher z-index
    next.css({ opacity: 0.0 })
	    .addClass('show')
	    .animate({ opacity: 1.0 }, 3000);

    //Hide the current image
    current.animate({ opacity: 0.0 }, 1000)
	    .removeClass('show');

};





function theRotatorHero() {
    //Set the opacity of all images to 0
    $('div#rotatorHero  ul li').css({ opacity: 0.0 });

    //Get the first image and display it (gets set to full opacity)
    $('div#rotatorHero  ul li:first').css({ opacity: 1.0 });

    //Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('rotateHero()', 4000);

}

function rotateHero() {
    //Get the first image

    var current = ($('div#rotatorHero ul li.show') ? $('div#rotatorHero ul li.show') : $('div#rotatorHero ul li:first'));

    //Get next image, when it reaches the end, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotatorHero ul li:first') : current.next()) : $('div#rotatorHero ul li:first'));

    //Set the fade in effect for the next image, the show class has higher z-index
    next.css({ opacity: 0.0 })
	    .addClass('show')
	    .animate({ opacity: 1.0 }, 2000);

    //Hide the current image
    current.animate({ opacity: 0.0 }, 1000)
	    .removeClass('show');

};

$(document).ready(function() {
    //Load the slideshow
    theRotator();
    theRotatorHero();
});

