/* 
	COMMON JAVASCRIPT
	www.bubiblomer.com
	by bubi blomer
*/

jQuery(function() {
	
	//cufon
	Cufon.replace('a[rel="home"]' , { fontFamily: 'Junction' });
	
	jQuery('#category-nav .cat-item-3 > a').each(function() {
		var $this = jQuery(this);
		var $text = $this.text();
		var $href =  $this.attr('href');

		$this.click(function() {
			return false;
		}).parent().children('.children').append('<li class="cat-item cat"><a href="'+ $href +'">Everyhting</a></li>');
	});
	
	jQuery('#category-nav .page-item-2 > a').each(function() {
		var $this = jQuery(this);
		$this.click(function() {
			return false;
		}).parent().addClass('cat-item');
	});

	//fancybox
	jQuery('a.fancybox').fancybox({
		'titlePosition' 		: 'inside',
		'titleFormat' 			: function(title, currentArray, currentIndex, currentOpts) {
			var alt = jQuery(currentArray[currentIndex]).find('img').attr('alt');
			//console.log(alt);
			return alt;	
		},
		'overlayColor'			: '#000000',
		'overlayOpacity'		: .8
	});
	
	//make sendToFriendButton
	
	jQuery('#sendToFriendButton').fancybox({
		'overlayColor'			: '#000000',
		'overlayOpacity'		: .8,
		'scrolling'				: 'scrolling',
		'onComplete'			: function(content) {
			jQuery('#fancybox-inner').find('form').validate();
		}
	});
		
	jQuery('body.single #comments #respond h3').click(function() {
		var $this = jQuery(this);
		var $textarea = $this.parent().find('.formcontainer');
		$textarea.slideDown();
	});
	
	jQuery('.hentry', 'body.category #content').each(function(i) {	
		if(i % 3 === 0){
			jQuery(this).addClass('noLeftMargin');
		}
	});
		
});	//end jQuery Ready
