$(document).ready(function () {

    /* Home Image Nav hover */

    $("ul#imgNav li a").hover(
	  function () {
	      var type = $(this).attr("class");
	      $("ul#nav li a." + type).css('background-color', '#aa0836');
	  },
	  function () {
	      var type = $(this).attr("class");
	      $("ul#nav li a." + type).css('background-color', '#f05a29');
	  }
	);

    /* JS just for the Menu Item Hovers (required due to image hover controls) */

    $("ul#nav li a").hover(
	  function () {
	      $(this).css('background-color', '#aa0836');
	  },
	  function () {
	      $(this).css('background-color', '#f05a29');
	  }
	);

    $("div.RadMenu ul.rmRootGroup li a").hover(
	  function () {
	      $(this).css('background-color', '#aa0836');
	  },
	  function () {
	      $(this).css('background-color', '#f05a29');
	  }
	);

    //Home Page Navigation Pictures
    $('a.come').fadeIn(800);
    $('a.worship').fadeIn(1000);
    $('a.children').fadeIn(1200);
    $('a.pastor').fadeIn(1400);
    $('a.history').fadeIn(1600);
    $('a.location').fadeIn(1800);
    $('a.contact').fadeIn(2000);

    $('a.come').cycle({
        fx: 'fade',
        timeout: 4000,
        speed: 500
    });

    $('a.worship').cycle({
        fx: 'fade',
        timeout: 4000,
        speed: 700
    });

    $('a.children').cycle({
        fx: 'fade',
        timeout: 4000,
        speed: 900
    });

    $('a.pastor').cycle({
        fx: 'fade',
        timeout: 4000,
        speed: 1100
    });

    $('a.history').cycle({
        fx: 'fade',
        timeout: 4000,
        speed: 1300
    });

    $('a.location').cycle({
        fx: 'fade',
        timeout: 4000,
        speed: 1500
    });

    $('a.contact').cycle({
        fx: 'fade',
        timeout: 4000,
        speed: 1700
    });

    //Sub Page Right Column Picutres
    $('.topImage').fadeIn(2000);

    $('.topImage').cycle({
        fx: 'fade',
        timeout: 3000
    });

    //Home Page Audio Stuff

    $("#areaOne").click(function () {
        $("#audioOne").fadeIn(1400);
        $("#mediaplayer").css("display", "block");
        $("#homeAudio").fadeOut();
    });

    $("#areaTwo").click(function () {
        $("#audioTwo").fadeIn(1400);
        $("#homeAudio").fadeOut();
    });

    $("#areaThree").click(function () {
        $("#audioThree").fadeIn(1400);
        $("#homeAudio").fadeOut();
    });

    $(".audioLinkOne").click(function () {
        $("#audioOne").fadeIn(1400);
        $("#audioTwo").fadeOut();
        $("#audioThree").fadeOut();
    });

    $(".audioLinkTwo").click(function () {
        $("#audioTwo").fadeIn(1400);
        $("#audioOne").fadeOut();
        $("#audioThree").fadeOut();
    });

    $(".audioLinkThree").click(function () {
        $("#audioThree").fadeIn(1400);
        $("#audioOne").fadeOut();
        $("#audioTwo").fadeOut();
    });

    //add class="show_popup" to any link that you
    //want to invoke popup with
    $(".show_popup").click(function () {
        show_popup();
        return false;
    });

    $(".show_popup2").click(function () {
        show_popup2();
        return false;
    });

    hideAudio();
});

function show_popup() {
    $("#contemporary").fadeIn(1200);
}
function close_popup() {
    $("#contemporary").fadeOut(1200);
}

function show_popup2() {
    $("#traditional").fadeIn(1200);
}
function close_popup2() {
    $("#traditional").fadeOut(1200);
}

function hideAudio() {
    $("#audioOne").hide();
    $("#audioTwo").hide();
    $("#audioThree").hide();
    $("#mediaplayer").hide();
}
