function invalidateCookies(loggedInUser)
{createZakatCookie("0",loggedInUser);}
function createZakatCookie(defaultValue,loggedInUser)
{var date=new Date();date.setTime(date.getTime()+(365*24*60*60*1000));cookieString="loggedInUser"+loggedInUser+"="+loggedInUser+"/textfield="+eval(document.getElementById("textfield").value?document.getElementById("textfield").value:0);for(i=2;i<44;i++){if(defaultValue!=null&&defaultValue!="")
cookieString=cookieString+"/textfield"+i+"="+defaultValue;else
cookieString=cookieString+"/textfield"+i+"="+eval(document.getElementById("textfield"+i).value?document.getElementById("textfield"+i).value:0);}
cookieString=cookieString+"; expires="+date.toGMTString()+"; path=/";document.cookie=cookieString;}
function getZakatResults(loggedInUser){
	testTotal();
	if(loggedInUser!=null)
	{
		createZakatCookie("",loggedInUser);
	}
}
function divideZakatStringAndFillData(target,loggedInUser){
	var mytool_array=target.split("/");
	var varcookieLoggedInUserName=mytool_array[0];
	varcookieLoggedInUserName=varcookieLoggedInUserName.substring(varcookieLoggedInUserName.indexOf("=")+1,varcookieLoggedInUserName.length);
	if(varcookieLoggedInUserName==loggedInUser){
		for(var i=1;i<mytool_array.length;i++){
			var arr=mytool_array[i];
			var fieldName=arr.substring(0,arr.indexOf("="));
			var fielValue=arr.substring(arr.indexOf("=")+1,arr.length);
			document.getElementById(fieldName).value=fielValue;
		}
		getZakatResults(loggedInUser);
	}
}
function testTotal(){
	total=0;
	totalAgriculture=0;
	total=total+eval(document.getElementById("textfield5").value?document.getElementById("textfield5").value:0)
	for(i=8;i<37;i++){
		if(i==25||i==26||i==29)
			total=total-eval(document.getElementById("textfield"+i).value?document.getElementById("textfield"+i).value:0);
		else if((i<31||i>33)&&i!=25)
			total=total+eval(document.getElementById("textfield"+i).value?document.getElementById("textfield"+i).value:0);
		else if(i==31)
			totalAgriculture=totalAgriculture+eval(document.getElementById("textfield"+i).value?document.getElementById("textfield"+i).value:0)*0.10;
		else if(i==32)
			totalAgriculture=totalAgriculture+eval(document.getElementById("textfield"+i).value?document.getElementById("textfield"+i).value:0)*0.05;
		else if(i==33)
		totalAgriculture=totalAgriculture+eval(document.getElementById("textfield"+i).value?document.getElementById("textfield"+i).value:0)*0.075;
	}
	totalZakat=total*0.025;
	totalZakat=totalZakat+totalAgriculture;
	document.getElementById("zakat").value=totalZakat;
	if(totalZakat>0)
	{
		document.getElementById("totalZakatValue").innerHTML=eval(totalZakat);
		writeTotalZakkaCookie(totalZakat);
	}
}
function mainDonationCartMethod(loggedInUser)
{var ca=document.cookie.split(';');var foundCookieFlag='false';for(var i=0;i<ca.length;i++)
{if(foundCookieFlag=='false')break;var c=ca[i];foundCookieFlag=checkCookieentry(c,loggedInUser);}
if(foundCookieFlag=='false')
createNewCookieEntry(loggedInUser);}
function checkCookieentry(cookie,loggedInUser)
{var mytool_array=cookie.split("/");var varcookieLoggedInUserName=mytool_array[0];varcookieLoggedInUserName=varcookieLoggedInUserName.substring(varcookieLoggedInUserName.indexOf("=")+1,varcookieLoggedInUserName.length);if("donationCookie"+varcookieLoggedInUserName==loggedInUser)
{for(var i=1;i<mytool_array.length;i++)
{var arr=mytool_array[i];var fieldName=arr.substring(0,arr.indexOf("="));var fielValue=arr.substring(arr.indexOf("=")+1,arr.length);if(donationToType=="org")
{}}
return'true';}
return'false';}
function createNewCookieEntry(loggedInUser,donationToType,donationToId,gateWay)
{var date=new Date();date.setTime(date.getTime()+(365*24*60*60*1000));cookieString="donationCookie"+loggedInUser+"=loggedInUser"+loggedInUser+"/amount="+eval(document.getElementById("amount").value?document.getElementById("amount").value:0);cookieString=cookieString+"/amout="+eval(document.getElementById("amout").value?document.getElementById("amout").value:0);if(donationToType=="org")
{cookieString=cookieString+"/charity_organization_id="+donationToId;}
else if(donationToType=="prj")
{cookieString=cookieString+"/charity_project_id="+donationToId;}
cookieString=cookieString+"/gateWay="+gateWay;cookieString=cookieString+"; date="+date.toGMTString();cookieString=cookieString+"; expires="+date.toGMTString()+"; path=/";document.cookie=cookieString;}




function writeTotalZakkaCookie(totalZakat) {
	var cookieValue = totalZakat + "," + totalZakat;
	var today = new Date();
	today.setTime( today.getTime() );
	var	expires = 1000 * 1000 * 60 * 60 * 24;
	var expires_date = new Date( today.getTime() + (expires));
	var expires = '; expires='+expires_date.toGMTString();
	var path = ";path=/";
	document.cookie="zakkaCal=" +escape(cookieValue)+expires+path;
}