﻿/*******************************************************************************************
Preload images
*******************************************************************************************/

$(document).ready(function() {
    if (document.images) {
        //Small transition images   
        small_preload_image1 = new Image(99, 133);
        small_preload_image1.src = "/images/small/Try.png";
        small_preload_image2 = new Image(99, 133);
        small_preload_image2.src = "/images/small/Watch.png";
        small_preload_image3 = new Image(99, 133);
        small_preload_image3.src = "/images/small/Vote.png";
        small_preload_image4 = new Image(99, 133);
        small_preload_image4.src = "/images/small/Win741.png";
        small_preload_image5 = new Image(99, 133);
        small_preload_image5.src = "/images/small/Connect.png";
        small_preload_image6 = new Image(99, 133);
        small_preload_image6.src = "/images/small/Find.png";
        small_preload_image7 = new Image(99, 133);
        small_preload_image7.src = "/images/small/Share.png";
        small_preload_image8 = new Image(99, 133);
        small_preload_image8.src = "/images/small/Tour.png";
        small_preload_image9 = new Image(99, 133);
        small_preload_image9.src = "/images/small/Buy.png";

        //Background images
        bg_preload_image2 = new Image(99, 133);
        bg_preload_image2.src = "/images/Buy/background.png";
        bg_preload_image3 = new Image(99, 133);
        bg_preload_image3.src = "/images/Connect/background.png";
        bg_preload_image4 = new Image(99, 133);
        bg_preload_image4.src = "/images/Find/background.png";
        bg_preload_image5 = new Image(99, 133);
        bg_preload_image5.src = "/images/Vote/countdown_bg.png";

        //Connect Images
        Connect_preload_image1 = new Image(99, 133);
        Connect_preload_image1.src = "/images/facebook_icon.gif";
        Connect_preload_image2 = new Image(99, 133);
        Connect_preload_image2.src = "/images/twitter_icon.gif";
        Connect_preload_image3 = new Image(99, 133);
        Connect_preload_image3.src = "/images/win_icon.gif";
        Connect_preload_image4 = new Image(99, 133);
        Connect_preload_image4.src = "/images/myspace_icon.gif";
        Connect_preload_image5 = new Image(99, 133);
        Connect_preload_image5.src = "/images/youtube_icon.gif";
        Connect_preload_image6 = new Image(99, 133);
        Connect_preload_image6.src = "/images/music_icon.gif";
    }
});
/*******************************************************************************************
AutoLoader
*******************************************************************************************/

$(document).ready(function() {
    // Check for anchor and select active image from nav
    if (window.location.hash) {
        PanelManager.panelClicked('.' + window.location.hash.substr(1));
    }
});

/*******************************************************************************************
Panel Data
*******************************************************************************************/
var PanelManager = {};

var finddisplayed = false;

