/* --------------------------------------------------------
   Fonctions globales Javascript
   global.js
   -------------------------------------------------------- */

/*
 preload_image()
 image preloading
*/
function preload_image(image_name, image_src) {
    if (document.images) {
        eval(image_name + ' = new Image()');
        eval(image_name + '.src = "' + image_src + '"');
    }
}

/*
 change_image()
 swap images
*/
function change_image(image_name, image_src) {
    if (document.images) {
        document.images[image_name].src = image_src;
    }
}

/*
 open_window()
 opens a new pop-up window
*/
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.focus();
}

/*
 anti_spam_email()
 protects email from spam bots
*/

function anti_spam_email(user,domain) {
    var username = user;
    var hostname = domain;
    var linktext = username + "&#064;" + hostname;
    document.write("<a href=" + "mail" + "to:" + username +"&#064;" + hostname + ">" + linktext + "</a>");
}
