function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }

    return vars;
}

$(document).ready(function() {

    var clients_scrollbox = $("#cooperation .scrollbox").scrollbox({
        'autoplay': true,
        'slideshow': false,
        'fading': true,
        'animate': false
    })
    
//     if( getUrlVars()['test'] ) { alert($("#content").height()); alert($(window).height()) }
    if($("#content").height() < $(window).height()) {
		if($("body").hasClass('note-page')) { } else {
            if($(window).height() > 700) {
                $("#content").css({'height': $(window).height() - 50 + 'px'})
            } else {
                $("#content").css({'height': 700 + 'px'})
            }
		}
    }
    if($(".content-body").height() < $(window).height()) {
		if($("body").hasClass('note-page')) { } else {
            if($(window).height() > 700) {
                $(".content-body").css({'height': $(window).height() - 50 + 'px'})
            } else {
                $(".content-body").css({'height': 700 + 'px'})
            }
		}
    }
    
    $(window).resize(function() {
        if($("#content").height() <= ($(window).height() - 50)) {
            $("#content").css({'height': $(window).height() - 50 + 'px'})
            $(".content-body").css({'height': $(window).height() - 50 + 'px'})
        }
    })
    
    $("#nav ul ul:not(.selected)").hide()
    $(".nav-header")
        .css({'cursor': 'pointer'})
        .click(function() {
            var visible = false
            if($(this).parent().find("ul").hasClass('selected')) {
                visible = true
            }
            $(".nav-header").removeClass('selected')
            $("#nav ul ul.selected")
                .removeClass('selected')
                .slideUp(500)
            if(!(visible)) {
                $(this).addClass('selected')
                $(this).parent().find("ul")
                    .addClass('selected')
                    .slideDown(500)
            }
        })

    $("#search-form input")
        .focus(function() {
            $(this).parent().find("label").hide()
            $(this).css({'width': '100px'})
        })
        .blur(function() {
            $(this).parent().find("label").show()
            $(this).css({'width': '60px'})
        })

            $(".share-box").hide()
            $(".share input").focus(function() {
                $(this).select()
            })
            $(".share-link")
                .css({'cursor': 'pointer'})
                .toggle(function() {
                    $(this).parent().find(".share-box").slideDown(500, function(callback) {
                        $(this).parent().find("input").focus()
                    })
                }, function() {
                    $(this).parent().find(".share-box").slideUp(500)
                })

})

