$(document).ready(function() {

  if ( $('#supersize').length > 0 )  
  {
    $(function(){
      $.fn.supersized.options = {
        startwidth: 1280,
        startheight: 1024,
        minsize: 2,
        slideshow: 0,
        slideinterval: 5000
      };
      $('#supersize').supersized();
    });
    $('#supersize').css({opacity:1});
  }
  
  if($('#gear').is(':visible')){
  sortUnorderedList("gear");
  sortUnorderedList("radio");
  sortUnorderedList("fx");
  sortUnorderedList("portable");
  }  
       
  $('.text-body ul').columnize({columns: 2});
  $('.contact_form').columnize({columns: 2});  

  $("img.thumb").thumbs(); // the wrapping function
  //$("img.thumb").thumbsImg(); // the img positioning function (optional)  
});

$(window).load(function () {
	// jquery that loads when the window loads (i.e. before the content is ready)...
});



/** 
* Sort List Alphabetically
* =================================
*/ 

function sortUnorderedList(ul, sortDescending) {
  if(typeof ul == "string")
    ul = document.getElementById(ul);

  // Get the list items and setup an array for sorting
  var lis = ul.getElementsByTagName("LI");
  var vals = [];

  // Populate the array
  for(var i = 0, l = lis.length; i < l; i++)
    vals.push(lis[i].innerHTML);

  // Sort it
  vals.sort();

  // Sometimes you gotta DESC
  if(sortDescending)
    vals.reverse();

  // Change the list on the page
  for(var i = 0, l = lis.length; i < l; i++)
    lis[i].innerHTML = vals[i];
}

