﻿/**
*	Tallest.
*	Given a jQuery result set, this set of functions will return the:
*	- tallest()		(biggest height)
*	- shortest()	(smallest height)
*	- widest()		(biggest width)
*	- thinnest()	(smallest width)
*	Add "Size" onto the end of those functions (eg: "tallestSize()") and it will
*	return just the pixel size, not the element.
*
*	@author	nickf
*	@date	2009-08-19
*	@version 1.0 $Id: jquery.tallest.js 100 2009-08-19 00:40:09Z spadgos $
*/
jQuery(function ($) {

    $.fn.tallest = function () { return this._extremities({ 'aspect': 'height', 'max': true })[0] };
    $.fn.tallestSize = function () { return this._extremities({ 'aspect': 'height', 'max': true })[1] };
    $.fn.shortest = function () { return this._extremities({ 'aspect': 'height', 'max': false })[0] };
    $.fn.shortestSize = function () { return this._extremities({ 'aspect': 'height', 'max': false })[1] };
    $.fn.widest = function () { return this._extremities({ 'aspect': 'width', 'max': true })[0] };
    $.fn.widestSize = function () { return this._extremities({ 'aspect': 'width', 'max': true })[1] };
    $.fn.thinnest = function () { return this._extremities({ 'aspect': 'width', 'max': false })[0] };
    $.fn.thinnestSize = function () { return this._extremities({ 'aspect': 'width', 'max': false })[1] };

    /**
    *	Returns an array: the first item is the matched element, and the second item is the dimension
    */
    $.fn._extremities = function (options) {
        var defaults = {
            aspect: 'height', // or 'width'
            max: true	// or false to find the min
        };
        options = $.extend(defaults, options);

        if (this.length < 2) {
            return [this, this[options.aspect]()];
        }

        var bestIndex = 0,
			bestSize = this.eq(0)[options.aspect](),
			thisSize
		;
        for (var i = 1; i < this.length; ++i) {
            thisSize = this.eq(i)[options.aspect]();
            if ((options.max && thisSize > bestSize) || (!options.max && thisSize < bestSize)) {
                bestSize = thisSize;
                bestIndex = i;
            }
        }

        return [this.eq(bestIndex), bestSize];
    };
});


/**
* Equal Heights Plugin
* Equalize the heights of elements. Great for columns or any elements
* that need to be the same size (floats, etc).
* 
* Version 1.0
* Updated 12/10/2008
*
* Copyright (c) 2008 Rob Glazebrook (cssnewbie.com) 
*
* Usage: $(object).equalHeights([minHeight], [maxHeight]);
* 
* Example 1: $(".cols").equalHeights(); Sets all columns to the same height.
* Example 2: $(".cols").equalHeights(400); Sets all cols to at least 400px tall.
* Example 3: $(".cols").equalHeights(100,300); Cols are at least 100 but no more
* than 300 pixels tall. Elements with too much content will gain a scrollbar.
* 
*/

(function ($) {
    $.fn.equalHeights = function (minHeight, maxHeight) {
        tallest = (minHeight) ? minHeight : 0;
        this.each(function () {
            if ($(this).height() > tallest) {
                tallest = $(this).height();
            }
        });
        if ((maxHeight) && tallest > maxHeight) tallest = maxHeight;
        return this.each(function () {
            $(this).css('height',tallest).css("overflow", "visible");
        });
    }
})(jQuery);

$.noConflict();
jQuery(document).ready(function ($) {

    $('.imgRotation').each(function () {
        $(this).css("height", $("img", this).tallestSize())
    });
    $(".twoColumnLayout:last .leftColumn,.twoColumnLayout:last .rightColumn, .twoColumnLayout:last .leftColumn div:first, .SpotGrid .container").equalHeights();
    $(".twoColumnLayout:last .rightColumn div.container").css("height", "100%");

    $(".searchField").focus(function () {
    if (this.value == this.defaultValue) {
        this.value = "";
    }
}).blur(function () {
    if (!this.value.length) {
        this.value = this.defaultValue;
    }
});
    
    $(".test").children(".toggle").toggleClass("container-closed");
    $(".fpImg .toggle").hoverIntent({ over: function (ev) {
        var currentHeight = $(this).height();
        $(this).css('height', 'auto');
        var height = $(this).height();
        $(this).css('height', currentHeight + 'px');
        $(this).css('background-image', 'url(/styles/images/transparentWhite.png)');
        $(this).animate({ height: height + "px" }, 1000);
    },
        timeout: 500,
        out: function (ev) {
            $(this).animate({ height: '30px', overflow: "hidden" }, 1000);
            $(this).css('background-image', 'url(/styles/images/transparentBlue.png)');
        }
    });

    $('.imgRotation').cycle({
        fx: 'fade',
        random: 1
    });



});

jQuery(function ($) {
    var $mainNav = $('#main-nav');

    $mainNav.children('.main-nav-item').hoverIntent({over:function (ev) {
        // show the dropdown
        $(this).addClass('main-nav-item-active');
    }, 
    timeout:0,
    out:function (ev) {
        // hide the dropdown
        $(this).removeClass('main-nav-item-active');
        }
    });
});

jQuery(function ($) {
    var $mainNav = $('#main-nav');

    $mainNav.children('.main-nav-item').hoverIntent(
        {
            over: function (ev) {
                $(this).addClass('main-nav-item-active');
            },
            timeout: 500,
            out: function (ev) {

                // hide the dropdown
                $(this).removeClass('main-nav-item-active');
            }
        });
});
 
//jQuery(function ($) {
//    var $mainNav = $('#main-nav'),
//    navWidth = $mainNav.width();

//    $mainNav.children('.main-nav-item').hover(function (ev) {
//        var $this = $(this),
//        $dd = $this.find('.main-nav-dd');

//        // get the left position of this tab
//        var leftPos = $this.find('.main-nav-tab').position().left;

//        // get the width of the dropdown
//        var ddWidth = $dd.width(),
//        leftMax = navWidth - ddWidth;

//        // position the dropdown
//        $dd.css('left', Math.min(leftPos, leftMax));

//        // show the dropdown
//        $this.addClass('main-nav-item-active');
//    }, function (ev) {

//        // hide the dropdown
//        $(this).removeClass('main-nav-item-active');
//    });
//});

