// date drop down selection boxes
function DateDropDownGenerator(n)
{
	var d=new Date();
	this.name = "dd";
	this.day = '';
	this.month = '';	
	this.year = '';
	this.lblDay = '';
	this.lblMonth = '';
	this.lblYear = '';	
	this.InsertDayDropDown=function(){document.write("<select class=\"dropdownDay\" name=\""+this.name+"_day\"><option value=\"\">"+this.lblDay+"</option>");for(var i=1;i<=31;i++){document.write("<option value=\""+i+"\""+((i==this.day)?"selected":"")+">"+i+"</option>");}document.write("</select>");}
	this.InsertMonthDropDown=function(){var months=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");document.write("<select class=\"dropdownMonth\" name=\""+this.name+"_month\"><option value=\"\">"+this.lblMonth+"</option>");for(var i=0;i<months.length; i++){document.write("<option value=\"" + (i+1) + "\""+(((i+1)==this.month)?"selected":"")+">" + months[i] + "</option>");}document.write("</select>");}
	this.InsertYearDropDown=function(){document.write("<select class=\"dropdownYear\" name=\""+this.name+"_year\"><option value=\"\">"+this.lblYear+"</option>");for(var i=d.getFullYear();i>=d.getFullYear()-100;i--){document.write("<option value=\""+i+"\""+((i==this.year)?"selected":"")+">"+i+"</option>");}document.write("</select>");}
	this.Generate=function(){this.InsertDayDropDown();this.InsertMonthDropDown();this.InsertYearDropDown();}
}

//
// select the a value from dropdown list and focus a textbox
//
function FocusTextboxFromDropdown(which, target) {
	if (which.selectedIndex != 0) {
		target.focus();
	}
}

function SelectDropDownByValue(e, val) {
	for (var i=0; i<e.options.length; i++) {
		if (e.options[i].value == val)
			e.options[i].selected = true;
	}
}

function SelectDropDownByText(e, val) {
	for (var i=0; i<e.options.length; i++) {
		if (e.options[i].text == val)
			e.options[i].selected = true;
	}
}

function TickAll(e, target) {
	for (i=0; i<target.length; i++) {
		target[i].checked=e.checked;
	}
}

function CreateChildElements(i, childName, d, m, y) {
	with (document) {
		write('<tr id="childDetails'+i+'" class="hidden">\n'); 
		write('<td><input name="ChildName'+i+'" size="20" maxlength="50" value="'+childName+'" /></td>');
		write('<td>');	
		var childDOB = 'ChildDOB'+i;						
		var ddg = new DateDropDownGenerator();
		ddg.name = childDOB;
		ddg.Generate();
		SelectDropDownByValue(document.subform[childDOB+'_day'], d);
		SelectDropDownByValue(document.subform[childDOB+'_month'], m);
		SelectDropDownByValue(document.subform[childDOB+'_year'], y);											  
		write('</td>');
		write('<td>&nbsp;</td>');
		write('</tr>');
	}				
}
function ShowHideChildren(n) {
	e = document.getElementById('childHeader');
	if (n>0)
		e.className = 'visible';
	else
		e.className = 'hidden';
		
	for (var i=1; i<=10; i++) {
		e = document.getElementById('childDetails'+i);
		if (i<=n)
			e.className = 'visible';
		else
			e.className = 'hidden';
	}
}

function ShowHideById(id, flag, n) {
	if (n == null) {
		e = document.getElementById(id);
		e.className = flag;
	} else {
		for (var i=0; i<n; i++) {
			e = document.getElementById(id+i);
			e.className = flag;
		}
	}
}

function LoadInFrame() {
	var framePage = 'index.html'
	if (top.location == self.location) { window.location = framePage +'?page='+ window.location.pathname + escape(window.location.search) }
}