// Wedding Window JavaScript Stuff


document.documentElement.className = 'js-enabled';
//document.getElementsByClassName('html')[0].className = 'js';


// test for include
//alert ('included!');

jQuery(document).ready(function() {
	
	// test for jQuery working
	//alert("Hello world!");
	
	// Make Category Columns
	
	// get total number of categories
	var total_cats = jQuery('li.cat-item').length;
	// define the number of groups you'd like
	var cat_groups = 3;
	// get number of categories to go in each group
	var cats_in_group = Math.ceil( total_cats / cat_groups);
	
	// create array to hold results
   var cat_list = [];
   
   // for each item...
   jQuery('li.cat-item').each(function (i, value) {
	
	// add current item to array
	cat_list.push(value);
	
	// if it's a break point or the last item...
	if (((i + 1) % cats_in_group === 0) || (i === total_cats -1))
	{
		// store array in new variable
		var current_set = jQuery(cat_list);
		
		// reset array to empty
		cat_list = [];
		
		// wrap div around the current group
		current_set.wrapAll(jQuery('<div class="cat-wrap"></div>'));
	 }
   });
	
	
	
	
	jQuery('body').addClass('js-enabled');
	
	
	// add class to header widgets for styling
	jQuery('#header-aside ul:eq(0)').addClass('dynamic');
	
	
	
	/*
	jQuery('.widget_openxwpwidget a')
		.not('.widget_openxwpwidget a:eq(0)')
		.css({
			'width': '125px',
			'float': 'left',
			'display': 'block',
			'clear': 'none',
			'padding': '17px 0 0 17px',
			'margin': '0'
		});
		*/
	
	
	
	// add mouse enter / out menu reveal
	/*
	jQuery('#header-aside ul.xoxo li').mouseenter(function(){
		jQuery(this).children('ul').slideDown(0);
		jQuery(this).children('h3').addClass('hover');
	}).mouseleave(function(){
		jQuery(this).children('ul').slideUp(0);
		jQuery(this).children('h3').removeClass('hover');
	});
	
	jQuery('#header-aside ul.xoxo li ul a').mouseenter(function(e){
		e.stopPropigation();
		jQuery(this).parent('ul').slideDown(0);
	}).mouseleave(function(e){
		e.stopPropigation();
		jQuery(this).parent('ul').slideUp(0);
	});
	*/
	
	var config = {    
     sensitivity: 4, // number = sensitivity threshold (must be 1 or higher)    
     interval: 0, // number = milliseconds for onMouseOver polling interval    
     over: menuOpen, // function = onMouseOver callback (REQUIRED)    
     timeout: 0, // number = milliseconds delay before onMouseOut    
     out: menuClose // function = onMouseOut callback (REQUIRED)    
	};
	
	//$("#demo3 li").hoverIntent( config );
	
	jQuery('#header-aside ul.xoxo li').hoverIntent( config );
	
	function menuOpen(){
		jQuery(this).children('ul').slideDown(0);
		jQuery(this).children('h3').addClass('hover');
	}
	
	function menuClose(){
		jQuery(this).children('ul').slideUp(0);
		jQuery(this).children('h3').removeClass('hover');
	}

	
	
	/*
	jQuery('#header-aside ul.xoxo li').hover(
      function () {
        jQuery(this).children('h3').addClass('hover');
		jQuery(this).children('ul').fadeIn();
      }, 
      function () {
		jQuery(this).children('h3').removeClass('hover');
        jQuery(this).children('ul').fadeOut();
      }
    );
*/
	
	
	// used for testing to make menu open
	/*
	jQuery('#header-aside ul.xoxo li ul:eq(0)').slideDown();
	jQuery('#header-aside ul.xoxo li h3:eq(0)').addClass('hover');
	*/
	
	
	
	jQuery('.sociable').not('.category-authors .sociable', '.category-mini-bio-only .sociable').each(function(i){
		var mama = '.the_post_comments:eq(' + i + ')';
		jQuery(this).appendTo(jQuery(mama)).not('.category-authors ' + mama, '.category-mini-bio-only ' + mama);
	});
	
	
	
	
	jQuery('.multiwidget_author_avatars .no_users').parent('.multiwidget_author_avatars').css('display', 'none');
	
	
	
	// move category info
	jQuery('.cat-links').each(function(i){
			var mama = '.post:eq(' + i + ')';
			var sister = '.the_post_comments:eq(' + i + ')';
			
			jQuery(mama).children('.entry-utility').addClass('cat-reveal-button').prepend('<span class="cat-links"><a>Filed under</a> |&nbsp;</span>');
				
			jQuery(this).insertBefore(jQuery(sister)).wrap('<div class="cat-reveal"></div>');
			
			jQuery(this).parent('.cat-reveal').slideUp(0);
	});
	
		
	//jQuery('.sociable').appendTo( jQuery(this).parent('body') );
	
	
	
	
	// add reveal
	jQuery('.cat-reveal-button .cat-links').click(function(){
		jQuery(this).parent('.cat-reveal-button').siblings('.cat-reveal').slideToggle('fast');
	});
	
	
	
	
	
	
	jQuery('.widget_openxwpwidget a').not('.widget_openxwpwidget a:eq(0)').addClass('small_ad');
 });
