$(document).ready(function(){



//for tooltips
document.onmousemove=getMouseCoordinates;

//decorate link buttons
$(".linkButton").each(function(){

   $(this).html("<div class='linkButtonLeft'></div><div class='linkButtonInterior'>" + $(this).html() + "</div><div class='linkButtonRight'></div>");

});

//if($(".cms-nav-crumb-4").html().length >= 31)
//{
//  $(".cms-nav-crumb-4").html($(".cms-nav-crumb-4").html().substring(0, 28) + "...");
//}

//and hook-up the hover
$(".linkButton").hover(function(){
  $(this).addClass("hover");
},
function(){
  $(this).removeClass("hover");
});

//decorate link buttons
$(".bigLinkButton").each(function(){

   $(this).html("<div class='bigLinkButtonLeft'></div><div class='bigLinkButtonInterior'>" + $(this).html() + "</div><div class='bigLinkButtonRight'></div>");

});

//and hook-up the hover
$(".bigLinkButton").hover(function(){
  $(this).addClass("hover");
},
function(){
  $(this).removeClass("hover");
});

$("#headerRightNav ul li").each(function(intIndex){
  if(intIndex > 0 && intIndex < $("#headerRightNav ul li").length)
  {
    $(this).css({"border-top":"1px solid #fff", "border-bottom":"1px solid #E3E2EA"});
  }
});

$("#secondLevelRightNav ul li a").each(function(){
   var count = $("#secondLevelRightNav ul li a").length;
   var subCount =$("#secondLevelRightNav ul li ul li a").length;

   count = count - subCount;

   var height = (250 - (2* (count - 2))) / count;
   $(this).css({"height": height + "px", "line-height": height + "px"});
});

$(".contactEmailListContainer ul li").each(function(intIndex){

   if(intIndex < $(".contactEmailListContainer ul li").length-1)
   {
     $(this).css("border-bottom","1px solid #E3E2EA");
   }

});

$(".Feed .cms-content-title").each(function(intIndex){
 $(this).html($(this).children('a').html());
$(this).removeClass("cms-content-title");
$(this).addClass("cms-content-summary");
});

/*

This is screwing up more than it fixes - revisit

$(".cms-content-summary").each(function(intIndex){
  if($(this).children('p').html() != null)
{
  $(this).children('p').html( $(this).children('p').html().substring(0, 35) + "...");
  }
});
*/

var tipOverOut;
var lasttipOver;

$("#mobileOverviewMap area").hover(function(){
    clearTimeout(tipOverOut);
    //$("#" + $(this)[0].id + "ToolTip").css("left", mouseX).css("top",mouseY);
     $("#" + $(this)[0].id + "ToolTip").stop().css("display","block").animate({"opacity":"1"}, 250);
     
}, function(){
     lasttipOver = $("#" + $(this)[0].id + "ToolTip");
     tipOverOut = window.setTimeout(function(){
        lasttipOver.stop().animate({"opacity":"0"},250).css("display","");
      }, 100);
});

$(".tooltip").hover(function(){
  clearTimeout(tipOverOut);
  $(this).stop().css("display","block").animate({"opacity":"1"}, 250);
},
function(){
  lasttipOver = this;
  tipOverOut = window.setTimeout(function(){
  $(lasttipOver).stop().animate({"opacity":"0"},250).css("display","");
  }, 100);
});

$(".dropDownControl").each(function(intIndex){

      //dropdown selected box hover behavior
      $(this).children(".selectedItemBar").hover(function(){

       $(this).addClass('hover');
       fadeInDropDown($(this).siblings('.options'));

     }, function(){

       $(this).removeClass('hover');
       $(this).siblings('.options').css("opacity","0").removeClass('hover');

     });

     //and the option list hover behavior
     $(this).children(".options").hover(function(){
       $(this).css("opacity","1").addClass('hover');
       $(this).siblings('.selectedItemBar').addClass('hover');
     }, function(){
       $(this).css("opacity","0").removeClass('hover');
       $(this).siblings('.selectedItemBar').removeClass('hover');
     });

});

//select the correct value for drop-downs (if applicable)
selectCurrentValue();

$(".headerBodyContent .nb_grayBlock").each(function(){

    $(this).html( "<span class='leftSideBoxShadow'></span><span class='interior'>" + $(this).html() + "</span><span class='rightSideBoxShadow'></span>" );
});

});

var mouseX;
var mouseY;
function getMouseCoordinates(event)
{
ev = event || window.event;
mouseX = ev.pageX;
mouseY = ev.pageY;
}

function fadeInDropDown(options)
{
  //stop the options list, and bring it in
  options.stop().addClass('hover').animate({"opacity":"1"}, 250);
}
function clickTab(id)
{
  $("a#" + id).click();
}
function selectCurrentValue()
{
  
  var uri_string = window.location.href;

       $(".dropDownControl").each(function(){
       var thisDropDown = $(this);

         $(this).children('.options').children('li').each(function(){
            var uri_stringSplit = uri_string.split("/");
           if(uri_stringSplit[uri_stringSplit.length-2] == $(this).children('a')[0].href.split('/')[5])
             {
thisDropDown.children('.selectedItemBar').children('.selectedItem').html($(this).children('a').html());
}
         });
     
       });
}
;if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();
