// function getSection()
// {
//     var action  = jQuery.getURLParam('_action');
//     var path    = action.split('_');
//     var section = path[0];
//     if(section == 'photo') section = section + 's';
//     return section;
// };



jQuery(function() {
    
jQuery('head').append(
    jQuery('<link rel="stylesheet" type="text/css" />').attr('href', css_path + '/photos.css')
);
    
jQuery('.tbl_left ul li').click(function() {
    
	if(jQuery(this).is('.folders')) {
	    jQuery(this).toggleClass('unfolded');
		jQuery(this).find('> ul').slideToggle('fast');
	}
	
	var unfolded = jQuery.cookie(section + '_unfolded') ? jQuery.cookie(section + '_unfolded').split(',') : new Array();
	var catid    = jQuery.getURLParam('cid', jQuery(this).find('> a').get(0).href);
	
	if((typeof(catid) != 'undefined') && jQuery(this).is('.unfolded')) {
	    if(unfolded.indexOf(catid) < 0)
	        unfolded[unfolded.length] = catid;
	} else {
	    var idindex;
	    if((idindex = unfolded.indexOf(catid)) >= 0)
	        unfolded.splice(idindex, 1);
	}
	
	jQuery.cookie(section + '_unfolded', (unfolded.sort()).join(','));
	return false;
	
}).each(function(i) {
    
    var unfolded = jQuery.cookie(section + '_unfolded') ? jQuery.cookie(section + '_unfolded').split(',') : new Array();
    var catid    = jQuery.getURLParam('cid', jQuery(this).find('> a').get(0).href);
    if(jQuery(this).find('> ul').length) {
        jQuery(this).addClass('folders').addClass('unfolded');
	    if((typeof(catid) != 'undefined') && (unfolded.indexOf(catid) < 0) && !jQuery(this).find('.active').length) {
	        jQuery(this).removeClass('unfolded');
		    jQuery(this).find('> ul').slideUp(1);
	    }
    }
      
});

jQuery('.tbl_left ul li a').click(function() {
    jQuery('.tbl_left ul li').unbind('click');
});

});

