var marked_row = new Array;

function markAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                    rows[i].className += ' marked';
                    marked_row[unique_id] = true;
                }
            }
        }
    }

    return true;
}


function unmarkAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;
            rows[i].className = rows[i].className.replace(' marked', '');
            marked_row[unique_id] = false;
        }
    }

    return true;
}


function openRoom(room){
    if (!room) room = id;
    mosaic_refresh_mode = false;
    lien = document.createElement("a");
	lien.href = "/open_room/"+room;
	lien.className = 'resizespeed_5 blocksize_700x525';
	
    initModalbox();
    myModalbox = new Modalbox(); 
    myModalbox.start(lien); 
}

function openMedia(id_media){
    mosaic_refresh_mode = false;
    lien = document.createElement("a");
	lien.href = "/open_media/"+id_media;
	lien.className = 'resizespeed_5 blocksize_395x300';
	
	//initModalbox();
    myModalbox = new Modalbox(); 
    myModalbox.start(lien); 
}


function openFichier(fichier,type){
    mosaic_refresh_mode = false;
    lien = document.createElement("a");
	lien.href = "/media/openFichier?fichier="+fichier+"&type="+type;
	lien.className = 'resizespeed_5 blocksize_390x300';
	
    myModalbox = new Modalbox(); 
    myModalbox.start(lien); 
}

function openWindow(url,nom,w,h){
        x = (screen.width-w)/2;
        y = (screen.height-h)/2;
        window.open(url,nom, "left="+x+",top="+y+", height="+h+",width="+w+",status=no,toolbar=no,menubar=no,location=no, resizable=yes,scrollbars=yes");
}

