/**
 * Created by mFramework.
 * User: Mauro
 * Date: 10/05/11
 * Time: 12:43
 */
var VASAVA = VASAVA || {};

VASAVA.typeLoading = function( type ) {
    $('#loading').removeClass('small').removeClass('all');
    $('#loading').addClass(type);
};

VASAVA.headerFixed = function() {
    var logoWidth = $('.logo a').width();
    var logoHeight = $('.logo a').height();
    $('#header_fixed .logo').click(VASAVA.toTop);
    $(window).scroll(function(){
        if($(window).scrollTop()>=100)
        {
            $('#header_fixed').show();
        }
        else
        {
            var value = -($(window).scrollTop()*(0.1))*6
            var width = value+logoWidth;
            var height = (width*logoHeight)/logoWidth;

            $('.logo a').stop().animate({
                width: width,
                height: height,
                marginTop: -(value)*1.5
            },100);
            $('#header_fixed').hide();
        }
    });
};

VASAVA.scrollToTop = function(el) {
    $("#toTop").removeAttr("href");
    if($(window).scrollTop()!="0"){
        $("#toTop").stop().animate({right: "0"},'normal');
    }
    var scrollDiv=el;
    $(window).scroll(function(){
        if($(window).scrollTop()=="0"){
            scrollDiv.stop().animate({right: "-48px"},'normal');
        }else{
            scrollDiv.stop().animate({right: "0"},'normal');
        }
    });
    el.click(VASAVA.toTop);
}

VASAVA.toTop = function() { $("html, body").animate({scrollTop:0},"slow"); return false;}

VASAVA.backTo = function(el) {
    el.click(function(){
        history.back();
        return false;
    });
}

jQuery(document).ready(function() {
    VASAVA.scrollToTop($('#toTop'));
    VASAVA.backTo($("#back"));
    VASAVA.headerFixed();
});
