// JavaScript Document
var radio_counter=1;
function add_field()
{
	radio_counter=1;
	inialization();
	var txt=$('select[name=field_type] option:selected').text();
	$("#text_type").val(txt);
	var val=$('select[name=field_type] option:selected').val();
	if(val==0)
	{
		$('#mytemp').html('');
	}
	else if(txt=='Dropdown Menu')
	{
		var element='<td width="6%">&nbsp;</td>';
            element+='<td width="14%"><strong>Select Type</strong></td><td>';
			element+='<input name="types" type="radio" value="year" checked="checked" onclick="empty_drop_down()"/>Year';
			element+='<input name="types" type="radio" value="month" onclick="empty_drop_down()"/>Month';
			element+='<input name="types" type="radio" value="other" onclick="add_drop_down()" />Other</td>';
		$("#drp_type").html(element)
	}
	
}

function empty_drop_down()
{
	$('#mytemp').html('');
}

function inialization()
{
	$("#drp_type").html('');
	$('#myerrordiv').html('');
	document.getElementById('mytable').style.display='none';
	$('#mytemp').html('');
	if(document.getElementById('state').value=='add')
	{
		document.getElementById('rad_counter').value=0;
		$('#mytemp').html('');
	}
	if(document.getElementById('state').value=='edit')
	{
		var r_val=document.getElementById('rad_counter').value;
		r_val=parseInt(r_val);
		var txt=$('select[name=field_type] option:selected').text();
		if(txt!='Texbox' && txt!='Text Area' && txt!='File Upload' && txt!='password')
		{
			if($("#selbox option:contains('Month')").val() || $("#selbox option:contains('Year')").val())
					document.getElementById('new_label').value=document.getElementById('old_lbl').value;
			else
					document.getElementById('new_label').value=txt;	
		}
		else
		{
			document.getElementById('new_label').value=txt;	
		}
		if(r_val>0)
		{
			if(txt=='Texbox' || txt=='Text Area' || txt=='File Upload' || txt=='Password' || txt=='Datepicker')
			{
				document.getElementById('option_row').style.display='none';
			}
			else
			{
				document.getElementById('option_row').removeAttribute("style");
			}
		}
	}
}
