jQuery.noConflict();
jQuery(document).ready(function($){
	
	// CONTENT: Clean up page title, and breadcrumbs
	if( $('#page-title').css('display') == 'none' && $('#breadcrumbs ul').size() == 0 ){
		$('#page-title').remove();
		$('#content-wrapper').css('paddingTop','0px');
	}
	if( $('#breadcrumbs ul').size() == 0 )
		$('#breadcrumbs').remove();
	
	// HEADER: Clean up title, slogan, and logo
	if( $('#title').text() == '' && $('#slogan').text() == '' && $('#logo').html() == '' ){
		$('#title,#slogan,#logo').remove();
		$('#header').css({paddingTop:'36px',paddingBottom:'0px'});
	}

	// MENU: Setup drop down menus
	$('#menu ul ul li:has(ul) > a').addClass('parent');
	
	$("#commentForm").validate();

	
	// GLOBAL: Enable Fancybox
	$('a.thermageGallery').fancybox({
		'transitionIn'	:'elastic', 
		'transitionOut'	:'elastic',
		'opacity' :true,
		'cyclic'	:true,
		'titleShow' :true,
		'titlePosition' :'inside'});
		
	$("a#inline").fancybox({
		'hideOnContentClick': true});
		
	$("a.singleimage").fancybox({
		'titleShow'     : true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titlePosition'  : 'inside'});
		
	$("#youtubeclip").click(function() {
		$.fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'none',
				'transitionOut'	: 'none',
				'title'			: this.title,
				'width'		: 680,
				'height'		: 495,
				'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'			: {
					 'wmode'		: 'transparent',
					'allowfullscreen'	: 'true'
				}
			});
	
		return false;
	});
	
	$("ul.sf-menu").supersubs({ 
		minWidth:    12,   // minimum width of sub-menus in em units 
		maxWidth:    27,   // maximum width of sub-menus in em units 
		extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
						   // due to slight rounding differences and font-family 
	}).superfish();  // call supersubs first, then superfish, so that subs are 
					 // not display:none when measuring. Call before initialising 
					 // containing tabs for same reason. 


	
    $('#announcements').pulse({
        opacity: [.2,.4,.6,.8,1,.8,.6,.4]
    }, {
        times: 999999    
    });

	// BLOG: Clean up blog sidebar
	if( $('.blog-entry').size() > 0 ){
		if( $('#sidebar-title').text() == '' ){
			$('#sidebar-title').hide();
			$('#blog-categories').css('marginTop','0px');
		}
		if( $('#blog-categories').html() == '' )
			$('#blog-categories').hide();
		if( $('#blog-archives').html() == '' )
			$('#blog-archives').hide();			
	}
		
	// FILE SHARING: Clean up File Sharing Description if unused
	if( $('.filesharing-description').size() > 0 ){
		if( $('.filesharing-description').html() == '' )
			$('.filesharing-description').hide();
	}
		
});