$(document).ready(function(){

    if( !navigator.geolocation && $("#geolocation"))
    {
        $("#geolocation").hide();
    }
    
    if( $('#original_avatar').length > 0 )
    {
        $('#original_avatar').Jcrop({
            bgColor: 'green',
            sideHandles: false,
            onChange: update_crop,
            onSelect: update_crop
        });
    }

    if( $('.tag_input').length > 0){
        $('.tag_input').tag({
            dataseperator : ',',
            unique : true,
            addOnEnter : true,
            style : {
                list : 'taglist',
                item : 'tag',
                input : 'input',
                remove : 'delete'
            }
        });
    }
    
    if($('.slider').length > 0){
        $('.slider').cycle({
            fx: 'scrollLeft', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
            timeout: 7000,
            speed: 1400
        });
    }

});

function update_crop(coords) {
    var rx = 100/coords.w;
    var ry = 100/coords.h;

    $("#crop_x").val(Math.round(coords.x));
    $("#crop_y").val(Math.round(coords.y));
    $("#crop_w").val(Math.round(coords.w));
    $("#crop_h").val(Math.round(coords.h));
}

function archive_edit(id){
    if($("#archive_edit_"+id).attr('rel') == 'used')
    {
        $("#archive_edit_"+id).attr('rel', '');
        $("#archive_edit_"+id).slideUp(1000);
    }
    else
    {
        $("#archive_edit_"+id).attr('rel', 'used');
        $("#archive_edit_"+id).slideDown(1000);
    }
}

