$(document).ready(function() {
    // Check if there are any ads on the side
    if($("#sideAds *").length < 1){
        $("#adWrap").addClass("empty");
    }
    // Login inputs handling
    var $loginbox_name = $("#loginbox input#username").attr("value");
    var $loginbox_pass = $("#loginbox input#password").attr("value");
    $("#loginbox input.text").css('color', '#999');
    $("#loginbox input#username").focus(function(){
        if ( $(this).attr('value') == $loginbox_name) {
            $(this).css('color', '#333');
            $(this).attr('value', '');
        }
    });
    $("#loginbox input#password").focus(function(){
        if ( $(this).attr('value') == $loginbox_pass) {
            $(this).css('color', '#333');
            $(this).attr('value', '');
        }
    });
    $("#loginbox input#username").blur(function(){
        if ( $(this).attr('value') == '' ) {
            $(this).attr('value', $loginbox_name);
            $(this).css('color', '#999');
        }
    });
    $("#loginbox input#password").blur(function(){
        if ( $(this).attr('value') == '' ) {
            $(this).attr('value', $loginbox_pass);
            $(this).css('color', '#999');
        }
    });
    // Insert demand (1st step under the navigation) hover
    $("#intro1 h2 a").hover(
        function(){
            $("#intro1-ico").toggleClass('active');
        },
        function(){
            $("#intro1-ico").toggleClass('active');
        }
        );
    $("#intro1-ico").hover(
        function(){
            $("#intro1 h2 a").toggleClass('active');
        },
        function(){
            $("#intro1 h2 a").toggleClass('active');
        }
        );
    // Active/inactive in 2nd step of demand creation
    $("#proccess.step2 .section1 label").click(function(){
        $("#proccess.step2 .section1 label.active").removeClass("active");
        $(this).toggleClass('active');
    });
    // Acutions table hovers (currently not working)
    $(".auctions tbody tr td, .auctions tbody tr th").hover(function(){
        $(this).parent().toggleClass("active");
        $(".auctions tbody tr.active th a").addClass("active");
    },
    function () {
        $(".auctions tbody tr.active th a").removeClass("active");
        $(this).parent().toggleClass("active");
    });
    $(".auctions tbody tr.active").click(function(){
        $(".auctions tbody tr.active th a.active").click();
    });
});
