$(document).ready(function () {
if($('#mailsent').length){
  $('#mailsent').delay(3000).fadeOut('slow');
}

    $('#mainmenu li a').click(function (event) {
        //prevent default click action
        event.preventDefault();

        if ($(this).hasClass('framed')) {
            //check if an iframe is in the way
            if ($('#main article').has('iframe')) {
                //it is, so fade out then remove it
                $('#main article iframe').fadeOut('slow').remove();
                //show blank box so not to show homepage landing slideshows inbetween fades
                $('#loading-placeholder').fadeIn();
            }

            //check if any base text boxes are visible
            if ($('div[id$="-text"]:visible')) {
                //if so, hide them
                $('article [id$="-text"]:visible').fadeOut('slow');
                //show blank box so not to show homepage landing slideshows inbetween fades
                $('#loading-placeholder').fadeIn();
            }

            //grab the link from the clicked item
            var frameSrc = $(this).attr('href');
            //console.log(frameSrc);

            //make the iframe html
            var iFrame = '<iframe name="frame" id="frame" src="' + frameSrc + '">You need to have a frames enabled browser to view this content</iframe>'
            //console.log(iFrame);

            //fade out current content area
            $('#main article').fadeOut('slow');

            //hide loading placeholder div
            $('#loading-placeholder').fadeOut();

            //replace current content html with new iframeiness
            $('#main article').append(iFrame).load().delay(750).fadeIn('slow');
        } else {
            //check if an iframe is in the way
            if ($('#main article').has('iframe')) {
                //show blank box so not to show homepage landing slideshows inbetween fades
                //$('#loading-placeholder').fadeIn();
                //it is, so fade out then remove it
                $('#main article iframe').fadeOut('slow').remove();
            }
            //console.log('non-framed content link clicked');

            //close any open text boxes
            $('article [id$="-text"]:visible').fadeOut('slow');

            //hide loading placeholder div
            //$('#loading-placeholder').fadeOut();

            //figure out which link you've clicked get correct text box
            var loadText = $(this).attr('id').replace('open-', '');
            //console.log(loadText);

            //fade the new text in
            $('#' + loadText).fadeIn('slow');
        }
    });

    //modal windows for photos
    $("a[rel^='prettyphoto']").prettyPhoto({
        theme: 'light_square',
        showTitle: false,
        animationSpeed: 'fast',
        overlay_gallery: false,
        markup: '<div class="pp_pic_holder"> \
						<div class="ppt">&nbsp;</div> \
						<div class="pp_top"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
						<div class="pp_content_container"> \
							<div class="pp_left"> \
							<div class="pp_right"> \
								<div class="pp_content"> \
									<div class="pp_loaderIcon"></div> \
									<div class="pp_fade"> \
										<a href="#" class="pp_expand" title="Expand the image">Expand</a> \
										<div class="pp_hoverContainer"> \
											<a class="pp_next" href="#">next</a> \
											<a class="pp_previous" href="#">previous</a> \
										</div> \
										<div id="pp_full_res"></div> \
										<div class="pp_details"> \
											<div class="pp_nav"> \
												<a href="#" class="pp_arrow_previous">Previous</a> \
												<p class="currentTextHolder">0/0</p> \
												<a href="#" class="pp_arrow_next">Next</a> \
											</div> \
											<a class="pp_close" href="#">Close</a> \
										</div> \
									</div> \
								</div> \
							</div> \
							</div> \
						</div> \
						<div class="pp_bottom"> \
							<div class="pp_left"></div> \
							<div class="pp_middle"></div> \
							<div class="pp_right"></div> \
						</div> \
					</div> \
					<div class="pp_overlay"></div>'
    });

    /*    $('.slides').nivoSlider({
    effect: 'fade',
    directionNav: false,
    controlNav: false,
    keyboardNav: false,
    pauseOnHover: false,
    captionOpacity: 0
    });*/

    // Copyright (c) 2010 TrendMedia Technologies, Inc., Brian McNitt. 
    // All rights reserved.
    //
    // Released under the GPL license
    // http://www.opensource.org/licenses/gpl-license.php
    //
    // **********************************************************************
    // This program is distributed in the hope that it will be useful, but
    // WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
    // **********************************************************************

    $(window).load(function () {
        //start after HTML, images have loaded

        var InfiniteRotator =
    {
        init: function () {
            //where are the slides?
            var slideContainer = $('#large-slides .slides');
            var slideElement = $('#large-slides .slides img');

            //how long before we remove the loady loader animation?
            var containerBgRemoveDelay = 3000;

            //initial fade-in time (in milliseconds)
            var initialFadeIn = 1250;

            //interval between items (in milliseconds)
            var itemInterval = 6000;

            //cross-fade time (in milliseconds)
            var fadeTime = 5000;

            //count number of items
            var numberOfItems = $(slideElement).length;

            //set current item
            var currentItem = 0;

            //show first item
            $(slideElement).eq(currentItem).fadeIn(initialFadeIn);
            //remove loady loader animation
            $(slideContainer).delay(containerBgRemoveDelay).css({ "backgroundImage": "none" });

            //loop through the items        
            var infiniteLoop = setInterval(function () {

                $(slideElement).eq(currentItem).fadeOut(fadeTime);

                if (currentItem == numberOfItems - 1) {
                    currentItem = 0;
                } else {
                    currentItem++;
                }

                $(slideElement).eq(currentItem).fadeIn(fadeTime);

            }, itemInterval);
        }
    };

        InfiniteRotator.init();

    });

    $(window).load(function () {
        //start after HTML, images have loaded

        var InfiniteRotator =
    {
        init: function () {
            //where are the slides?
            var slideContainer = $('#slides1 .slides');
            var slideElement = $('#slides1 .slides img');

            //how long before we remove the loady loader animation?
            var containerBgRemoveDelay = 1500;

            //initial fade-in time (in milliseconds)
            var initialFadeIn = 1250;

            //interval between items (in milliseconds)
            var itemInterval = 3000;

            //cross-fade time (in milliseconds)
            var fadeTime = 2500;

            //count number of items
            var numberOfItems = $(slideElement).length;

            //set current item
            var currentItem = 0;

            //show first item
            $(slideElement).eq(currentItem).fadeIn(initialFadeIn);
            //remove loady loader animation
            $(slideContainer).delay(containerBgRemoveDelay).css({ "backgroundImage": "none" });

            //loop through the items        
            var infiniteLoop = setInterval(function () {

                $(slideElement).eq(currentItem).fadeOut(fadeTime);

                if (currentItem == numberOfItems - 1) {
                    currentItem = 0;
                } else {
                    currentItem++;
                }

                $(slideElement).eq(currentItem).fadeIn(fadeTime);

            }, itemInterval);
        }
    };

        InfiniteRotator.init();

    });

    $(window).load(function () {
        //start after HTML, images have loaded

        var InfiniteRotator =
    {
        init: function () {
            //where are the slides?
            var slideContainer = $('#slides2 .slides');
            var slideElement = $('#slides2 .slides img');

            //how long before we remove the loady loader animation?
            var containerBgRemoveDelay = 1500;

            //initial fade-in time (in milliseconds)
            var initialFadeIn = 1250;

            //interval between items (in milliseconds)
            var itemInterval = 3000;

            //cross-fade time (in milliseconds)
            var fadeTime = 2500;

            //count number of items
            var numberOfItems = $(slideElement).length;

            //set current item
            var currentItem = 0;

            //show first item
            $(slideElement).eq(currentItem).fadeIn(initialFadeIn);
            //remove loady loader animation
            $(slideContainer).delay(containerBgRemoveDelay).css({ "backgroundImage": "none" });

            //loop through the items        
            var infiniteLoop = setInterval(function () {

                $(slideElement).eq(currentItem).fadeOut(fadeTime);

                if (currentItem == numberOfItems - 1) {
                    currentItem = 0;
                } else {
                    currentItem++;
                }

                $(slideElement).eq(currentItem).fadeIn(fadeTime);

            }, itemInterval);
        }
    };

        InfiniteRotator.init();

    });

    $(window).load(function () {
        //start after HTML, images have loaded

        var InfiniteRotator =
    {
        init: function () {
            //where are the slides?
            var slideContainer = $('#slides3 .slides');
            var slideElement = $('#slides3 .slides img');

            //how long before we remove the loady loader animation?
            var containerBgRemoveDelay = 1500;

            //initial fade-in time (in milliseconds)
            var initialFadeIn = 1250;

            //interval between items (in milliseconds)
            var itemInterval = 3000;

            //cross-fade time (in milliseconds)
            var fadeTime = 2500;

            //count number of items
            var numberOfItems = $(slideElement).length;

            //set current item
            var currentItem = 0;

            //show first item
            $(slideElement).eq(currentItem).fadeIn(initialFadeIn);
            //remove loady loader animation
            $(slideContainer).delay(containerBgRemoveDelay).css({ "backgroundImage": "none" });

            //loop through the items        
            var infiniteLoop = setInterval(function () {

                $(slideElement).eq(currentItem).fadeOut(fadeTime);

                if (currentItem == numberOfItems - 1) {
                    currentItem = 0;
                } else {
                    currentItem++;
                }

                $(slideElement).eq(currentItem).fadeIn(fadeTime);

            }, itemInterval);
        }
    };

        InfiniteRotator.init();

    });

    $(window).load(function () {
        //start after HTML, images have loaded

        var InfiniteRotator =
    {
        init: function () {
            //where are the slides?
            var slideContainer = $('#slides4 .slides');
            var slideElement = $('#slides4 .slides img');

            //how long before we remove the loady loader animation?
            var containerBgRemoveDelay = 1500;

            //initial fade-in time (in milliseconds)
            var initialFadeIn = 1250;

            //interval between items (in milliseconds)
            var itemInterval = 3000;

            //cross-fade time (in milliseconds)
            var fadeTime = 2500;

            //count number of items
            var numberOfItems = $(slideElement).length;

            //set current item
            var currentItem = 0;

            //show first item
            $(slideElement).eq(currentItem).fadeIn(initialFadeIn);
            //remove loady loader animation
            $(slideContainer).delay(containerBgRemoveDelay).css({ "backgroundImage": "none" });

            //loop through the items        
            var infiniteLoop = setInterval(function () {

                $(slideElement).eq(currentItem).fadeOut(fadeTime);

                if (currentItem == numberOfItems - 1) {
                    currentItem = 0;
                } else {
                    currentItem++;
                }

                $(slideElement).eq(currentItem).fadeIn(fadeTime);

            }, itemInterval);
        }
    };

        InfiniteRotator.init();

    });

    $(window).load(function () {
        //start after HTML, images have loaded

        var InfiniteRotator =
    {
        init: function () {
            //where are the slides?
            var slideContainer = $('#slides5 .slides');
            var slideElement = $('#slides5 .slides img');

            //how long before we remove the loady loader animation?
            var containerBgRemoveDelay = 1500;

            //initial fade-in time (in milliseconds)
            var initialFadeIn = 1250;

            //interval between items (in milliseconds)
            var itemInterval = 3000;

            //cross-fade time (in milliseconds)
            var fadeTime = 2500;

            //count number of items
            var numberOfItems = $(slideElement).length;

            //set current item
            var currentItem = 0;

            //show first item
            $(slideElement).eq(currentItem).fadeIn(initialFadeIn);
            //remove loady loader animation
            $(slideContainer).delay(containerBgRemoveDelay).css({ "backgroundImage": "none" });

            //loop through the items        
            var infiniteLoop = setInterval(function () {

                $(slideElement).eq(currentItem).fadeOut(fadeTime);

                if (currentItem == numberOfItems - 1) {
                    currentItem = 0;
                } else {
                    currentItem++;
                }

                $(slideElement).eq(currentItem).fadeIn(fadeTime);

            }, itemInterval);
        }
    };

        InfiniteRotator.init();

    });

    $(window).load(function () {
        //start after HTML, images have loaded

        var InfiniteRotator =
    {
        init: function () {
            //where are the slides?
            var slideContainer = $('#slides6 .slides');
            var slideElement = $('#slides6 .slides img');

            //how long before we remove the loady loader animation?
            var containerBgRemoveDelay = 1500;

            //initial fade-in time (in milliseconds)
            var initialFadeIn = 1250;

            //interval between items (in milliseconds)
            var itemInterval = 3000;

            //cross-fade time (in milliseconds)
            var fadeTime = 2500;

            //count number of items
            var numberOfItems = $(slideElement).length;

            //set current item
            var currentItem = 0;

            //show first item
            $(slideElement).eq(currentItem).fadeIn(initialFadeIn);
            //remove loady loader animation
            $(slideContainer).delay(containerBgRemoveDelay).css({ "backgroundImage": "none" });

            //loop through the items        
            var infiniteLoop = setInterval(function () {

                $(slideElement).eq(currentItem).fadeOut(fadeTime);

                if (currentItem == numberOfItems - 1) {
                    currentItem = 0;
                } else {
                    currentItem++;
                }

                $(slideElement).eq(currentItem).fadeIn(fadeTime);

            }, itemInterval);
        }
    };

        InfiniteRotator.init();

    });

    $(window).load(function () {
        //start after HTML, images have loaded

        var InfiniteRotator =
    {
        init: function () {
            //where are the slides?
            var slideContainer = $('#slides .slides');
            var slideElement = $('#slides .slides img');

            //how long before we remove the loady loader animation?
            var containerBgRemoveDelay = 1500;

            //initial fade-in time (in milliseconds)
            var initialFadeIn = 1250;

            //interval between items (in milliseconds)
            var itemInterval = 3000;

            //cross-fade time (in milliseconds)
            var fadeTime = 2500;

            //count number of items
            var numberOfItems = $(slideElement).length;

            //set current item
            var currentItem = 0;

            //show first item
            $(slideElement).eq(currentItem).fadeIn(initialFadeIn);
            //remove loady loader animation
            $(slideContainer).delay(containerBgRemoveDelay).css({ "backgroundImage": "none" });

            //loop through the items        
            var infiniteLoop = setInterval(function () {

                $(slideElement).eq(currentItem).fadeOut(fadeTime);

                if (currentItem == numberOfItems - 1) {
                    currentItem = 0;
                } else {
                    currentItem++;
                }

                $(slideElement).eq(currentItem).fadeIn(fadeTime);

            }, itemInterval);
        }
    };

        InfiniteRotator.init();

    });
});
