var PopupStatus = 0;

function OpenPopup() {
	if(PopupStatus==0) {
		(function($){
			
			$('li.join a span').click(function() {
				$(".join-list-container").css({
		   		"z-index": "10" 		
		   		});
		   		
		   		$('.join-list-container').fadeIn('medium');
		   		
		   		$('.mce_inline_error').html('');
		   		$('#mce-error-response').html('');
		   		$('#mce-success-response').html('');
		   		$('#mce-EMAIL').removeClass('mce_inline_error');
		   		
		   		$("#backgroundPopup").fadeIn("slow");
		   		
		   		$("#backgroundPopup").css({
		   		"z-index": "3" 		
		   		}); 		   		
		   		 
		 });
		 PopupStatus=1;
		 
		  })(jQuery);
	}
}

function ClosePopup() {
	
	if(PopupStatus==1) {
		
			(function($){
			 //Click out event! 	
			 $(".join_div_header a").click(function(){ 		
			 	$('.join-list-container').fadeOut('medium');
			 	/*$("#backgroundPopup").css({
			   		"z-index": "1" 		
			   		}); */	
			 }); 	
			 
			 //Press Escape event! 	
			 $(document).keypress(function(e){ 		
			 	if(e.keyCode==27 && PopupStatus==1){ 			
			 		$('.join-list-container').slideUp('medium');
			 		 $("#backgroundPopup").fadeOut("slow");	
			 		 $("#backgroundPopup").css({
			   		"z-index": "1" 		
			   		}); 	
			 	} 	
			 }); 
			  PopupStatus=0; 
			 })(jQuery);
	}
}



function LightBoxVideoDisplay() { 
	
	/*var j = jQuery.noConflict();		
		j(document).ready(function(){			
			j("#sidebar_media a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
			
		});
	
*/
	
	
}


function ToolTipDisplay() { 

//	$(function() {
/*
var $j = jQuery.noConflict();;

$j(document).ready(function() {
		
			$j('#pretty').tooltip({
				track: true,
				delay: 0,
				showURL: false,
				showBody: " - ",
				extraClass: "pretty",
				fixPNG: true,
				left: -120
			});		
	

	});
*/
	
//	});

}

(function($) { 
  $(function() {
//$(document).ready(function(){
	
	OpenPopup();
	ClosePopup();
});
})(jQuery);
	
//});

//ToolTipDisplay();
LightBoxVideoDisplay();
