function get_comment(m_id,p_id,rdm) {
	$('#loading').show();
	$.getJSON('/ch/comment/', {'m_id':m_id,'p_id':p_id,'rdm':rdm} ,function(JSON){
	$('#loading').hide();
	$('#Searchresult').empty();
	if (!JSON.success) { $('#Pagination').hide();  $('#Searchresult').append('<h3 align="center">Henüz yorum yok. İlk yorumu siz yapın...</h3>'); }
	$.each(JSON.comments, function(i, comment){
	  $('#Searchresult')
	  .append('<li class="comment even"><div class="comment-body"><div class="comment-author vcard"><cite class="fn">' + comment.adsoyad + '</cite> <span class="says">yazdı:</span></div><div class="comment-meta commentmetadata">' + comment.tarih + '</div><p>' + comment.yorum + '</p></div></li>')
	  });
	 });
}

function post_comment(isim,email,yorum,m_id) {
	$('#loading-post').show();
	$('input').attr('disabled','true'); $('textarea').attr('disabled','true');
	$.getJSON('/ch/post_comment/', {'isim':isim,'email':email,'yorum':yorum,'m_id':m_id} ,function(JSON){
	$('input').attr('disabled',''); $('textarea').attr('disabled','');
	$('#loading-post').hide();
	if (JSON.success == true) {$('#post-result').html('<strong>' + JSON.msg + '</strong>'); $('#webForm')[0].reset(); pageselectCallback(0,''); }
	else {$('#post-result').html('<strong>' + JSON.msg + '</strong>');}
	});
}

function post_contact(isim,email,mesaj,captcha) {
	$('#loading-post').show();
	$('input').attr('disabled','true'); $('textarea').attr('disabled','true');
	$.getJSON('/ch/post_contact/', {'isim':isim,'email':email,'mesaj':mesaj,'captcha':captcha} ,function(JSON){
	$('input').attr('disabled',''); $('textarea').attr('disabled','');
	$('#loading-post').hide();
	if (JSON.success == true) {$('#post-result').html('<strong>' + JSON.msg + '</strong>'); $('#webForm')[0].reset(); $('#captchaimage').attr('src', $('#captchaimage').attr('src')+'/'+ new Date().getTime());  }
	else {$('#post-result').html('<strong>' + JSON.msg + '</strong>');}
	});
}

function send_friend(name,email,mesaj,captcha,m_id) {
	$('#loading-send').show();
	$('input').attr('disabled','true'); $('textarea').attr('disabled','true');
	$.getJSON('/ch/send_friend/1/', {'name':name,'email':email,'mesaj':mesaj,'captcha':captcha,'m_id':m_id} ,function(JSON){
	$('input').attr('disabled',''); $('textarea').attr('disabled','');
	$('#loading-send').hide();
	if (JSON.success == true) {$('#send-result').html('<strong>' + JSON.msg + '</strong>'); $('#sendForm')[0].reset(); $('#captchaimage').attr('src', $('#captchaimage').attr('src')+'/'+ new Date().getTime());  }
	else {$('#send-result').html('<strong>' + JSON.msg + '</strong>');}
	});
}

$(function(){
	$.extend($.fn.disableTextSelect = function() {
		$(this).bind("contextmenu",function(e){ alert("Copyright - ©fwmail.net"); return false;  }); 
		return this.each(function(){
			if($.browser.mozilla){//Firefox
				$(this).css('MozUserSelect','none');
			}else if($.browser.msie){//IE
				$(this).bind('selectstart',function(){return false;});
			}else{//Opera, etc.
				$(this).mousedown(function(){return false;});
			}
		});
	});
});

function btest(sid,secid) {
	$('#loading-test').show(); $('#testContent').empty(); $('#testContent').height(400);
	$.getJSON('/ch/btest/1', {'sid':sid,'secid':secid,'random':new Date().getTime()} ,function(JSON){
	$('#loading-test').hide();
	if (JSON.success == true) { $('#testContent').height('auto'); $('#testContent').html(JSON.msg); $('#testContent').disableTextSelect(); }
	else {$('#testContent').html(JSON.msg);}
	});
}

