function load_screen_cb(html) {
    parent.document.getElementById("main").innerHTML = html;
}

function load_screen(screen) {
    async_GET("screens/"+screen+".php", load_screen_cb, 0);
}

function find_images_cb(msg) {
    load_screen("main");
}

function find_images() {
    var model = parent.document.getElementById("model").value;
    if (model) {
        async_POST("lib/get_images.php", "model="+model, find_images_cb, 0);
    }
}

function show_image_cb(html) {
    var preview = parent.document.getElementById("preview");
    preview.innerHTML = html;
    preview.style.visibility = 'visible';
}

function show_image(image) {
    async_GET("lib/show_image.php?image="+image, show_image_cb, 0);
}

function close_image() {
    var preview = parent.document.getElementById("preview");
    preview.innerHTML = "";
    preview.style.visibility = 'hidden';
}

function clear_history_cb(msg) {
    load_screen("main");
}

function clear_history() {
    async_POST("lib/history.php", "func=clear", clear_history_cb, 0);
}
