 $(document).ready(function() {

  $("#printsummary").click(function(e){
    e.preventDefault();
    window.open(this.href, "", "width=840,height=700,scrollbars=yes");
  });
              //apply border to quicklinks
              $("#quicklink_container li a:not(:first)").css("border-left", "1px solid #000000");
  
              //display trade article categories
              var PreviousCategory = "";
              $("#tradearticles li").each(function(e) {
                  if (PreviousCategory != this.className) {
                      $(this).prepend("<p>" + this.className + ":</p>");
                      PreviousCategory = this.className;
                      if (e != 0) {
                          this.className = "padding-top";
                      }
                  }
              });
  
              //hook up arrows for carousel
              var ImageCount = $("#imagecarousel .images a").length;
              var CurrentImageIndex = 1;
              $(".leftarrow").click(function(e) {
                  e.preventDefault();
                  if (CurrentImageIndex != 1) {
                      CurrentImageIndex--;
                      $("#imagecarousel .images").animate({ left: (CurrentImageIndex - 1) * -192 }, 200);
                  }
              });
              $(".rightarrow").click(function(e) {
                  e.preventDefault();
                  if (CurrentImageIndex * 3 < ImageCount) {
                      $("#imagecarousel .images").animate({ left: CurrentImageIndex * -192 }, 200);
                      CurrentImageIndex++;
                  }
              });
  
              //show first image
              var PreviousImageID = 1;
              PreviousImageID = $("#currentimage img:first").fadeIn(200).attr("class").replace("img", "");
  
              //hook up carousel thumbnail images
              $("#imagecarousel .images a").click(function(e) {
                  e.preventDefault();
                  var id = $(this).attr("href").replace("#", "");
                  if (PreviousImageID != id) {
                      $("#currentimage .img" + PreviousImageID).fadeOut(300);
                      $("#currentimage .img" + id).fadeIn(300);
                      PreviousImageID = id;
                  }
              });
  
          //for modal window
              $("#addition-video-container a").click(function(e) {
                  //load youtube video
                  $("#video-title").html($(this).attr("title"));
                  $("#videoplayer").load("/machines/YouTubeFlashHtml.aspx?id=" + $(this).attr("href").replace("#", ""));
              });
              
              
              $("#videothumbnail_container a").click(function(e) {
                  //load youtube video
                  $("#video-title").html($(this).attr("title"));
                  $("#videoplayer").load("/machines/YouTubeFlashHtml.aspx?id=" + $(this).attr("href").replace("#", ""));
  
                  //show modal window
                  window.scroll(0,0);
                  $("#overlay").css("opacity", 0.7).show();
                  $("#modalvideo").fadeIn(200);
                  if ($("body").height() > $(document).height()) {
                      $("#overlay").height($("body").height() + 50);
                  }
                  else {
                      $("#overlay").height($(document).height());
                  }
                  
                  if((navigator.appVersion.indexOf("MSIE 6") > 0) ? true : false){
                    $("#overlay").width($(document).width());
                  }
              });
  
              $("#overlay").click(function() {
                  $("#modalvideo").fadeOut(200);
                  $("#overlay").fadeOut(200);
              });
              $(".modalclose").click(function(e) {
                  e.preventDefault();
                  $("#modalvideo").fadeOut(200);
                  $("#overlay").fadeOut(200);
              });
         
        });
        
        $(window).resize(function() {
            if ($("body").height() > $(document).height()) {
                $("#overlay").height($("body").height());
            }
            else {
                $("#overlay").height($(document).height());
            }
        });