stringToNumber = function(str) {
    num = str.replace(',','.');
    return Number(num);
}

checkMail = function (mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){
            return true;
        }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
            return true;
        }
    }else{
        return false;
    }
}



updateCoords = function(c) {
    $('#x').val(c.x);
    $('#y').val(c.y);
    $('#w').val(c.w);
    $('#h').val(c.h);
}

showPreview = function(coords) {
    if (parseInt(coords.w) > 0) {
        //        var rx = 128 / coords.w;
        //        var ry = 149 / coords.h;
        //
        //        jQuery('#preview').css({
        //            width: Math.round(rx * <?php echo $arquivo->getWidth();?>) + 'px',
        //            height: Math.round(ry * <?php echo $arquivo->getHeight();?>) + 'px',
        //            marginLeft: '-' + Math.round(rx * coords.x) + 'px',
        //            marginTop: '-' + Math.round(ry * coords.y) + 'px'
        //        });
        updateCoords(coords);

    }
}
