$(document).ready(function(){
    $("dt").css({
        'background-image': 'url(/Pictures/Contact_Info/faq-open.png)',
        'background-repeat': 'no-repeat'
    });
    var square = 0;
    
    // create the toggle link
    //$("#hide_this").before("<p><a href='#' id='toggle_link'>" + showText + "</a>");
    
    var viewall = "view all";
    var closeall = "close all";
    $("dd").hide();
    
    //$('.viewall').before("<a href='#' class='viewall'>" + viewall + "</a>");
    
    $('.closeall').click(function(){
    
       
            
            $(this).parent('.left').parent('.headspace').parent('.wrap').children("dl").children("dt").css({
                'background-image': 'url(/Pictures/Contact_Info/faq-open.png)',
                'background-repeat': 'no-repeat'
            });
            square = 1;
            $(this).parent('.left').parent('.headspace').parent('.wrap').children("dl").children("dd:not(:hidden)").toggle();
			return false;
         });
    
      $('.viewall').click(function(){ 
            
            $(this).parent('.left').parent('.headspace').parent('.wrap').children("dl").children("dt").css({
                'background-image': 'url(/Pictures/Contact_Info/faq-close.png)',
                'background-repeat': 'no-repeat'
            });
            square = 0;
            $(this).parent('.left').parent('.headspace').parent('.wrap').children("dl").children("dd:hidden").toggle();
			return false;
       });
        
 
    
    
    $("dt").click(function(){
        // $("hide_this").hide();
        
        if (square == 0) {
            $(this).css({
                'background-image': 'url(/Pictures/Contact_Info/faq-close.png)',
                'background-repeat': 'no-repeat'
            });
            square = 1;
        }
        else {
            $(this).css({
                'background-image': 'url(/Pictures/Contact_Info/faq-open.png)',
                'background-repeat': 'no-repeat'
            });
            square = 0;
        }
        
        
        // toggle the display
        $(this).parent("dl").children("dd").toggle();
        
        // return false so any link destination is not followed
        return false;
    });
    
});
