/*-------------------------------------------------------------------------------------------------*
 *  FUMC 2011 by AM Design
 *
 *  JavaScript functions for the "FUMC2011" theme by AM Design, built for the AM Design Content Management 
 *	System
 *
 *  Last Updated:  3/2011
 *  Updated By:  Jake Thompson
 *-------------------------------------------------------------------------------------------------*/

/* Global Variables */
var BASEURL, ADMINURL, COREURL, SITEURL, MEDIAURL, THEMEURL, THE_URL;
var BASEPATH, ADMINPATH, COREPATH, SITEPATH, MEDIAPATH, THEMEPATH;
var timeouts = [];

function init_site(){
	clearClick();
	setBrowserClass();
	
	Cufon.replace('#nav > li > a', { fontFamily: 'GB' });
	Cufon.replace('#page_header > h1', { fontFamily: 'GB' });
	Cufon.replace('#text h3', { fontFamily: 'GM' });
	Cufon.replace('#text h4', { fontFamily: 'GM' });
	Cufon.replace('.subnav > ul > li > a', { fontFamily: 'GM' });
	Cufon.replace('.thumbGallery h3', { fontFamily: 'DIN' });
	
	Cufon.replace('.ttl_quicklinks', { fontFamily: 'GBD' });
	// Initialize UI functionality (e.g. navigation hover)
	$('#nav>li').hover(
		function(){
			var navID = $(this).attr('id');
			clearTimeout( timeouts[navID] );
			$(this).addClass('sfHover');
			$(this).children('ul').fadeIn(200);
		},
		function(){
			var navID = $(this).attr('id');
			clearTimeout( timeouts[navID] );
			$(this).removeClass('sfHover');
			var to = setTimeout("$('#nav #"+navID+" ul').fadeOut(200);", 150);
			timeouts[navID] = to;
		}
	);
	
	//jQuery('ul.sf-menu').superfish();
	/*$('#nav').superfish({ 
		delay		: 100,
		speed		: 200,
		animation	: {opacity:'show',height:'show'},
		dropShadows:   false,
		autoArrows	: false
	});*/
	// this toggle the height and opacity of the quicklinks //mg
	$('.qlinks').click(function() {
		$( '#quicklinks' ).animate({
		  "height": "toggle", "opacity": "toggle"
		}, { duration: "fast" });
		
		if($('a.btn_quicklinks').hasClass('quicklinks_open') == false) {
			$('a.btn_quicklinks').addClass('quicklinks_open');	
		} else {
			$('a.btn_quicklinks').removeClass('quicklinks_open');
		}
		return false;
	});
	// home page gallery
	$('.slideGallery').jCarouselLite({
		btnNext: ".gallery_next",
		btnPrev: ".gallery_prev",
		easing: "easeinout",
		auto: 6000,
		speed: 400,
		visible:1
	});
	
	// home page thumbnail gallery
	$('.thumbGallery').jCarouselLite({
		btnNext: ".thumb_next",
		btnPrev: ".thumb_prev",
		easing: "easeinout",
		speed: 300,
		visible:5
	});

	$("#newsletter_signup").fancybox({
		'width'				: 500,
		'height'			: 250,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

	
	// subfooter 4 CTA rollover animation
	
	$('.news_list').mouseenter(function() {
		$(this).children('.news_over').animate({opacity: ['.3', 'easeInOutSine']}, 300);
		$(this).children('.news_image').children('.news_icon').animate({opacity: ['1', 'easeInOutSine'],  top: ['99', 'easeInOutCubic']}, 300);
	  	//$(this).children('.news_image').animate({border: ['4px solid #663366', 'easeInOutSine']}, 300);
	});	
	
	$('.news_list').mouseleave(function() {
		$(this).children('.news_over').animate({opacity: ['0', 'easeInOutSine']}, 300);
		$(this).children('.news_image').children('.news_icon').animate({opacity: ['0', 'easeInOutSine'],  top: ['139', 'easeInOutCubic']}, 300);
	  	//$(this).children('.news_image').animate({border: ['4px solid #c0c0c0', 'easeInOutSine']}, 300);
	});
	
}

function css_tweaks(){
}

// home page video in a pop up from flash or html*
// *not yet set via html
function showVideo(url) {
	
	$.ajax({
			type	: "POST",
			cache	: false,
			url		: "/am-site/themes/FUMC2011/xml/view_video.php?video=" + url,
			success: function(data) {
				$.fancybox(data);
			}
		});
		
		return false;

}