PanelManager.panels = {

    ".Win741": {
        id: ".Win741",
        size: "standard",
        small: {
            top: "0px",
            left: "0px",
            img: "images/small/Win741.png"
        },
        standard: {
            top: "0px",
            left: "0px",
            img: "images/standard/Win741.png"
        },
        full: {
            img: "images/full.png"
        },
        onload: function() {
            AtlasTagging.performAction(AtlasTagging.Win741);
            VideoManager.loadVideoIntoObject("#Win741Content .Video", VideoManager.Win741Video, "402", "534", true);
        },
        onquit: function() {
            $("#Win741Content .Video").html("");
        }
    },

    ".Try": {
        id: ".Try",
        size: "standard",
        small: {
            top: "0px",
            left: "250px",
            img: "images/small/Try.png"
        },
        standard: {
            top: "0px", left: "266px",
            img: "images/standard/Try.png"
        },
        full: {
            img: "images/full.png"
        },
        onload: function() {
            AtlasTagging.performAction(AtlasTagging.Try);
            AtlasTagging.performAction(AtlasTagging.Vid1);
            $("#TryContent .thumb_1").click();
            VideoManager.loadVideoIntoObject('#TryContent .video', VideoManager.Try1, '300', '400', false);
        },
        onquit: function() {
            $("#TryContent .video").html("");
        }
    },

    ".Watch": {
        id: ".Watch",
        size: "standard",
        small: {
            top: "0px",
            left: "500px",
            img: "images/small/Watch.png"
        },
        standard: {
            top: "0px",
            left: "532px",
            img: "images/standard/Watch.png"
        },
        full: {
            img: "images/full.png"
        },
        onload: function() {
            AtlasTagging.performAction(AtlasTagging.Watch);
        },
        onquit: function() {

        }
    },

    ".Buy": {
        id: ".Buy",
        size: "standard",
        small: {
            top: "100px",
            left: "0px",
            img: "images/small/Buy.png"
        },
        standard: {
            top: "200px",
            left: "0px",
            img: "images/standard/Buy.png"
        },
        full: {
            img: "images/full.png"
        },
        onload: function() {
            AtlasTagging.performAction(AtlasTagging.Buy);
        },
        onquit: function() {

        }
    },

    ".Share": {
        id: ".Share",
        size: "standard",
        small: {
            top: "200px",
            left: "0px",
            img: "images/small/Share.png"
        },
        standard: {
            top: "200px",
            left: "266px",
            img: "images/standard/Share.png"
        },
        full: {
            img: "images/full.png"
        },
        onload: function() {
            AtlasTagging.performAction(AtlasTagging.Share);
        },
        onquit: function() {

        }
    },

    ".Vote": {
        id: ".Vote",
        size: "standard",
        small: {
            top: "150px",
            left: "750px",
            img: "images/small/Vote.png"
        },
        standard: {
            top: "200px",
            left: "532px",
            img: "images/standard/Vote.png"
        },
        full: {
            img: "images/full.png"
        },
        onload: function() {
            AtlasTagging.performAction(AtlasTagging.Vote);
        },
        onquit: function() {

        }
    },

    ".Tour": {
        id: ".Tour",
        size: "standard",
        small: {
            top: "550px",
            left: "50px",
            img: "images/small/Tour.png"
        },
        standard: {
            top: "400px",
            left: "0px",
            img: "images/standard/Tour.png"
        },
        full: {
            img: "images/full.png"
        },
        onload: function() {
            AtlasTagging.performAction(AtlasTagging.Tour);
            VideoManager.loadVideoIntoObject('#TourContent .video', VideoManager.Tour1, '300', '402', false);
        },
        onquit: function() {
            $("#TourContent .video").html("");
        }
    },

    ".Find": {
        id: ".Find",
        size: "standard",
        small: {
            top: "550px",
            left: "250px",
            img: "images/small/Find.png"
        },
        standard: {
            top: "400px",
            left: "266px",
            img: "images/standard/Find.png"
        },
        full: {
            img: "images/full.png"
        },
        onload: function() {
            AtlasTagging.performAction(AtlasTagging.Find);
            AtlasTagging.performAction(AtlasTagging.Vid1);
            //findPanelPopup();
            VideoManager.loadVideoIntoObject("#FindContent .Video", VideoManager.Laugh1, "402", "534", true);
        },
        onquit: function() {
            $("#FindContent .Video").html("");
        }
    },

    ".Connect": {
        id: ".Connect",
        size: "standard",
        small: {
            top: "501px",
            left: "667px",
            img: "images/small/Connect.png"
        },
        standard: {
            top: "400px",
            left: "532px",
            img: "images/standard/Connect.png"
        },
        full: {
            img: "images/full.png"
        },
        onload: function() {
            AtlasTagging.performAction(AtlasTagging.Connect);
        },
        onquit: function() {

        }
    }

};

function findPanelPopup(){
        if(finddisplayed != true ){
            window.setTimeout( function popUpSweepStakes(){
            var id_string = getQuerystring("id");
            if( id_string == "" ){
            var url = "Sweepstakes.aspx";
            }
            else
            {
             var url = "Sweepstakes.aspx" + "?id=" + id_string;
            }
                newwindow=window.open(url,"sweepstakes","height=300,width=400,toolbar=no,scrollbars=no,location=no,status=no,directories=no,menubar=no,resizable=no,left = 300,top = 200");
	            if (window.focus) {newwindow.focus()}
	                            },25000);
            clearTimeout(window);
            }
        finddisplayed = true;
        }
        
/*******************************************************************************************
Panel Management
*******************************************************************************************/

PanelManager.small = { size: "small", height: "99px", width: "133px", center: { top: "251px", left: "334px"} };
PanelManager.standard = { size: "standard", height: "200px", width: "266px", center: { top: "200px", left: "267px"} };
PanelManager.full = { size: "full", height: "402px", width: "534px", center: { top: "99px", left: "133px"} };
PanelManager.animating = false;

