// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults


function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}


// $(document).ready(function() {
//     equalHeight($("#about-left"));
//     equalHeight($("#about-right"));
// });

function set_crop(img, selection){
    $('#crop_left').val(selection.x1)
    $('#crop_top').val(selection.y1)
    $('#crop_width').val(selection.width)
    $('#crop_height').val(selection.height)
    preview_image(img, selection);
}
function preview_image(img, selection)
{
  var scaleX = 320 / selection.width;
  var scaleY = 480 / selection.height;
  $('#image_preview + div > img').css({
    width: Math.round(scaleX * $('#image_preview').width()) + 'px',
    height: Math.round(scaleY * $('#image_preview').height()) + 'px',
    marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
    marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
  });
}
function setup_preview_image(src)
{
  $('<div><img src="' + src + '" style="position: relative;" /></div>').css({ float: 'left', position: 'relative', overflow: 'hidden', width: '320px', height: '480px' }) .insertAfter($('#image_preview'));
}  

$(window).load(function()  
{ 
    $('.rounded').corners("20px transparent");
});