function initCustomScroll(){
	jQuery('.js-box').each(function(){
		var _h = jQuery(this).height();
		var _scrolls = jQuery('.scrollable', this);
		var _minH = 463;
		if(_h > _minH){
			_scrolls.css({height: _h});
		};
		VSA_initScrollbars();
	})
}

jQuery(document).ready(function(){
	
	$(".attachment-post-thumbnail").reflect({height:25,opacity:0.3});
	$(".attachment-subpage-thumbnail").reflect({height:25,opacity:0.3});
	$(".attachment-107x80").reflect({height:25,opacity:0.3});
	$(".attachment-thumb").reflect({height:25,opacity:0.3});
	
	corners(".attachment-post-thumbnail");
	corners(".attachment-subpage-thumbnail");
	corners(".attachment-107x80");
	corners(".attachment-thumb");
	
	// activates the lightbox page, if you are using a dark color scheme use another theme parameter
	my_lightbox("a[rel^='prettyPhoto'], a[rel^='lightbox']");
	
	initCustomScroll();
	
	
});


function corners(theId)
{
	$(theId).load( function () {
		var img = $(this);
		
		// build wrapper
		var wrapper = $('<div class="rounded_wrapper"></div>');
		wrapper.width(img.width());
		wrapper.height(img.height());
		
		// move CSS properties from img to wrapper
		wrapper.css('float', img.css('float'));
		img.css('float', 'none')
		
		wrapper.css('margin-right', img.css('margin-right'));
		img.css('margin-right', '0')
	
		wrapper.css('margin-left', img.css('margin-left'));
		img.css('margin-left', '0')
	
		wrapper.css('margin-bottom', img.css('margin-bottom'));
		img.css('margin-bottom', '0')
	
		wrapper.css('margin-top', img.css('margin-top'));
		img.css('margin-top', '0')
	
		wrapper.css('display', 'block');
		img.css('display', 'block')
	
		// wrap image
		img.wrap(wrapper);
		
		// add rounded corners
		img.after('<div class="tl"></div>');
		img.after('<div class="tr"></div>');
		img.after('<div class="bl"></div>');
		img.after('<div class="br"></div>');
	});	
}

function my_lightbox($elements)
{
$($elements).prettyPhoto({
		"theme": 'light_rounded' /* light_rounded / dark_rounded / light_square / dark_square */																
	});

$($elements).each(function()
{	
	var $image = $(this).contents("img");
	$newclass = 'lightbox_video';
	
	if($(this).attr('href').match(/(jpg|gif|jpeg|png|tif)/)) $newclass = 'lightbox_image';
		
	if ($image.length > 0)
	{	
		if($.browser.msie &&  $.browser.version < 7) $(this).addClass('ie6_lightbox');
		
		/*var $bg = $("<span class='"+$newclass+" ie6fix'></span>").appendTo($(this));
		
		$(this).bind('mouseenter', function(){
			$height = $image.height();
			$width = $image.width();
			$pos =  $image.position();		
			$bg.css({height:$height, width:$width, top:$pos.top, left:$pos.left});
		});*/
	}
	
	
	
});	
	
$($elements).contents("img").hover(function(){
		$(this).stop().animate({opacity:0.5},400);
		},function(){
		$(this).stop().animate({opacity:1},400);
		});


}


