if statement and passing click event

if statement and passing click event

I got a pretty large function, one that could essentially be condensed (if you feel so inclined).

I would like to know how I can get my if statements inside the toggle functions working properly.

I have 4 functions and 2 of them are click functions for closing (display:none). I would like to pass a listener to the toggle funciton to listen for the $close.click()

The if statement in the toggle funcitons is not doing anything.

  1. <script type="text/javascript" >
  2. $(document).ready(function()
  3. {
  4.     var $contactLink = $("#contactLink");
  5.     var $contactBox = $("#contact-container");
  6.     var $qrLink = $("#qrLink");
  7.     var $qrBox = $("#qr-container");
  8.     var $qrBack = $("#qrBack");
  9.     var $contactBack = $("#contactBack");   
  10.     $contactBox.css("display","none");
  11.     $qrBox.css("display","none");
  12.     $contactLink.toggle(
  13.                    function()
  14.                    {
  15.                        if($contactBox.css("display","none")){
  16.                            $contactBox.css("display","inherit");
  17.                                  alert('here');
  18.                        }
  19.                        $contactBox.css("display","inherit");
  20.                        $qrBox.css("display","none");
  21.                        $contactBox.animate({marginTop:'-=378px'},400);
  22.                        $("#footer").css("overflow","visible");
  23.                        $("#contact-form").css("visibility","visible");
  24.                       
  25.                    },
  26.                    function()
  27.                    {
  28.                       $contactBox.animate({marginTop:'0px'},400);
  29.                       $("#contact-form").css("visibility","hidden");
  30.                       $("#footer").css("overflow","hidden")
  31.                    });
  32.     $qrLink.toggle(
  33.                    function()
  34.                    {
  35.                        if($qrBox.css("display","none")){
  36.                            $qrBox.css("display","inherit");
  37.                        }
  38.                       $qrBox.css("display","inherit");
  39.                       $contactBox.css("display","none");
  40.                       $qrBox.animate({marginTop:'-=378px'},400);
  41.                       $("#footer").css("overflow","visible");
  42.                       $("#contact-qr").css("visibility","visible");
  43.                        },
  44.                    function()
  45.                    {
  46.                       $qrBox.animate({marginTop:'0px'},400);
  47.                       $("#contact-qr").css("visibility","hidden");
  48.                       $("#footer").css("overflow","hidden")
  49.                    });
  50.    
  51.    
  52.     $qrBack.click(
  53.                    function()
  54.                    {
  55.                       $qrBox.animate({marginTop:'0px'},400);
  56.                       $qrBox.css("display","none");
  57.                       return false;
  58.                    });
  59.     $contactBack.click(
  60.                    function()
  61.                    {
  62.                       $contactBox.animate({marginTop:'0px'},400);
  63.                       $contactBox.css("display","none");
  64.                       return false;
  65.                    });
  66.    
  67. });
  68. </script>