/*
Author: Joe Tan (joetan54@gmail.com)
*/

jQuery(function($) {
	$('input[type=text]:not(.noclear), textarea:not(.noclear)').focus(function() {
		if ($(this).attr('defaultValue') == $(this).val()) $(this).val('')
	}).blur(function() {
		if ($(this).val() == '') { $(this).val($(this).attr('defaultValue'))}
	});
	
	$('blockquote p:has(img)').addClass('img')
	
	$('img.framed').each(function(i,obj) {
		var div = document.createElement('div')
		$(div).addClass('framed').addClass($(obj).attr('class'))
		$(obj).attr('class','')
		$(obj).wrap(div)
	});
	
	$('ul').find('> li:last').addClass('last');

});

// drop down menu handlers
jQuery(function($) {
	var nav = $('#nav');
	nav.find('> ul > li').addClass('level-1');
	nav.find('> ul > li > ul').addClass('level-2');
	nav.find('> ul > li:not(.opened)').hover(
		function() { //over
			if(nav.data('menuTimer'))    clearTimeout(nav.data('menuTimer'))
			if(nav.data('menuTimerOut')) clearTimeout(nav.data('menuTimerOut'))
			if ($(this).find('ul.level-2').hasClass('hover')) { return;} // already opened
			
			nav.data('menuDropDown', $(this).find('ul.level-2'));
			nav.data('menuTimer', setTimeout(function() {
				$('#nav > ul > li:not(.opened) ul.level-2').hide().removeClass('hover');
				$('#nav > ul > li > a').removeClass('hover');

				var menu = $('#nav').data('menuDropDown')
				$(menu).addClass('hover').slideDown(50);
				$(menu).closest('li').addClass('hover').show();
				
			}, 150));
			$(this).addClass('over');
		},
		function() { //out
			if(nav.data('menuTimer'))    clearTimeout(nav.data('menuTimer'))
			if(nav.data('menuTimerOut')) clearTimeout(nav.data('menuTimerOut'))
			nav.data('menuTimerOut', setTimeout(function() {
				$('#nav > ul > li:not(.opened) ul.level-2').hide().removeClass('hover');
				$('#nav > ul > li > a').removeClass('hover');
			}, 1500));
			$(this).removeClass('over');
		}
	);
	nav.find('ul > li a').each(function(i, obj) {
		$(obj).attr('class', $(obj).parent().attr('class'));
	});
	nav.find('ul > li li, ul > li li a').mouseover(function() {
		var nav = $('#nav');
		if(nav.data('menuTimer'))    clearTimeout(nav.data('menuTimer'))
		if(nav.data('menuTimerOut')) clearTimeout(nav.data('menuTimerOut'))
	});
	nav.addClass('initialized');
});
/*

if (typeof Cufon != 'undefined') {
	Cufon.replace('#sidebar .subnav h3', {fontSize:'40px', wordSpacing:'-11px'});
	Cufon.replace('h3.featured strong', {fontSize:'55px'});
	
	
	//Cufon.replace('h1');
} else {
	jQuery('#sidebar .subnav h3, h3.featured strong').addClass('alt')
}

*/
// staff
jQuery(function($) {
	$('#staff li.profile .passion a').click(function() {
		$(this).siblings().slideToggle();
		return false;
	});
});


var tb_pathToImage = SITEBASE+"/wp-includes/js/thickbox/loadingAnimation.gif";
var tb_closeImage = SITEBASE+"/wp-includes/js/thickbox/tb-close.png";

jQuery(function($) { return;
	if (typeof tb_init != 'function') return;


	tb_init(".popup");
	
	$('a[href*=integration.fellowshipone.com]:not(.thickbox)').each(function(i,obj) {
		//$(this).attr('href', $(this).attr('href')+'&TB_iframe=true&height=600&width=800');
		//tb_init(this);
		//$(this).attr('target', '_blank');
		$(this).click(function() {
			var w = window.open($(this).attr('href'), '_blank', 'width=700,height=700,scrollbars=1');
			return false;
		});
	});
});


jQuery(function($) {
	$('#quicklinks strong').mouseover(function() {
		$('#quicklinks ul').slideDown('fast');

	});
	$('#quicklinks ul').hover(function() {
	}, function() {
		$(this).slideUp('fast')
	});
});
