function roots_popup_wrapper($){
    lgbtpop={
   
    init:function (){
	lgbtpop.popupLoginStatus = 0; 
        lgbtpop.popupSignUpStatus = 0; 
        $("#menu-member-login a").click(function(){  
          
            lgbtpop.activatePopup('login');  
        });  
         $("#menu-newsletter-sign-up a").click(function(){  
           
            lgbtpop.activatePopup('signup'); 
        });  
         
       
        //Click out event!  
        $("#popupLoginClose a").click(function(){  
            lgbtpop.disablePopup();  
        }); 
          $("#popupSignUpClose a").click(function(){  
            lgbtpop.disablePopup();  
        }); 
          $("#backgroundPopup").click(function(){  
            lgbtpop.disablePopup();  
        });  
        //Press Escape event!  
        $(document).keypress(function(e){  
            if(e.keyCode==27 && popupLoginStatus==1){  
                lgbtpop.disablePopup();  
            }  
            else if(e.keyCode==27 && popupSignUpStatus==1)
                {
                 lgbtpop.disablePopup(); 
                }
        });
        
    },
    
   activatePopup:function(typ){
        //load popup  
          
            $("#backgroundPopup").css({  
                "opacity": "0.5"  
            });  
            $("#backgroundPopup").fadeIn("slow");  
            
            if(typ =='login'){
                $("#popupLogin").fadeIn("slow"); 
                   lgbtpop.popupLoginStatus = 1; 
            }
            else if(typ =='signup'){
                $("#popupSignUp").fadeIn("slow"); 
                   lgbtpop.popupSignUpStatus  = 1; 
            }
          
            
         //centering with css  
            lgbtpop.centerLoginPopup(typ);  
           
   },
    disablePopup: function(){  
        //disables popup only if it is enabled  
        if(lgbtpop.popupLoginStatus==1){  
            $("#backgroundPopup").fadeOut("slow");  
            $("#popupLogin").fadeOut("slow");  
            lgbtpop.popupLoginStatus = 0;  
        }  
        else if(lgbtpop.popupSignUpStatus ==1){  
            $("#backgroundPopup").fadeOut("slow");  
            $("#popupSignUp").fadeOut("slow");  
            lgbtpop.popupSignUpStatus = 0;  
        }  
    },
   centerLoginPopup: function(typ){  
        //request data for centering  
        var windowWidth = $(window).width();  
        var windowHeight = $(window).height();  
         var popupHeight='300px';
         var popupWidth = '300px';
        
        if(typ=='login'){
         
             popupHeight = $("#popupLogin").height();  
            popupWidth = $("#popupLogin").width(); 
              $("#popupLogin").css({  
            "position": "absolute",  
            "top": windowHeight/2-popupHeight/2,  
            "left": windowWidth/2-popupWidth/2  
        });  
        }
        else if(typ=='signup'){
            popupHeight = $("#popupSignUp").height(); 
            popupWidth = $("#popupSignUp").width(); 
              $("#popupSignUp").css({  
            "position": "absolute",  
            "top": windowHeight/2-popupHeight/2,  
            "left": windowWidth/2-popupWidth/2  
        });  
        }
      
      
      
        //only need force for IE6  
  
        $("#backgroundPopup").css({  
            "height": windowHeight  
        });  
  
    }  
 }
    $(document).ready(function(){
        lgbtpop.init();
    });
	
}roots_popup_wrapper(jQuery); 


