//This script handles the setup of the main GMS site

(function () {
    
    //Check the status of the website as mobile
    
    var isMobile        =   ($(window).width() < 800) ? true : false;
    var mobileEnabled   =   (((me = getCookieData('mobile_enabled')) == null) ? null : Boolean(parseInt(me))); ;
    
    //Check if the device is an "iDevice"
    
    var isAppleDevice   =   (/iphone|ipod|ipad/gi).test(navigator.platform);
    
    //
    
    if(isAppleDevice) isMobile = true;
    
    //Setup the stage
    
    function browser_check () {
        
        //If the mobile_enabled cookie is null and device is mobile, set it
        
        if(mobileEnabled == null && isMobile) {
            
            //Set the mobile_enabled cookie to true
            
            setCookieData('mobile_enabled', '1', new Date().getTime() + 3200, '/');
            location.reload(true);
            
            //Return value to prevent further script execution
            
            return 0;
            
        }
        else if(!isMobile) setCookieData('mobile_enabled', '0', new Date().getTime() + 3200, '/');
        
        //Load the "add to homescreen" script if the device is mobile
        
        if(mobileEnabled) {
            
            RSXResourceLoader.loadScript('/_scripts/add2home/add2home.js');
            RSXResourceLoader.loadStylesheet('/_scripts/add2home/add2home.css');
            
        }
        
        //Add an event listener to the DOMContentLoaded event
        //Makes the
        
        window.addEventListener('DOMContentLoaded', setup, false);
        
        //Return 0
        
        return 0;
        
    }
    
    
    
    //Handles the setup of the page
    
    function setup () {
        
        
        
    }
    
    
    browser_check(); //Initiate the browser check immediately
    
})();
