Cufon.replace('.page-title h1.title', { color: '-linear-gradient(#f9e4ae, #d8ba67)' });

function mycarousel_initCallback(carousel) {
    $('.logos-slider-nav a.next').bind('click', function() {
        carousel.next();
        return false;
    });

    $('.logos-slider-nav a.prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};
$(function(){
	$('a[href="https://thermalstreamsecureserver.com/truthmissionary/give-online/give-online.php"]').click(function(){
		window.open('https://thermalstreamsecureserver.com/truthmissionary/give-online/give-online.php','Give Online','width=700,height=400,scrollbars=yes');
		return false;
	});
	$(".logos-slider").jcarousel({
	    scroll: 1,
	    wrap: 'both',
	    initCallback: mycarousel_initCallback,
	    buttonNextHTML: null,
	    buttonPrevHTML: null
	}); 
	
	$('.formModule .field input, .formModule .field textarea').each(function(){
		var formTitle = $(this).attr('value');
		$(this).attr('title',formTitle).addClass('blink');
	});
	
	$('.blink').focus(function () {
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('').css('color', '#222');
		}
	});
	
	$('.blink').blur(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('title')).css('color', '#bfb7a8');
		}
	});
	
	$('#dd-nav > ul > li').hover(function() {
		$(this).find('span:eq(0)').stop(true, true).slideDown('fast', function() {
			$(this).parent().find('.dd:eq(0)').fadeIn('fast');
		});
	}, function() {
		if ($(this).hasClass('active')) {
			
		} else {
			$(this).find('span:eq(0)').stop(true, true).fadeOut('fast');
		};
		$(this).find('.dd:eq(0)').stop(true, true).fadeOut('fast');
	});
	
	$('.faq .entry h3 a').click(function(){
		$(this).parents('h3').next().slideToggle();
		$(this).parents('h3').toggleClass('expanded');
		return false;
	});

	
	$('.section').hover(function(){
		$(this).addClass('hovered');
	},function(){
		$(this).removeClass('hovered');
	});
	
	
	
	$('a.tip-trigger').hover(function(){
		$(this).parents('.mission').find('.tip').fadeIn('fast');
		$(this).parents('.mission').hover(function(){
			$(this).css('z-index', 100);
		},function(){
			$(this).css('z-index', '');
			$(this).find('.tip').fadeOut('fast');
		});
	});
	
	$('.home-block').hover(function(){
		$(this).addClass('hover-block');
	},function(){
		$(this).removeClass('hover-block');
	});
	
	if($.browser.msie && $.browser.version==6)
	{
		DD_belatedPNG.fix('.home-head h2.home-page-main-txt, h1#logo a, #navigation ul li span, .ribbon, .ribbon span, .home-block, .container .shell, .logos-slider .logos-slider-nav a, .logos-slider .logos-slider-holder ul li a, h3.footer-logo a, .socials a, #externalcontrols a.next, #externalcontrols a.prev, .slider-holder a#prev, .slider-holder a#next, .mission-map , .mission a.tip-trigger, .tip-t, .tip-c, .tip-b, p.map-legend, .entry-img, #sidebar, .request-form span.field, .request-form span.textarea-field, .request-form input.request-submit, .section .badge, .section, .contacts-info, .map-holder, .contact-form span.field, .contact-form span.textarea-field, .contact-form input.contact-submit, .faq .entry-c, .faq .entry-b, .faq .entry-t, .faq .entry h3 a span, .slider div.panel, .slider div.panel .inside, .dd-top-arr');
	}
	
	//Calendar
	$('.event-calendar-table tr:eq(0)').addClass('heading-months').next().addClass('heading-days');
	$('.event-calendar .heading-months a:first').prepend('&laquo;&nbsp;');
	$('.event-calendar .heading-months a:last').append('&nbsp;&raquo;');
	$('.event-calendar .heading-days td:eq(0)').addClass('sunday');
	$('.event-calendar-table tr:nth-child(n+3)').addClass('calendar-cnt');
	$('.event-calendar-table tr:nth-child(2n+4)').addClass('even');
	$('.calendar-cnt td').wrapInner('<div class="cell-cnt" />');
	$('.calendar-cnt .cell-cnt').each(function() {
		$(this).find('a').length > 0 ? $(this).find('a').eq(0).addClass('day') : $(this).wrapInner('<span class="day" />');
	});
	$('.calendar-cnt .cell-cnt > a').addClass('day');
	
	$('.cell-cnt .event-box').hover(
		function() {
			$(this).parents('.cell-cnt').eq(0).css('z-index', '1000');
		},
		function() {
			$(this).parents('.cell-cnt').eq(0).css('z-index', '0');
		}
	);
	
})

function setButtonsPosition() {
	var slider_width = $('.home-head-center .scroll').width();
	var focusElem = 514;
	
	var new_width = slider_width/2 - 304;
	
	$('.slider-holder #prev').css({
		left :new_width
	});
	$('.slider-holder #next').css({
		left: new_width + 572
	});
};