function ktest(sid,secid) {
	$('#loading-test').show(); $('#ktestMain').hide(); $('.postWide').height(500); ;
	$.getJSON('/ch/ktest/1', {'sid':sid,'secid':secid,'random':new Date().getTime()} ,function(JSON){
	$('#loading-test').hide(); $('#ktestMain').show(); 
	if (JSON.success == true) { $('.postWide').height('auto'); $('#ktestMain').empty(); $('#ktestMain').html(JSON.content); $('#ktestMain').disableTextSelect()  }
	else {$('#ktestSoru').html(JSON.qst);$('#ktestNo').html(JSON.sno);$('#ktestContent').html(JSON.content); }
	});
}

function iqtest(sid,secid) {
	if (secid == '') { alert('Lütfen bir değer giriniz.'); $('#texta').focus(); return false; }
	window.data[sid] = secid;
	if (sid==30) { $('#countdown').stopCountDown(); }
	$('#loading-test').show(); $('#testContent').height(480); $('#countdown').show(); $('#testContent').empty();
	xt = $.getJSON('/ch/iqtest/1', {'sid':sid,'secid':secid,'data':window.data,'random':new Date().getTime()} ,function(JSON){
	$('#loading-test').hide();
	if (JSON.success == true) { $('#testContent').height('auto'); $('#countdown').stopCountDown(); $('#testContent').html(JSON.msg); $('#countdown').hide(); }
	else {$('#testContent').html(JSON.msg); }
	});
}

function uanaliz() {
	if ($('#gunx').val()==0 || $('#ayx').val()==0 || $('#yilx').val()==0 || $('#guny').val()==0 || $('#ayy').val()==0 || $('#yily').val()==0) { alert("Lütfen doğru tarih girdiğinizden emin olunuz."); return false; }
	if ((($('#ayx').val()==2 || $('#ayx').val()==4 || $('#ayx').val()==6 || $('#ayx').val()==9 || $('#ayx').val()==11) && $('#gunx').val()>30) || ($('#ayx').val()==2 && $('#gunx').val()>29)) { alert("Lütfen doğru tarih girdiğinizden emin olunuz."); return false; }
	if ((($('#ayy').val()==2 || $('#ayy').val()==4 || $('#ayy').val()==6 || $('#ayy').val()==9 || $('#ayy').val()==11) && $('#guny').val()>30) || ($('#ayy').val()==2 && $('#guny').val()>29)) { alert("Lütfen doğru tarih girdiğinizden emin olunuz."); return false; }
	var d1=$('#yilx').val()+'-'+$('#ayx').val()+'-'+$('#gunx').val(); var d2=$('#yily').val()+'-'+$('#ayy').val()+'-'+$('#guny').val();
	$('#loading-test').show(); $('#uyumSonuc').empty();
	$.getJSON('/ch/utest/1', {'d1':d1,'d2':d2,'random':new Date().getTime()} ,function(JSON){
	$('#loading-test').hide(); $('#uyumTitle').show();
	if (JSON.success == true) { $('#uyumSonuc').empty(); $('#uyumSonuc').html(JSON.content); $('#uyumSonuc').disableTextSelect()  }
	else { $('#uyumTitle').hide(); alert(JSON.content); }
	});
}

function kartest(sid,secid) {
	window.data[sid] = secid;
	$('#loading-test').show(); $('#testContent').height(400); $('#testContent').hide();
	$.getJSON('/ch/kartest/1', {'sid':sid,'secid':secid,'data':window.data,'random':new Date().getTime()} ,function(JSON){
	$('#loading-test').hide(); $('#testContent').show();
	if (JSON.success == true) { $('#testContent').height('auto'); $('#testContent').html(JSON.content); $('#testContent').disableTextSelect(); }
	else {$('#ktestSoru').html(JSON.qst);$('#ktestNo').html(JSON.sno);$('#kartestContent').html(JSON.content); }
	});
}
