//	********************************************************************************************************
//		CSearchChildFormBuilder.js
//	********************************************************************************************************
//
//		CREATED FROM:	Robert Stiehler (idaSys)
//		CREATED AT:	13.10.2008
//		
//		UPDATES:
//
//	--------------------------------------------------------------------------------------------------------


//class CSearchChildFormBuilder
//{
//public:
	function CSearchChildFormBuilder()
	{
	//public:
		this.createSearchChildForm = declared_createSearchChildForm;
		
	//protected:
		this.createHeadline = declared_createHeadline;
		this.createSubHeadline = declared_createSubHeadline;
		this.createBirthdayInput = declared_createBirthdayInput;
		
	//private attributes:
		this.numberOfChildren = 0;
		
	//private methods
		this.log = xajax_logStringToFile;
	}
	
//public:
	function declared_createSearchChildForm(setTo, selectedChildren)
	{
		try
		{
			this.numberOfChildren = selectedChildren;
			
			var ChildrenTable = document.createElement("table");
			ChildrenTable.className = "stat_searchForm";
			ChildrenTable.width = "100%";
			ChildrenTable.style.height = "200px";
			
			var ChildrenTableBody = document.createElement("tbody");
			var ChildrenTableHeadRow = document.createElement("tr");
			var ChildrenTableHeadColumn = document.createElement("td");
			var attrColspan = document.createAttribute("colspan");
			attrColspan.nodeValue = "4"
			ChildrenTableHeadColumn.setAttributeNode(attrColspan);
			
			ChildrenTableHeadColumn.appendChild(this.createHeadline(translationsTextSearchForm["ErgaenzenSieGeburtsdatenKinder"]));
			ChildrenTableHeadColumn.appendChild(this.createSubHeadline("(" + translationsTextSearchForm["Reisende12Jahre"] + ")."));
			
			ChildrenTableHeadRow.appendChild(ChildrenTableHeadColumn);
			ChildrenTableBody.appendChild(ChildrenTableHeadRow);
			
			for(var ChildNum = 1; ChildNum <= selectedChildren; ChildNum++)
				ChildrenTableBody.appendChild(this.createBirthdayInput(ChildNum));
			
			var ButtonRow = document.createElement("tr");
			var ButtonColumn = document.createElement("td");
			var attrColspan = document.createAttribute("colspan");
			attrColspan.nodeValue = "4"
			ButtonColumn.setAttributeNode(attrColspan);
			
			var ButtonDiv = document.createElement("div");
			ButtonDiv.className = "link_right";
			ButtonDiv.style.position = "relative";
			ButtonDiv.style.top = "20px";
			
			var ButtonLink = document.createElement("a");
			ButtonLink.href = "JavaScript:objSearchFormHandler.objSearchChildFormHandler.checkAndSubmit();";
			ButtonLink.className = "r2_StdLinkIconRight";
			ButtonLink.innerHTML = translationsTextSearchForm["ReiseFinden"];
			ButtonDiv.appendChild(ButtonLink);
			ButtonColumn.appendChild(ButtonDiv);
			ButtonRow.appendChild(ButtonColumn);
			ChildrenTableBody.appendChild(ButtonRow);
			
			ChildrenTable.appendChild(ChildrenTableBody);
			
			document.getElementById(setTo).appendChild(ChildrenTable);
		}
		catch(e) {this.log("CSearchChildFormBuilder::createSearchChildForm\n" + e.message, "logging/JSExceptionLog.txt");}
	}
	
//protected:
	function declared_createHeadline(TextString)
	{
		try
		{
			var ChildrenHeadLine = document.createElement("p");
			var ChildrenHeadLineStrong = document.createElement("strong");
			ChildrenHeadLineStrong.innerHTML = TextString;
			ChildrenHeadLine.appendChild(ChildrenHeadLineStrong);
			
			return ChildrenHeadLine;
		}
		catch(e) {this.log("CSearchChildFormBuilder::createHeadline\n" + e.message, "logging/JSExceptionLog.txt");}
	}
	
//protected:
	function declared_createSubHeadline(TextString)
	{
		try
		{
			var ChildrenHeadLine = document.createElement("p");
			ChildrenHeadLine.innerHTML = TextString;
			
			return ChildrenHeadLine;
		}
		catch(e) {this.log("CSearchChildFormBuilder::createSubHeadline\n" + e.message, "logging/JSExceptionLog.txt");}
	}
	
//protected:
	function declared_createBirthdayInput(ChildNum)
	{
		try
		{
			var ChildRow = document.createElement("tr");
			ChildRow.id = "dyn_Alter" + ChildNum + "_DIV";
			
			var ChildRowHeadLine = document.createElement("td");
			ChildRowHeadLine.innerHTML = ChildNum + ". " + translationsTextSearchForm["Kind"];
			ChildRow.appendChild(ChildRowHeadLine);
			
			
			var ChildRowBirthDay = document.createElement("td");
			var ChildBirtdayInput = document.createElement("select");
			ChildBirtdayInput.id = "dyn_gebtag" + ChildNum;
			ChildBirtdayInput.name = "dyn_gebtag" + ChildNum;
			ChildBirtdayInput.style.width = "40px";
			ChildBirtdayInput.appendChild(document.createElement("option"));
			for(var i = 1; i <= 31; i++)
			{
				var DayOption = document.createElement("option");
				
				if(i < 10)
					var day = "0" + i;
				else
					var day = i;
					
				DayOption.value = day;
				DayOption.innerHTML = day;
				
				ChildBirtdayInput.appendChild(DayOption);
			}
			ChildRowBirthDay.appendChild(ChildBirtdayInput);
			ChildRow.appendChild(ChildRowBirthDay);
			
			
			var ChildRowBirthMonth = document.createElement("td");
			var ChildBirtMonthInput = document.createElement("select");
			ChildBirtMonthInput.id = "dyn_gebmonat" + ChildNum;
			ChildBirtMonthInput.name = "dyn_gebmonat" + ChildNum;
			ChildBirtMonthInput.style.width = "40px";
			ChildBirtMonthInput.appendChild(document.createElement("option"));
			for(var i = 1; i <= 12; i++)
			{
				var MonthOption = document.createElement("option");
				
				if(i < 10)
					var Month = "0" + i;
				else
					var Month = i;
					
				MonthOption.value = Month;
				MonthOption.innerHTML = Month;
				
				ChildBirtMonthInput.appendChild(MonthOption);
			}
			ChildRowBirthMonth.appendChild(ChildBirtMonthInput);
			ChildRow.appendChild(ChildRowBirthMonth);
			
			
			var ChildRowBirthYear = document.createElement("td");
			var ChildBirtYearInput = document.createElement("select");
			ChildBirtYearInput.id = "dyn_gebjahr" + ChildNum;
			ChildBirtYearInput.name = "dyn_gebjahr" + ChildNum;
			ChildBirtYearInput.style.width = "54px";
			ChildBirtYearInput.appendChild(document.createElement("option"));
			var actuallDate = new Date();
			for(var i = actuallDate.getFullYear(); i >= actuallDate.getFullYear() - 12; i--)
			{
				var YearOption = document.createElement("option");
				YearOption.value = i;
				YearOption.innerHTML = i;
				
				ChildBirtYearInput.appendChild(YearOption);
			}
			ChildRowBirthYear.appendChild(ChildBirtYearInput);
			ChildRow.appendChild(ChildRowBirthYear);
			
			return ChildRow;
		}
		catch(e) {this.log("CSearchChildFormBuilder::createBirthdayInput\n" + e.message, "logging/JSExceptionLog.txt");}
	}
//};