
$(function() {
    $('.progressbar').progressbar();
    $('.convert').hide();
    $('.status .filename').hide();
    $('.status .download-btn').hide();
    
    $('.convert-btn').click(function() {
        return false;
    });

    $('.animated-btn').hover(function() {
        $(this).children(':eq(1)').fadeOut();
    }, function() {
        $(this).children(':eq(1)').fadeIn();
    });

    $('.animated-btn').mousedown(function() {
        $(this).find('a, input').addClass('btn-down');
    });

    $('.animated-btn').mouseup(function() {
        $(this).find('a, input').removeClass('btn-down');
    });

    $('.blink')
		.focus(function() {
		    if ($(this).val() == $(this).attr('title')) {
		        $(this).val('');
		    }
		})
		.blur(function() {
		    if ($(this).val() == '') {
		        $(this).val($(this).attr('title'));
		    }
		});
});

var intervalID;
var percent = 0;

function StartConvert() {
    intervalID = setInterval(function() {
       
        percent++;
        if (percent <= 100) {
            UpdateProgressBar();
        } else {
            StopConvert();
        }
    }, 100); 
}

function StopConvert() {
    clearInterval(intervalID);
}

function UpdateProgressBar() {
    $('.progressbar').progressbar('value', percent);
    $('.percents p').text(percent + '%');
}

function UpdateProgressBar2(percent) {
    $('.progressbar').progressbar('value', percent);
    $('.percents p').text(percent + '%');
    if (percent == 100) {
        StopConvert();
    }
}

function UpdateStatusMessage(message) {
    $('.status p').html('<span>Status:</span> ' + message);
}

function ShowControls() {
    $('.status .filename').show();
    $('.status .download-btn').show();
}

function HideControls() {
    if ($('.convert').is(":hidden")) {
        $('.convert').slideToggle("slow");
    }

    $('.status p').html('<span>Status:</span> Analyzing');
    $('.status .filename').hide();
    $('.status .download-btn').hide();
}

function scrollWin() {
    $('html, body').animate({
        scrollTop: $("#head").offset().top
    }, 2000);
}
