﻿// JScript File
// Author: Tim Castagna
// Date: 9-29-2009

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1;
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) 
                c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        }
    }
    return "";
}
function checkSoundCookie()
{
    PlaySound =getCookie('PlaySound');
    if (PlaySound != null && PlaySound != "")
    {
        return PlaySound;
    }
}
function checkHeaderCookie()
{
    headSize =getCookie('headSize');
    if (headSize != null && headSize != "")
    {
        return headSize;
    }
}
function FlipFlashHeaderDisplay()
{
    //get the class name of the div to determine which size we are using
    var currentHeader = document.getElementById("topflash").className;
    //get the headsize cookie
    headSize = checkHeaderCookie();
    
    //check to see if this is the first time visiting / clicking the button 
    if(headSize == null)
    {
        //we know we are home and not set, so set it to small and flip the header
        DisplaySmallHeader();
        setCookie('headSize','small',1);
    }
    else
    {
        //we know they clicked the button so set the right flash player and cookie
        if(currentHeader == "topflashLarge")
        {
            DisplaySmallHeader();
            setCookie('headSize','small',1);
        }
        else
        {
            DisplayLargeHeader();
            setCookie('headSize','large',1);
        }
    }
}
function DisplaySmallHeader()
{
    var flashvars2 = {};
    var vloc = document.getElementById('ctl00_hfIsHomePage').value;
    sPlaySound = checkSoundCookie(); 
    if(vloc == "false")
    {
        flashvars2 = {_strInterior : "true", _strAction : "/default.aspx" }; 
        if(sPlaySound == "false")
            flashvars2 = {_strInterior : "true", _strAction : "/default.aspx", _strMute : "true" };
    }
    else
    {
        if(sPlaySound == "false")
            flashvars2 = {_strMute : "true" };
    }
    
    var params2 = { wmode : "transparent", allowScriptAccess: "always" };
    var attributes2 = {id : "header_flash", name : "header_flash"};
    document.getElementById("topflash").className = "topflashSmall";
    $("#topflash").html("<div id='topflashSwf'></div>");
    swfobject.embedSWF("/flash/header_Small.swf", "topflashSwf", "980", "300", "9.0.0","expressInstall.swf",flashvars2,params2,attributes2);    
    
}
function DisplayLargeHeader()
{
    var flashvars2 = {};
    lPlaySound = checkSoundCookie();
    if(lPlaySound == "false")
        flashvars2 = {_strMute : "true" };
        
    var params2 = { wmode : "transparent", allowScriptAccess: "always" };
    var attributes2 = {id : "header_flash", name : "header_flash"};
    document.getElementById("topflash").className = "topflashLarge";
    $("#topflash").html("<div id='topflashSwf'></div>");
    swfobject.embedSWF("/flash/header_large.swf", "topflashSwf", "980", "594", "9.0.0","expressInstall.swf",flashvars2,params2,attributes2);    
    
}
function DisplayFlashHeader()
{
    //if not the home page, show small
    var vloc = document.getElementById('ctl00_hfIsHomePage').value;
    if(vloc == "false")
    {
        //not on the home page so always show the small header
        DisplaySmallHeader();
    }
    else
    {
        //this is the home page, check cookie and display accordingly
        headSize = checkHeaderCookie();
        if(headSize == "small")
            DisplaySmallHeader();
        else if (headSize == "large")
            DisplayLargeHeader();
        else
            DisplayLargeHeader();//alert("do nothing");
    }
}
function MuteFlash()
{
    //this is what happens on button click 
    //so we check to see if there is a cookie, if there is then flip it, 
    //if not set it to false to mute the sound
    vPlaySound = checkSoundCookie();
    if(vPlaySound == null)
    {
        //no cookie set, so we just set the cookie as false
        setCookie('PlaySound','false',1);
    }
    else
    {
        //flip the settings
        if(vPlaySound == "false")
            setCookie('PlaySound','true',1);
        if(vPlaySound == "true")
            setCookie('PlaySound','false',1);
    }
}
function doSilenceFlash() {

        //alert("hit");
		var isIE = navigator.appName.indexOf("Microsoft") != -1;
        var theMovie = (isIE) ? window["header_flash"] : document["header_flash"];	
        //alert(theMovie);
		theMovie.SilenceFlash();
}
//page load calls this function
DisplayFlashHeader();
