function extractDomain(url) {
    var domain;
    //find & remove protocol (http, ftp, etc.) and get domain
    if (url.indexOf("://") > -1) {
        domain = url.split('/')[2];
    } else {
        domain = url.split('/')[0];
    }
    domain = domain.split(':')[0];
    return domain;
}

function genpass() {
    url = document.getElementById("url").value;
    url = extractDomain(url);
    maxchars = document.getElementById("maxchars").value;
    maxchars = parseInt(maxchars, 10);
    if (!(maxchars > 0)) maxchars = 512;
    salt = document.getElementById("salt").value;
    line = any_sha512(salt + url, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
    document.getElementById("resAlNum").value = line.substr(0, maxchars);
    line = any_sha512(salt + url, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,;:!?./*+§#{([-|_@)]=}");
    document.getElementById("resAlNumSpe").value = line.substr(0, maxchars);
    delete line

    url = "";
    salt = "";
    return false;
}

$(document).ready(function () {
    console.log("ready!");
//material contact form animation
    var floatingField = $('.material-form .floating-field').find('.form-control');
    var formItem = $('.material-form .input-block').find('.form-control');

//##case 1 for default style
//on focus
    formItem.focus(function () {
        $(this).parent('.input-block').addClass('focus');
    });
//removing focusing
    formItem.blur(function () {
        $(this).parent('.input-block').removeClass('focus');
    });

//##case 2 for floating style
//initiating field
    floatingField.each(function () {
        var targetItem = $(this).parent();
        if ($(this).val()) {
            $(targetItem).addClass('has-value');
        }
    });

//on typing
    floatingField.blur(function () {
        $(this).parent('.input-block').removeClass('focus');
        //if value is not exists
        if ($(this).val().length == 0) {
            $(this).parent('.input-block').removeClass('has-value');
        } else {
            $(this).parent('.input-block').addClass('has-value');
        }
    });

//dropdown list
    $('body').click(function () {
        if ($('.custom-select .drop-down-list').is(':visible')) {
            $('.custom-select').parent().removeClass('focus');
        }
        $('.custom-select .drop-down-list:visible').slideUp();
    });
    $('.custom-select .active-list').click(function () {
        $(this).parent().parent().addClass('focus');
        $(this).parent().find('.drop-down-list').stop(true, true).delay(10).slideToggle(300);
    });
    $('.custom-select .drop-down-list li').click(function () {
        var listParent = $(this).parent().parent();
        //listParent.find('.active-list').trigger("click");
        listParent.parent('.select-block').removeClass('focus').addClass('added');
        listParent.find('.active-list').text($(this).text());
        listParent.find('input.list-field').attr('value', $(this).text());
    });


});