/* --------------------------------------------------------
    Javascript Global Functions
    Website: Name
    Created by: Guillaume - guillaume@tearsfromthesky.com
    Filename: js/global.js
   -------------------------------------------------------- */

/* --------------------------------------------------------
    Function:     open_window()
    Description:  Opens window (popup) with a set of params
    Params:       @page_url        - string
                  @page_name       - string
                  @window_width    - numeric, no quotes
                  @window_height   - numeric, no quotes
                  @scrollbar_value - boolean, 'yes' or 'no'
                  @is_center       - boolean, 'yes' or 'no'
   -------------------------------------------------------- */

    function open_window(page_url, page_name, window_width, window_height, scrollbar_value, is_center) {
        var window_pos_x = 20;
        var window_pos_y = 20;
        if (is_center == 'yes') {
            window_pos_x = (screen.width / 2) - (window_width / 2);
            window_pos_y = (screen.height / 2) - (window_height / 2);
        }
        popup_window = this.open(page_url, page_name, "toolbar=no,status=no,menubar=no,location=no,scrollbars=" + scrollbar_value + ",resizable=no,width=" + window_width + ",height=" + window_height + ",screenX=" + window_pos_x + ",screenY=" + window_pos_y + ",left=" + window_pos_x + ",top=" + window_pos_y);
        popup_window.resizeTo(window_width + 6, window_height + 54);
        popup_window.focus();
    }

/* --------------------------------------------------------
    Function:     anti_spam_email()
    Description:  Protects email from spam bots
    Params:       @user     - string
                  @domain   - string
                  @linktext - string (not required)
   -------------------------------------------------------- */

    function anti_spam_email(user, domain, linktext) {
        var username = user;
        var hostname = domain;
        if (linktext == '') {
            linktext = username + "&#064;" + hostname;
        }
        document.write("<a href=" + "mail" + "to:" + username +"&#064;" + hostname + ">" + linktext + "</a>");
    }

/* --------------------------------------------------------
    Function:     show_hide_element()
    Description:  Shows and hides DOM element by ID
    Params:       @obj - string
   -------------------------------------------------------- */

    function show_hide_element(id){
        var my_element = document.getElementById(id);
        if (my_element.style.display == "none"){
            my_element.style.display = "block";
        } else {
            my_element.style.display = "none";
        }
    }
    
/* --------------------------------------------------------
    Function:     add_to_favorites()
    Description:  Adds page to favorites
    Params:       none
   -------------------------------------------------------- */
    
    function add_to_favorites() {
        if (navigator.appName != 'Microsoft Internet Explorer') {
            window.sidebar.addPanel("Rapartists.com - Your #1 Rap Resource on the Net",'http://www.rapartists.com/',"");
        } else {
            window.external.AddFavorite('http://www.rapartists.com/',"Rapartists.com - Your #1 Rap Resource on the Net");
        }
    }