;
// Initializes User Scripts:
$(document).ready(function() {
 // resizeColumns();
 // setInterval(resizeColumns, 1000);
  groupHeaders();
  newLineAfterGroup();
    
  // Initiates Home Page Slides
  $('.slidesTxt h3').each(function(){
  if ( !$(this).html() )
   // alert($(this).size());
  {$(this).parent('.slidesTxt').hide();} 
   else{
   $(this).parent('.slidesTxt').show();
   } 
  });
  $('#homeSlideShow').cycle({
  fx:     'fade',
  speed:  500,
  timeout: 8000,
   pager:'#nav-1'
  });
  
 //show slides when page loads
  $('#rightColumncycle').show();
  $('#rightColumncycle').cycle({
    fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
  });
 
   // Selects text in Search Box when focused:
    $('input[type=text].clearText').each(function() {
        var txtSearchText = $(this).val();
        $(this).focus(function() {
            if ($(this).val() == txtSearchText) {
                $(this).val('');
            }
        });
        $(this).blur(function() {
            if ($(this).val() == '') {
                $(this).val(txtSearchText);
            }
        });
     });

  // Links - pop up in new window / tab:
  $("a.lnkBlank").click(function() {
    window.open($(this).attr("href"), 'window2', '');
    return false;
  });

  $("img").each(function() {
    var img = $(this).attr("src");
    if ( typeof(img) == 'undefined' || img == '' || img == '/' || img.substr(0, 1) == '?' || img.substr(0, 2) == '/?' ) $(this).hide();
  });
  
    $(".avMediaLink").each(function() {
      var disable = $(this).attr("href");
      if ( typeof(disable) == 'undefined' || disable == '' || disable == '/' || disable.substr(0, 1) == '?' || disable.substr(0, 2) == '/?' ) $(this).hide();
    });
  
    $(".avPdfLink").each(function() {
      var disable = $(this).attr("href");
      if ( typeof(disable) == 'undefined' || disable == '' || disable == '/' || disable .substr(0, 1) == '?' || disable .substr(0, 2) == '/?' ) $(this).hide();
    });
  
  $(".featuredEventTicket a").each(function(){
  if($(this).attr("href") == '') $(this).hide();
  });

  pixelsilk2.renderSkin({skin: '[' + '[Menu1]' + ']', path: ''}, function(html) {
    $("#siteMenu").after('<div id="subNavigation" style="display:none;"></div>');
    $("#subNavigation").html(html);
    var sections = $("#subNavigation div");
    var topElements = $("#topMenu li:not(.separator)");
    for (z = 0; z < sections.length; z++) {
      var li = topElements[z];
      var lihtml = li.innerHTML;
      li.innerHTML = lihtml + sections[z].innerHTML;
    }
    $("#topMenu").navMenu({
      menuWidth: 200,
      containerElement: "#theme",
      menuElement: "ul",
      rightArrow: ' &raquo;'
    });
    $("#subNavigation").remove();
  });

  if ($('#content').size() >0) {
    adjustColumns('#content','div.column',true,true);
  }
      // Adjust the columns (container class or ID, column class, margin-[true|false], padding-[true|false])
    function adjustColumns(container,cssclass,margin,padding) {
        $(cssclass).each(function() {
            var tHeight = 0;
            if (margin) {
                tHeight += Number(Number($(this).css('margin-top').replace('px','')) + Number($(this).css('margin-bottom').replace('px','')));
            }
            if (padding) {
                tHeight += Number(Number($(this).css('padding-top').replace('px','')) + Number($(this).css('padding-bottom').replace('px','')));
            }
            $(this).css('min-height',Number($(container).height()-tHeight));
        });
    }
});


function groupHeaders(){
  var categoryGroup = "somethingrandom";
  $(".groupHeading").each(function(){
    if ($(this).text() != categoryGroup)
      categoryGroup = $(this).text();
    else
      $(this).hide(0);
  });
}

function newLineAfterGroup(){
//add class to containing div
 $('.SponsorItem .groupHeading').each(function(){ 
   var categoryClass = $(this).text().replace(/ /g,'');  
  $(this).parent().addClass(categoryClass) 
    
 });
 //
   $('.sponsorsItemContainer').each(function(){
   if($(this).parent().find('>h2').is(':hidden'))
     $(this).css('padding-top', '30px');     
   });
 //find the last div and add a break
    $('.RubyPartner').last().after("<br class='clear' />");
    $('.GoldPartner').last().after("<br class='clear' />");
    $('.SapphirePartner').last().after("<br class='clear' />");
}

function resizeColumns(){
var highestCol = Math.max($('#mainColumn').height(),$('#rightColumn').height()); $('.mainCols').height(highestCol);
}

