common_class = function() {

    $('li.products').mouseover(function() {
        $(this).addClass('showDropdown');
        $("#productsDropdown").show();
    });

    $('li.content').mouseover(function() {
        $(this).addClass('showDropdown');
        $("#contentDropdown").show();
    });

    var self = this;
    
    $(window).bind('resize', function() {
        self.positionFooter();
    });

    this.positionFooter();
}

common_class.prototype.positionFooter = function() {
    var windowHeight = $(window).height();
    var windowWidth = $(window).width();
    var wrapperHeight = $('.wrapper').height();

    if (wrapperHeight < (windowHeight - 111)) {
        var footerWidth = $('.footer').width();
        var footerLeft = ((windowWidth - footerWidth) / 2) - 16;
        $('.footer').css({ 'position': 'absolute', 'bottom': '0', 'left': footerLeft });
    }
    else {
        $('.footer').css({ 'position': 'relative', 'bottom': 'auto', 'left': 'auto' });
    }
    $('.footer').css({ 'display': 'block' });
}

common_class.prototype.showAjaxLoader = function(el) {
    $(el).css("opacity", ".25");
    $(el).css("filter", "alpha(opacity=25)");

    var top = $(el).attr("offsetTop") + ($(el).height() / 2) - 40;
    var left = $(el).attr("offsetLeft") + ($(el).width() / 2) - 20;

    $("#ajax-loader").css("top", top + "px");
    $("#ajax-loader").css("left", left + "px");
    $("#ajax-loader").show();
}

common_class.prototype.hideAjaxLoader = function(el) {
    $("#ajax-loader").hide();
    $(el).css("filter", "alpha(opacity=100)");
    $(el).css("opacity", "1.0");
}

$(document).ready(function() {

    common = new common_class();

    $(document.body).mouseover(function(event) {
    var mouseover = $(event.target);
                
        if (!mouseover.is('li.products, li.products a, ul') && !mouseover.is('#productsDropdown, #productsDropdown li, #productsDropdown li a')) {
            $('#productsDropdown').hide();
            $('li.products').removeClass('showDropdown');
        }

        if (!mouseover.is('li.content, li.content a, ul') && !mouseover.is('#contentDropdown, #contentDropdown li, #contentDropdown li a')) {
            $('#contentDropdown').hide();
            $('li.content').removeClass('showDropdown');
        }
    });

});

function log(logwhat) {
    console.log(logwhat);
}