jQuery.fn.callouts = function() {
  return this.each(function() {
    var I = $("p", this), i = I.prev("img").attr("width");
    I.css("width", i)
  })
};
$(function() {
  try {
    $("#right h4").each(function(I) {
      var i = this;
      if(!$(i).find("span").length) {
        $(i).wrapInner("<span/>")
      }
    })
  }catch(e) {
  }
	// external links
	$("a[rel=external]").attr({title: "Opens in new window", target: "_blank"})
		.click(function(){
			var href = $(this).attr("href");
			// only log external sites
			// prevents double logging of external documents such as PDF's
			// which occationally open in a new window
			if( href.search(/http/i) >= 0 ){
				try{
					pageTracker._trackPageview("/outgoing/" + href);
				}catch(e){}
			}
		});
	
	//track file downloads
	$("a[href$=exe],a[href$=pdf],a[href$=zip],a[href$=pps],a[href$=doc],a[href$=xls]")
		.click(function(){
			var href = $(this).attr("href");
			try{
				pageTracker._trackPageview("/download/" + href);
			}catch(e){}
		});

/* -------------------------------------------
	// FlowPlayer w/Overlay
	------------------------------------------- */
	try{
		
		// inserts the overlay and flvplayer containers
		// if not found
		if($("a[href$=flv]").length && !$("#overlay-video").length){
			$("<div id=\"overlay-video\"><div id=\"flvplayer\">&nbsp;</div></div>").appendTo("body");
		}
		
		//FlowPlayer Object
		var $flvPlayer = $f("flvplayer", "/global/flash/flowplayer.swf", {
							clip:{
								scaling: "fit"
							}
		});
		
		// overlay trigger
		$("a[href$=flv]").overlay({
			mask: {
				color: "#000000",
				loadSpeed: 200,
				opacity: 0.5
			},
			target: "#overlay-video",
			// when overlay is opened, load our player
			onLoad: function() {
				var trigger = this.getTrigger(),
					href = trigger.attr("href");
				$flvPlayer.load().play(href);
				try{
					pageTracker._trackPageview(href);
				}catch(e){}
			},
			// when we close the overlay
			// close the player
			onClose: function() {	
				$flvPlayer.unload();
			}	
		});
		
	}catch(e){}
  $("#query").val("Search...").blur(function() {
    var i = this;
    if($(i).val().length == 0 || $(i).val() == "Search...") {
      $(i).val("Search...")
    }
  }).focus(function() {
    var i = this;
    if($(i).val() == "Search...") {
      $(i).val("")
    }
  });
  $("#searchform").submit(function() {
    var i = $("#query");
    if(i.length == 0 || i.val() == "Search...") {
      var I = $(":hidden[name=cq]").val();
      window.location = "/texis/webinator/search?pr=Bemis&amp;cq=" + I;
      return false
    }
  });
  try {
    $(".expandme > a").removeAttr("onclick").attr({href:"#", title:"Click to expand"}).click(function() {
      $(this).parent().nextAll(".contentstub:eq(0)").slideToggle("normal");
      return false
    })
  }catch(e) {
  }
  try {
    var l = $("<img/>").attr({src:"/global/images/new-transparent.gif", width:"17", height:"5", alt:"New!"});
    $(".new").prepend(l.clone())
  }catch(e) {
  }
  try {
    $("div.callout").callouts()
  }catch(e) {
  }
  try {
    $("#listtools").remove();
    $("#list").attr("id", "navtree");
    $("#navtree").menuTree()
  }catch(e) {
  }
});
