﻿

function displayAjaxLoader() {
    $('#ajaxLoaderBackground').addClass('active');
    $('#loadingGif').show();

}
function hideAjaxLoader() {
    $('#ajaxLoaderBackground').removeClass('active');
    $('#loadingGif').hide();
}

function navigateToHome() {
    displayAjaxLoader();

    var d = new Date();
    var rndNum = d.getMilliseconds().toString();

    $("#ajaxContainer").load("http://" + window.location.hostname + "/Home/Index?rnd=" + rndNum + " .ajaxContent", function (response, status, xhr) {

        hideAjaxLoader();
        if (status == "error") {
            //alert("Sorry but there was an error: ");
            window.location = "http://" + window.location.hostname + "/Home/Index?rnd=" + rndNum;
        }
    });
}
function navigateToJHGallery() {
    displayAjaxLoader();

    var d = new Date();
    var rndNum = d.getMilliseconds().toString();

    $("#ajaxContainer").load("http://" + window.location.hostname + "/JHGallery/Index?rnd=" + rndNum + " .ajaxContent", function (response, status, xhr) {

        hideAjaxLoader();
        if (status == "error") {
            //alert("Sorry but there was an error: ");
            window.location = "http://" + window.location.hostname + "/JHGallery/Index?rnd=" + rndNum;
        } else {
            JHGalleryREBIND();

        }
    });
}
function navigateToFanGallery() {
    displayAjaxLoader();

    var d = new Date();
    var rndNum = d.getMilliseconds().toString();

    $("#ajaxContainer").load("http://" + window.location.hostname + "/FanGallery/Index?rnd=" + rndNum + " .ajaxContent", function (response, status, xhr) {

        hideAjaxLoader();
        if (status == "error") {
            //alert("Sorry but there was an error: ");
            window.location = "http://" + window.location.hostname + "/FanGallery/Index?rnd=" + rndNum;
        } else {
            FanGalleryREBIND();
        }
    });
}
function navigateToBlog() {
    displayAjaxLoader();

    var d = new Date();
    var rndNum = d.getMilliseconds().toString();

    $("#ajaxContainer").load("http://" + window.location.hostname + "/Blog/Index?rnd=" + rndNum + " .ajaxContent", function (response, status, xhr) {

        hideAjaxLoader();
        if (status == "error") {
            //alert("Sorry but there was an error: ");
            window.location = "http://" + window.location.hostname + "/Blog/Index?rnd=" + rndNum;
        }
    });
}
function navigateToSpeakUp() {
    displayAjaxLoader();

    var d = new Date();
    var rndNum = d.getMilliseconds().toString();

    $("#ajaxContainer").load("http://" + window.location.hostname + "/SpeakUp/Index?rnd=" + rndNum + " .ajaxContent", function (response, status, xhr) {
        hideAjaxLoader();
        if (status == "error") {
            //alert("Sorry but there was an error: ");
            window.location = "http://" + window.location.hostname + "/SpeakUp/Index?rnd=" + rndNum;
        } else {
            SpeakUpREBIND();
        }
    });
}
function navigateToTour() {
    displayAjaxLoader();

    var d = new Date();
    var rndNum = d.getMilliseconds().toString();

    $("#ajaxContainer").load("http://" + window.location.hostname + "/Tour/Index?rnd=" + rndNum + " .ajaxContent", function (response, status, xhr) {

        hideAjaxLoader();
        if (status == "error") {
            //alert("Sorry but there was an error: ");
            window.location = "http://" + window.location.hostname + "/Tour/Index?rnd=" + rndNum;
        } else {
            TourReBind();
        }
    });
}
function navigateToContact() {
    displayAjaxLoader();

    var d = new Date();
    var rndNum = d.getMilliseconds().toString();

    $("#ajaxContainer").load("http://" + window.location.hostname + "/Contact/Index?rnd=" + rndNum + " .ajaxContent", function (response, status, xhr) {

        hideAjaxLoader();
        if (status == "error") {
            //alert("Sorry but there was an error: ");
            window.location = "http://" + window.location.hostname + "/Contact/Index?rnd=" + rndNum;
        }
    });
}
function navigateToDiscography() {
    displayAjaxLoader();

    var d = new Date();
    var rndNum = d.getMilliseconds().toString();

    $("#ajaxContainer").load("http://" + window.location.hostname + "/Discography/Index?rnd=" + rndNum + " .ajaxContent", function (response, status, xhr) {

        hideAjaxLoader();
        if (status == "error") {
            //alert("Sorry but there was an error: ");
            window.location = "http://" + window.location.hostname + "/Discography/Index?rnd=" + rndNum;
        } else {
            DiscographyReBind();
        }
    });
}
function navigateToVideos() {
    displayAjaxLoader();

    var d = new Date();
    var rndNum = d.getMilliseconds().toString();

    $("#ajaxContainer").load("http://" + window.location.hostname + "/Videos/Index?rnd=" + rndNum + " .ajaxContent", function (response, status, xhr) {

        hideAjaxLoader();
        if (status == "error") {
            //alert("Sorry but there was an error: ");
            window.location = "http://" + window.location.hostname + "/Videos/Index?rnd=" + rndNum;
        }
    });
}
function navigateToStore() {
    displayAjaxLoader();

    var d = new Date();
    var rndNum = d.getMilliseconds().toString();

    $("#ajaxContainer").load("http://" + window.location.hostname + "/Store/Index?rnd=" + rndNum + " .ajaxContent", function (response, status, xhr) {

        hideAjaxLoader();
        if (status == "error") {
            //alert("Sorry but there was an error: ");
            window.location = "http://" + window.location.hostname + "/Store/Index?rnd=" + rndNum;
        }
    });
}
function navigateToLegacySites() {
    displayAjaxLoader();

    var d = new Date();
    var rndNum = d.getMilliseconds().toString();

    $("#ajaxContainer").load("http://" + window.location.hostname + "/LegacySites?rnd=" + rndNum + " .ajaxContent", function (response, status, xhr) {

        hideAjaxLoader();
        if (status == "error") {
            //alert("Sorry but there was an error: ");
            window.location = "http://" + window.location.hostname + "/LegacySites?rnd=" + rndNum;
        }
    });
}