PanelManager.gridHeight = 3;
PanelManager.gridWidth = 3;

PanelManager.animationCallbackCount = 0;
PanelManager.scambleAnimationCallbackCount = 18;

PanelManager.selectedPanel = false;

/*Resets all panels to their appropriate starting position*/
PanelManager.reset = function() {
    if (!PanelManager.animating) {
        tb_remove();
        if (PanelManager.selectedPanel) {
            PanelManager.panels[PanelManager.selectedPanel].onquit();
            PanelManager.selectedPanel = false;
        }
        PanelManager.animating = true;
        PanelManager.animationCallbackCount = 0;
        $.each(PanelManager.panels, function() {
            var temp = this;
            $(this.id + " .panelImage").attr("src", this.small.img);
            $(this.id + " .panelImage").css("display", "");
            $(this.id + " > .panelContent").css("display", "");
            $(this.id).css("cursor", "pointer");
            $(this.id).animate({
                top: this.standard.top,
                left: this.standard.left
            }, "slow").animate({
                height: PanelManager.standard.height,
                width: PanelManager.standard.width
            }, "slow", function() { PanelManager.resetCallback(temp); });
            this.size = PanelManager.standard.size;
        });
    }
}

PanelManager.resetCallback = function(temp) {
    $(temp.id + " .panelImage").attr("src", temp.standard.img);
    if (PanelManager.animationCallbackCount < PanelManager.scambleAnimationCallbackCount - 1) {
        PanelManager.animationCallbackCount++;
    } else {
        PanelManager.animating = false;
    }
}

PanelManager.shuffledPositions;
PanelManager.generateDynamicShufflePositions = function() {
    var arrayIndex = 0;
    var smallWidth = parseInt(PanelManager.small.width.substring(0, PanelManager.small.width.length - 2));
    var smallHeight = parseInt(PanelManager.small.height.substring(0, PanelManager.small.height.length - 2));
    var positionArray = [];

    //Generate 2 spots on the top bar. Offset for static element
    var numbers = PanelManager.generateTwoNumbersNoConflicts(800 - smallWidth, smallWidth);
    positionArray[arrayIndex] = { top: "0px", left: smallWidth + numbers.one + "px" };
    arrayIndex++;
    positionArray[arrayIndex] = { top: "0px", left: smallWidth + numbers.two + "px" };
    arrayIndex++;

    //Generate 2 spots on the bottom bar
    numbers = PanelManager.generateTwoNumbersNoConflicts(800 - smallWidth, smallWidth);
    positionArray[arrayIndex] = { top: (600 - smallHeight) + "px", left: numbers.one + "px" };
    arrayIndex++;
    positionArray[arrayIndex] = { top: (600 - smallHeight) + "px", left: numbers.two + "px" };
    arrayIndex++;

    //Generate 2 spots on the left bar
    numbers = PanelManager.generateTwoNumbersNoConflicts(600 - (2 * smallHeight), smallHeight);
    positionArray[arrayIndex] = { top: smallHeight + numbers.one + "px", left: "0px" };
    arrayIndex++;
    positionArray[arrayIndex] = { top: smallHeight + numbers.two + "px", left: "0px" };
    arrayIndex++;

    //Generate 2 spots on the right bar
    numbers = PanelManager.generateTwoNumbersNoConflicts(600 - (2 * smallHeight), smallHeight);
    positionArray[arrayIndex] = { top: smallHeight + numbers.one + "px", left: (800 - smallWidth) + "px" };
    arrayIndex++;
    positionArray[arrayIndex] = { top: smallHeight + numbers.two + "px", left: (800 - smallWidth) + "px" };
    arrayIndex++;

    PanelManager.shuffledPositions = $.shuffle(positionArray);
}

