﻿$(document).ready(function () {
    resizeWindow();
    $(".hover").hover(
      function () {
          $(this).find("a.tab").stop().animate({ "opacity": "0" }, 200);
      },
      function () {
          $(this).find("a.tab").stop().animate({ "opacity": "1" }, 500);
      }
    );

    $(".services_item, .services_item").hover(
      function () {
          $(this).find("a.service").stop().animate({ "opacity": "0" }, 200);
      },
      function () {
          $(this).find("a.service").stop().animate({ "opacity": "1" }, 500);
      }
    );


    $(".middle_inner_left .services_item:last, .middle_inner_right .services_item:last, .middle_right .news_item:last").css({ "border-bottom": "none", "padding-bottom": "0px" });
    $(window).resize(resizeWindow);

    nextSlideshowImage();
    setInterval(nextSlideshowImage, 5000);

});

//treat child divs like table cells and resize them
function setCellHeight(tag) {
    $(tag).each(function () {
        var element = $(this);
        element.children("div").height(element.height());
    });
}

// load the next image in the slideshow
function nextSlideshowImage() {
    $(".slideshow img:first").hide().remove().insertAfter(".slideshow img:last").fadeIn(1000);
}

//resize window attributes
function resizeWindow() {
    var page = $("#page");
    if ($(window).width() < (page.width() + ($("#shadow_left").width() * 2))) {
        $("#shadow_left, #shadow_right").css("display", "none");
    }
    else {
        $("#shadow_left, #shadow_right").css("display", "block");
    }
    $("#sidebar").height(Math.max((page.height() - $("#header").height()), $("#inner_page").height()));
    $(".top_right").height($(".top_left").height());
}