$(document).ready(function () {
    $('#navHomeTrigger').click(function (e) {
        e.preventDefault();
        ShowHideAdminPanels();
        navigateToHome();
    });

    $('#navJHGalleryTrigger').click(function (e) {
        e.preventDefault();
        ShowHideAdminPanels();
        navigateToJHGallery();
    });

    $('#FanGalleryTrigger').click(function (e) {
        e.preventDefault();
        ShowHideAdminPanels();
        navigateToFanGallery();
    });

    $('#navBlogTrigger').click(function (e) {
        e.preventDefault();
        ShowHideAdminPanels();
        navigateToBlog();
    });

    $('#navSpeakUpTrigger').click(function (e) {
        e.preventDefault();
        ShowHideAdminPanels();
        navigateToSpeakUp();
    });

    $('#navTourTrigger').click(function (e) {
        e.preventDefault();
        ShowHideAdminPanels();
        navigateToTour();
    });

    $('#navContactTrigger').click(function (e) {
        e.preventDefault();
        ShowHideAdminPanels();
        navigateToContact();
    });

    $('#navDiscographyTigger').click(function (e) {
        e.preventDefault();
        ShowHideAdminPanels();
        navigateToDiscography();
    });

    $('#navJHVideosTrigger').click(function (e) {
        e.preventDefault();
        ShowHideAdminPanels();
        navigateToVideos();
    });
    $('#navStoreTrigger').click(function (e) {
        e.preventDefault();
        ShowHideAdminPanels();
        navigateToStore();
    });
});



/* ///////////////////////////////////////////////////////////////////////// */
/* ADDS FUNCTIONAITY TO MAIN NAVIGATION                                      */
/* ///////////////////////////////////////////////////////////////////////// */
$(document).ready(function () {
    $('.navBlog').mouseover(function () {
        $('.navBlog').css('margin-left', '-1980px');
    }).mouseout(function () {
        $('.navBlog').css('margin-left', '-1800px');
    });
    /*
    $('#navBlogTrigger').click(function () {
        ShowHideAdminPanels();
        ResizeRails();
    });*/

    $('.navJHGallery').mouseover(function () {
        $('.navJHGallery').css('margin-left', '-540px');
    }).mouseout(function () {
        $('.navJHGallery').css('margin-left', '-360px');
    });
    /*
    $('#navJHGalleryTrigger').click(function () {
        ShowHideAdminPanels();
        ResizeRails();
    });*/

    $('.navFanPics').mouseover(function () {
        $('.navFanPics').css('margin-left', '-900px');
    }).mouseout(function () {
        $('.navFanPics').css('margin-left', '-720px');
    });
    /*
    $('#FanGalleryTrigger').click(function () {
        ShowHideAdminPanels();
        ResizeRails();
    });*/

    $('.navJHVideos').mouseover(function () {
        $('.navJHVideos').css('margin-left', '-1260px');
    }).mouseout(function () {
        $('.navJHVideos').css('margin-left', '-1080px');
    });
    /*
    $('#navJHVideosTrigger').click(function () {
        ShowHideAdminPanels();
        ResizeRails();
    });*/

    $('.navStore').mouseover(function () {
        $('.navStore').css('margin-left', '-1620px');
    }).mouseout(function () {
        $('.navStore').css('margin-left', '-1440px');
    });
    /*
    $('#navStoreTrigger').click(function () {
        ShowHideAdminPanels();
        ResizeRails();
    });*/

    $('.navHome').mouseover(function () {
        $('.navHome').css('margin-left', '-180px');
    }).mouseout(function () {
        $('.navHome').css('margin-left', '0px');
    });
    /*
    $('#navHomeTrigger').click(function () {
        ShowHideAdminPanels();
        ResizeRails();
    });*/

    $('.navSpeakUp').mouseover(function () {
        $('.navSpeakUp').css('margin-left', '-2340px');
    }).mouseout(function () {
        $('.navSpeakUp').css('margin-left', '-2160px');
    });
    /*
    $('#navSpeakUpTrigger').click(function () {
        ShowHideAdminPanels();
        ResizeRails();
    });*/

    $('.navLive').mouseover(function () {
        $('.navLive').css('margin-left', '-2700px');
    }).mouseout(function () {
        $('.navLive').css('margin-left', '-2520px');
    });
    /*
    $('#navLiveTrigger').click(function () {
        ShowHideAdminPanels();
        ResizeRails();
    });
    */

    $('.navNews').mouseover(function () {
        $('.navNews').css('margin-left', '-3060px');
    }).mouseout(function () {
        $('.navNews').css('margin-left', '-2880px');
    });
    /*
    $('#navNewsTrigger').click(function () {
        ShowHideAdminPanels();
        ResizeRails();
    });*/

    $('.navDiscography').mouseover(function () {
        $('.navDiscography').css('margin-left', '-3420px');
    }).mouseout(function () {
        $('.navDiscography').css('margin-left', '-3240px');
    });
    /*
    $('#navDiscographyTigger').click(function () {
        ShowHideAdminPanels();
        ResizeRails();
    });*/

});
