jQuery(function($){
  var drop;
    
  $("#mainNav a").not(".current, li ul a").css( {backgroundPosition: "0 0"} )

  .hover(
    function(e){
      
      $(this).stop().animate({backgroundPosition: "(0 -80px)", color: "#000"}, 250, function(){
        });
    },function(e){
      $(this).stop().animate({backgroundPosition: "(0 0)", color: "#fff"}, 250);
    });//end main nav hover
    
		if ( !$(".IE6").length){
    $("#mainNav a").not("li ul a").hover(
      function(e){
        $(".close").removeClass("close");
        $(drop).stop().slideUp("fast", function(){
          $(this).removeAttr("style");
          });
        drop = $(this).siblings("ul:first");
        $(drop).css({opacity: "1.0"});
        $(drop).stop().slideDown("fast");
      }, function(e){
        // NOTHIGN ELSE
      }
    );
		}
    
    $("#mainNav li ul").not("li ul ul").hover(
      function(e){
        $(this).removeClass("close");
        $(this).stop().animate({opacity: "1.0"}, 300);
    },function(e){
      $(this).addClass("close");
      $(this).stop().animate({opacity: "1.0"}, 500, function(){
        $(".close").fadeOut("slow");
      });
    });// end drop menue hover
    
    $("#mainNav li ul a").hover(
      function(e){
        $(this).css({background: "#fff"});
      },function(e){
        $(this).css({background: "transparent"});
      }
    );
    
    $("#secondaryNav li a").not(".current")
    
    .hover(
      function(e){
        $(this).stop().animate({color: "#6e2a8d"}, 250);
      },function(e){
        $(this).stop().animate({color: "#c3afd4"}, 250);
      }
    );
    //Start Video Player setup
    var targetID = 1;
    $(".player, p:has(span.player)").each(function(){
      $(this).attr("id", "target" + targetID);
      $(this).text("");
      $(this).nextUntil(".player", "p, ol, ul").find("a").has(".video").attr("rel","target" + targetID);
      $(this).wrap("<div class='vp' id='player-target" + targetID + "'/>");
      targetID ++;
    });
		//top
    $("a:not(a:has('.video'))").click(function(e){
      if( $(".playing").length ){
        $("#player-" + target).html("");
				$(".playing").remove();
      }
    });
    var target;
    $("a").has(".video").click(function(e){
      e.preventDefault();
      $(".playing").remove();
      $("#player-" + target).html("");
      $(this).append("<span class='playing'> &lArr; Now Playing</span>");
      var path =  $(this).attr("href");
      target = $(this).attr("rel");
      flashIt(path, target);
    });
    
  $(".download a, a:has(.download)").attr('href', function(){
  return this.href + "?attachment=yes";
  });
//	ARTICLE EXPANDER 
	$(".article").hide();
		$("a:contains('+Read More')").addClass("readMore");
		$("#mainContent a, #sideNav a, #sideContent a").not(".current").hover(function(){
	    $(this).animate({color: "red" }, 250); 
		},function(){
			$(this).animate({color: "#708EA4" }, 250);
		});
    var $target;
    $("a.readMore").click(function(e){
        $target = $(this).parents(".Freeform").prev(".article");
        var $clicked = $(this);
        $target.slideToggle("slow", function(){
            if ($clicked.text() == "+Read More") {
                $clicked.text("-Less");
            }
            else {
                $clicked.text("+Read More");
            }
        });
        e.preventDefault();
    })

});//end jquery ready

function flashIt(_path, _target){
  $("#player-" + _target).html("<p id='"+_target+"' class='player'>New Video Area</p>");//UA-12161257-5
  var flashvars = {};
  flashvars.file = _path;
  flashvars.autostart = true;
  flashvars.plugins = "gapro-1";
  flashvars['gapro.accountid'] = "UA-12161257-5";
  flashvars['gapro.trackstarts'] = "true";
  flashvars['gapro.trackpercentage'] = "true";
  flashvars['gapro.tracktime'] = "true";
  var params = {};
  params.menu = "false";
  params.bgcolor = "#000000";
  params.allowscriptaccess = "always";
  params.allowfullscreen = true;
  var attributes = {};
  attributes.id = "flash content";
  attributes.name = "flash content";
  swfobject.embedSWF("/Commonscripts/videoPlayer/player-licensed.swf", _target, 427, 320, "9.0.0", "false", flashvars, params, attributes);
}




