$(function(){

	$(".pop").click(function(e){
	
		o = $(this);
		e.preventDefault();
		
		afile = o.attr('href');
		atitle = o.attr('title');
		atype = (afile.indexOf('oral') >= 0) ? 'Oral History' : 'Program';
		
		$('.audio-title').text(atitle);
		$('.audio-overline').text(atype);
		$('.audio-link').attr('href', afile);

		$.jPlayer.timeFormat.showHour = true;
		
		$("#jquery_jplayer_1").jPlayer({
			ready: function () {
				$(this).jPlayer("setMedia", {
					mp3: afile
				});				
			},
			swfPath: "/js/",
			supplied: "mp3"
		});	

        //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        //Set height and width to mask to fill up the whole screen
        $('#mask').css({'width':maskWidth,'height':maskHeight});

        //transition effect     
        $('#mask').fadeTo("slow",0.8);

		$("#cn-aud").css("left", 400); 

	}); 	

    //if close button is clicked
    $('.close').click(function (e) {
		e.preventDefault();
		$("#jquery_jplayer_1").jPlayer( "clearMedia" );
		$("#jquery_jplayer_1").jPlayer( "destroy" );
		$("#cn-aud").css("left", -6000);		
        $('#mask').hide();
		
    });     

    //if mask is clicked
    $('#mask').click(function (e) {
		$("#jquery_jplayer_1").jPlayer( "clearMedia" );
		$("#jquery_jplayer_1").jPlayer( "destroy" );
		$("#cn-aud").css("left", -6000);
        $(this).hide();
    });  

});