PanelManager.generateTwoNumbersNoConflicts = function(range, object_width) {
    var numbers = { one: -1, two: -1 };
    //The first number
    numbers.one = Math.floor(Math.random() * (range - object_width));
    //The size of the first partion, theoretically the area to the left of the object
    var partition1 = numbers.one;
    //The second partition theoretically the area to the right of the object
    var partition2 = range - numbers.one - (2 * object_width);
    //Make a random choice as to where the object should go
    var in_partition1 = (Math.random() < .5);

    //Force the object into a partition it can fit in
    if (partition1 < object_width) {
        in_partition1 = false;
    }
    if (partition2 < object_width) {
        in_partition1 = true;
    }

    if (in_partition1) {
        numbers.two = Math.floor(Math.random() * (partition1 - object_width));
    } else {
        numbers.two = numbers.one + object_width + Math.floor(Math.random() * (partition2 - object_width));
    }
    return numbers;
}

/*Scrambles the panels on the screen, with the speficied panel in the center*/
PanelManager.scramblePanels = function(panel) {
    tb_remove();
    if (PanelManager.selectedPanel) {
        PanelManager.panels[PanelManager.selectedPanel].onquit();
        PanelManager.selectedPanel = false;
    }

    //Disable further animations from starting
    PanelManager.animating = true;

    //Prep callback function
    PanelManager.animationCallbackCount = 0;
    $.each(PanelManager.panels, function() {
        if (this.id != panel) {
            //Disable content, and display smallest image for faster animations
            $(this.id + " .panelImage").attr("src", this.small.img);
            $(this.id + " .panelImage").css("display", "");
            $(this.id + " > .panelContent").css("display", "");
            $(this.id).css("cursor", "pointer");
            $(this.id).animate({
                height: PanelManager.small.height,
                width: PanelManager.small.width
            }, "slow", function() { PanelManager.arrangePanels(panel); });
            this.size = PanelManager.small.size;
        } else {
            PanelManager.arrangePanels(panel);
            PanelManager.arrangePanels(panel);
        }
    });
}

PanelManager.arrangePanels = function(panel) {
    if (PanelManager.animationCallbackCount < PanelManager.scambleAnimationCallbackCount - 1) {
        PanelManager.animationCallbackCount++;
    } else {
        PanelManager.animationCallbackCount = 0;
        PanelManager.generateDynamicShufflePositions();
        var shuffleIndex = 0;
        $.each(PanelManager.panels, function() {
            if (this.id != panel) {
                var new_left;
                var new_top;
                if (this.id != ".Connect" && this.id != ".Win741") {
                    var newPos = PanelManager.shuffledPositions[shuffleIndex];
                    shuffleIndex++;
                    new_left = newPos.left;
                    new_top = newPos.top;
                } else {
                    new_left = this.small.left;
                    new_top = this.small.top;
                }
                $(this.id).animate({
                    top: new_top,
                    left: new_left
                }, "slow", function() { PanelManager.zoomFull(panel); });
            } else {
                var top;
                var left;
                //Change to standard image, to hopefullly reduce blur
                $(this.id).attr("src", this.standard.img);
                if (this.size == PanelManager.small.size) {
                    top = PanelManager.small.center.top;
                    left = PanelManager.small.center.left;
                } else if (this.size == PanelManager.standard.size) {
                    top = PanelManager.standard.center.top;
                    left = PanelManager.standard.center.left;
                } else if (this.size == PanelManager.full.size) {
                    top = PanelManager.full.center.top;
                    left = PanelManager.full.center.left;
                }
                $(this.id).animate({
                    top: top,
                    left: left
                }, "slow", function() { PanelManager.zoomFull(panel); });
            }
        });
    }
}

PanelManager.zoomFull = function(panel) {
    if (PanelManager.animationCallbackCount < PanelManager.scambleAnimationCallbackCount - 1) {
        PanelManager.animationCallbackCount++;
    } else {
        PanelManager.animationCallbackCount = PanelManager.scambleAnimationCallbackCount - 2;
        $(panel).animate({
            top: PanelManager.full.center.top,
            left: PanelManager.full.center.left,
            height: PanelManager.full.height,
            width: PanelManager.full.width
        }, "slow", function() { PanelManager.scramblePanelsCallback(panel); });
        PanelManager.panels[panel].size = PanelManager.full.size;
    }
}

PanelManager.scramblePanelsCallback = function(panel) {
    if (PanelManager.animationCallbackCount < PanelManager.scambleAnimationCallbackCount - 1) {
        PanelManager.animationCallbackCount++;
    } else {
        $(PanelManager.panels[panel].id + " .panelImage").css("display", "none");
        $(PanelManager.panels[panel].id + " > .panelContent").css("display", "block");
        $(PanelManager.panels[panel].id).css("cursor", "auto");
        PanelManager.panels[panel].onload();
        PanelManager.selectedPanel = panel;
        PanelManager.animating = false;
    }
}

