/* --------------------------------------------------------
    Javascript Global Functions
    Website: Zone Maison
    Created by: Guillaume - guillaume@falzhobel.ca
    Filename: js/global.js
   -------------------------------------------------------- */

$j = jQuery;

/* --------------------------------------------------------
    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:     onload() event
    Description:  Function that will start onload of the page
    Params:       -
   -------------------------------------------------------- */
   
window.onload = function() {
    jQuery('#main_search_field').focus();
}
    
    
