/**
 * Main Grooveshark Script
 */
(function(){
    var gs = window.gs = {
        
        /* Global Variables */
        
        // logging variables
        DEBUG: true,
       
        // url info
        rootUrl : location.protocol + "//" + location.host,
        pageUrl : location.protocol + "//" + location.host + location.pathname,
        scriptUrl : location.href,
        
        lbFactory: null
    };
    
    // shortcuts
    gs.debug = (top.debug) ? top.debug : function(){};

    // get lightbox factory
    if(typeof window.ModalBoxFactory=='function') {
        gs.lbFactory = new ModalBoxFactory();
    }
     
    /**
     * Standardized show event for all modal boxes
     */
    gs.modal_show = function(hash) {
        hash.w.show();
    }
    
    /**
     * Standardized hide event for all modal boxes
     */
    gs.modal_hide = function(hash) {
        hash.o.remove();
        hash.w.hide();
    }
    
    gs.copy = function(inElement) {
        if (!$.browser.opera && inElement.createTextRange) {
            var range = inElement.createTextRange();
            if (range && range.execCommand) {
                range.execCommand("Copy");
                //range.execCommand("copy");
            }
        } else {
            var flashcopier = "flashcopier";
            if (!document.getElementById(flashcopier)) {
                var divholder = document.createElement("div");
                divholder.id = flashcopier;
                document.body.appendChild(divholder);
            }
            document.getElementById(flashcopier).innerHTML = "";
            var flashPath = (gs.staticPath) ? gs.staticPath+'flash/clipboard.swf' : '/_clipboard.swf';
            var divinfo = "<embed src='"+flashPath+"' FlashVars='clipboard=" + escape(inElement.value) + "' width='1' height='1' type='application/x-shockwave-flash'></embed>";
            document.getElementById(flashcopier).innerHTML = divinfo;
        }
    }

    gs.refreshPage = function() {
        location.hash = "";
        location.href = location.href + " ";
    }
    
    $(document).ready(function() {
    });

})();
