$(document).ready(function() {
  // initialise the main navigation menu, using the superfish plugin
  $('#vsee2_top_nav ul.list').superfish({
    dropShadows: true
  });

  // wrap links around various award and grading logos. The links point at the awads and logos explained page. This means that the various grading and awards logos around the site are clickable, functionality that is not possible out of the box.
  $("img.membership").wrap("<a href='/site/awards-and-logos-explained#tse_membership' title='An explanation of the various logos, awards and gradings used on this site'></a>");
  $("div.vaqas img").wrap("<a href='/site/awards-and-logos-explained#vaqas' title='An explanation of the various logos, awards and gradings used on this site'></a>");
  $("img.gtbsaward").wrap("<a href='/site/awards-and-logos-explained#gtbs' title='An explanation of the various logos, awards and gradings used on this site'></a>");
  $("div.enjoyengland img").wrap("<a href='/site/awards-and-logos-explained#gradings' title='An explanation of the various logos, awards and gradings used on this site'></a>");
  $("span.awardimage img").wrap("<a href='/site/awards-and-logos-explained' title='An explanation of the various logos, awards and gradings used on this site'></a>");
  $("div.gradings img[src^=\/engine\/shared_gfx\/designators]").wrap("<a href='/site/awards-and-logos-explained#gradings' title='An explanation of the various logos, awards and gradings used on this site'></a>");
  $("div.gradings img[src^=\/engine\/shared_gfx\/nasratings]").wrap("<a href='/site/awards-and-logos-explained#nas' title='An explanation of the various logos, awards and gradings used on this site'></a>");
  
  // wrap links around special offer icons
  // These are currently not required as Special Offers are not being used on the site - southeastoffers.com provides the special offers
  /*
    $("div.special_offers_acco").wrap("<a href='/site/special-offers/accommodation' title='Special offers on accommodation'></a>");
    $("div.special_offers_attr").wrap("<a href='/site/special-offers/things-to-do' title='Special offers on things to do'></a>");
    $("div.special_offers_cate").wrap("<a href='/site/special-offers/where-to-eat' title='Special offers on where to eat'></a>");
    $("div.special_offers_even").wrap("<a href='/site/special-offers/events' title='Special offers on events'></a>");
    $("div.special_offers_tran").wrap("<a href='/site/special-offers/getting-around' title='Special offers on getting around'></a>");
    */
  // add class to superfluous <p> tag added by FCKEditor to allow manipulation by CSS - FCKEditor insists on wrapping every element in <p> tags - in this case, images
  $("div.main_page_content p:has(img)").addClass("image_wrapper");
  
  // add class to first paragraph of text to allow highlight by CSS
  $("div.main_page_content p:not(.image_wrapper):first").addClass("first");
  $(".ctl_ProductDetail .description p:first").addClass("first");

  // add icons to links based on filetype and external links - see tmLib.js
  tmLinkIcons();

  // fix ie6's dodgy png support - see tmLib.js
  if($.browser.msie && $.browser.version < 7) {  
    tmFixPngs();
  }
});