jQuery.fn.topLink = function (settings) {
    settings = jQuery.extend({
        min: 1,
        fadeSpeed: 200
    }, settings);
    return this.each(function () {
        //listen for scroll
        var el = $(this);
        el.hide(); //in case the user forgot
        $(window).scroll(function () {
            if ($(window).scrollTop() >= settings.min) {
                el.fadeIn(settings.fadeSpeed);
            }
            else {
                el.fadeOut(settings.fadeSpeed);
            }
        });
    });
};

//usage w/ smoothscroll
$(document).ready(function () {
    if (!IsIE7()) {
        //set the link
        $('#top-link').topLink({
            min: 400,
            fadeSpeed: 500
        });
        //smoothscroll
        $('#top-link').click(function (e) {
            e.preventDefault();
            $.scrollTo(0, 300);
        });
    
    }
    
});


function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}
function IsIE7() {

    var ver = getInternetExplorerVersion();

    if (ver > -1) {
        if (ver == 7.0)
            return true;
        else
            return false;
    }

    else {
        return false;
    }
}

/*$(document).ready(function () {

    $("img.fade").hover(
function () {
    $(this).stop().animate({ "opacity": "0" }, "slow");
},
function () {
    $(this).stop().animate({ "opacity": "1" }, "slow");
});

});*/


jQuery.fn.dwFadingLinks = function (settings) {
    settings = jQuery.extend({
        color: '#457c18',
        duration: 500
    }, settings);
    return this.each(function () {
        var original = $(this).css('color');
        $(this).mouseover(function () { $(this).animate({ color: settings.color }, settings.duration); });
        $(this).mouseout(function () { $(this).animate({ color: original }, settings.duration); });
    });
};

/* usage */
$(document).ready(function () {
    $('.fade').dwFadingLinks({
        color: '#457c18',
        duration: 700
    });
});

$(document).ready(function () {
    $('.navhead').dwFadingLinks({
        color: '#8ECA5E',
        duration: 700
    });
});

