// JavaScript Document

  //$(document).ready(function(){ 
   // $("#tabs > ul").tabs();
        
  //});
  
  
  
  //accordian
  
   $(document).ready(function() { 
		//javascript for accordion
	//hide the all of the element with class accordion_body
	$(".accordion_body").hide();
	
	//slides the element with class "accordion_body" when paragraph with class "accordion_header" is clicked 
	$("div.accordion_header").click(function() {
	
	 	$(this).toggleClass('active');
		$(this).next("div.accordion_body").slideToggle("normal").siblings("div.accordion_body").slideUp("normal");
			
		$(this).siblings("div.accordion_header").removeClass("active");
	}); 
 
	
})
  
  
//TableStripe
$(document).ready(function() {

	//tabs
	$("#tabs > ul").tabs();
 	
	$('.contentTable table').each(function() {
		$(this).bind('stripe', function() {
		var rowIndex = 0
		$('tbody tr:not(.filtered)', this).each(function(index) {
			if ($('th',this).length) {
				$(this).addClass('subhead')
				rowIndex = -1
			} else {
			if (rowIndex % 2 < 1) {
				$(this).removeClass('odd').addClass('even')
			}
			else {
				$(this).removeClass('even').addClass('odd')
			}
		}
		rowIndex++
		})
	})
	$(this).trigger('stripe')
	}) 
	
});

//Code for show/hide dropdown menus
//For How do I dropdown

$(document).ready(function(){ 

	$('#IWantTo').change(function() {
	$('#taskContainer div').hide('slow');            // added a bit of animation
	var e = '#' + $(':selected', $(this)).attr('name');
	$(e).show('slow');                             // while we change the feed
	});

	$('#taskContainer div').hide();
	$('#taskContainer div#task0').show();


});

//Code for sortable/searchable Service Index
// JavaScript Document

$(document).ready(function() { 
	$("#tabs > ul").tabs();
	var alternateRowColors = function($table) { 
		$('tbody tr:odd', $table).removeClass('even').addClass('odd') 
		$('tbody tr:even', $table).removeClass('odd').addClass('even') 
	} 

	$('table.sortable').each(function() { 
		var $table = $(this) 
		alternateRowColors($table) 
		$('th', $table).each(function(column) { 
			if ($(this).is('.sort-alpha')) { 
				$(this).addClass('clickable').hover(function() { 
					$(this).addClass('hover') 
				}, function() { 
					$(this).removeClass('hover') 
				}).click(function() { 
					var rows = $table.find('tbody > tr').get() 
					rows.sort(function(a, b) { 
					var keyA = $(a).children('td').eq(column).text().toUpperCase() 
					var keyB = $(b).children('td').eq(column).text().toUpperCase() 
					if (keyA < keyB) return -1 
					if (keyA > keyB) return 1 
					return 0 
				}) 
				$.each(rows, function(index, row) { 
					$table.children('tbody').append(row) 
				}) 
				alternateRowColors($table) 
			}) 
		} 
	}) 
	}) 
	 //add index column with all content.   
 $(".filterable tr:has(td)").each(function(){   
   var t = $(this).text().toLowerCase(); //all row text   
   $("<td class='indexColumn'></td>")   
    .hide().text(t).appendTo(this);   
 });//each tr   
 $("#FilterTextBox").keyup(function(){   
   var s = $(this).val().toLowerCase().split(" ");   
   //show all rows.   
   $(".filterable tr:hidden").show();   
   $.each(s, function(){   
       $(".filterable tr:visible .indexColumn:not(:contains('"  
          + this + "'))").parent().hide();   
   });//each   
 });//key up.   
	$(".viewAll").click(function() {
		$(".filterable tr:hidden").show();
	})
})
//






//tables javascript
$(document).ready(function() { 

	
	
	//view only filter results
  $('table.filterable').each(function() {
    var $table = $(this);
    $table.find('th').each(function (column) {
      if ($(this).is('.filter-column')) {
        var $filters = $('<div class="filters"><h4>View Policies by ' + $(this).text() + '</h4></div>');
        var keywords = {};

        $table.find('tbody tr td').filter(':nth-child(' + (column + 1) + ')').each(function() {
          keywords[$(this).text()] = $(this).text();
        });


        $('<p class="filter">View all</p>').click(function() {
          $table.find('tbody tr').show().removeClass('filtered');
         $(this).addClass('active').siblings().removeClass('active');
         $table.trigger('stripe');
        }).addClass('clickable active').appendTo($filters);

        $.each(keywords, function (index, keyword) {
          $('<p class="filter"></p>').text(keyword).bind('click', {'keyword': keyword}, function(event) {
            $table.find('tbody tr').each(function() {
              if ($('td', this).filter(':nth-child(' + (column + 1) + ')').text() == event.data['keyword']) {
                $(this).show().removeClass('filtered');
								
              }
              else if ($('th',this).length == 0) {
                $(this).hide().addClass('filtered');
								
              }
            });

           $(this).addClass('active').siblings().removeClass('active');
          	$table.trigger('stripe');
          }).addClass('clickable').appendTo($filters);

        });
        $filters.insertBefore('div.showFilterButtons');
      }
    });
  });
	  });
// JavaScript Document
$(document).ready(function() { 	
	$('.contentTable table').each(function() {
		$(this).bind('stripe', function() {
		var rowIndex = 0
		$('tbody tr:not(.filtered)', this).each(function(index) {
			if ($('th',this).length) {
				$(this).addClass('subhead')
				rowIndex = -1
			} else {
			if (rowIndex % 2 < 1) {
				$(this).removeClass('odd').addClass('even')
			}
			else {
				$(this).removeClass('even').addClass('odd')
			}
		}
		rowIndex++
		})
	})
	$(this).trigger('stripe')
	}) 
	
});


  
  
