$thumb_size = $previewHeight;
    if ($ratio > 1) {
        $thumb_size = $previewWidth;
    }
}
//echo '<p>ratio: '.$ratio.'<p>';
$h_thumb = 0;
//$h_view;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    require_once "imagefunctions.php";
    //Löscht das bisherige Thumbnail
    //deleteFile($thumb_file);
    //Neues Thumb erstellen
    //echo "<p>$thumb_file<br/>w_thumb: $w_thumb, h_thumb: $h_thumb, w: ".$_POST['w'].' h: '. $_POST['h'].'<p>';
    //die();
    if (resizepic($full_file, $thumb_file, $w_thumb, $h_thumb, 0, $_POST['x'], $_POST['y'], $_POST['w'], $_POST['h'])) {
        $admin->print_success('Thumb erfolgreich geändert', WB_URL . '/modules/' . $mod_dir . '/picupload/uploadview.php?' . $p . '&fn=' . $subdir . $file_name);
    }
} else {
    echo '
	<!-- Gives the Jcrop the variable to work -->
	<script type="text/javascript">
		var relWidth = \'' . $width . '\';
		var relHeight = \'' . $height . '\';
		var thumbSize = \'' . $thumb_size . '\';
		var settingsRatio = \'' . $ratio . '\'
	</script>
		<div style="float: left; padding: 0 20px 0 20px;">
		<img src="' . $full_file_link . '" id="cropbox" style="max-width: 500px; max-height: 500px;"/>
	</div>
	<div style="float:left;" align="center">
        if (file_exists($filepath)) {
            if (!move_uploaded_file($tmp_name, $filepath)) {
                die(' <h2>Speichern fehlgeschlagen!</h2>');
            } else {
                $messages .= ' <b>thumb replaced</b>';
                return 0;
            }
        }
    }
    //---------------------------------------------------------------------------------
    if ($width > $w_zoom and $height > $h_zoom) {
        // Original behalten und dann verkleinern
        $filepath = $picture_dir . '/original/' . $imagename;
        if (!move_uploaded_file($tmp_name, $filepath)) {
            die(' <h2>Speichern fehlgeschlagen!</h2>');
        }
        $newfilepath = $picture_dir . '/zoom/' . $imagename;
        resizepic($filepath, $newfilepath, $w_zoom, $h_zoom);
        $filepath = $newfilepath;
    } else {
        //nur verschieben
        $filepath = $picture_dir . '/zoom/' . $imagename;
        if (!move_uploaded_file($tmp_name, $filepath)) {
            die(' <h2>Speichern fehlgeschlagen!</h2>');
        }
    }
    $newfilepath = $picture_dir . '/' . $imagename;
    resizepic($filepath, $newfilepath, $w_view, $h_view);
    $newfilepath = $picture_dir . '/thumbs/' . $imagename;
    resizepic($filepath, $newfilepath, $w_thumb, $h_thumb);
}