$(document).ready(function(){
    /* textfield input onFocus */
    $('.textfield input').focus(function() {
        $(this).parent().addClass("active");
    });
    $('.textfield input').blur(function() {
        $(this).parent().removeClass("active");
    });
});

/* maybe for future use - RM
function show_message(id, msg) {
    var e = $(id);
    e.html(msg).show();
    setTimeout(
        function(){
            e.fadeOut("slow")
        },
        2000
    )
}
*/

// this is for the popup select style which is used for language selection on home page
// based on: http://css-tricks.com/snippets/jquery/styled-popup-menu/
(function($){
    $.fn.styleddropdown = function(){
        return this.each(function(){
            var obj = $(this);
            obj.find('.list_link').click(function() { //onclick event, 'list' fadein
                obj.find('.list').fadeIn(400);

                $(document).keyup(function(event) { //keypress event, fadeout on 'escape'
                    if(event.keyCode == 27) {
                        obj.find('.list').fadeOut(400);
                    }
                });

                obj.find('.list').hover(function(){ },
                    function(){
                        $(this).fadeOut(400);
                });
                return false;
            });

            obj.find('.list li').click(function() { //onclick event, fadeout 'list'
                var href = $(this).find('a').attr("href");
                if (href) {
                    window.location.href = href;
                } else {
                    // do something with the selected value - alert( $(this).html() );
                    obj.find('.list').fadeOut(400);
                }
                return false;
            });
        });
    };
    $.fn.textfill = function(options) {
        var defaults = {
            maxFontPixels: 40,
            innerTag: 'span'
        };
        var Opts = jQuery.extend(defaults, options);
        return this.each(function() {
            var fontSize = Opts.maxFontPixels;
            var ourText = $(Opts.innerTag + ':visible:first', this);
            var maxHeight = $(this).height();
            var maxWidth = $(this).width();
            var textHeight;
            var textWidth;
            do {
                ourText.css('font-size', fontSize);
                textHeight = ourText.height();
                textWidth = ourText.width();
                fontSize = fontSize - 1;
            } while ((textHeight > maxHeight || textWidth > maxWidth) && fontSize > 3);
        });
    };
})(jQuery);
function goToByScroll(id){
    $('html,body').animate({scrollTop: $("#"+id).offset().top}, 500);
}

