
/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_submitContactUsForm																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_submitContactUsForm ()
{
	var formValidator = new Validator("contactForm");

	formValidator.clearAllValidations ();

	formValidator.addValidation("title",				"required",		"יש להזין את כותרת ההודעה");
	formValidator.addValidation("fullname",				"required",		"יש להזין שם");
	formValidator.addValidation("email",				"required",		"יש להזין דוא\"ל");
	formValidator.addValidation("email",				"email",		"יש להזין דוא\"ל חוקי");
	formValidator.addValidation("phone",				"phone",		"יש להזין טלפון חוקי");

	return formValidator.validate ();
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_submitLoginForm																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_submitLoginForm ()
{
	var formValidator = new Validator("loginForm");
			
	formValidator.clearAllValidations ();
	formValidator.addValidation("username",				"required",		"יש להזין דוא\"ל");
	formValidator.addValidation("username",				"email",		"יש להזין דוא\"ל חוקי");
	formValidator.addValidation("password",				"required",		"יש להזין סיסמא");
		
	return formValidator.validate ();	
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_submitForgotPass																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_submitForgotPass ()
{
	var formValidator = new Validator("loginForm");
			
	formValidator.clearAllValidations ();
	formValidator.addValidation("username",				"required",		"יש להזין דוא\"ל");
	formValidator.addValidation("username",				"email",		"יש להזין דוא\"ל חוקי");
		
	if (formValidator.validate ())
	{
		oLoginForm = document.getElementById("loginForm");
		oPassForm  = document.getElementById("forgotPassForm");

		oPassForm.username.value = oLoginForm.username.value;

		oPassForm.submit ();
	}

	return false;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_submitRegisterForm																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_submitRegisterForm ()
{
	var formValidator = new Validator("registerForm");
			
	formValidator.clearAllValidations ();
	formValidator.addValidation("username",				"required",		"יש להזין דוא\"ל");
	formValidator.addValidation("username",				"email",		"יש להזין דוא\"ל חוקי");
	formValidator.addValidation("password",				"required",		"יש להזין סיסמא");
	formValidator.addValidation("confirmPassword",		"required",		"יש להזין אימות סיסמא");
	
	if (formValidator.validate ())
	{
		oForm = document.getElementById("registerForm");

		if (oForm.password.value != oForm.confirmPassword.value)
		{
			alert ("סיסמא ואימות סיסמא אינם תואמים! יש להזינם שוב");
			oForm.confirmPassword.value = "";
			oForm.password.focus ();
			oForm.password.select ();

			return false;
		}

		oForm.email.value = oForm.username.value;

		if (oForm.birthDay.value != "" && oForm.birthMonth.value != "" && oForm.birthYear.value != "")
			theBirthDate = oForm.birthDay.value + "-" + oForm.birthMonth.value + "-" + oForm.birthYear.value;
		else
			theBirthDate = "";
		oForm.birthDate.value = theBirthDate;

		oForm.birthDate.value = theBirthDate;

		formValidator.clearAllValidations ();
		formValidator.addValidation("firstname",		"required",		"יש להזין שם פרטי");
		formValidator.addValidation("lastname",			"required",		"יש להזין שם שמפחה");
		formValidator.addValidation("phone",			"phone",		"יש להזין מספר טלפון חוקי");

		if (formValidator.validate ())
		{
			verification_check ("registerForm", "HEB");
		}
	}

	return false;
}
 
/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectBook																									*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectBook (type)
{
	var oBook = document.getElementById("query_bookId");

	if (oBook.value == "")
	{
		dailyZohar_setChapterOptions  ("", type);
		dailyZohar_setMainSubjOptions ("", type);
		dailyZohar_setSubSubjOptions  ("", type);
	}
	else
	{
		xml  = 	"<request>" +
					"<command>private.getOptionsByBook</command>" 		+
					"<type>" 		+ type 			+ "</type>"			+
					"<bookId>" 		+ oBook.value 	+ "</bookId>"		+
				"</request>";
			
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_onSelectBook_response");
	}
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectBook_response																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectBook_response ()
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));

	try
	{
		var type     = xmlRequest.getValue("type");
		var chapters = xmlRequest.getValue("chapters");
		var mains	 = xmlRequest.getValue("mains");
	}
	catch (e)
	{
		return false;
	}

	dailyZohar_setChapterOptions  (chapters, type);
	dailyZohar_setMainSubjOptions (mains, type);
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_setChapterOptions																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_setChapterOptions (options, type)
{
	var selectHtml = "<select name='query_chapterId' id='query_chapterId' onchange='dailyZohar_onSelectChapter(\"" + type + "\")'>" + 
					 " 	<option value=''>--שם הפרשה--</option>" +
					 	options	+
					 "</select>";

	document.getElementById("selectChapterId").innerHTML = selectHtml;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectChapter																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectChapter (type)
{
	var oBook    = document.getElementById("query_bookId");
	var oChapter = document.getElementById("query_chapterId");

	if (oBook.value == "" && oChapter.value == "")
	{
		dailyZohar_setMainSubjOptions ("", type);
		dailyZohar_setSubSubjOptions  ("", type);
	}
	else
	{
		xml  = 	"<request>" +
					"<command>private.getMainSubjOptions</command>" 	+
					"<type>" 		+ type 			 + "</type>"		+
					"<bookId>"		+ oBook.value	 + "</bookId>"		+
					"<chapterId>"	+ oChapter.value + "</chapterId>"	+
				"</request>";
			
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_onSelectChapter_response");
	}
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectChapter_response																						*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectChapter_response ()
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));

	try
	{
		var type     = xmlRequest.getValue("type");
		var options  = xmlRequest.getValue("options");
	}
	catch (e)
	{
		return false;
	}

	dailyZohar_setMainSubjOptions (options, type);
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_setMainSubjOptions																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_setMainSubjOptions (options, type)
{
	var selectHtml = "<select name='query_mainSubject' id='query_mainSubject' onchange='dailyZohar_onSelectMainSubject(\"" + type + "\")'>" + 
					 " 	<option value=''>--נושא ראשי--</option>" +
					 	options	+
					 "</select>";

	document.getElementById("selectMainSubj").innerHTML = selectHtml;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectMainSubject																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectMainSubject (type)
{
	if (type == "zohar")
	{
		var oBook    = document.getElementById("query_bookId");
		var oChapter = document.getElementById("query_chapterId");
		

		var addToXml = "<bookId>"		+ oBook.value	 + "</bookId>"	+
					   "<chapterId>"	+ oChapter.value + "</chapterId>";
	}
	else
	{
		var addToXml = "";
	}

	var oMainSubj = document.getElementById("query_mainSubject");

	if (oMainSubj.value == "")
	{
		dailyZohar_setSubSubjOptions ("", type);
	}
	else
	{
		xml  = 	"<request>" +
					"<command>private.getSubSubjOptions</command>" 		+
					"<type>" 		+ type 			 + "</type>"			+
					addToXml		+
					"<mainSubject>"	+ oMainSubj.value + "</mainSubject>"	+
				"</request>";
			
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_onSelectMainSubject_response");
	}
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectMainSubject_response																					*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectMainSubject_response ()
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));

	try
	{
		var type     = xmlRequest.getValue("type");
		var options  = xmlRequest.getValue("options");
	}
	catch (e)
	{
		return false;
	}

	dailyZohar_setSubSubjOptions (options, type);
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_setSubSubjOptions																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_setSubSubjOptions (options, type)
{
	var selectHtml = "<select name='query_subSubject' id='query_subSubject'>" + 
					 " 	<option value=''>--נושא משני--</option>" +
					 	options	+
					 "</select>";

	document.getElementById("selectSubSubj").innerHTML = selectHtml;
}

var currRow = null;

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectRow																									*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectRow (oRow)
{
	if (currRow != null)
		currRow.className = "unselected";

	if (currRow == oRow)
	{
		currRow = null;
	}
	else
	{
		currRow = oRow;
		currRow.className = "selected";
	}
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_doLessonAction																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_doLessonAction (action)
{
	if (currRow == null)
	{
		alert ("יש לבחור שורה בטבלת התוצאות");
		return false;
	}

	if (action == "go")
	{
		window.location.href = "index2.php?id=" + currRow.id + "&lang=HEB";
		return false;
	}
	else if (action == "listen")
	{
		currSoundFile = document.getElementById("soundFile" + currRow.id).innerHTML;

		if (currSoundFile == "")
		{
			alert ("אין קובץ שמע עבור שיעור זה");
			return false;
		}

		window.open (currSoundFile);
	}
	else	// action = download
	{
		var currVideoFile = document.getElementById("videoFile" + currRow.id).innerHTML;
		var currSoundFile = document.getElementById("soundFile" + currRow.id).innerHTML;

		if (currSoundFile == "" && currVideoFile == "")
		{
			alert ("אין קבצים להורדה עבור שיעור זה");
			return false;
		}

		if (currSoundFile == "")
		{
			dailyZohar_lessonDownload (currRow.id, "video");
			return false;
		}

		if (currVideoFile == "")
		{
			dailyZohar_lessonDownload (currRow.id, "video");
			return false;
		}
		else
		{
			dailyZohar_showDownloadPopup ();
			return false;
		}
	}
}	

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_lessonMediaPlay																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_lessonMediaPlay (newSrc)
{
	if (document.getElementById("mediaPlayerEmbed"))
	{
		document.getElementById("mediaPlayerEmbed").src = newSrc;
	}
	else
	{
		document.getElementById("mediaPlayerObj").fileName = newSrc; 
	}
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_showHideLessonFeedback																						*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_showHideLessonFeedback (id)
{
	var oFeedback = document.getElementById("lessonFeedback" + id);

	if (oFeedback.style.display == "")
		oFeedback.style.display = "none";
	else
		oFeedback.style.display = "";
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_hideLessonFeedback																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_hideLessonFeedback (id)
{
	var oFeedback = document.getElementById("lessonFeedback" + id);

	oFeedback.style.display = "none";
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_showHideFeedbackForm																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_showHideFeedbackForm ()
{
	var oForm = document.getElementById("addFeedbackForm");

	if (oForm.style.display == "")
		oForm.style.display = "none";
	else
		oForm.style.display = "";
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_addFeedback																									*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_addFeedback (itemId)
{
	// validate form
	oForm = document.getElementById("feedbackForm");

	// - name
	if (oForm.fullname.value == "")
	{
		alert ("יש להזין שם");
		oForm.fullname.focus ();
		return false;
	}
	// - title
	if (oForm.title.value == "")
	{
		alert ("יש להזין נושא");
		oForm.title.focus ();
		return false;
	}

	// ------------------------------------------------------------------------------------------------
	requestXml = "<data>"	+
					"<command>talkbacks.addTalkback</command>" +
					"<type>specific</type>"					   +
					"<status>new</status>"  		  		   +
					"<specificId>"  + itemId	 	  		   + "</specificId>"  	+
					"<fullname>" 	+ oForm.fullname.value     + "</fullname>" 		+
					"<title>" 	 	+ oForm.title.value 	   + "</title>" 		+
					"<talkback>" 	+ oForm.feedback.value     + "</talkback>" 		+
				 "</data>";
	
	xmlRequest.init (requestXml);
	
	xmlRequest.sendAsyncRequest ('server.php', xmlRequest.obj, "dailyZohar_addFeedback_response");

	return false;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_addFeedback_response																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_addFeedback_response ()
{
	dailyZohar_showHideFeedbackForm ();

	oForm = document.getElementById("feedbackForm");

	oForm.fullname.value = "";
	oForm.title.value 	 = "";
	oForm.feedback.value = "";

	alert ("קיבלנו את פרטי החידוש ונשתדל להוסיפו בקרוב, בכפוף לשיקולי המערכת");
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectPlace																									*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectPlace ()
{
	oForm = document.getElementById("orderDedicationForm");

	document.getElementById("priceBox").innerHTML = "";

	for (var i=0; i < oForm.place.length; i++)
		if (oForm.place[i].checked)
      		var placeVal = oForm.place[i].value;

	xml  = 	"<request>" +
				"<command>private.getDedicationPriceIdsByPlace</command>" 		+
				"<place>" 		+ placeVal 		 + "</place>"					+
			"</request>";
		
	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_onSelectPlace_response");
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectPlace_response																						*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectPlace_response ()
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));

	try
	{
		var options  = xmlRequest.getValue("options");
	}
	catch (e)
	{
		return false;
	}

	var selectHtml = "<select id='period' name='period' onchange='dailyZohar_onSelectPeriod()'>" + 
					 " 	<option value=''>בחר תקופה</option>" +
					 	options	+
					 "</select>";

	document.getElementById("selectPeriod").innerHTML = selectHtml;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectPeriod																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectPeriod ()
{
	oForm = document.getElementById("orderDedicationForm");

	if (oForm.period.value == "")
		document.getElementById("priceBox").innerHTML = "";
	else
	{
		for (var i=0; i < oForm.place.length; i++)
			if (oForm.place[i].checked)
      			var placeVal = oForm.place[i].value;

		xml  = 	"<request>" +
					"<command>private.getDedicationPrice</command>" 		+
					"<place>" 		+ placeVal 			   + "</place>"		+
					"<period>"		+ oForm.period.value   + "</period>"	+
				"</request>";
		
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_onSelectPeriod_response");
	}
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectPeriod_response																						*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectPeriod_response ()
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));

	try
	{
		var priceText   = xmlRequest.getValue("priceText");
		var priceValue  = xmlRequest.getValue("price");
	}
	catch (e)
	{
		return false;
	}

	document.getElementById("priceBox").innerHTML = priceText;
	
	// save amount (for paypal)
	oForm = document.getElementById("orderDedicationForm");
	oForm.amount.value = priceValue;

}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_submitOrderDedicationFormByEmail																				*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_submitOrderDedicationFormByEmail ()
{
	oForm = document.getElementById("orderDedicationForm");

	oForm.orderType.value = "email";

	return dailyZohar_submitOrderDedicationForm ();
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_submitOrderDedicationFormForPay																				*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_submitOrderDedicationFormForPay ()
{
	oForm = document.getElementById("orderDedicationForm");

	oForm.orderType.value = "pay";

	return dailyZohar_submitOrderDedicationForm ();
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_submitOrderDedicationForm																						*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_submitOrderDedicationForm ()
{
	var formValidator = new Validator("orderDedicationForm");

	formValidator.clearAllValidations ();

	formValidator.addValidation("firstName",			"required",		"יש להזין שם פרטי");
	formValidator.addValidation("parentName",			"required",		"יש להזין את שם האב או שם האם");
	formValidator.addValidation("familyName",			"required",		"יש להזין שם משפחה");
	formValidator.addValidation("period",				"required",		"יש לבחור תקופה");
	formValidator.addValidation("ordererName",			"required",		"יש להזין את שם מזמין ההקדשה");
	formValidator.addValidation("ordererPhone",			"required",		"יש להזין את טלפון מזמין ההקדשה");
	formValidator.addValidation("ordererPhone",			"phone",		"יש להזין טלפון חוקי");
	formValidator.addValidation("ordererEmail",			"required",		"יש להזין את דוא\"ל מזמין ההקדשה");
	formValidator.addValidation("ordererEmail",			"email",		"יש להזין דוא\"ל חוקי");

	if (formValidator.validate ())
	{
		oForm = document.getElementById("orderDedicationForm");

		// check jewish date
		xml  = 	"<request>" +
					"<command>private.checkJewishDate</command>" 		+
					"<year>" 		+ oForm.year.value    + "</year>"	+
					"<month>"		+ oForm.month.value   + "</month>"	+
					"<day>"			+ oForm.day.value     + "</day>" 	+
				"</request>";
		
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_afterCheckJewishDate");
	}

	return false;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_afterCheckJewishDate																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_afterCheckJewishDate ()
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));

	try
	{
		var valid  = xmlRequest.getValue("valid");
	}
	catch (e)
	{
		return false;
	}

	if (valid == "1")
		dailyZohar_continueSubmitOrderDedicationForm ();
	else
		alert ("תאריך הפטירה אינו חוקי");

	return false;
	
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_continueSubmitOrderDedicationForm																				*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_continueSubmitOrderDedicationForm ()
{
	oForm = document.getElementById("orderDedicationForm");

	var theDate  = oForm.dateField.value;

	if (theDate == "")
	{
		alert ("יש לבחור את תאריך הופעת ההקדשה");
		return false;
	}

	// check date (future date)
	
	var theDay	 = theDate.substr(0,2)*1;
	var theMonth = theDate.substr(3,2)*1;
	var theYear	 = ("20"+theDate.substr(6,2))*1;

	theMonth--;

	var formDate = new Date(theYear, theMonth, theDay, 23, 59, 00); 
	var today    = new Date(); 
    
	if (formDate < today) 
    { 
	    alert ("לא ניתן לבחור תאריך מוקדם מהתאריך הנוכחי") 
	    return false; 
    } 

	oForm.startDate.value = theDate;

	for (var i=0; i < oForm.place.length; i++)
		if (oForm.place[i].checked)
			var placeVal = oForm.place[i].value;

	// check availability
	xml  = 	"<request>" +
				"<command>private.checkDedicationAvailability</command>" 		+
				"<place>" 		+ placeVal 			   + "</place>"			+
				"<period>"		+ oForm.period.value   + "</period>"		+
				"<startDate>"	+ theDate			   + "</startDate>"	 	+
			"</request>";
	
	xmlRequest.init (xml);
	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_dedicationAvailability_response");
	
	return false;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_dedicationAvailability_response																				*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_dedicationAvailability_response ()
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));

	try
	{
		var available  = xmlRequest.getValue("available");
	}
	catch (e)
	{
		return false;
	}

	if (available == "1")
	{
		oForm = document.getElementById("orderDedicationForm");

		var placeVal = "";
		for (var i=0; i < oForm.place.length; i++)
			if (oForm.place[i].checked)
    	  		placeVal = oForm.place[i].value;

		var genderVal = "";
		for (var i=0; i < oForm.gender.length; i++)
			if (oForm.gender[i].checked)
    	  		genderVal = oForm.gender[i].value;

		// save donation
		xml  = 	"<request>" +
					"<command>private.saveDedication</command>" 	+
					"<place>"			+ placeVal 			  		+ "</place>"		+
					"<gender>"			+ genderVal  		 		+ "</gender>"		+
					"<firstName>"		+ oForm.firstName.value   	+ "</firstName>"	+
					"<parentName>"		+ oForm.parentName.value   	+ "</parentName>"	+
					"<familyName>"		+ oForm.familyName.value   	+ "</familyName>"	+
					"<day>"				+ oForm.day.value   		+ "</day>"			+
					"<month>"			+ oForm.month.value   		+ "</month>"		+
					"<year>"			+ oForm.year.value   		+ "</year>"			+
					"<dedication>"		+ oForm.dedication.value   	+ "</dedication>"	+
					"<startDate>"		+ oForm.startDate.value   	+ "</startDate>"	+
					"<period>"			+ oForm.period.value   		+ "</period>"		+
					"<ordererName>"		+ oForm.ordererName.value   + "</ordererName>"	+
					"<ordererPhone>"	+ oForm.ordererPhone.value  + "</ordererPhone>"	+
					"<ordererEmail>"	+ oForm.ordererEmail.value  + "</ordererEmail>"	+
				"</request>";
	
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_afterSaveDedication");
	}
	else
	{
		alert ("בשלב זה לא נמצא מקום פנוי לפרסום ההקדשה");
	}

	return false;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_afterSaveDedication																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_afterSaveDedication ()
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));

	try
	{
		var id  = xmlRequest.getValue("id");
	}
	catch (e)
	{
		alert ("הפעולה נכשלה");
		return false;
	}

	oForm = document.getElementById("orderDedicationForm");

	if (oForm.orderType.value == "pay")
	{
		oForm.rowId.value = id;
		oForm.submit ();
	}
	else
	{
		// send email dedication
		xml  = 	"<request>" +
					"<command>private.sendEmailDedication</command>" 	+
					"<id>"	+ id   	+ "</id>"	+
				"</request>";
	
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_afterSendEmailDedication");

	}

	return false;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_afterSendEmailDedication																						*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_afterSendEmailDedication ()
{
	window.location.href = "index2.php?id=40&lang=HEB";
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_submitDonationFormByEmail																						*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_submitDonationFormByEmail ()
{
	oForm = document.getElementById("donationForm");

	oForm.orderType.value = "email";

	return dailyZohar_submitDonationForm ();
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_submitDonationFormForPay																						*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_submitDonationFormForPay ()
{
	oForm = document.getElementById("donationForm");

	oForm.orderType.value = "pay";

	return dailyZohar_submitDonationForm ();
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_submitDonationForm																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_submitDonationForm ()
{
	var formValidator = new Validator("donationForm");

	formValidator.clearAllValidations ();

	formValidator.addValidation("firstName",			"required",		"יש להזין שם פרטי");
	formValidator.addValidation("familyName",			"required",		"יש להזין שם משפחה");
	formValidator.addValidation("email",				"required",		"יש להזין דוא\"ל");
	formValidator.addValidation("email",				"email",		"יש להזין דוא\"ל חוקי");
	formValidator.addValidation("phone",				"required",		"יש להזין טלפון");
	formValidator.addValidation("phone",				"phone",		"יש להזין טלפון חוקי");
	formValidator.addValidation("amount",				"required",		"יש להזין סכום");
	formValidator.addValidation("amount",				"num",			"יש להזין סכום בספרות בלבד");

	if (formValidator.validate ())
	{
		oForm = document.getElementById("donationForm");

		// save donation
		xml  = 	"<request>" +
					"<command>private.saveDonation</command>" 	+
					"<firstName>"	+ oForm.firstName.value   	+ "</firstName>"	+
					"<familyName>"	+ oForm.familyName.value   	+ "</familyName>"	+
					"<address>"		+ oForm.address.value   	+ "</address>"		+
					"<email>"		+ oForm.email.value   		+ "</email>"		+
					"<phone>"		+ oForm.phone.value   		+ "</phone>"		+
					"<remarks>"		+ oForm.remarks.value   	+ "</remarks>"		+
					"<amount>"		+ oForm.amount.value   		+ "</amount>"		+
				"</request>";
	
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_afterSaveDonation");
	}

	return false;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_afterSaveDonation																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_afterSaveDonation ()
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));

	try
	{
		var id  = xmlRequest.getValue("id");
	}
	catch (e)
	{
		alert ("הפעולה נכשלה");
		return false;
	}

	oForm = document.getElementById("donationForm");

	if (oForm.orderType.value == "pay")
	{
		oForm.rowId.value = id;
		oForm.submit ();
	}
	else
	{
		// send email donation
		xml  = 	"<request>" +
					"<command>private.sendEmailDonation</command>" 	+
					"<id>"	+ id   	+ "</id>"	+
				"</request>";
	
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_afterSendEmailDonation");

	}

	return false;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_afterSendEmailDonation																						*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_afterSendEmailDonation ()
{
	window.location.href = "index2.php?id=41&lang=HEB";
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_showDownloadPopup																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_showDownloadPopup ()
{
	var oPopup = document.getElementById("lessonDownloadPopup");

	if (oPopup != undefined)
		oPopup.style.display = "";

}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_hideDownloadPopup
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_hideDownloadPopup ()
{
	var oPopup = document.getElementById("lessonDownloadPopup");

	if (oPopup != undefined)
		oPopup.style.display = "none";

}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_lessonDownload																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_lessonDownload (lessonId, type)
{
	if (lessonId == 0)	// from lesson results page
		lesson = currRow.id;

	dailyZohar_hideDownloadPopup ();

	window.open ("privateLessonDownload.php?id=" + lessonId + "&type=" + type);
}

var membersOnlyWin = new floatWindow();

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_membersOnlyMsg																								*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_membersOnlyMsg (e)
{
	var html = document.getElementById("membersOnlyMsg").innerHTML;

	var xPoint 		= 340;	// center;
	var yPoint 		= dailyZohar_getClickY(e) - 60;

	var parentName  = document.getElementById("membersOnlyMsgParent").innerHTML 
	if (document.getElementById(parentName) == undefined)
		parentName = "";

	membersOnlyWin.create(parentName, "membersOnlyWin", html, xPoint, yPoint);

	membersOnlyWin.show ();
}

var notYetMsgWin = new floatWindow();

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_notYetMsg																										*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_notYetMsg (e)
{
	var html = document.getElementById("notYetMsg").innerHTML;

	var xPoint 		= 340;	// center;
	var yPoint 		= dailyZohar_getClickY(e) - 60;

	var parentName  = document.getElementById("notYetMsgParent").innerHTML 
	if (document.getElementById(parentName) == undefined)
		parentName = "";

	notYetMsgWin.create(parentName, "notYetMsgWin", html, xPoint, yPoint);

	notYetMsgWin.show ();
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_getClickY																										*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_getClickY (e)
{
	if (e == undefined) return 300;

	if (!e) var e = window.event;
	clickY = e.clientY;

	if (e.pageX || e.pageY) 	
	{
		clickX = e.pageX;
		clickY = e.pageY;
	}
	else if (e.clientX || e.clientY) 	
	{
		clickX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		clickY = e.clientY + document.body.scrollTop  + document.documentElement.scrollTop;
	}

	return clickY;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectEssayAuthor																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectEssayAuthor ()
{
	var oAuthor = document.getElementById("query_essayAuthor");

	if (oAuthor.value == "")
	{
		dailyZohar_setEssayTitleOptions ("");
	}
	else
	{
		xml  = 	"<request>" +
					"<command>private.getEssayTitleOptions</command>" 	+
					"<author>"	+ oAuthor.value + "</author>"			+
				"</request>";
			
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_onSelectEssayAuthor_response");
	}
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectEssayAuthor_response																					*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectEssayAuthor_response ()
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));

	try
	{
		var options  = xmlRequest.getValue("options");
	}
	catch (e)
	{
		return false;
	}

	dailyZohar_setEssayTitleOptions (options);
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_setEssayTitleOptions																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_setEssayTitleOptions (options)
{
	var selectHtml = "<select name='query_essayTitle' id='query_essayTitle' onchange='dailyZohar_onSelectEssayTitle()'>" + 
					 " 	<option value=''>--נושא ראשי--</option>" +
					 	options	+
					 "</select>";

	document.getElementById("selectEssayTitle").innerHTML = selectHtml;
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectEssayTitle																							*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectEssayTitle ()
{
	var oTitle = document.getElementById("query_essayTitle");

	if (oTitle.value == "")
	{
		dailyZohar_setEssaySubTitleOptions ("");
	}
	else
	{
		xml  = 	"<request>" +
					"<command>private.getEssaySubTitleOptions</command>" 	+
					"<title>"	+ oTitle.value + "</title>"			+
				"</request>";
			
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "dailyZohar_onSelectEssayTitle_response");
	}
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_onSelectEssayTitle_response																					*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_onSelectEssayTitle_response ()
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));

	try
	{
		var subTitlesOptions  = xmlRequest.getValue("subTitlesOptions");
//		var authorOptions  	  = xmlRequest.getValue("authorOptions");
	}
	catch (e)
	{
		return false;
	}

	dailyZohar_setEssaySubTitleOptions (subTitlesOptions);
}

/* ------------------------------------------------------------------------------------------------------------------------	*/
/* dailyZohar_setEssaySubTitleOptions																						*/
/* ------------------------------------------------------------------------------------------------------------------------	*/
function dailyZohar_setEssaySubTitleOptions (options)
{
	var selectHtml = "<select name='query_essaySubTitle' id='query_essaySubTitle'>" + 
					 " 	<option value=''>--נושא משני--</option>" +
					 	options	+
					 "</select>";

	document.getElementById("selectEssaySubTitle").innerHTML = selectHtml;
}


