// RollOver
$(function () {
    $.rollover = {
        init: function () {
            $('a img,input[type="image"]').not('[src*="_on."]')
                .bind('mouseover', this.over)
                .bind('mouseout',  this.out)
                .each(this.preload);
        },

        over : function () {
            this.setAttribute('src', this.getAttribute('src').replace('_off.', '_on.'));
        },

        out : function () {
            this.setAttribute('src', this.getAttribute('src').replace('_on.', '_off.'));
        },

        preload : function () {
            new Image().src = this.getAttribute('src').replace('_off.', '_on.');
        }
    };

    $.rollover.init();
});


//fancybox
$(function () {
 if    ($.fn.fancybox) $("a[href$=jpg],a[href$=gif]").attr('rel', 'gallery').fancybox({
        'hideOnContentClick': true,
        'overlayOpacity': 0.8,
        'overlayColor': '#000000'
    });
});


//flatheight
$(window).bind('load',function(){
    var sets = [], temp = [];
    $('ul.gallery.construction li').each(function(i) {
        temp.push(this);
        if (i % 3 == 2) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);
    $.each(sets, function() {
        $(this).flatHeights();
    });
});


$(function () {
    //slides the element with class "menu_body" when paragraph with class "menu_head" is clicked 
    $("div#navigation dl dt").click(function(){
        $(this)
            .next("dd").children("ul").slideToggle(300)
            .end().siblings("dd").children("ul").slideUp("slow");
    });
				
				//
    $(".index .gallery dt").click(function(){
        $(this)
            .next("dd").children("ul").slideToggle(300)
            .end().siblings("dd").children("ul").slideUp("slow");
    });
});


//if (window.DD_belatedPNG) DD_belatedPNG.fix('html, body, #wrapper, img');



//toppage image
$(function () {
	$('.topimage').innerFade({
		'animationType':'fade',
		'animate': true,
		'easing':'linear',
		'speed':2000,
		'type':'sequence',
		'timeout':4000,
		'startDelay': 0,
		'loop': false,
		'containerHeight':'auto',
		'runningClass':'innerFade'
    });
});
var objTr;
$(function () {
	/*
  $("div#body.index > div.calendarTable > table > tr:last").each(function(){
     objTr = $(this);
					alert($(this).html());						
		});
		objTr.attrClass("last");
	*/

  $("ul.sub_navigation li:last").addClass("last");
  $("div#body.index tr:last").addClass("last");
});
