var _active;
function ShowForm (name) {
	if (_active != null)
		_HideActive ();
	_ShowForm(name);
}


function _HideActive() {
	/*_active.effect('height',{
		duration: 1000,
		transition: Fx.Transitions.bounceOut
	}).start(300,0);*/
	_active.height=0;
	_active.style.display='none';
}


function _ShowForm (name) {
	var tab = $(name+"_TABLE");
	
	tab.style.display='block';	
	/*tab.effect('height',{
		duration: 1000
//		,transition: Fx.Transitions.bounceOut
	}).start(0,80);*/
	_active=tab;
	
}


function ChangePregnant(type, value) {
	var pregnantVisible = false;
	var plannedVisible = false;
	if (value == 'yes')
		pregnantVisible = true;
	if (value == 'planned')
		plannedVisible = true;
	var pregnantVisibleNow = ($(type+"_PREGNANT_YES").style.display=='block');
	var plannedVisibleNow = ($(type+"_PREGNANT_PLANNED").style.display=='block');
	height = (type == "m") ? 138 : 65;
	if (pregnantVisibleNow != pregnantVisible)
		ChangeDivVisible (type+"_PREGNANT_YES", pregnantVisible, height);
	if (plannedVisibleNow != plannedVisible) {
		ChangeDivVisible (type+"_PREGNANT_PLANNED", plannedVisible, 30);
		
	}
		
}


function ChangeDivVisible (divId, visible, height) {
	height+=25;
	var div=$(divId);
	if (visible) {
		div.style.display='block';
		div.height=0;
		
		var fx = new Fx.Styles(divId);
		fx.start({
			'width':[0,305],
			'height':[0,height]});
		
		//div.effect('height',{
//			duration: 500
	//	}).start(0,height);
	} else {
		div.style.display='none';
	}
}

function CheckForm (form) {
	if (form.birth_date_year.value == "" || form.birth_date_month.value == "" || form.birth_date_day.value == "")
	{
		if (form.type.value=="mother")
			alert("Your birthday is empty");			
		else
			alert("Baby's mother birthday is empty");
		return false;
	}
	
	pregnant = getCheckedValue (form.pregnant);
	
	if (pregnant == "yes") {
		if (form.conceiving_date_year.value == "" || form.conceiving_date_month.value == "" || form.conceiving_date_day.value == "")
		{
			alert("Fill the conceiving date");
			return false;
		}
	}
	
	return true;
}





function getCheckedValue(radioObj) {
if(!radioObj)
return "";
var radioLength = radioObj.length;
if(radioLength == undefined)
if(radioObj.checked)
return radioObj.value;
else
return "";
for(var i = 0; i < radioLength; i++) {
if(radioObj[i].checked) {
return radioObj[i].value;
}
}
return "";
}

function LinkedDateSelected(obj, linked, type) {
	if(obj.form.elements[linked + "_" + type].value == "")
		obj.form.elements[linked + "_" + type].value = obj.value;
}