function endcrop(coords, dimensions) {
    //    alert("@"+coords.x1+","+coords.y1+": "+dimensions.width+"x"+dimensions.height);
    $('x1').value = coords.x1;
    $('y1').value = coords.y1;
    $('x2').value = coords.x2;
    $('y2').value = coords.y2;
    $('w').value = dimensions.width;
    $('h').value = dimensions.height;
}

function findpic(t) {
    new Ajax.Updater('pic'+t, '/admin/pictool.php?op=find&t='+t);
}

function selectpic(t, i) {
    $('pic'+t).innerHTML = '<input type="hidden" name="'+t+'" id="'+t+'" value="'+i+'"/><div style="clickable" onclick="findpic(\''+t+'\')"><img src="/files/pic'+i+'tn.jpg">Click to replace</div>';
}

function replacead(c) {
    new Ajax.Updater('adiv'+c, '/admin/adtool.php?op=replace&c='+c);
}

function removead(c,i) {
    var p = $F('page');
    new Ajax.Updater('adiv'+c, '/admin/adtool.php?op=remove&c='+c+'&i='+i+'&p='+p);
}

function selectad(c,i) {
    var p = $F('page');
    new Ajax.Updater('adiv'+c, '/admin/adtool.php?op=select&c='+c+'&i='+i+'&p='+p);
}

function insertad() {
    var c = $F('adcount');
    $('adcount').value = c+1;
    new Ajax.Updater('adiv', '/admin/adtool.php?op=insert&c='+c, {insertion:Insertion.Bottom});
}

