

// Initializes User Scripts:
$(document).ready(function() {
  $('.homeSlideShowNavItem ul.subNavFlyOut').css({'display':'none'})
  groupHeaders();
  groupDateHeaders();
  
$(".amountDue input[type=radio]").change(function() {
       var test = $(this).val();
       $(".AmountDueOther").hide();
       $(".AmountDueOther."+test).show();
   }); 
  
  if($('#secondColumn').size() == 0)
    $('#mainColumn').css('width', '100%')
  
  $('.slidesTxt').show();
  
  //Changes the look of an interior page  
  if ($('#interiorSubHeaderWrapper').size() == 1)  
  $('.interior #contentWrapper').css('background', 'url("/content-shadow.gif") repeat-x scroll 0 0 #E9E9E9');
  
  // Starts Cycle Function  
  $('#slideShow').cycle({
  fx:     'fade',
  speed:  500,
  timeout: 8000,
  pager:'#nav-1'
  });
  
  // Nivo Code
 //  $('#slideShow').nivoSlider({effect:'fold',pauseTime:4500});
 //  $('#slideShow').css("overflow","visible");

  $('ul#topMenu>li:first-child').addClass('navFirst');
  $('ul#topMenu>li:last-child').addClass('navLast');

  // Selects text in Search Box when focused:
  $('input.txtSearch').focus(function() {
    this.select();
  });
  $('input.txtSearch').blur(function() {
    if ( $(this).val() == '' ) $(this).val('search');
  });

  // 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();
    });

  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();
    homeNav();
  });
  
  if (window.location.href.indexOf("path=%2Ffree-music-download") > -1)
   freedownload();
//  End Document.ready
});

function homeNav() {
    var sections2 = $("#homeSlideShowNav>li");
    var topElements2 = $("#homeSlideShowNav>li>ul");
    for (z = 0; z < sections2.length; z++) {
      var li = topElements2[z];
      var lihtml = li.innerHTML;
      li.innerHTML = lihtml + sections2[z].innerHTML;
    }
    $("#homeSlideShowNav").navMenu({
      menuWidth: 200,
      containerElement: "#theme",
      menuElement: "ul",
      rightArrow: ''
    });

}

function groupHeaders(){
  var categoryGroup = "somethingrandom";
  $("#calendarItems #CalendarDay .groupHeading").each(function(){
    if ($(this).text() != categoryGroup)
      categoryGroup = $(this).text();
    else
      $(this).hide(0);
  });
}
function groupDateHeaders(){
  var categoryGroup = "somethingrandom";
  $(".dateHeading").each(function(){
    if ($(this).text() != categoryGroup)
      categoryGroup = $(this).text();
    else
      $(this).html('&nbsp;');
  });
}

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

function showHomePieceNav(){    
    $('.homeSlideShowNavItem').hover(function(){
        $(this).find('.subNavFlyOut').css({'display':'block'});
        $('.subNavFlyOut', this)
            .stop()
            .animate({
                opacity: 1.0
            }, 300);
    }, function() {
        $('.subNavFlyOut', this)
            .stop()
            .animate({
                opacity: 0
            }, 100, function() {$(this).css({'display':'none'});
        });
    });
  

 
}
 function freedownload(){
 $('.loginControl').addClass('freeDownloadForm');
 $('#username').parent('td').parent('tr').addClass('freeDownloadFormUsername');
  $('#password').parent('td').parent('tr').addClass('freeDownloadFormPassword');
  $('#loginButton').addClass('freeDownloadFormSubmit');
 
   $('.freeDownloadFormSubmit').val('Submit');
    $('.freeDownloadFormUsername #username').attr("value", "FreeMusicDownload");
     $('.freeDownloadFormUsername').hide();
 
 $('.freeDownloadForm').parent().parent('#mainColumn').prepend('<div><h1> Please Enter the Password to Receive Your Free Music Download</h1></div>');
 }


