﻿
//Global Constants **************
    var glVersionNumber = 0;
    var glPlatformName = "DESKTOP";
    var glDisplayType = "Desktop";
    var glMsgNoFavorites = new Array("TOUCH HERE TO SIGN UP", "HOW DO I ADD FAVORITES?");
    var glMsgNoHistory = new Array("TOUCH HERE TO SIGN UP", "YOU HAVE NO HISTORY");
    
    var glShowFavorites =1;
    var glShowSettings = 1;
    var glShowSearch = 1;
    var glShowShoutcast = 1;
    var glShowHistory = 1;
    
    var glClientServer = "";  
    var glWhiteLabel = "FLYCAST";
    var glAppName = "FlyCast";
    
    var glVolume = 10;
    
//Global Variables **************

    //User Settings
    var glUserID = "";
    var glAutoRestart = "0";

    //Station Variables
    var glNetStationID = "";
    var glStationURL = "";
    var glSID = "";
    var glStationName = "";
    var glStationImage = "";
    var glStationDescription = "";
    var glStationFavorite = "";
    var glPreviousNetStationID = "";
    var glSkipActive = "";
    var glShiftActive = "";

    //webmode variables
    var glWebURL = "";
    var glType = "";
    var glPlayer = "";
    var glWebToolbarState=1;
    var adClickedLink = "";

    //states
    var glPlayState = "STOPPED";
    var glFavoritesClean = 0;

    //These are the unique page ids and link id numbers used by the parser
    var glPGID=0;
    var glLKID=0;

//Global Functions ******************
    function preloadImages()
    {
        var preloader = document.createElement("div");
        preloader.id = "preloader";
        document.body.appendChild(preloader);
    }
    
    //gets global values regardless of whether called from AIR of HTML,
    //useful for testing a certain simple HTML page as well
    function glGet(globalVariableName)
    {
        try
        {

            if (eval("window.top." + globalVariableName))
            {
                return eval("window.top." + globalVariableName);
            }
            else
            {
                if (eval('window.top.frames["root0"].' + globalVariableName) != null)
                {
                    return eval('window.top.frames["root0"].' + globalVariableName);
                }
            }

        }
        catch(e)
        { 
            if (globalVariableName == "glPGID")
            {
                return glPGID;
            }
            if (globalVariableName == "glLKID") 
            {  
                return glLKID;  
            }

        }

    }
    
    function glSet(globalVariableName, value)
    {
        //Debug("in setGlobal");
        try
        {
            if (inAir() == false)  //can we see the static version number?
            {
                eval("window.top." + globalVariableName + "=value;");
            }
            else
            {
                eval('window.top.frames["root0"].' + globalVariableName + "=value;")
            }
            
            //Debug(globalVariableName + " written as " + getGlobal(globalVariableName));
        }
        catch(e)
        {
            if (globalVariableName == "glPGID")
            {
                glPGID = value;
            }
            if (globalVariableName == "glLKID") 
            {  
                glLKID = value;  
            }
        }
    }
    
    function inAir()
    {
        if (window.top.glVersionNumber == 0)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    
    //root window
    var glRootWindow = window.top;
    if (inAir() == true)
    {glRootWindow = window.top.frames["root0"];}

    
    
    //server in web
    if (!window.top.glVersionNumber)
    {
        glClientServer = location.href.substring(location.href.toUpperCase().indexOf("HTTP://")+7,location.href.indexOf("/",location.href.toUpperCase().indexOf("HTTP://")+7));
        
        //is this an alternate platform calling?
        if (location.search.toUpperCase().indexOf("PLAT=") != -1)
        {
            if (location.search.toUpperCase().indexOf("&",location.search.toUpperCase().indexOf("PLAT=")+5) > -1)
            {
                glPlatformName = location.search.substring(location.search.toUpperCase().indexOf("PLAT=")+5,location.search.toUpperCase().indexOf("&",location.search.toUpperCase().indexOf("PLAT=")+5));
            }
            else
            {
                 glPlatformName = location.search.substring(location.search.toUpperCase().indexOf("PLAT=")+5);
            }
        }
    }