/*Decides what to do when a panel icon is clicked on*/
PanelManager.panelClicked = function(panel) {
    if (!PanelManager.animating && PanelManager.panels[panel].size != PanelManager.full.size) {
        PanelManager.scramblePanels(panel);
    }
}

/*******************************************************************************************
Video Management
*******************************************************************************************/
var VideoManager = {};
var displayed = false;

VideoManager.loadVideoIntoOverlay = function(selector, media, height, width, autoplay) {
    $("#VideoHolder").html(VideoManager.generateVideoString(media, autoplay, parseInt(height) + 24, width));
    tb_show(selector, "", "#TB_inline?height=" + height + "&width=" + width + "&inlineId=VideoLoader", null, "TB_title_video");
}

VideoManager.loadVideoIntoObject = function(selector, media, height, width, autoplay) {
    $(selector).html(VideoManager.generateVideoString(media, autoplay, height, width));
}

VideoManager.generateVideoString = function(media, autoplay, height, width) {
    if (Silverlight.isInstalled("2.0") || Silverlight.isInstalled("3.0")) {
        return "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='" +
                width + "px' height='" +
                height + "px' id='Object2'><param name='windowless' value='true'/><param name='source' value='OVP/OVP.xap'/><param name='minRuntimeVersion' value='2.0.30923.0' /><param name='onerror' value='onSilverlightError' /><param name='background' value='black' /><param name='MaxFrameRate' value='30' /><a href='http://go.microsoft.com/fwlink/?LinkID=124807' style='text-decoration: none;'><img src='http://go.microsoft.com/fwlink/?LinkId=108181' alt='Get Microsoft Silverlight' style='border-style: none'/></a><param name='initparams' value='showstatistics=false, autoplay=" + autoplay + ", muted=false, playlistoverlay=true, theme=OVP/SmoothHD.xaml, stretchmode=Fit, stretchmodefullscreen=Fit, mediasource=" + media + "' /></object>";
    } else {
        var auto_start_binary = 0;
        if (autoplay) {
            auto_start_binary = 1;
        }
        return "<OBJECT id='mediaPlayer' width='" + width +
            "' height='" + height +
            "' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'><param name='fileName' value='" +
            media + "'><param name='animationatStart' value='" + autoplay + "'><param name='transparentatStart' value='true'><param name='autoStart' value='" +
            autoplay + "'><param name='showControls' value='true'><param name='loop' value='false'><EMBED type='application/x-ms-wmp' pluginspage='http://microsoft.com/windows/mediaplayer/en/download/' id='mediaPlayer' name='mediaPlayer' width='" +
            width + "' height='" + height + "' ShowControls='1' ShowStatusBar='0' ShowDisplay='0' autostart='" + auto_start_binary + "' src='" + media + "'></EMBED></OBJECT>"
    }
}

VideoManager.Win741Video = "mms://a66.v521976.c52197.g.vm.akamaistream.net/7/66/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Win741/Win741.wmv";

VideoManager.Tour1 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Tour/christina.wmv";
VideoManager.Tour2 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Tour/mike.wmv";
VideoManager.Tour3 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Tour/brian.wmv";
VideoManager.Tour4 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/sample.wmv";
VideoManager.Tour5 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/sample.wmv";
VideoManager.Tour6 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/sample.wmv";
VideoManager.Tour7 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/sample.wmv";
VideoManager.Tour8 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/sample.wmv";

VideoManager.Try1 = "mms://a1194.v521975.c52197.g.vm.akamaistream.net/7/1194/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Try/TRY_1.wmv";
VideoManager.Try2 = "mms://a1194.v521975.c52197.g.vm.akamaistream.net/7/1194/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Try/TRY_2.wmv";
VideoManager.Try3 = "mms://a1194.v521975.c52197.g.vm.akamaistream.net/7/1194/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Try/TRY_3.wmv";
VideoManager.Try4 = "mms://a1194.v521975.c52197.g.vm.akamaistream.net/7/1194/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Try/TRY_4.wmv";
VideoManager.Try5 = "mms://a1194.v521975.c52197.g.vm.akamaistream.net/7/1194/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Try/TRY_5.wmv";
VideoManager.Try6 = "mms://a1194.v521975.c52197.g.vm.akamaistream.net/7/1194/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Try/TRY_6.wmv";

