﻿
$('html').addClass('js');
$('html').addClass('flash');
$(document).ready(function() {
    //ps_wrapper
    if ($('.ps_wrapper').length) {
        $('html').addClass('publisiteEditor');
    } else {
        $('html').addClass('frontEnd');

    };
    //stop the flash of images in the slideshow in IE by hiding images with a 'js' class
    $('html').removeClass('flash');

    //DROPDOWN MENU
    $('ul.sf-menu').superfish({
        delay: 10, // delay on mouseout
        animation: { opacity: 'show' }, // fade-in and slide-down animation
        speed: '100',
        autoArrows: false, // disable generation of arrow mark-up 
        dropShadows: false// disable drop shadows 
    });

    // SOFT ROLLOVERS ON TOP NAV DROPDOWN
    $('.primary_nav ul ul a').hover(
        function() {
            $(this).css({ color: "#ffffff" }).animate({ color: "#D9D9D8" }, 200);
        },
        function() {
            $(this).animate({ color: "#ffffff" }, 200);
    });


    /* FIX IOS VIEWPORT BUG */
    var viewport = $('meta[name="viewport"]');
    var nua = navigator.userAgent;
    if ((nua.match(/iPad/i)) || (nua.match(/iPhone/i)) || (nua.match(/iPod/i))) {
        viewport.attr('content', 'width=device-width, minimum-scale=1.0, maximum-scale=1.0');
        $('body')[0].addEventListener("gesturestart", gestureStart, false);
    }
    function gestureStart() {
        viewport.attr('content', 'width=device-width, minimum-scale=0.25, maximum-scale=1.6');
    }

    if ($('.smartListGrid').length) {
        $('.smartListGrid .SmartListDescription').wrapInner('<p><a></a></p>');
    }

    // SOFT ROLLOVERS ON SMARTLIST
    $('.smartListGrid li').hover(
	    function() {
	        var link = $(this).children('.SmartListPageLink').attr('href');
	        $('.smartListGrid .SmartListDescription p a').attr('href', link);
	        $(this).children('.SmartListDescription').css({ "-moz-opacity:": "0", "opacity": "0", "filter": "alpha(opacity=0)" });   	        
	        $(this).children('.SmartListDescription').stop().animate({ "opacity": "0.99" }, 200);
	        $(this).children('.SmartListPageLink').animate({ color: "#FFD600" }, 200);
	    },
	    function() {
	        $(this).children('.SmartListDescription').stop().animate({ "opacity": "0.0" }, 200);
	        $(this).children('.SmartListPageLink').animate({ color: "#162229" }, 200);
	    });

    //commented out by Danielle
    /*
    $('.primary_nav ul.horizontal>li>a').hover(

        function() {
    $(this).animate({ color: "#FFCD00" }, 200);
    $(this).animate({ backgroundColor: "#162229" }, 200);
    },
    function() {

            var currentItemClass = $(this).attr("class");
    var defaultLinkColor = "#000";
    var activeLinkColor = "#FFCD00";

            if ($(this).hasClass(".topnavitem1ps_topnav_selected_section, .topnavitem2ps_topnav_selected_section, .topnavitem3ps_topnav_selected_section")) {
    defaultLinkColor = activeLinkColor;
    }

            $(this).animate({ color: defaultLinkColor }, 200);
    $(this).animate({ backgroundColor: "#ffffff" }, 200);
       
    });
    */

    /*
    $('.smartListBlock li').hover(
    function() {
    $(this).animate({ backgroundColor: "#D9D9D8" }, 200);
    },
    function() {
    $(this).animate({ backgroundColor: "#EBEBEA" }, 200);
    });
    */
});
$(window).load(function() {

// SOFT ROLLOVERS TOP NAV
    
    
/*
    $('ul.sf-menu li ul li a').mouseover(
        function() {
            $(this).css({ color: "#ffffff" });
            $(this).animate({ color: "#dededc" }, 200);
        },
        function() {
            $(this).animate({ color: "#ffffff" }, 200);
        });

        $('ul.sf-menu a').mouseover(
        function() {
            $(this).css({ color: "#ffffff" });
            $(this).animate({ color: "#dededc" }, 200);
        },
        function() {
            $(this).animate({ color: "#ffffff" }, 200);
        });
*/
        // WORK SLIDESHOW 
    
        $('#ctl00_Content1_slideshow_contentDiv').wrap('<div class="slideshowWrapper"></div>').before('<ul id="slideshowThumbs">').cycle({
        fx: 'fade',
        speed: 'fast',
        timeout: 5000,
        pager: '#slideshowThumbs',
        pagerAnchorBuilder: function(idx, slide) {
            return '<li><a href="javascript:void(0);"><img src="' + slide.src + '" width="100" height="60" /></a></li>';
        }
    });

    // HOME SLIDES
    $('.frontEnd ul.home_slides').cycle({
        activePagerClass: 'activeSlide',
        fx: 'fade',
        speed: 'fast',
        timeout: 5000

    })

    /**/
    equalHeight($(".smartListGrid li"));
});



function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if (thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}



