﻿var popUpVid;
function openGreenPopUpVid(vidName, vidWidth, vidHeight) {
    var gotGreenLink = document.createElement("a");
    openPopUpVid(vidName, vidWidth, vidHeight);
    gotGreenLink.id = "gotGreenLink";
    gotGreenLink.style.color = "white";
    gotGreenLink.style.backgroundColor = "#b5d335";
    gotGreenLink.style.border = "2px solid transparent";
    gotGreenLink.style.position = "absolute";
    gotGreenLink.style.left = "300px";
    gotGreenLink.style.bottom = "-30px";
    gotGreenLink.style.textDecoration = "none";
    gotGreenLink.style.fontSize = "20pt";
    gotGreenLink.style.backgroundColor = "#b5d335";
    gotGreenLink.style.padding = "20px";
    gotGreenLink.innerHTML = "Got Green?";
    gotGreenLink.onmouseover = function() {
        gotGreenLink.style.borderColor = "white";
    };
    gotGreenLink.onmouseout = function() {
        gotGreenLink.style.borderColor = "transparent";
    };
    gotGreenLink.setAttribute("href", "/goinggreen/GoingGreen.aspx");
    setTimeout(function() {
        popUpVid.appendChild(gotGreenLink);
    }, 40000);
    
}
function openPopUpVid(vidName, vidWidth, vidHeight) {
    var closeButton = document.createElement("img"); //close button
    popUpVid = document.createElement("div"); //create pop up div
    popUpVid.style.zIndex = "1000";
    closeButton.setAttribute("src", "/media/images/general/closeButton.png");
    closeButton.onclick = closePopUpVid;
    closeButton.style.position = "absolute";
    closeButton.style.height = "22px";
    closeButton.style.width = "35px";
    closeButton.style.left = "250px";
    closeButton.style.bottom = "54px";
    closeButton.title = "Close";
    closeButton.onmouseover = function() {
        closeButton.style.cursor = "pointer";
        closeButton.src = "/media/images/general/closeButtonHover.png";
    };
    closeButton.onmouseout = function() {
        closeButton.src = "/media/images/general/closeButton.png";
        closeButton.style.cursor = "default";
    };
    //Show the Shadow Cover ooooh
    try { //try is here in case shadow cover is not in use
        addShadowCover();
    }
    catch (e) { 
    }

    //set the Pop Up Vid Settings
    popUpVid.id = "vidDiv";
    popUpVid.style.position = "fixed";
    if (navigator.userAgent.search("MSIE 6") >= 0) {
        popUpVid.style.position = "absolute"; //set the div to absolute positioning
    }
    popUpVid.style.left = document.body.scrollWidth / 2 - vidWidth / 2 + "px";
    popUpVid.style.top = "50px";
    popUpVid.className = "vidDivClass";

    //append pop up vid, inset the video, and add the close butotn
    document.body.appendChild(popUpVid);
    changeVid(vidName, vidWidth, vidHeight, true);
    setTimeout(function() {
        popUpVid.appendChild(closeButton);
    }, 1200);
}
function closePopUpVid() {
    document.getElementById("vidDiv").innerHTML = "";
    document.body.removeChild(popUpVid);
    try {
        deleteShadowCover();
    }
    catch (e) { 
    }
}
function openPopupSWF(SWFFile, SWFWidth, SWFHeight) {
    closeButton = document.createElement("img"); //close button
    popupSWF = document.createElement("div"); //create pop up div
    popupSWF.style.zIndex = "1000";
    closeButton.setAttribute("src", "/media/images/general/closeButton.png");
    closeButton.onclick = closePopupSWF;
    closeButton.style.position = "absolute";
    closeButton.style.height = "22px";
    closeButton.style.width = "35px";
    closeButton.style.right = "10px";
    closeButton.style.top = "10px";
    closeButton.title = "Close";
    closeButton.onmouseover = function() {
        closeButton.style.cursor = "pointer";
        closeButton.src = "/media/images/general/closeButtonHover.png";
    };
    closeButton.onmouseout = function() {
        closeButton.src = "/media/images/general/closeButton.png";
        closeButton.style.cursor = "default";
    };
    //Show the Shadow Cover ooooh
    try { //try is here in case shadow cover is not in use
        addShadowCover();
    }
    catch (e) {
    }

    //set the Pop Up Vid Settings
    popupSWF.id = "SWFDiv";
    availWidth = window.innerWidth;
    if (!availWidth) {
        availWidth = document.documentElement.clientWidth;
    }
    newLeft = availWidth / 2 - SWFWidth / 2;
    popupSWF.style.left = newLeft + "px";
    availHeight = window.innerHeight;
    if (!availHeight) {
        availHeight = document.documentElement.clientHeight;
    }
    newTop = availHeight / 2 - SWFHeight / 2;
    if (newTop > availHeight / 6) {
        newTop = availHeight / 6;
    }
    popupSWF.style.top = newTop + "px";
    
    popupSWF.style.position = "fixed";
    if (navigator.userAgent.search("MSIE 6") >= 0 || availHeight < SWFHeight) {
        popupSWF.style.position = "absolute"; //set the div to absolute positioning
        popupSWF.style.top = "50px";
    }
    
    /*popupSWF.style.left = document.body.scrollWidth / 2 - SWFWidth / 2 + "px";
    popupSWF.style.top = "50px";*/
    popupSWF.innerHTML = "<embed src=\"" + SWFFile + "\" wmode=\"transparent\" flashvars=\"&MM_ComponentVersion=1&skinName=/media/flash/Halo_Skin_1 scale=\"noscale\" width=\"" + SWFWidth + "\" height=\"" + SWFHeight + "\" name=\"BuildABath\" salign=\"LT\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" />";
    

    document.body.appendChild(popupSWF);
    popupSWF.appendChild(closeButton);
}

function closePopupSWF() {
    var SWFDiv = window.document.getElementById("SWFDiv");
    SWFDiv.innerHTML = "";
    SWFDiv.parentNode.removeChild(SWFDiv);
    try {
        deleteShadowCover();
    }
    catch (e) {
    }
}