/**
* MDC Post Images
* Javascript functions
* Dependancies: jQuery Framework
**/

function matty_animate_graph (selector) {
	jQuery(selector + ' .graph_bar').each ( function() {
		
		var percentage = jQuery(this).text();
		jQuery(this).css('width', '0%');
		jQuery(this).stop().animate({ width: percentage }, 1500, 'swing');
		
	});
} // end matty_animate_graph()

jQuery(document).ready(function() {
	
	jQuery('.poll_edit').hide();
	
	jQuery('.poll_row .row-title').click( function () {
		var edit = jQuery(this).parent().parent();
		edit.next().toggle();
		matty_animate_graph('.admin_graph_container');
	} );
	
	jQuery('.poll_row .edit').click( function () {
		var edit = jQuery(this).parent().parent().parent();
		edit.next().toggle();
		matty_animate_graph('.admin_graph_container');
	} );

	jQuery('.poll_cancel').click( function () {
		var edit = jQuery(this).parent().parent().parent().parent();
		edit.toggle();
		matty_animate_graph('.admin_graph_container');
	} );
	
	matty_animate_graph('.matty_poll');
	
});
