//Aborts a POST method form-submit and transforms it into a GET request
function doGetInsteadOfPost(e)
{
	var evt,form,elements,elementsLength,i,location,
		requiredValidator, rangeValidator;
	evt=new CommonEvent(e);
	evt.cancel();
	form=document.forms[0];
	elements=form.elements;
	elementsLength=elements.length;
	location='';
	requiredValidator=document.getElementById(IDPREFIX+'MaskoretRequiredFieldValidator');
	rangeValidator=document.getElementById(IDPREFIX+'MaskoretRangeValidator');
	if((false===requiredValidator.isvalid)||(false===rangeValidator.isvalid))
	{
		return false;//No point in sending invalid data
	}
	for(i=0;i<elementsLength;i++)
	{
		if(('hidden'!==elements[i].type)&&('submit'!==elements[i].type)&&('reset'!==elements[i].type))//Some elements need not be sent.
		{
			if(('radio'===elements[i].type)&&(!(elements[i].checked))){continue;}
			location+='&'+elements[i].name.replace(NAMEPREFIX,'')+'='+elements[i].value;
		}
	}
	if(i>0)
	{
		location=appendLogo(location)
		location=document.location.protocol+'//'+document.location.hostname+document.location.pathname+'?'+location.substr(1);
		document.location.href=location;
	}
	return false;
}
//Toggles fields according to the new state of the form
function resultTypeRadioButtonList_Click(e)
{
	var evt,calculationInputsDiv,requirdeValidator;
	evt=new CommonEvent(e);
	calculationInputsDiv=document.getElementById('CalculationInputsDiv');
	requirdeValidator=document.getElementById(IDPREFIX+'MaskoretRequiredFieldValidator');
	if(-1===evt.sender.value.indexOf('Calculation'))
	{
		addClass('Gone',calculationInputsDiv,false);
		requirdeValidator.enabled=false;
	}
	else
	{
		removeClass('Gone',calculationInputsDiv,true);
		requirdeValidator.enabled=true;
	}
}
//Toggles fields according to the new state of the form
function periodRadioButtonList_Click(e)
{
	var evt,dateDiv,taarA0,taarA1,taarA0Label,taarA1Label,shanaA0Label,shanaA1Label;
	evt=new CommonEvent(e);
	alternateDateDiv=document.getElementById('AlternateDateDiv');
	taarA0=document.getElementById(IDPREFIX+'TaarA0');
	taarA1=document.getElementById(IDPREFIX+'TaarA1');
	taarA0Label=document.getElementById(IDPREFIX+'TaarA0Label');
	taarA1Label=document.getElementById(IDPREFIX+'TaarA1Label');
	shanaA0Label=document.getElementById(IDPREFIX+'ShanaA0Label');
	shanaA1Label=document.getElementById(IDPREFIX+'ShanaA1Label');
	if(0===evt.sender.value.indexOf('Two'))
	{//Two dates
		removeClass('Gone',alternateDateDiv,true);
	}
	else
	{
		addClass('Gone',alternateDateDiv,false);
	}
	if(-1===evt.sender.value.indexOf('Month'))
	{//Whole year
		addClass('Gone',taarA0,false);
		addClass('Gone',taarA1,false);
		addClass('Gone',taarA0Label,false);
		addClass('Gone',taarA1Label,false);
		removeClass('Gone',shanaA0Label,true);
		removeClass('Gone',shanaA1Label,true);
	}
	else
	{
		removeClass('Gone',taarA0,true);
		removeClass('Gone',taarA1,true);
		removeClass('Gone',taarA0Label,true);
		removeClass('Gone',taarA1Label,true);
		addClass('Gone',shanaA0Label,false);
		addClass('Gone',shanaA1Label,false);
	}
}
//Attaches event listeners
function body_Load()
{
	var form,i,
		periodRadioButtonList,periodRadioButtonListLength,periodRadioButton,
		resultTypeRadioButtonList,resultTypeRadioButtonListLength,resultTypeRadioButton,
		maskoret;
	form=document.forms[0];
	maskoret=document.getElementById(IDPREFIX+'Maskoret');
	attachEventListener('focus',maskoret,textBox_Focus);
	attachEventListener('blur',maskoret,textBox_Blur);
	periodRadioButtonList=form[NAMEPREFIX+'PeriodRadioButtonList'];
	periodRadioButtonListLength=periodRadioButtonList.length;
	for(i=0;i<periodRadioButtonListLength;i++)
	{
		periodRadioButton=periodRadioButtonList[i];
		attachEventListener('click',periodRadioButton,periodRadioButtonList_Click);
	}
	periodRadioButtonList_Click({target:getCheckedRadio(periodRadioButtonList)});
	resultTypeRadioButtonList=form[NAMEPREFIX+'ResultTypeRadioButtonList'];
	resultTypeRadioButtonListLength=resultTypeRadioButtonList.length;
	for(i=0;i<resultTypeRadioButtonListLength;i++)
	{
		resultTypeRadioButton=resultTypeRadioButtonList[i];
		attachEventListener('click',resultTypeRadioButton,resultTypeRadioButtonList_Click);
	}
	resultTypeRadioButtonList_Click({target:getCheckedRadio(resultTypeRadioButtonList)});
	attachEventListener('submit',form,doGetInsteadOfPost);
}
