function redimImage(inImg, n, ImgH) { 
     objImage = new Image();
     objImage.src = inImg;
     t = ImgH;
     w = 0;
     h = 0;
    if (objImage.width < t && objImage.height < t) 
    { w = objImage.width; h = objImage.height;} 
    else if ( objImage.width > objImage.height ) { w = t; h = objImage.height / (objImage.width / t);} 
    else if ( objImage.width == objImage.height ) { w = t; h = t;} 
    else { h = t; w = objImage.width / (objImage.height / t);} 
    if (w > 0 && h > 0) { document.images[n].width = w; document.images[n].height = h;}

}

function note_photo(id_photo,note) {

    var http = getHTTPObject();
    var url = "libs/apiAjax.inc.php?action=note_photo&id_photo=" + id_photo + "&note=" + note + "&time=" + Date("mdHis") ;
    http.onreadystatechange = function() {
        var notation = document.getElementById("notation");
        var noter = document.getElementById("noter");

        if (http.readyState == 4) {
            var results = http.responseText;
            notation.innerHTML= results;
            noter.innerHTML= "<p class='txt_fonce'>Vous avez déjà noté cette photo</p>";             
        }
    } ;    
    
    http.open("GET", url , true);
    http.send(null);

}

function getHTTPObject() {
    if(window.XMLHttpRequest) {// Firefox   
        xhr = new XMLHttpRequest();   
    } else if(window.ActiveXObject) {// Internet Explorer   
        xhr = new ActiveXObject("Microsoft.XMLHTTP"); 
    } else { // XMLHttpRequest non supporté par le navigateur   
        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");   
        return   
    } 
    return xhr;
}

function view_flickr (src_img) {
    document.getElementById("masque").style.display = "block";
    document.getElementById("popin").style.display = "block";
    document.getElementById("popin").src = src_img;
    document.getElementById("popin").style.marginLeft =  -1*document.getElementById("popin").width/2; 
}

function close_flickr() {
    document.getElementById("masque").style.display = "none";
    document.getElementById("popin").style.display = "none";
}

function view_site(url) {
    w = (document.all ? screen.width : screen.width) * 0.9;
    h = (document.all ? screen.height : screen.height-100) * 0.9;
    var popup = window.open(url,"Eleveur","width=" + w + ",height=" + h + ",top=0,left=0,scrollbars=yes,toolbar=yes,location=yes,directories=yes,menubar=yes,resizable=yes,status=yes");
    if (window.event) {
        window.event.cancelBubble = true;
    } else {
        evt.stopPropagation();
    } 
}