jQuery(function() { 
  // wire up tabs
  jQuery(".about_tabs.cms").tabs("#tab_container");
  jQuery(".about_tabs.cms > li:first").addClass('on');
  jQuery(".about_tabs.cms li a").css({'display':'block','height':'32px'});
 
  jQuery(".about_tabs.cms li").click(function(e) {    
    jQuery(".about_tabs.cms li a").css({'outline':'0'});
    jQuery(".about_tabs.cms li").removeClass('on');
    jQuery(this).addClass('on');
    //the code below only fires the click event if the target is the li
    if (jQuery(e.target).is('li')){
      jQuery(this).find("a").click();
    }
  });
  
  // hide empty tabs
  jQuery.each(jQuery(".about_tabs.cms li"), function(index, value) {
    if (jQuery(value).find('a').html().length == 0) {
      jQuery(value).hide();
    }
  });
  // pre-select tabs if they have a fragment identifier in the URL
  $taburl = window.location.href;
  $partUrl = $taburl.split('\=');
  var fragmentID = $partUrl[1];
  var tabLength = jQuery('#about_landing .about_tabs.cms li').length;
  if (fragmentID != null) {
    	  //var fragmentIDIndex = matchResult[0];
      var fragmentIDIndex = $partUrl[1];
      fragmentIDIndex = parseInt(fragmentIDIndex) - 1;
      var locatedTabLink = jQuery(".about_tabs.cms a.tab-for")[fragmentIDIndex];
     //$('#aboutslot'+[fragmentIDIndex]).parent().addClass('on');
      var $div_on = fragmentIDIndex+1;
      
      for (i=0;i<=tabLength+1;++i){
    	  if(i==$div_on){
    	  jQuery('#slot'+i).parent().attr({'class':'on'}); 
    	  jQuery('#aboutslot'+i).parent().attr({'class':'on'});
    	  jQuery('#abouttriaslot'+i).parent().attr({'class':'on'});
    	  jQuery('#pdpslot'+i).parent().attr({'class':'on'});
    	  }
      else{
    	  jQuery('#slot'+i).parent().attr({'class':'abcd'});
    	  jQuery('#aboutslot'+i).parent().attr({'class':'abcd'});
    	  jQuery('#abouttriaslot'+i).parent().attr({'class':'abcd'});
    	  jQuery('#pdpslot'+i).parent().attr({'class':'abcd'});
    	  
      }
    }
      
      if (locatedTabLink != null) { jQuery(locatedTabLink).click();}
  
  }
});
