function textLimit(field, maxlen) {
if (field.value.length > maxlen + 1)
alert('Yorumunuz biraz uzun.!');
if (field.value.length > maxlen)
field.value = field.value.substring(0, maxlen);
} 
$(document).ready(function(){
	
	$("#preview_comment").hide();
	
	$("#js_kabul").click(function(){
		
		//	hide the button
		//$(this).hide();
		
		//	display the 'loading' gif;
		$("#mycommentspan").html('<img src="'+ADRES+'/ajax/yukleniyor.gif" alt="Yukleniyor" id="loading" />').show();

		//	get the info
		var userId = $("#js_email").val();
		var videoId	= $("#js_vid").val();
		var commentTxt = $("#js_yorum").val();
		var uName = $("#js_adi").val();
		var captchaCode = $("#js_kod").val();
		
		
			// guest comment
			$.post( ADRES+"/ajax/yorum.php", { adi: uName, kod: captchaCode, vid: videoId, email: userId, yorum: commentTxt },
   					function(data){
						if(data.cond == true)
						{
							$("#myform").slideUp("normal", function() {
								$("#ozinleme").html(data.msg).show();
								
								//	preview comment
								if(data.preview == true)
								{
									$comment = data.html;
									$comment = $comment.replace(/\n/g, "<br />").replace(/\n\n+/g, '<br /><br />');
									$("#yorum_goster").html($comment).fadeIn(700);
								}
							});
						}
						else if(data.cond == false)
						{
							$("#js_kabul").show();
						 	$("#mycommentspan").html(data.msg).show();									
						}
						
   					},"json"
				 );
		
		
      return false;

	});	
});

function addsmilie(code)
{
document.myform.js_yorum.value += code;

}
