/**
 * JavaScript to integrate file browsing and selection with the editor.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package clearFusionCMS
 * @copyright Copyright (c) 2012 fusionLib. All rights reserved.
 * @link http://clearfusioncms.com
 */

$fl(document).ready(function() {
	$fl('.treeviewwidget a').bind('click', function(evt) {
		if(evt.target.tagName != 'A' && !$fl(evt.target).parent().parent().hasClass('container')) {
			if(evt.target.tagName == 'EM')
				parent.fileclick($fl(evt.target).parent().parent().attr('href').replace(/^.*#/, ''));
			else
				parent.fileclick($fl(evt.target).parent().attr('href').replace(/^.*#/, ''));
		}
	});
});