
// @release 2009-10-08 spinks

var s_url;
var filter ="recent";
var nl_switch;
var subSection;


function splitSS() {
   var subSplit = sub_path;
   var arr = subSplit.split("/");
   subSection = arr[2];
}

function setFilter(filval) {
  filter = filval;
  s_url = "/i/dispatcher/?h=subsection&path=" + sub_path + "&filter=" + filter; 
  splitSS();
  runSubjax();
  $("#currFilter span").removeClass('dd-interesting');
  $("#currFilter span").removeClass('dd-recent');
  $("#currFilter span").addClass('dd-' + filter);
}

function getOption(s_path){ 
  sub_path = s_path;
  s_url = "/i/dispatcher/?h=subsection&path=" + sub_path + "&filter=" + filter; 
  }
  
function get_subsection_contents(elem,sub_path){ 
  s_url = "/i/dispatcher/?h=subsection&path=" + sub_path + "&filter=" + filter; 
  $('#subsection_nav_ul li').each(function() {
    $(this).find('a').removeClass('selected');
  })
  $(elem).addClass('selected');
  var newLink = "<a href='" + sub_path + "'><h3 class='title'><span class='nocss'>View All</span></h3></a>";
  nl_switch = newLink;
  
  splitSS();
  runSubjax(); 
}

function runSubjax() {
  G.doPixelTracking(6,9,true);
  snAdRefresh();
  $("#loading_subcontent").ajaxStart(function(){
   $(this).css("visibility","visible");
  });
 
  $("#loading_subcontent").ajaxStop(function(){
   $(this).css("visibility","hidden");
  });
  jQuery.ajax({
  url: s_url,
  cache: true,
  success: function(html){
  $("#offleads").html("");
  $("#offleads").append(html); 
  $("#view_all_link").append(nl_switch);  
  }
  });
    
}

function snAdRefresh() {
  var rf = new NBC.Helpers();
  rf.AdFrameRefresher("#nbc_ad_970_66_iframe",subSection);
  rf.AdFrameRefresher("#nbcad_300x250_iframe",subSection);
}

$(document).ready(function() {

  if ( nbc.subsection  == "" )	{
  // execute onclick but keep href there for seo 
  $("#subsection_nav_ul a").click(function(event) {
    event.preventDefault();
  }); 
  }
  
    // flips the drop down arrow and shows it on add moment layer
    $("#the_most").click( function() {
      if ($("#mostdropDownList").is(":hidden")) {
        $("#mostdropDownList").slideDown("fast");
        $("#mostDropDownArrow").removeClass('dropDownArrow');
        $("#mostDropDownArrow").addClass('dropUpArrow');
      } else {
        $("#mostdropDownList").slideUp("fast");
        $("#mostDropDownArrow").removeClass('dropUpArrow');
        $("#mostDropDownArrow").addClass('dropDownArrow');
      }
    });
  });

function closeDropDown() {
    if ($("#mostdropDownList").is(":hidden")) {
     $("#mostdropDownList").slideDown("fast");
     $("#mostDropDownArrow").removeClass('dropDownArrow');
     $("#mostDropDownArrow").addClass('dropUpArrow');
   } else {
     $("#mostdropDownList").slideUp("fast");
     $("#mostDropDownArrow").removeClass('dropUpArrow');
     $("#mostDropDownArrow").addClass('dropDownArrow');
   }
  }
