jQuery(function($){
	var hoverElements = ['.blog_big', '.blog_small', '.blog_middle', '.blog_full'];
	
	$.each(hoverElements, function(key, value){
		if(!$(value).hasClass('no-hover')){
			$(value).bind('mouseenter mouseleave', function(e){		
				var blogString;
				
				if(value){
					blogString = value.slice(value.lastIndexOf('_') + 1);
					
					switch(e.type){
						case 'mouseenter':
							$(this).children('.blog_' + blogString + '_head').css({
								//backgroundImage : 'url(layout/img/blog_big_head_a.jpg)'
								backgroundPosition : 'right top'
							})
							$(this).children('.blog_' + blogString + '_bottom').css({
								//backgroundImage : 'url(layout/img/blog_big_bottom_a.jpg)'
								backgroundPosition : 'right bottom'
							})
							$(this).children('.blog_' + blogString + '_main').css({
								//backgroundImage : 'url(layout/img/blog_big_texture_a.jpg)'
								backgroundPosition: 'right top'
							})
						break;
						case 'mouseleave':
							$(this).children('.blog_' + blogString + '_head').css({
								backgroundPosition : 'left top'
								//backgroundImage : 'url(layout/img/blog_big_head_n.jpg)'
							})
							$(this).children('.blog_' + blogString + '_bottom').css({
								//backgroundImage : 'url(layout/img/blog_big_bottom_n.jpg)'
								backgroundPosition : 'left bottom'
							})
							$(this).children('.blog_' + blogString + '_main').css({
								backgroundPosition : 'left top'
								//backgroundImage : 'url(layout/img/blog_big_texture_n.jpg)'
							})
						break;
					}
				}
			})	
		}
		
	})
	
	if($('.tagcloud a').length > 9){
		$('.tagcloud a').each(function(i){
			if(i > 8){
				$(this).hide();
			}
		})
	} 
	$('.ngg-galleryoverview img').css({
		opacity: '.3',
	  	filter: 'alpha(opacity = 30)'
	});
	$('.ngg-galleryoverview img').bind({
		mouseover : function(){
			$(this).animate({
				opacity: '1.0',
			  	filter: 'alpha(opacity = 100)'
			}, 200)
		},
		
		mouseleave : function(){
			$(this).animate({
				opacity: '0.3',
				filter: 'alpha(opacity = 30)'
			}, 200)
		}
	})
	
	$('.blog_small ul li a').each(function(){
		if($(this).children('img:first').length){
			if($(this).children('img:first').attr('src').lastIndexOf('_nrm') >= 0){
				$(this).bind({
					mouseenter : function() {
						var srcAttr = $(this).children('img:first').attr('src').replace('_nrm', '');
						$(this).children('img:first').attr('src', srcAttr);
						
					},
					mouseleave : function() {
						var srcAttr = $(this).children('img:first').attr('src').replace('.gif', '_nrm.gif');
						$(this).children('img:first').attr('src', srcAttr);
					}
				})
			}
		}
	})
	
	$('#main_container_head_menu ul li a').each(function(){
		$(this).css('fontWeight', 'bold');
		//page-item-66
		$(this).parent().css('width', $(this).parent().width());
		
		$(this).removeAttr('style');
		
		
	});
	
	var sideBarPos = $('.blog_big:first').position();
	
	$('#sidebar').traveller({
		offset : 490,
		fixedXPos : 900,
		origY : 920,
		fixed: false
	});
	
	$('.children li a').each(function(){
		var r = new RegExp(/\s+/);
		$(this).html($(this).text().replace(r, '&nbsp;').replace(r, '&nbsp;').replace(r, '&nbsp;'));
		$(this).parent().width($(this).parent().width() + 5);
	})
	
	if(sideBarPos){
		$('.page-id-19 #main_container_content_right').traveller({
			offset : sideBarPos.top,
			fixedYPos : 700,
			fixedXPos : 680,
			origY : 871,
			origX : 680,
			fixed : false
		});
		
		$('.page-id-19 #main_container_content_right').css({
			position : 'absolute',
			left: 730,
			top: sideBarPos.top
			
		});
	}
	
	$('#sidebar > a').live('click', function(e){
		e.preventDefault();
		var showElement;
		
		socialDefaultState();
		
		showElement = this.className;

		$('div.' + showElement).show();
		
		$(this).addClass(this.className + '_active');
	})
	
	var socialDefaultState = function(){
		$('div.rss, div.facebook, div.google').hide();
		$('a.rss').removeClass('rss_active');
		$('a.facebook').removeClass('facebook_active');
		$('a.google').removeClass('google_active');
	}
	
	$('body').bind('click', function(){
		socialDefaultState();
	})
})

