
/* Index flash player 
==================================================================*/
var flashvars = {}
var params = {
	base: ".",
	allowscriptaccess: "always",
	wmode: "transparent"
	}             
var attributes = {}

function loadVideo() {swfobject.embedSWF("/assets/flash/slideshowVideoFeature.swf", "video_player", "535", "276", "9.0.0", false, flashvars, params, attributes);}
function loadVideoWLOH() {swfobject.embedSWF("/assets/flash/weLoveOurHouse.swf", "video_player", "535", "276", "9.0.0", false, flashvars, params, attributes);}

function closeVideo() {
		$('#popup_video').fadeOut('fast', function() {
			$('div#upcoming_playa > p').fadeIn('fast');
		});
		return false;
	}
/*================================================================*/

$(function(){
	
	/* slideFadeToggle Menus
	==================================================================*/
	jQuery.fn.slideFadeToggle = function(speed, easing, callback) {
	  return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);  
	};
	
	$("p#close_notification a").click(function (){
		$("#notification").slideFadeToggle('slow');
		return false;
	});
	
	/* $("p.meta.toggle").remove(); <img src="/assets/images/show_hide.png" /> */
	
	$("h1.toggle").before('<p class="meta toggle"><a href="#">hide / show</a></p>');
	
	$("p.meta.toggle").click(function (){
		$("div.top_border").slideFadeToggle('slow');
		return false;
	});
	/*================================================================*/
	
	/* Index Slideshow 
	==================================================================*/
	$('div#features').cycle({
				speed: 500,
				prev: '#prev',
				next: '#next',
				before: onBefore,
				pause: 1
		    });
	function onBefore() {$('#title').html(this.title);}
	
	$('div#features a.video_feature').click(function (){
		$('div#upcoming_playa > p').fadeOut('fast', function() {
			$('#popup_video').fadeIn('fast');
			loadVideo();
		});
		return false;
	});
	
	$('div#features a.video_we_love_our_house').click(function (){
		$('div#upcoming_playa > p').fadeOut('fast', function() {
			$('#popup_video').fadeIn('fast');
			loadVideoWLOH();
		});
		return false;
	});
	
	$('#popup_video p a').click(function () {
		$('#popup_video').fadeOut('fast', function() {
			$('div#upcoming_playa > p').fadeIn('fast');
		});
		return false;
	});
	/*================================================================*/
	
	/* Media Player Stuff
	==================================================================*/
	$('a.watch_popup').live('click', function() {
		$(this).popupWindow({ centerScreen: 1, width: 500, height: 370}); 
		$.fn.colorbox.close()
		return false;
	});
	
	$('a.watch_popup.details').click(function() {
		$(this).popupWindow({ centerScreen: 1, width: 500, height: 370}); 
		//var player = "player";
		//player.sendEvent("PLAY","true");
		return false;
	});
	
	$('a.listen_popup').live('click', function() {
		$(this).popupWindow({ centerScreen: 1, width: 500, height: 115}); 
		$.fn.colorbox.close()
		return false;
	});
	
	jQuery.fn.fadeToggle = function(speed, easing, callback) {
	  return this.animate({opacity: 'toggle'}, speed, easing, callback);  
	};
	
	var page_h = $(document).height();
	
	$('div#lights').css({height: page_h + 'px'});
	
	$('ul#mediaplayer_icons li a#lights').click(function () {
		$('div#lights').fadeToggle();
		$(this).toggleClass('lights_off');
		return false;
	});
	
	/* 
	==================================================================*/
	$(".f1").colorbox({width:"755px", height:"80%", iframe:true});
	$("a.colorbox").colorbox({width:"430px", opacity:".7"});
	$("a.colorbox_video").colorbox({opacity:".7"});
	$("a[title='Service Times']").colorbox({width:"400px", opacity:".7"});
	$("a.open_campus_maps").colorbox({width:"866px", height:"632px", opacity:".7", inline:true, href:"#campus_map", title:"Campus Map"});
	$("a[title='Mission Statement']").colorbox({width:"350px", opacity:".7"});
	$("a[title='Statement of Faith - What We Believe'], a[title='Seven Pillars of The Rock']").colorbox({width:"600px", opacity:".7"});

	$("a[title='The Story - SPT']").colorbox({width:"500px", height:"650px", opacity:".7"});
	$("a[title='SPT Bulletin Board']").colorbox({width:"602px", height:"530px", opacity:".7"});
	$("a[title='SPT Newsletters']").colorbox({width:"400px", opacity:".7"});
	$("#volunteer_vid").colorbox({href:"/assets/video/volunteer.php", opacity:".7"});
	$("a.listen, a.video").colorbox({opacity:".7"});
	
	
	$("a.listen.alt_domain").colorbox({width:"545px", height:"190px", iframe:true});
	$("a.video.alt_domain").colorbox({width:"545px", height:"450px", iframe:true});
    
    $(".tip").tipTip({edgeOffset: 5, maxWidth: "150px"});
    
    /*
	var mensConf = new Date();
	mensConf = new Date(mensConf.getFullYear() + 0, 3 - 1, 5, 19, 0, 0);
	$('#countdown').countdown({until: mensConf});
	*/
	
	var addShortTitle = $('ul#mediaplayer_add_links li.short_url span.short_url_title');
	var addShortLink = $('ul#mediaplayer_add_links li.short_url span.short_url');
	
	$('ul#mediaplayer_add_links li.short_url').hover(
		function () {
			$(this).css({'background-color' : '#327bc0'});
			addShortTitle.css({'display' : 'none'});
			addShortLink.css({'display' : 'inline'});
		},
		
		function () {
			if (navigator.appName == "Microsoft Internet Explorer") {
				$(this).css({'background-color' : 'rgb(0,0,0)'});
				addShortLink.css({'display' : 'none'});
				addShortTitle.css({'display' : 'inline'});
			} else {
				$(this).css({'background-color' : 'rgba(0,0,0,.65)'});
				addShortLink.css({'display' : 'none'});
				addShortTitle.css({'display' : 'inline'});
			}
		}
	);
	
	$('ul#mediaplayer_add_links li.short_url span input#short_url').click(function() {
		this.select();
	});
	
	$("a[rel='proof']").colorbox();
	
	/* $.fn.colorbox({href:'/includes/blank/spt_resources'}); */
	
	/* WIP
	==================================================================*/
	jQuery.fn.slideToggle = function(speed, easing, callback) {
	  return this.animate({height: 'toggle'}, speed, easing, callback);  
	};
	
	$("div.content_item > ul > li.wip_notes").hide();
	
	var notes_button = $("div.content_item > ul > li > span.wip_notes");
	
	$(notes_button).css({'cursor' : 'pointer','margin-left' : '7px'});
	
	$(notes_button).click(function(){
		$(this).parent().next().slideToggle();
		
	});
	/*================================================================*/
	

		    
	var smallgroupLeaders = $('div.content_item.small_groups');
		    smallgroupLeaders.hide().filter('.featured_item').show();

		    $('ul.smallgroup_leaders li a').click(function () {
		    	//bioContainers.fadeOut('slow').slideUp('slow').animate({opacity: 1.0}, 1100);
		    	smallgroupLeaders.hide();
				smallgroupLeaders.filter(this.hash).fadeIn('slow').slideDown('slow');
		    	return false;
		    }).filter('.featured_item').click();







// MAP
//==============================================================================================
//==============================================================================================
	$('#campus_map').zoommap({
			// Width and Height of the Map
			width: '823px',
			height: '560px',

			//Misc Settings
			blankImage: 'http://www.rockchurch.com/assets/images/campus_map/blank.png',
			zoomDuration: 1000,
			bulletWidthOffset: '10px',
			bulletHeightOffset: '10px',

			//ids and classes
			zoomClass: 'zoomable',
			popupSelector: 'div.popup',
			popupCloseSelector: 'a.close',

			//Return to Parent Map Link
			showReturnLink: true,
			returnId: 'returnlink',
			returnText: 'return to campus map',

			//Initial Region to be shown
			map: {
				id: 'campus',
				image: 'http://www.rockchurch.com/assets/images/campus_map/campus_v2.jpg'
				//data: '/lib/campus_map/campus.html'
				//maps: [
				//{
				//	id: 'quads',
				//	parent: 'campus',
				//	image: '/assets/images/campus_map/quads.png',
				//	data: '/lib/campus_map/quads.html',
				//	width: '69px',
				//	height: '103px',
				//	top: '57px',
				//	left: '134px'
					/* More maps can be nested
					maps : [ ]
					*/
				//}
				//]
			}
		});

});