$(document).ready(function(){
	
			$('#future_rss').rssfeed('http://teachertwoteacher.wordpress.com/feed/',{}, function(e) {
			$(e).find('div.rssBody').vTicker();
			    limit: 1
			});
			
			
			
					 
			
					//select all the a tag with name equal to modal
					$('a[name="modal"]').live('click', function(e) {

					//Cancel the link behavior
					e.preventDefault();
					
					//Get the A tag
					var atag_split = $(this).attr('href').split('-');
					var id = atag_split[0];
					var sample_level = atag_split[1];
					
					
					// Video	
					if(id == '#dialog')
					swapVideo(sample_level);
						
						
					//Audio	
					if(id == '#dialog_audio')
					swapAudio(sample_level);
						
						
					
					
					
					//Get the screen height and width
					var maskHeight = $(document).height();
					var maskWidth = $(window).width();
				
					//Set heigth and width to mask to fill up the whole screen
					$('#mask').css({'width':maskWidth,'height':maskHeight});
					
					//transition effect		
					$('#mask').fadeIn(1000);	
					$('#mask').fadeTo("slow",0.8);	
				
					//Get the window height and width
					var winH = $(window).height();
					var winW = $(window).width();
						  
					//Set the popup window to center
					
					var dialogH = 500;
					var top_scroll =($(window).scrollTop());
					var dialog_top = top_scroll + ((winH-dialogH)/2);
					
					$(id).css('top',  dialog_top);
					$(id).css('left', winW/2-$(id).width()/2);
				
					//transition effect
					$(id).fadeIn(1000); 
				
				});
				
				//if close button is clicked
				$('.exit').live('click',function () {
					
					//Cancel the link behavior
					//e.preventDefault();
					
					$('#mask').hide();
					$('.window').hide();
					$('#dialog_audio').hide();
				});		
				
				//if mask is clicked
				$('#mask').live('click',function () {
					$(this).hide();
					$('.window').hide();
				});			



							
			$(".samples,.samples_btm").live('click', function() {
			
			$("#opaque").css('visibility','hidden');

			
			});
			
			
			
			$(".close_sample_view").live('click', function() {
			

			$("#div_swap").css('display','none');
			
			$("#opaque").css('visibility','visible');
			
			});
			
			$("#dialog_audio").click(swapAudio);

		
			
});

function swapVideo(level) {
    var url = "../includes/pop_flow.php";
	
    $.post(url, {video_level: level} ,function(data) {
		
       $("#dialog").html(data);
    });
};

function swapAudio(level) {
    var url = "../includes/audio_playlist.php";
	
    $.post(url, {audio_level: level} ,function(data) {
		
       $("#dialog_audio").html(data);
    });
};



