// JavaScript Document

$(function() {
			$("#btnAddComment").click(function() {
																	try {					
																				 var oldButtonContent = $("#btnAddComment").html();
																					var name = $("#name").val();
																					var comment = $("#comment").val();
																					if ($("#btnAddComment").html() == 'Dodajem')
																						return false;
																					if (name == '' || comment == '') {
																						alert('Ime i poruka ne smiju biti prazni');
																						return false;
																					}
																						
																					$.ajax({ 
																								 type: "POST",
																								 url: siteURL + 'index.php/start/addComent',
																								 data: "name="+name+"&comment="+comment+"&matchID=" + matchID,
																								 beforeSend: function() {
																										$("#old_comments").html('Loading ...');
																										$("#btnAddComment").html('Dodajem');
																								 },
																								 success: function(){
																								 },
																									complete : function(XMLHttpRequest, textStatus) {
																										//$("#old_comments").html('Komentar snimljen');
																										$("#name").val('');
																										$("#comment").val('');
																										$("#btnAddComment").html(oldButtonContent);
																										$("#matchCommentList").html(XMLHttpRequest.responseText);
																										//$("#old_comments").html(XMLHttpRequest.responseText);
																										//ajaxCall('matchCommentList', "http://www.livescore.ba/index.php/start/reloadComments/"+matchID, 0, 0);
																								 }
																					});
																			} catch(e) {
																				//alert(e);
																			}
		});
});


