/**
 * Javascript file for the servicii section of timisoreni
 * @author Radu Almasan
 * @version 0.1
 */



jQuery(document).ready(function() {

	/**
	 * Adding click action to the button bellow. When clicked it slide toggles
	 * the div.firma_feedback
	 */
	jQuery('button.firma_feedback_btn').click(function() {
		currentHeight = jQuery('div.firma_feedback').height();
		jQuery('div.firma_feedback').animate({height: (currentHeight ? 0 : 30)});
	});



	/**
	 * Adding click events to feedback buttons. When clicked, it sends an ajax POST
	 * to mark the selected data as incorect.
	 */
	jQuery('div.firma_feedback button.what').click(function() {
		var button = this;

		// Parse current url to get the business` id. Url has the form /foo/bar/name_bid.htm
		var tmp = window.location.pathname.split('/');
		tmp = tmp[tmp.length-1];
		tmp = tmp.split('.');
		tmp = tmp[0];
		tmp = tmp.split('_');
		bid = tmp[tmp.length-1];

		jQuery.post(base_url + url_firme_feedback, {bid: bid, what: this.name}, function() {
			jQuery(button).attr('disabled', true).addClass('inactive').html(thanks_message);
		});
	});

});
