
// 

function imagePopup (src, name, features) {
    win = window.open ('', '', features);
    win.focus();
    win.document.write ("<html><head><title>"+name+"</title></head><body style=\"margin:0\"><img src=\""+src+"\" onclick=\"self.close();\"/></body></html>");
    win.document.close();
}

// comments

function sendComment (msg_alert1, msg_alert2) {
    var form = document.getElementById("comments");
    var author = $("#author").val();
    var text = $("#text").val();
    var email = $("#email").val();

    // json remote_ip fct...
    form.contest.value = hex_md5(form.contest.value);

    if (trim (email)) {
        if ( !emailOk (email)) {
            alert (msg_alert1);
            return false;
        }
    }
    if (!trim (author) || !trim (text)) {
        window.alert(msg_alert2);
        return false;
    }
    return true;
}

function trim (field) {
    field = field.replace( /^\s+/, "");
    field = field.replace( /\s+$/, "");
    if (field.length == 0) {
        return false;
    }
    return true;
}

function emailOk (email) {
    var regexp_email = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.?$/;
    email = email.replace( /^\s+/, "");
    email = email.replace( /\s+$/, "");
    if (!regexp_email.test (email)) {
        return false;
    }
    return true;
}


$(document).ready(function() {

    $('.tooltip').Tooltip({
         delay: 0,
         track: true
    });

    $('.imageTooltip').Tooltip({
         delay: 0,
         track: true,
         loadURL: true
    });
  
});
