$(document).ready( function()
{
	getCurrentKhatmatCount();
	
//	toggleSubmitKhatmaBtn(); 
	
	//setInterval("getCurrentKhatmatCount()", 500);
	
});

function toggleSubmitKhatmaBtn()
{
	if (checkCookie("5atma_done"))
	{
		$("#submit5atma").attr('disabled','disabled');
	}
}

function getCurrentKhatmatCount()
{
	$.ajax(
			{
				type :"POST",
				url :"ajax/khatmat.ajax.php",
				data :"mod=get",
				success : function(result)
				{
					$("#khatmatCounter").html(result);
				},
				error : function(e1, e2, e3)
				{
					alert("error");
				}
			});
}

function submitKhatma()
{
//	var sec_code=document.getElementById("sec_code");
//	var sec_valid=document.getElementById("sec_valid");
	
	$.ajax(
			{
				type :"POST",
				url :"ajax/khatmat.ajax.php",
				data :"mod=set",
				success : function(result)
				{
					$("#khatmatCounter").html(result);
					//var cookieName = "5atma_done";
					//createCookie(cookieName, '5atma_done', 3);
					//$("#submit5atma").attr('disabled','disabled');
				},
				error : function(e1, e2, e3)
				{
					//alert("error");
				}
			});
}
function validateCaptcha()
{
	//empty the fields
	document.getElementById("sec_code_error_msg").value='';
	var code=$("#sec_code").val();
		
	$.ajax(
			{
				type :"POST",
				url :"ajax/validate_captcha.php",
				data :"code="+code,
				success : function(result)
				{
				if(result!=1){
					document.getElementById('sec_code_error_msg').innerHTML="الكود غير صحيح";
					document.getElementById('sec_valid').value="0";
				}else
				document.getElementById('sec_valid').value="1";	
				},
				error : function(e1, e2, e3)
				{
					alert("error");
				}
			});
}