VideoManager.Watch_1 = "mms://a1194.v521975.c52197.g.vm.akamaistream.net/7/1194/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/MiniGolf.wmv";
VideoManager.Watch_2 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/sample.wmv";
VideoManager.Watch_3 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/sample.wmv";
VideoManager.Watch_4 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/sample.wmv";
VideoManager.Watch_5 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/sample.wmv";

VideoManager.Laugh1 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/FG/FG_WIN_7_741_49.wmv";
VideoManager.Laugh2 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/FG/FG_WIN_7_LAPTOP_31.wmv";
VideoManager.Laugh3 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/FG/FG_WIN_7_BROADCAST_42.wmv ";
VideoManager.Laugh4 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/FG/sample.wmv";
VideoManager.Laugh5 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/FG/sample.wmv";

VideoManager.Watch1 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content1.wmv";
VideoManager.Watch2 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content2.wmv";
VideoManager.Watch3 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content3.wmv";
VideoManager.Watch4 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content4.wmv";
VideoManager.Watch5 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content5.wmv";
VideoManager.Watch6 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content6.wmv";
VideoManager.Watch7 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content7.wmv";
VideoManager.Watch8 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content8.wmv";
VideoManager.Watch9 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content9.wmv";
VideoManager.Watch10 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content10.wmv";
VideoManager.Watch11 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content11.wmv";
VideoManager.Watch12 = "mms://a488.v52197f.c52197.g.vm.akamaistream.net/7/488/52197/v0001/brandnetsto.download.akamai.com/52198/Win741/Watch/content12.wmv";

/*******************************************************************************************
Thumbnail Management
*******************************************************************************************/
var thumbnail_last_opacity = "";

$(document).ready(function() {
    $(".toggletransparency").css("opacity", "0.5");
    //Add onclick event
    $(".toggletransparency").bind("click", function(e) {
        $(".toggletransparency").css("opacity", "0.5");
        thumbnail_last_opacity = "1.0";
        $(this).css("opacity", "");
    });
    
    
    $(".toggletransparency").hover(
        function(e) { thumbnail_last_opacity = $(this).css("opacity"); $(this).css("opacity", ""); },
        function(e) { $(this).css("opacity", thumbnail_last_opacity); }
    );
    //HiSoftware edited so that visual focus was drawn when using the keyboard
    $(".toggletransparency").focus(
        function(e) { thumbnail_last_opacity = $(this).css("opacity"); $(this).css("opacity", ""); },
        function(e) { $(this).css("opacity", thumbnail_last_opacity); }
    );
    $(".toggletransparency").blur(
        function(e) { thumbnail_last_opacity = $(this).css("opacity"); $(this).css("opacity", "0.5"); },
        function(e) { $(this).css("opacity", thumbnail_last_opacity); }
    );
});

/*******************************************************************************************
ToolTip Management
*******************************************************************************************/

