function ep_settings() {
}

ep_settings.prototype.id;
ep_settings.prototype.url;
ep_settings.instance = null;

ep_settings.getInstance = function() {
    if (this.instance == null) {
        this.instance = new ep_settings();
    }
    return this.instance;
}
function updatePage(step) {
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: ep_settings.getInstance().url + "/GetJqPage",
        data: "{id :" + ep_settings.getInstance().id + ", pagetypename : " +
            "'" + step + "'}",
        dataType: "json",
        success: function(result) {
            $("#result").html(result.d);
            updatePageLinks();
        }
    });
    if (step == 'second') {
        $('#mountain1-zoom').css({ backgroundPosition: '50px 101px' });
        $('#ground-zoom').css({ backgroundPosition: '0 127px' });
        $('#tree-zoom').css({ backgroundPosition: '940px 0' });
        $('#way-sign').css({ backgroundPosition: '950px 82px' });
        setTimeout('beginAnimation2()', 1500);
    }
    else if (step == 'third') {
    $('#mountain1-zoom').css({ backgroundPosition: '50px 101px' });
    $('#ground-zoom').css({ backgroundPosition: '0 127px' });
    $('#tree-zoom').css({ backgroundPosition: '940px 0' });
    $('#way-sign').css({ backgroundPosition: '950px 82px' });
    setTimeout('skipAnimation()', 1500);
    }
    else if (step == 'first') {
        $('#mountain').css({ backgroundPosition: '858px -173px' });
        $('#ground').css({ backgroundPosition: '0px 0px' });
        $('#tree').css({ backgroundPosition: '778px 103px' });
        setTimeout('beginAnimation()', 1500);
    }
}
function fadeout(element) {
    // OPACITY OF BUTTON SET TO 30%
    $(element).animate({
            opacity: 0.3
        }, "slow");
}
function replaceLinkWithHash(link) {
    $(link).attr('href', $(link).attr('href').replace("?", "#"));
}

function updatePageLinks() {
    $("#navigation").find("a").each(function() {
        replaceLinkWithHash(this);
    });
}
function hashChanged(hash) {
    if (hash != "")
        updatePage(hash.split('=')[1]);
}

function beginAnimation() {
    $('#loader').fadeOut(500);
    $('#navigation').fadeIn(500);
    $('#wrapper').fadeIn(500);
    $('#mountain').animate({ backgroundPosition: '(243px -173px)' }, 5000);
    $('#ground').animate({ backgroundPosition: '(-300px 0px)' }, 5000);
    $('#tree').animate({ backgroundPosition: '(496px 103px)' }, 5000);
}
function beginAnimation2() {
    $('#loader').fadeOut(500);
    $('#navigation').fadeIn(500);
    $('#wrapper').fadeIn(500);
    $('#mountain1-zoom').animate({ backgroundPosition: '(50px 101px)' }, 5000);
    $('#ground-zoom').animate({ backgroundPosition: '(-324px 127px)' }, 5000);
    $('#tree-zoom').animate({ backgroundPosition: '(439px 0)' }, 5000);
    $('#way-sign').animate({ backgroundPosition: '(751px 82px)' }, 5000);
    setTimeout("swapImage2()", 5100);
}
function swapImage2() {
    $('#wrapper').hide();
    $('#full-image').show();

    $("#full-image-arrow-1").hover(
        function() {
            $(this).addClass('arrow-1-on');
        },
        function() {
            $(this).removeClass('arrow-1-on');
        }
    );
    $("#full-image-arrow-2").hover(
        function() {
            $(this).addClass('arrow-2-on');
        },
        function() {
            $(this).removeClass('arrow-2-on');
        }
    );
    $("#full-image-arrow-3").hover(
        function() {
            $(this).addClass('arrow-3-on');
        },
        function() {
            $(this).removeClass('arrow-3-on');
        }
    );
}
function skipAnimation() {
    $('#wrapper').hide();
    $('#full-image').fadeIn(500);
    $("#full-image-arrow-1").hover(
        function() {
            $(this).addClass('arrow-1-on');
        },
        function() {
            $(this).removeClass('arrow-1-on');
        }
    );
    $("#full-image-arrow-2").hover(
        function() {
            $(this).addClass('arrow-2-on');
        },
        function() {
            $(this).removeClass('arrow-2-on');
        }
    );
    $("#full-image-arrow-3").hover(
        function() {
            $(this).addClass('arrow-3-on');
        },
        function() {
            $(this).removeClass('arrow-3-on');
        }
    );
}
$(document).ready(function() {
    updatePageLinks();
    $.history.init(hashChanged);
    $('#mountain').css({ backgroundPosition: '858px -173px' });
    $('#ground').css({ backgroundPosition: '0px 0px' });
    $('#tree').css({ backgroundPosition: '778px 103px' });
    setTimeout("beginAnimation()", 1500);   
});
