window.onunload = function() {
    setTimeout(function(){
        location.href = location.href;
    }, 100);
    //location.href = location.href;
}
var _ie = false;
var _app = navigator.appVersion;
if(navigator.userAgent.indexOf('MSIE') > -1) {
    if(_app.indexOf('MSIE 6.0') > - 1|| _app.indexOf('MSIE 7.0') > - 1 || _app.indexOf('MSIE 8.0') > - 1) {
        _ie = true;
    } else {
        _ie = false;
    }
} else {
    _ie = false;
}
jQuery(document).ready(function() {
    var _preLoadImg = {};
    jQuery('img.over').each(function(){
        var _imgSrc = this.src;
        var _sep = _imgSrc.lastIndexOf('.');
        var _onSrc = _imgSrc.substr(0, _sep) + '_ovr' + _imgSrc.substr(_sep, 4);
        _preLoadImg[_imgSrc] = new Image();
        _preLoadImg[_imgSrc].src = _onSrc;
        jQuery(this).hover(
            function(){this.src = _onSrc},
            function(){this.src = _imgSrc}
            );
    });
    jQuery('img.rollover').bind('mouseover', onOver).bind('mouseout', onOut);
    if(_ie) {
        jQuery('img.pngRollover').fixPng();
        jQuery('img.pngRollover').parent()
            .bind('mouseover', pngOver)
            .bind('mouseout', pngOut)
            .css('cursor', 'pointer');
    } else {
        jQuery('img.pngRollover').bind('mouseover', pngOver)
            .bind('mouseout', pngOut);
    }
    
    jQuery('a[href*=#]').click(function(){
        if(location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                jQuery('html,body').animate({scrollTop: targetOffset},
                                            500, 'quart');
                return false;
            }
        }
    });
});

function onOver() {
    jQuery(this).css('opacity', .5);
}

function onOut() {
    jQuery(this).css('opacity', 1);
}

function pngOver() {
    if(_ie) {
        jQuery(this).find('img').css('opacity', .5);
    } else {
        jQuery(this).css('opacity', .5);
    }
}

function pngOut() {
    if(_ie) {
        jQuery(this).find('img').css('opacity', 1);
    } else {
        jQuery(this).css('opacity', 1);
    }
}


jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t = t / d - 1) * t * t * t - 1) + b;
};