ToolTipManager = {};
ToolTipManager.init = function() {

    //Panel Tooltips
    $("#Win741Image").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Windows 7 created for student’s life wants and needs";
        }
    });

    $("#TryImage").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "See all the fun you can have with Windows 7";
        }
    });

    $("#WatchImage").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Students share their Windows 7 experience";
        }
    });

    $("#BuyImage").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Take advantage of the student price on Windows 7.";
        }
    });

    $("#ConnectImage").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Download free music tracks and learn more about Windows 7";
        }
    });

    $("#FindImage").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Exclusive Windows 7 Family Guy content";
        }
    });

    $("#ShareImage").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Upload your Windows videos, pictures and even desktop art designs";
        }
    });

    $("#TourImage").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "What’s happening on the 741 Campus Tour";
        }
    });

    $("#VoteImage").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "Get your Skin It";
        }
    });
    //End Panel Tooltips

    //Try video Tooptips
    $("#TryContent .thumb_1").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Windows Live Movie Maker by Catherine Feeny";
        }
    });

    $("#TryContent .thumb_2").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Aero Shake ";
        }
    });

    $("#TryContent .thumb_3").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Windows Personalization";
        }
    });

    $("#TryContent .thumb_4").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Multiple Features by Loyale - Feat. Allen Stone ";
        }
    });

    $("#TryContent .thumb_5").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Windows Media Center by Daniel Kamas";
        }
    });
    //End Try Video Tooltips

    //Music Tooltips
    $("#Connect .music1").tooltip({
        delay: 0,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Catherine Feeny - \"Windchime\"";
        }
    });

    $("#Connect .music2").tooltip({
        delay: 0,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Daniel Kamas - \"Seven\"";
        }
    });

    $("#Connect .music3").tooltip({
        delay: 0,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Loyale - Feat. Allen Stone \"The Moment\"";
        }
    });
    $("#Connect .music4").tooltip({
        delay: 0,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Tha Union - Feat. Allen Stone \"Give Me That Seven\"";
        }
    });

    $("#Connect .music5").tooltip({
        delay: 0,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "The Physics - Feat. Carson Henley \"The New Me\"";
        }
    });

    $("#Connect .music6").tooltip({
        delay: 0,
        track: true,
        showURL: false,
        bodyHandler: function() {
            return "Bright Wings - \"All I Need\"";
        }
    });
    //End Music Tooltips

    //Watch Tooltips
    $("#Watch .thumb1").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "Windows 7 Rangoli (Sand Art)";
        }
    });
    $("#Watch .thumb2").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "Students demo Snap Feature ";
        }
    });
    $("#Watch .thumb3").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "BC Student Video – Made with Windows Movie Maker ";
        }
    });
    $("#Watch .thumb4").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "UW Student Movie – Made with Windows Movie Maker";
        }
    });
    $("#Watch .thumb5").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "University of Houston Student Movie – Made with Windows Movie Maker";
        }
    });
    $("#Watch .thumb6").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "Georgia Tech Student Movie – Made with Windows Movie Maker";
        }
    });
    $("#Watch .thumb7").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "UW Student Movie – Made with Windows Movie Maker";
        }
    });
    $("#Watch .thumb8").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "UCSD Student Movie – Made with Windows Movie Maker";
        }
    });
    $("#Watch .thumb9").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "UCF Student Movie – Made with Windows Movie Maker";
        }
    });
    $("#Watch .thumb10").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "Penn State Student Movie – Made with Windows Movie Maker";
        }
    });
    $("#Watch .thumb11").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "Fresno Student Movie – Made with Windows Movie Maker";
        }
    });
    $("#Watch .thumb12").tooltip({
        delay: 250,
        track: true,
        showURL: false,
        bodyHandler: function() {
        return "USC Student Movie – Made with Windows Movie Maker";
        }
    });
    //End Watch Tooltips
}
$(document).ready(ToolTipManager.init);

/*******************************************************************************************
Social Button
*******************************************************************************************/

function bindSocialBookmarks() {
    var sbList = $get("social_bookmarks");
    var sbLinks = sbList.getElementsByTagName("a");
    for (var i = 0; i < sbLinks.length; i++) {
        if (sbLinks[i].id != "sb_share") {
            sbLinks[i].href = sbLinks[i].href.replace("www.microsoft.com/windows", window.location.href).replace("Microsoft%20Windows", encodeURI(document.title));
        }
    }
    var sbTrigger = $get("sb_share");
    $addHandler(sbTrigger, "mouseover", showSocialBookmarks);
    $addHandler(sbTrigger, "mouseout", hideSocialBookmarks);
    //HiSoftware added keyboard handlers
    $addHandler(sbTrigger, "focus", showSocialBookmarks);
    $addHandler(sbTrigger, "blur", hideSocialBookmarks);
}

function toggleSocialBookmarks(dir) {
    var direction = dir;
    var sbList = $get("social_bookmarks");
    var sbBookmarks = sbList.getElementsByTagName("li");
    for (var i = 0; i < sbBookmarks.length; i++) {
        if (sbBookmarks[i].id != "sb_share") {
            if ("hide" == direction) {
                Sys.UI.DomElement.addCssClass(sbBookmarks[i], "hidden");
            } else if ("show" == direction) {
                Sys.UI.DomElement.removeCssClass(sbBookmarks[i], "hidden");
            }
        }
    }
};

function showSocialBookmarks() {
    toggleSocialBookmarks("show");
};

function hideSocialBookmarks() {
    toggleSocialBookmarks("hide");
};

$(document).ready(bindSocialBookmarks);

