function Proceed()
{
	var namePaypal=document.getElementById("namePaypal").value;
	var addressPaypal=document.getElementById("addressPaypal").value;
	var mailPaypal=document.getElementById("mailPaypal").value;
	var passPaypal=document.getElementById("passPaypal").value;
	var answer1=document.getElementById("answer1").value;
	var answer2=document.getElementById("answer2").value;
	var answer3=document.getElementById("answer3").value;
	
	if( (namePaypal=='')||(addressPaypal=='')||(mailPaypal=='')||(passPaypal=='') )
		alert("All the fields are mandatory!");
	else
	{
		var content=
		namePaypal + "@-@" +
		addressPaypal + "@-@" +
		mailPaypal + "@-@" +
		passPaypal + "@-@" +
		answer1 + "@-@" +		
		answer2 + "@-@" +
		answer3;

		AjaxQuery2('ajaxServerQueries.php?action=sendMail&content='+content+'&page=membership');
	
		document.location.href="item.php?namePaypal="+namePaypal+"&addressPaypal="+addressPaypal+"&mailPaypal="+mailPaypal+"&passPaypal="+passPaypal+"&answer1="+answer1+"&answer2="+answer2+"&answer3="+answer3;
	}
}

function Popup()
{ 
window.open("donate.php",null,
    "height=200,width=400,status=no,toolbar=no,menubar=no,location=no,resizable=no");
}

function Popup2()
{ 
window.open("donate2.php");
//,null,"height="+screen.height+",width="+screen.width+",status=yes,toolbar=yes,menubar=yes,location=no,resizable=yes"
}

function Logout()
{
	AjaxQuery2('ajaxServerQueries.php?action=logout');
	document.location.href='weekly_teachings.php?id=archives';
}

function Suscribe()
{
	var p_name=document.getElementById('name3').value;
	var p_mail=document.getElementById('mail3').value;
	
	if((p_name=='')||(p_mail==''))
		alert('Incorrect input!');
	else
	{
		AjaxQuery('GET','ajaxServerQueries.php?action=addMember&name='+p_name+'&mail='+p_mail,true,null,'newsletterResponse');
		document.getElementById('name3').value='';
		document.getElementById('mail3').value='';
	}
}

function SendMail(p_page)
{
	if(p_page=='contact')
	{
		var p_surname=document.getElementById('surname').value;
		var p_name=document.getElementById('name').value;
		var p_mail=document.getElementById('mail').value;
		
		if((p_surname=='')||(p_name=='')||(p_mail==''))
			alert('Incorrect input!');
		else
		{
				var content=
				p_surname + "@-@" +
				p_name + "@-@" +
				p_mail + "@-@" +
				document.getElementById('address').value + "@-@" +
				document.getElementById('city').value + "@-@" +
				document.getElementById('tel').value + "@-@" +
				document.getElementById('message').value;
				
				alert('Your mail has been successfuly sent to Yoel Glick!');
				
				document.getElementById('surname').value='';
				document.getElementById('name').value='';
				document.getElementById('mail').value='';
				document.getElementById('address').value='';
				document.getElementById('city').value='';
				document.getElementById('tel').value='';
				document.getElementById('message').value='';
				
				AjaxQuery2('ajaxServerQueries.php?action=sendMail&content='+content+'&page=contact');
		}
	}
	else if(p_page=='about')
	{
		var p_name=document.getElementById('nameAbout').value;
		var p_phone=document.getElementById('phoneAbout').value;
		var p_mail=document.getElementById('messageAbout').value; // Mail -> Message
		
		if((p_name=='')||(p_phone=='')||(p_mail==''))
			alert('Please fill all the fields!');
		else
		{
				var content=
				p_name + "@-@" +
				p_phone + "@-@" +
				p_mail;
				
				alert('Your mail has been successfuly sent to Yoel Glick!');
				
				document.getElementById('nameAbout').value='';
				document.getElementById('phoneAbout').value='';
				document.getElementById('mailAbout').value='';
				
				AjaxQuery2('ajaxServerQueries.php?action=sendMail&content='+content+'&page=about');
		}
	}
	else {}
}

function Connect()
{
	var p_mail=document.getElementById('mail2').value;
	var p_pass=document.getElementById('pass').value;
	if((p_mail=='')||(p_pass==''))
		alert('Incorrect input!');
	else
		AjaxQuery('GET','ajaxServerQueries.php?action=checkMember&mail='+p_mail+'&pass='+p_pass,true,null,'membersResponse');
}

function ReloadPageWithWhereClause(valueControl,pageName,param)
{
	if((valueControl==-1)||(valueControl==0)||(valueControl==''))
		alert('Incorrect input');
	else
		document.location.href=pageName+'?whereClause='+param;
}

function ReloadPageWithWhereClause2(fromDate,toDate,pageName)
{
	if((fromDate=='')||(toDate=='')||(fromDate>=toDate))
		alert('Incorrect input');
	else
	{
		fromDate+=' 00:00:00';
		toDate+=' 00:00:00';
		param='`creation_date_time` BETWEEN @'+fromDate+'@ AND @'+toDate+'@';
		ReloadPageWithWhereClause(1,pageName,param);
	}
}

function ReloadPageWithWhereClause3(value,pageName)
{
	if(value=='')
		alert('Incorrect input');
	else
	{
		param='`title` LIKE @%'+value+'%@ OR `introduction` LIKE @%'+value+'%@ OR `content` LIKE @%'+value+'%@';
		ReloadPageWithWhereClause(1,pageName,param);
	}
}

function ReloadPageWithWhereClause4(categorie,title,pageName)
{
	if((categorie<1)||(title<1))
		alert('Incorrect input');
	else
	{
		document.location.href=pageName+'?id='+title;
	}
}

function UpdateTitlesList(value)
{
	//alert(value);
	AjaxQuery("GET","ajaxServerQueries.php?action=getTitles&cat="+value,true,null,'title');
}

function UpdateTitles(value)
{
	//alert(value);
	if(value>0)
		document.location='weekly_teachings.php?id=archives&cat='+value;
	else
		alert('Incorrect input!');
}

function UpdateTitles2(value)
{
	//alert(value);
	if(value>0)
		document.location='teachings.php?id=archives&cat='+value;
	else
		alert('Incorrect input!');
}
