﻿///////////// SLIDES FOR NON-FLASH HOMEPAGE SLIDESHOW //////////////////
function slideSwitch() {
    var $active = $('#slideshow img.active');

    if ($active.length == 0) $active = $('#slideshow img:last');

    var $next = $active.next().length ? $active.next('img')
        : $('#slideshow img:first');

    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function () {
            $active.removeClass('active last-active');
        });
}
$(document).ready(function () {
    //on page load
    //first fade in the slogen
    $('#sloganHolder').delay(1000).css({ opacity: 0.0 }).animate({ opacity: 1.0 }, 1400, function () {
    });
    //next fade in the logo
    $('#logoHolder').delay(2000).css({ opacity: 0.0 }).animate({ opacity: 1.0 }, 1400, function () {
    });
    //next fade in the top nav
    $('#headerNav').delay(3000).css({ opacity: 0.0 }).animate({ opacity: 1.0 }, 1400, function () {
    });
    //we need the first image to have a class of active, Because we are adding images dynamically we must use this to give the first one an active class
    $('#slideshow IMG:first').addClass('active');
    //to fade in our first image we set it's opacity to 0 then animate it up to 1 slowly
    $('#slideshow IMG.active').css({ opacity: 0.0 }).animate({ opacity: 1.0 }, 1100, function () {
    });
    //now call our slideswitch to fade images in and out
    setInterval("slideSwitch()", 5000);
});



///////////// SWITCH THE SWV OBJECT FROM JS TO JQUERY DEPENDING ON THE BROWSER //////////////////
//function callback() {
//    // this is the callback function
//    // execute after external script finishes loading
//    if (NOTIE9) {
//        $('#flashHome').flash(
//                    {
//                        swf: '/Flash/portfolio.swf',
//                        allowFullScreen: true,
//                        scale: 'noscale',
//                        height: '100%',
//                        width: '100%',
//                        hasVersion: 10,
//                        bgcolor: "#ffffff",
//                        expressInstaller: '/flash/ExpressInstaller.swf'
//                    }
//		);
//    }
//    else {
//        initFlash();
//    }
//}
//var script = document.createElement('script');
//script.src = "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js";

//if (script.readyState) { // IE, incl. IE9
//    script.onreadystatechange = function () {
//        if (script.readyState == "loaded" || script.readyState == "complete") {
//            script.onreadystatechange = null;
//            callback();
//        }
//    };
//} else {
//    script.onload = function () { // Other browsers
//        callback();
//    };
//}
//document.getElementsByTagName('head')[0].appendChild(script);