/****************
Vertical Centering
****************/

function getWindowHeight() {
    var windowHeight = 0;
    if (typeof (window.innerHeight) == 'number') {
        windowHeight = window.innerHeight;
    }
    else {
        if (document.documentElement && document.documentElement.clientHeight) {
            windowHeight = document.documentElement.clientHeight;
        }
        else {
            if (document.body && document.body.clientHeight) {
                windowHeight = document.body.clientHeight;
            }
        }
    }
    return windowHeight;
}
function setContent() {
    if (document.getElementById) {
        var windowHeight = getWindowHeight();
        if (windowHeight > 0) {
            var contentElement = document.getElementById('centering_container');
            var contentHeight = contentElement.offsetHeight;
            if (windowHeight - contentHeight > 0) {
                contentElement.style.position = 'relative';
                contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
            }
            else {
                contentElement.style.position = 'static';
            }
        }
    }
}
window.onload = function() {
    setContent();
}
window.onresize = function() {
    setContent();
}

/*****************
Atlas Tagging
*****************/

var AtlasTagging = {};

AtlasTagging.performAction = function(action_link) {
    var fileref = document.createElement('script');
    fileref.setAttribute("type", "text/javascript");
    fileref.setAttribute("src", action_link);
    document.getElementsByTagName("head")[0].appendChild(fileref);
}

$(document).ready(function() {
    AtlasTagging.performAction(AtlasTagging.PageLoad);
});

AtlasTagging.PageLoad = "http://view.atdmt.com/jaction/win7_development_pageload";

AtlasTagging.Win741 = "http://view.atdmt.com/jaction/win7_development_panel_741";
AtlasTagging.Try = "http://view.atdmt.com/jaction/win7_development_panel_try";
AtlasTagging.Watch = "http://view.atdmt.com/jaction/win7_development_panel_watch";
AtlasTagging.Buy = "http://view.atdmt.com/jaction/win7_development_panel_buy";
AtlasTagging.Share = "http://view.atdmt.com/jaction/win7_development_panel_share";
AtlasTagging.Vote = "http://view.atdmt.com/iaction/win7_development_panel_vote";
AtlasTagging.Tour = "http://view.atdmt.com/jaction/win7_development_panel_tour";
AtlasTagging.Find = "http://view.atdmt.com/jaction/win7_development_panel_find";
AtlasTagging.Connect = "http://view.atdmt.com/iaction/win7_development_panel_windows7";

AtlasTagging.BuyButton = "http://view.atdmt.com/jaction/win7_development_buybutton";

AtlasTagging.Vid1 = "http://view.atdmt.com/jaction/win7_development_vid1";
AtlasTagging.Vid2 = "http://view.atdmt.com/jaction/win7_development_vid2";
AtlasTagging.Vid3 = "http://view.atdmt.com/jaction/win7_development_vid3";
AtlasTagging.Vid4 = "http://view.atdmt.com/jaction/win7_development_vid4";
AtlasTagging.Vid5 = "http://view.atdmt.com/jaction/win7_development_vid5";
AtlasTagging.Vid6 = "http://view.atdmt.com/jaction/win7_development_vid6";

AtlasTagging.Facebook = "http://view.atdmt.com/jaction/win7_development_social_facebook";
AtlasTagging.Twitter = "http://view.atdmt.com/jaction/win7_development_social_twitter";
AtlasTagging.MySpace = "http://view.atdmt.com/jaction/win7_development_social_myspace";
AtlasTagging.YouTube = "http://view.atdmt.com/jaction/win7_development_social_youtube";
AtlasTagging.WindowsSite = "http://view.atdmt.com/jaction/win7_development_social_windows";

AtlasTagging.music_allINeed = "http://view.atdmt.com/jaction/win7_development_music_allIneed";
AtlasTagging.music_givemetheseven = "http://view.atdmt.com/jaction/win7_development_music_givemetheseven";
AtlasTagging.music_seven = "http://view.atdmt.com/jaction/win7_development_music_seven";
AtlasTagging.music_themoment = "http://view.atdmt.com/jaction/win7_development_music_themoment";
AtlasTagging.music_thenewme = "http://view.atdmt.com/jaction/win7_development_music_thenewme";
AtlasTagging.music_windchime = "http://view.atdmt.com/jaction/win7_development_music_windchime";