//Begin of JQuery code to pull in You Tube feedhttp://www.youtube.com/user/PHEgov#grid/user/A05C8BBFC398C518

$(document).ready(function() {            
	$.jGFeed('http://gdata.youtube.com/feeds/api/playlists/A05C8BBFC398C518?v=2',
	function(feeds){
		// Check for errors
		if(!feeds){
			// there was an error
			return false;
		}

		var html = '<div id="showVids_0">';

		// Writes the HTML to the designated dic "#slideshowVideos"
		
		for(var i=0; i<feeds.entries.length; i++){
			
			var entry = feeds.entries[i];

			// Adds a div around ever 3 videos to work with jQuery Cycle plugin
			if ((i) %3 == 0 && i != 0) {
				html += '</div> <div id="showVids_'+i+'">'
			}
			// HTML added to div that displays Videos
			html += '<div class="videoHPWrapper"><a href="' + entry.link + '" class="youTube"><img src="' + $.jYoutube(entry.link, 'small') + '" alt="'+ entry.title +'" /></a><h4>'+ entry.title +'</h4></div>';
		}
		html +='</div>';
		
		$('#slideshowVideos').html(html); // Outputs code
		
		// Fancybox code to display Youtube video popup
		$("a.youTube").click(function() {
			var ytVideo =this.href.replace(new RegExp("http://www.youtube.com/watch\\?v=", "i"), ""); 
			ytVideo= ytVideo.replace("&feature=youtube_gdata", "");
			$.fancybox({
					'padding'		: 0,
					'autoScale'		: false,
					'transitionIn'	: 'none',
					'transitionOut'	: 'none',
					'title'			: this.title,
					'width'			: 854,
					'height'		: 480,
					'centerOnScroll': true,
					'overlayColor': "#f8e3c6",
					'href'			: '/esarvhp/flash/YoutubeAPI.swf',
					//'href' : 'player.swf?file=/uploadz/test.mp3&autostart=true',
					'type'			: 'swf',					
					'swf'			: {
										'wmode'		: 'transparent',
										'allowfullscreen'	: 'true',
										'flashvars' :'ytSwf=http://www.youtube.com/apiplayer?version=3&ytVideo='+ytVideo+'&ytTranscript=/pages/transcript-'+ytVideo+'.html&ytTitle='+entry.title+''
									  }
				});
				return false;
			});	
			// jQuery Cycle function
			$(function() {		
			$('#slideshowVideos').cycle({
				fx:      'scrollHorz',
				timeout:  0,
				prev:    '.prevVid',
				next:    '.nextVid',
				pager:   '#navVid',
				cleartype:  1,
				cleartypeNoBg:  true
			});
		});		
		
	}, 24);
});

//Begin of JQuery code to pull in You Tube feed

$(document).ready(function() {            
	$.jGFeed('http://gdata.youtube.com/feeds/api/playlists/A05C8BBFC398C518?v=2',
	function(feeds){
		// Check for errors
		if(!feeds){
			// there was an error
			return false;
		}

		var html = '<div id="memVids_0">';

		// Writes the HTML to the designated dic "#slideshowVideos"		
		for(var i=0; i<feeds.entries.length; i++){
			
			var entry = feeds.entries[i];
			// Adds a div around ever 3 videos to work with jQuery Cycle plugin
			if ((i) %6 == 0 && i != 0) {
				html += '</div> <div id="memVids_'+i+'">'
			}
			// HTML added to div that displays Videos
			html += '<div class="vidWrapper"><a href="' + entry.link + '" class="youTube"><img src="' + $.jYoutube(entry.link, 'small') + '" alt="'+ entry.title +'" /></a><h4>'+ entry.title +'</h4></div>';
		}
		html +='</div>';
		
		$('#memberVideos').html(html); // Outputs code
		
		// Fancybox code to display Youtube video popup
		$("a.youTube").click(function() {
			var ytVideo =this.href.replace(new RegExp("http://www.youtube.com/watch\\?v=", "i"), ""); 
			ytVideo= ytVideo.replace("&feature=youtube_gdata", "");
			$.fancybox({
					'padding'		: 0,
					'autoScale'		: false,
					'transitionIn'	: 'none',
					'transitionOut'	: 'none',
					'title'			: this.title,
					'width'			: 854,
					'height'		: 480,
					'centerOnScroll': true,
					'overlayColor': "#f8e3c6",
					'href'			: '/esarvhp/flash/YoutubeAPI.swf',
					'type'			: 'swf',					
					'swf'			: {
										'wmode'		: 'transparent',
										'allowfullscreen'	: 'true',
										'flashvars' :'ytSwf=http://www.youtube.com/apiplayer?version=3&ytVideo='+ytVideo+'&ytTranscript=/pages/transcript-'+ytVideo+'.html&ytTitle='+entry.title+''
									  }
				});
		
				return false;
			});	
			// jQuery Cycle function			
			$(function() {		
			$('#memberVideos').cycle({
				fx:      'scrollHorz',
				timeout:  0,
				prev:    '.prevVid',
				next:    '.nextVid',
				pager:   '#nav',
				cleartype:  1,
				cleartypeNoBg:  true
			});
			function pagerFactory(idx, slide) {
				var s = idx > 3 ? ' style="display:none"' : '';
				return '<li'+s+'><a href="#">'+(idx+1)+'</a></li>';
			};
		});		
		
	}, 24);// Pulls in video count
});



// jQuery Cycle function for images
$(function() {		
	$('#slideshowImages').cycle({
		fx:      'scrollHorz',
		timeout:  0,
		prev:    '.prevImg',
		next:    '.nextImg',
		pager:   '#navImg',
		cleartype:  1,
		cleartypeNoBg:  true
	});
});


$(function() {		
$('#memberImages').cycle({
	fx:      'scrollHorz',
	timeout:  0,
	prev:    '.prevVid',
	next:    '.nextVid',
	pager:   '#nav',
	cleartype:  1,
	cleartypeNoBg:  true
});
	function pagerFactory(idx, slide) {
		var s = idx > 3 ? ' style="display:none"' : '';
		return '<li'+s+'><a href="#">'+(idx+1)+'</a></li>';
	};
});

// jQuery slide show for images
jQuery(function(){
	jQuery.fn.getTitle = function() {
	var arr = jQuery("a.fancybox");	
}

// Supported file extensions
	var thumbnails = 'a:has(img)[href$=".bmp"],a:has(img)[href$=".gif"],a:has(img)[href$=".jpg"],a:has(img)[href$=".jpeg"],a:has(img)[href$=".png"],a:has(img)[href$=".BMP"],a:has(img)[href$=".GIF"],a:has(img)[href$=".JPG"],a:has(img)[href$=".JPEG"],a:has(img)[href$=".PNG"]';
	jQuery(thumbnails).addClass("fancybox").getTitle();
		jQuery("a[rel=example_group]").fancybox({
		'imageScale': true,
		'padding': 10,
		'zoomOpacity': true,
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,
		'zoomSpeedChange': 300,
		'overlayShow': true,
		'overlayColor': "#f8e3c6",
		'overlayOpacity': 0.3,
		'enableEscapeButton': true,
		'showCloseButton': true,
		'hideOnOverlayClick': true,
		'hideOnContentClick': false,
		'callbackOnStart': null,
		'callbackOnShow': null,
		'callbackOnClose': null,
		'centerOnScroll': true,
		'showNavArrows': true
	});

});


