// JavaScript Document
$(document).ready(function() {
    /*swfobject.embedSWF(
    "/webassets/flash/CDS-header.swf",
    "flashHeader",
    "770",
    "124",
    "6.0.0",
    "/webassets/flash/expressInstall.swf",
    "",
    { wmode: "Transparent" }
    );	
    */

    var h = $(window).height();
    h = h - $("#header").height() - $("#superficial").height();
    $("#container").height(h)

    $("#news .upcoming .item:odd").addClass("alt");
    var HomeBucketH = 0;
    $(".home .bucket").each(function() {
        if ($(this).height() > HomeBucketH) {
            HomeBucketH = $(this).height();
        }
    });
    $(".home .bucket").height(HomeBucketH);

    fixCalendarArrows();

    $(".imgover").imageOver();
    //perform search label coolness
    var lblText = $(".search label span").text();
    $(".search label span").hide();
    $(".txtSearch").val(lblText);
         $(".txtSearch").focus(function(){
              if($(this).val() == ''){
                
              }else if($(this).val() == lblText){
                $(this).val('');
              }
            });

    // Check if a field is empty when the user switches out
     $(".txtSearch").blur(function(){
      if($(this).val() == ''){
        $(this).val(lblText);         
      }
    });
    

});

function executeSlider(){
        function formatText(index, panel) {
		  return index + "";
	    }
    
        $(function () {
        
            $('.anythingSlider').anythingSlider({
                easing: "swing",        // Anything other than "linear" or "swing" requires the easing plugin
                autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 5000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 00,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
        		startText: "<span>Go</span>",             // Start text
		        stopText: "<span>Stop</span>",               // Stop text
		        navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
            });
            
            $("#slide-jump").click(function(){
                $('.anythingSlider').anythingSlider(6);
            });
            
        });
}

//$.fn.hoverClass = function(c) {
//    return this.each(function(){
//        $(this).hover( 
//            function() { $(this).addClass(c);  },
//            function() { $(this).removeClass(c); }
//        );
//    });
//};
$.fn.imageOver = function() {
    return this.each(function() {
        var objSrc = $(this).attr("src");
        var ftype = objSrc.substring(objSrc.lastIndexOf("."), objSrc.length);
        var objSrcOver = objSrc.replace(ftype, "-ovr" + ftype);
        // var objSrcActive = objSrc.replace(ftype, "-active" + ftype);

        //        $(this).parent().append('<img src=\"'+objSrcOver+'\ class=' + 'hide' + ' />');
        //        $(this).parent().append('<img src=\"'+objSrcActive+'\ class=' + 'hide' + ' />');

        $(this).hover(function() {
            $(this).attr("src", objSrcOver);
        }, function() {
            $(this).attr("src", objSrc);
        });
    });
};    


function fixCalendarArrows() {
    var text = $("#Calendar1 .mup_monthHeaderPrev a").text();
    text = text.substring((text.length - 3));
    text = "<span class='LArrow'>" + text + "</span>";
    $("#Calendar1 .mup_monthHeaderPrev a").html(text);

    var text = $("#Calendar1 .mup_monthHeaderNext a").text();
    text = text.substring(0,3);
    text = "<span class='RArrow'>" + text + "</span>";
    $("#Calendar1 .mup_monthHeaderNext a").html(text);
    
}