﻿$(document).ready(function(){
$("#content ul:not(.sitemapWidget):not(.noFloat)").each(function(){
     var liCount = $(this).children().size();
     if (liCount >= 6) {
          var firstList = this;
          $(firstList).wrap("<div class='colContainer'><div class='twoCols'></div></div>");
          var colContainer = $(firstList).parent().parent();
          $(colContainer).append("<div class='twoCols next'><ul></ul></div>");
          var secondList = $(".twoCols:last ul", colContainer);
          var secondListLIs = $(firstList).children().slice(Math.ceil(liCount/2));
          $(secondList).append(secondListLIs);
          $("div.colContainer").next().addClass("clear");   
     };//close if nonsense

}); //closing the each-thingy

//make a cool 'external' selector. exceptions: mailto: and javscript jazz
$.expr[':'].external = function(obj){return !obj.href.match(/^mailto\:/)
       && !obj.href.match(/^javascript/) && (obj.hostname != location.hostname);};

//add the class "external", and add popup.
$("#content a:external, a[href*=.pdf], a[href*=.doc], a[href*=.docx]").addClass("external").click(function(){window.open(this.href); return false;;})
//add another class for specific file types
$("a[href*=.pdf]").addClass("pdf");
$("a[href*=.doc], a[href*=.docx]").addClass("doc");
});
